aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-27 18:41:58 +0000
committerDavid Robillard <d@drobilla.net>2011-04-27 18:41:58 +0000
commit68aa3540cb71c5e0473cc4568431a0e5f5ae29f0 (patch)
tree33939eafb4bd864059fd31b17dc28d15532c9508
parent0b04f70d827a850ca5e779819095766194cd0e94 (diff)
downloadserd-68aa3540cb71c5e0473cc4568431a0e5f5ae29f0.tar.gz
serd-68aa3540cb71c5e0473cc4568431a0e5f5ae29f0.tar.bz2
serd-68aa3540cb71c5e0473cc4568431a0e5f5ae29f0.zip
Don't hide pointers in typedefs.
git-svn-id: http://svn.drobilla.net/serd/trunk@150 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r--serd/serd.h62
-rw-r--r--src/env.c16
-rw-r--r--src/reader.c173
-rw-r--r--src/serdi.c16
-rw-r--r--src/writer.c32
5 files changed, 149 insertions, 150 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 91dbb15c..d4326c2f 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -59,7 +59,7 @@ extern "C" {
A SerdEnv represents a set of namespace prefixes, and is used to resolve
CURIEs to full URIs.
*/
-typedef struct SerdEnvImpl* SerdEnv;
+typedef struct SerdEnvImpl SerdEnv;
/**
RDF reader.
@@ -67,7 +67,7 @@ typedef struct SerdEnvImpl* SerdEnv;
A SerdReader parses RDF by reading some syntax and calling user-provided
sink functions as input is read (much like an XML SAX parser).
*/
-typedef struct SerdReaderImpl* SerdReader;
+typedef struct SerdReaderImpl SerdReader;
/**
Read state.
@@ -77,7 +77,7 @@ typedef struct SerdReaderImpl* SerdReader;
separately from SerdReader so the reader can avoid the overhead in cases
where this information is unnecessary (e.g. streaming reserialisation).
*/
-typedef struct SerdReadStateImpl* SerdReadState;
+typedef struct SerdReadStateImpl SerdReadState;
/**
RDF writer.
@@ -87,7 +87,7 @@ typedef struct SerdReadStateImpl* SerdReadState;
functions used by SerdReader, so a reader can be directly connected to a
writer to re-serialise a document.
*/
-typedef struct SerdWriterImpl* SerdWriter;
+typedef struct SerdWriterImpl SerdWriter;
/**
RDF syntax type.
@@ -402,7 +402,7 @@ typedef bool (*SerdEndSink)(void* handle,
Create a new environment.
*/
SERD_API
-SerdEnv
+SerdEnv*
serd_env_new();
/**
@@ -410,14 +410,14 @@ serd_env_new();
*/
SERD_API
void
-serd_env_free(SerdEnv env);
+serd_env_free(SerdEnv* env);
/**
Add namespace @a uri to @a ns using prefix @a name.
*/
SERD_API
void
-serd_env_add(SerdEnv env,
+serd_env_add(SerdEnv* env,
const SerdNode* name,
const SerdNode* uri);
@@ -426,7 +426,7 @@ serd_env_add(SerdEnv env,
*/
SERD_API
bool
-serd_env_qualify(const SerdEnv env,
+serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix,
SerdChunk* suffix);
@@ -436,7 +436,7 @@ serd_env_qualify(const SerdEnv env,
*/
SERD_API
bool
-serd_env_expand(const SerdEnv env,
+serd_env_expand(const SerdEnv* env,
const SerdNode* curie,
SerdChunk* uri_prefix,
SerdChunk* uri_suffix);
@@ -446,7 +446,7 @@ serd_env_expand(const SerdEnv env,
*/
SERD_API
void
-serd_env_foreach(const SerdEnv env,
+serd_env_foreach(const SerdEnv* env,
SerdPrefixSink func,
void* handle);
@@ -460,7 +460,7 @@ serd_env_foreach(const SerdEnv env,
Create a new RDF reader.
*/
SERD_API
-SerdReader
+SerdReader*
serd_reader_new(SerdSyntax syntax,
void* handle,
SerdBaseSink base_sink,
@@ -479,7 +479,7 @@ serd_reader_new(SerdSyntax syntax,
*/
SERD_API
void
-serd_reader_set_blank_prefix(SerdReader reader,
+serd_reader_set_blank_prefix(SerdReader* reader,
const uint8_t* prefix);
/**
@@ -487,7 +487,7 @@ serd_reader_set_blank_prefix(SerdReader reader,
*/
SERD_API
bool
-serd_reader_read_file(SerdReader reader,
+serd_reader_read_file(SerdReader* reader,
FILE* file,
const uint8_t* name);
@@ -496,14 +496,14 @@ serd_reader_read_file(SerdReader reader,
*/
SERD_API
bool
-serd_reader_read_string(SerdReader me, const uint8_t* utf8);
+serd_reader_read_string(SerdReader* me, const uint8_t* utf8);
/**
Free @a reader.
*/
SERD_API
void
-serd_reader_free(SerdReader reader);
+serd_reader_free(SerdReader* reader);
/**
Create a new read state with the given initial base URI and environment.
@@ -512,8 +512,8 @@ serd_reader_free(SerdReader reader);
state is modified.
*/
SERD_API
-SerdReadState
-serd_read_state_new(SerdEnv env,
+SerdReadState*
+serd_read_state_new(SerdEnv* env,
const uint8_t* base_uri_str);
/**
@@ -521,14 +521,14 @@ serd_read_state_new(SerdEnv env,
*/
SERD_API
void
-serd_read_state_free(SerdReadState state);
+serd_read_state_free(SerdReadState* state);
/**
Expand @a node, which must be a CURIE or URI, to a full URI.
*/
SERD_API
SerdNode
-serd_read_state_expand(SerdReadState state,
+serd_read_state_expand(SerdReadState* state,
const SerdNode* node);
/**
@@ -536,15 +536,15 @@ serd_read_state_expand(SerdReadState state,
*/
SERD_API
SerdNode
-serd_read_state_get_base_uri(SerdReadState state,
- SerdURI* out);
+serd_read_state_get_base_uri(SerdReadState* state,
+ SerdURI* out);
/**
Set the current base URI.
*/
SERD_API
bool
-serd_read_state_set_base_uri(SerdReadState state,
+serd_read_state_set_base_uri(SerdReadState* state,
const SerdNode* uri_node);
/**
@@ -552,7 +552,7 @@ serd_read_state_set_base_uri(SerdReadState state,
*/
SERD_API
bool
-serd_read_state_set_prefix(SerdReadState state,
+serd_read_state_set_prefix(SerdReadState* state,
const SerdNode* name,
const SerdNode* uri_node);
@@ -566,10 +566,10 @@ serd_read_state_set_prefix(SerdReadState state,
Create a new RDF writer.
*/
SERD_API
-SerdWriter
+SerdWriter*
serd_writer_new(SerdSyntax syntax,
SerdStyle style,
- SerdEnv env,
+ SerdEnv* env,
const SerdURI* base_uri,
SerdSink sink,
void* stream);
@@ -579,14 +579,14 @@ serd_writer_new(SerdSyntax syntax,
*/
SERD_API
void
-serd_writer_free(SerdWriter writer);
+serd_writer_free(SerdWriter* writer);
/**
Set the current output base URI (and emit directive if applicable).
*/
SERD_API
void
-serd_writer_set_base_uri(SerdWriter writer,
+serd_writer_set_base_uri(SerdWriter* writer,
const SerdURI* uri);
/**
@@ -594,7 +594,7 @@ serd_writer_set_base_uri(SerdWriter writer,
*/
SERD_API
bool
-serd_writer_set_prefix(SerdWriter writer,
+serd_writer_set_prefix(SerdWriter* writer,
const SerdNode* name,
const SerdNode* uri);
@@ -603,7 +603,7 @@ serd_writer_set_prefix(SerdWriter writer,
*/
SERD_API
bool
-serd_writer_write_statement(SerdWriter writer,
+serd_writer_write_statement(SerdWriter* writer,
const SerdNode* graph,
const SerdNode* subject,
const SerdNode* predicate,
@@ -616,7 +616,7 @@ serd_writer_write_statement(SerdWriter writer,
*/
SERD_API
bool
-serd_writer_end_anon(SerdWriter writer,
+serd_writer_end_anon(SerdWriter* writer,
const SerdNode* node);
/**
@@ -624,7 +624,7 @@ serd_writer_end_anon(SerdWriter writer,
*/
SERD_API
void
-serd_writer_finish(SerdWriter writer);
+serd_writer_finish(SerdWriter* writer);
/**
@}
diff --git a/src/env.c b/src/env.c
index 01a6124d..8e831d53 100644
--- a/src/env.c
+++ b/src/env.c
@@ -32,10 +32,10 @@ struct SerdEnvImpl {
};
SERD_API
-SerdEnv
+SerdEnv*
serd_env_new()
{
- SerdEnv env = malloc(sizeof(struct SerdEnvImpl));
+ SerdEnv* env = malloc(sizeof(struct SerdEnvImpl));
env->prefixes = NULL;
env->n_prefixes = 0;
return env;
@@ -43,7 +43,7 @@ serd_env_new()
SERD_API
void
-serd_env_free(SerdEnv env)
+serd_env_free(SerdEnv* env)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
serd_node_free(&env->prefixes[i].name);
@@ -54,7 +54,7 @@ serd_env_free(SerdEnv env)
}
static inline SerdPrefix*
-serd_env_find(SerdEnv env,
+serd_env_find(const SerdEnv* env,
const uint8_t* name,
size_t name_len)
{
@@ -71,7 +71,7 @@ serd_env_find(SerdEnv env,
SERD_API
void
-serd_env_add(SerdEnv env,
+serd_env_add(SerdEnv* env,
const SerdNode* name,
const SerdNode* uri)
{
@@ -90,7 +90,7 @@ serd_env_add(SerdEnv env,
SERD_API
bool
-serd_env_qualify(const SerdEnv env,
+serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix_name,
SerdChunk* suffix)
@@ -113,7 +113,7 @@ serd_env_qualify(const SerdEnv env,
SERD_API
bool
-serd_env_expand(const SerdEnv env,
+serd_env_expand(const SerdEnv* env,
const SerdNode* qname,
SerdChunk* uri_prefix,
SerdChunk* uri_suffix)
@@ -137,7 +137,7 @@ serd_env_expand(const SerdEnv env,
SERD_API
void
-serd_env_foreach(const SerdEnv env,
+serd_env_foreach(const SerdEnv* env,
SerdPrefixSink func,
void* handle)
{
diff --git a/src/reader.c b/src/reader.c
index 0f250a0c..3463c6df 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -93,7 +93,7 @@ struct SerdReaderImpl {
};
struct SerdReadStateImpl {
- SerdEnv env;
+ SerdEnv* env;
SerdNode base_uri_node;
SerdURI base_uri;
};
@@ -105,7 +105,7 @@ typedef enum {
} SerdStatus;
static int
-error(SerdReader reader, const char* fmt, ...)
+error(SerdReader* reader, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
@@ -123,7 +123,7 @@ make_node(SerdType type, Ref value, Ref datatype, Ref lang)
}
static inline bool
-page(SerdReader reader)
+page(SerdReader* reader)
{
assert(reader->from_file);
reader->read_head = 0;
@@ -139,7 +139,7 @@ page(SerdReader reader)
}
static inline bool
-peek_string(SerdReader reader, uint8_t* pre, int n)
+peek_string(SerdReader* reader, uint8_t* pre, int n)
{
uint8_t* ptr = reader->read_buf + reader->read_head;
for (int i = 0; i < n; ++i) {
@@ -160,13 +160,13 @@ peek_string(SerdReader reader, uint8_t* pre, int n)
}
static inline uint8_t
-peek_byte(SerdReader reader)
+peek_byte(SerdReader* reader)
{
return reader->read_buf[reader->read_head];
}
static inline uint8_t
-eat_byte(SerdReader reader, const uint8_t byte)
+eat_byte(SerdReader* reader, const uint8_t byte)
{
const uint8_t c = peek_byte(reader);
++reader->read_head;
@@ -189,7 +189,7 @@ eat_byte(SerdReader reader, const uint8_t byte)
}
static inline void
-eat_string(SerdReader reader, const char* str, unsigned n)
+eat_string(SerdReader* reader, const char* str, unsigned n)
{
for (unsigned i = 0; i < n; ++i) {
eat_byte(reader, ((const uint8_t*)str)[i]);
@@ -198,7 +198,7 @@ eat_string(SerdReader reader, const char* str, unsigned n)
#ifdef SERD_STACK_CHECK
static inline bool
-stack_is_top_string(SerdReader reader, Ref ref)
+stack_is_top_string(SerdReader* reader, Ref ref)
{
return ref == reader->alloc_stack[reader->n_allocs - 1];
}
@@ -206,7 +206,7 @@ stack_is_top_string(SerdReader reader, Ref ref)
// Make a new string from a non-UTF-8 C string (internal use only)
static Ref
-push_string(SerdReader reader, const char* c_str, size_t n_bytes)
+push_string(SerdReader* reader, const char* c_str, size_t n_bytes)
{
uint8_t* mem = serd_stack_push(&reader->stack,
sizeof(SerdString) + n_bytes);
@@ -223,7 +223,7 @@ push_string(SerdReader reader, const char* c_str, size_t n_bytes)
}
static inline SerdString*
-deref(SerdReader reader, const Ref ref)
+deref(SerdReader* reader, const Ref ref)
{
if (ref) {
return (SerdString*)(reader->stack.buf + ref);
@@ -232,7 +232,7 @@ deref(SerdReader reader, const Ref ref)
}
static inline void
-push_byte(SerdReader reader, Ref ref, const uint8_t c)
+push_byte(SerdReader* reader, Ref ref, const uint8_t c)
{
#ifdef SERD_STACK_CHECK
assert(stack_is_top_string(reader, ref));
@@ -250,7 +250,7 @@ push_byte(SerdReader reader, Ref ref, const uint8_t c)
}
static void
-pop_string(SerdReader reader, Ref ref)
+pop_string(SerdReader* reader, Ref ref)
{
if (ref) {
if (ref == reader->rdf_nil.value
@@ -274,7 +274,7 @@ pop_string(SerdReader reader, Ref ref)
}
static inline SerdNode
-public_node_from_ref(SerdReader reader, SerdType type, Ref ref)
+public_node_from_ref(SerdReader* reader, SerdType type, Ref ref)
{
if (!ref) {
return SERD_NODE_NULL;
@@ -285,13 +285,13 @@ public_node_from_ref(SerdReader reader, SerdType type, Ref ref)
}
static inline SerdNode
-public_node(SerdReader reader, const Node* private)
+public_node(SerdReader* reader, const Node* private)
{
return public_node_from_ref(reader, private->type, private->value);
}
static inline bool
-emit_statement(SerdReader reader,
+emit_statement(SerdReader* reader,
const Node* g, const Node* s, const Node* p, const Node* o)
{
assert(s->value && p->value && o->value);
@@ -310,12 +310,12 @@ emit_statement(SerdReader reader,
&object_lang);
}
-static bool read_collection(SerdReader reader, ReadContext ctx, Node* dest);
-static bool read_predicateObjectList(SerdReader reader, ReadContext ctx);
+static bool read_collection(SerdReader* reader, ReadContext ctx, Node* dest);
+static bool read_predicateObjectList(SerdReader* reader, ReadContext ctx);
// [40] hex ::= [#x30-#x39] | [#x41-#x46]
static inline uint8_t
-read_hex(SerdReader reader)
+read_hex(SerdReader* reader)
{
const uint8_t c = peek_byte(reader);
if (in_range(c, 0x30, 0x39) || in_range(c, 0x41, 0x46)) {
@@ -326,7 +326,7 @@ read_hex(SerdReader reader)
}
static inline bool
-read_hex_escape(SerdReader reader, unsigned length, Ref dest)
+read_hex_escape(SerdReader* reader, unsigned length, Ref dest)
{
uint8_t buf[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (unsigned i = 0; i < length; ++i) {
@@ -375,7 +375,7 @@ read_hex_escape(SerdReader reader, unsigned length, Ref dest)
}
static inline bool
-read_character_escape(SerdReader reader, Ref dest)
+read_character_escape(SerdReader* reader, Ref dest)
{
switch (peek_byte(reader)) {
case '\\':
@@ -393,7 +393,7 @@ read_character_escape(SerdReader reader, Ref dest)
}
static inline bool
-read_echaracter_escape(SerdReader reader, Ref dest)
+read_echaracter_escape(SerdReader* reader, Ref dest)
{
switch (peek_byte(reader)) {
case 't':
@@ -414,7 +414,7 @@ read_echaracter_escape(SerdReader reader, Ref dest)
}
static inline bool
-read_scharacter_escape(SerdReader reader, Ref dest)
+read_scharacter_escape(SerdReader* reader, Ref dest)
{
switch (peek_byte(reader)) {
case '"':
@@ -426,7 +426,7 @@ read_scharacter_escape(SerdReader reader, Ref dest)
}
static inline bool
-read_ucharacter_escape(SerdReader reader, Ref dest)
+read_ucharacter_escape(SerdReader* reader, Ref dest)
{
switch (peek_byte(reader)) {
case '>':
@@ -442,7 +442,7 @@ read_ucharacter_escape(SerdReader reader, Ref dest)
// | '\\'
// | [#x20-#x5B] | [#x5D-#x10FFFF]
static inline SerdStatus
-read_character(SerdReader reader, Ref dest)
+read_character(SerdReader* reader, Ref dest)
{
const uint8_t c = peek_byte(reader);
assert(c != '\\'); // Only called from methods that handle escapes first
@@ -479,7 +479,7 @@ read_character(SerdReader reader, Ref dest)
// [39] echaracter ::= character | '\t' | '\n' | '\r'
static inline SerdStatus
-read_echaracter(SerdReader reader, Ref dest)
+read_echaracter(SerdReader* reader, Ref dest)
{
uint8_t c = peek_byte(reader);
switch (c) {
@@ -498,7 +498,7 @@ read_echaracter(SerdReader reader, Ref dest)
// [43] lcharacter ::= echaracter | '\"' | #x9 | #xA | #xD
static inline SerdStatus
-read_lcharacter(SerdReader reader, Ref dest)
+read_lcharacter(SerdReader* reader, Ref dest)
{
const uint8_t c = peek_byte(reader);
uint8_t pre[3];
@@ -532,7 +532,7 @@ read_lcharacter(SerdReader reader, Ref dest)
// [42] scharacter ::= ( echaracter - #x22 ) | '\"'
static inline SerdStatus
-read_scharacter(SerdReader reader, Ref dest)
+read_scharacter(SerdReader* reader, Ref dest)
{
uint8_t c = peek_byte(reader);
switch (c) {
@@ -554,7 +554,7 @@ read_scharacter(SerdReader reader, Ref dest)
// Spec: [41] ucharacter ::= ( character - #x3E ) | '\>'
// Impl: [41] ucharacter ::= ( echaracter - #x3E ) | '\>'
static inline SerdStatus
-read_ucharacter(SerdReader reader, Ref dest)
+read_ucharacter(SerdReader* reader, Ref dest)
{
const uint8_t c = peek_byte(reader);
switch (c) {
@@ -574,7 +574,7 @@ read_ucharacter(SerdReader reader, Ref dest)
// [10] comment ::= '#' ( [^#xA #xD] )*
static void
-read_comment(SerdReader reader)
+read_comment(SerdReader* reader)
{
eat_byte(reader, '#');
uint8_t c;
@@ -585,7 +585,7 @@ read_comment(SerdReader reader)
// [24] ws ::= #x9 | #xA | #xD | #x20 | comment
static inline bool
-read_ws(SerdReader reader)
+read_ws(SerdReader* reader)
{
const uint8_t c = peek_byte(reader);
switch (c) {
@@ -601,13 +601,13 @@ read_ws(SerdReader reader)
}
static inline void
-read_ws_star(SerdReader reader)
+read_ws_star(SerdReader* reader)
{
while (read_ws(reader)) {}
}
static inline bool
-read_ws_plus(SerdReader reader)
+read_ws_plus(SerdReader* reader)
{
TRY_RET(read_ws(reader));
read_ws_star(reader);
@@ -616,7 +616,7 @@ read_ws_plus(SerdReader reader)
// [37] longSerdString ::= #x22 #x22 #x22 lcharacter* #x22 #x22 #x22
static Ref
-read_longString(SerdReader reader)
+read_longString(SerdReader* reader)
{
eat_string(reader, "\"\"\"", 3);
Ref str = push_string(reader, "", 1);
@@ -631,7 +631,7 @@ read_longString(SerdReader reader)
// [36] string ::= #x22 scharacter* #x22
static Ref
-read_string(SerdReader reader)
+read_string(SerdReader* reader)
{
eat_byte(reader, '\"');
Ref str = push_string(reader, "", 1);
@@ -647,7 +647,7 @@ read_string(SerdReader reader)
// [35] quotedString ::= string | longSerdString
static Ref
-read_quotedString(SerdReader reader)
+read_quotedString(SerdReader* reader)
{
uint8_t pre[3];
peek_string(reader, pre, 3);
@@ -665,7 +665,7 @@ read_quotedString(SerdReader reader)
// [34] relativeURI ::= ucharacter*
static inline Ref
-read_relativeURI(SerdReader reader)
+read_relativeURI(SerdReader* reader)
{
Ref str = push_string(reader, "", 1);
SerdStatus st;
@@ -682,7 +682,7 @@ read_relativeURI(SerdReader reader)
// | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF]
// | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
static inline uchar
-read_nameStartChar(SerdReader reader, bool required)
+read_nameStartChar(SerdReader* reader, bool required)
{
const uint8_t c = peek_byte(reader);
if (c == '_' || is_alpha(c)) {
@@ -698,7 +698,7 @@ read_nameStartChar(SerdReader reader, bool required)
// [31] nameChar ::= nameStartChar | '-' | [0-9]
// | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
static inline uchar
-read_nameChar(SerdReader reader)
+read_nameChar(SerdReader* reader)
{
uchar c = read_nameStartChar(reader, false);
if (c)
@@ -717,7 +717,7 @@ read_nameChar(SerdReader reader)
// [33] prefixName ::= ( nameStartChar - '_' ) nameChar*
static Ref
-read_prefixName(SerdReader reader)
+read_prefixName(SerdReader* reader)
{
uint8_t c = peek_byte(reader);
if (c == '_') {
@@ -735,7 +735,7 @@ read_prefixName(SerdReader reader)
// [32] name ::= nameStartChar nameChar*
static Ref
-read_name(SerdReader reader, Ref dest, bool required)
+read_name(SerdReader* reader, Ref dest, bool required)
{
uchar c = read_nameStartChar(reader, required);
if (!c) {
@@ -752,7 +752,7 @@ read_name(SerdReader reader, Ref dest, bool required)
// [29] language ::= [a-z]+ ('-' [a-z0-9]+ )*
static Ref
-read_language(SerdReader reader)
+read_language(SerdReader* reader)
{
const uint8_t start = peek_byte(reader);
if (!in_range(start, 'a', 'z')) {
@@ -777,7 +777,7 @@ read_language(SerdReader reader)
// [28] uriref ::= '<' relativeURI '>'
static Ref
-read_uriref(SerdReader reader)
+read_uriref(SerdReader* reader)
{
TRY_RET(eat_byte(reader, '<'));
Ref const str = read_relativeURI(reader);
@@ -790,7 +790,7 @@ read_uriref(SerdReader reader)
// [27] qname ::= prefixName? ':' name?
static Ref
-read_qname(SerdReader reader)
+read_qname(SerdReader* reader)
{
Ref prefix = read_prefixName(reader);
if (!prefix) {
@@ -806,7 +806,7 @@ except:
}
static bool
-read_0_9(SerdReader reader, Ref str, bool at_least_one)
+read_0_9(SerdReader* reader, Ref str, bool at_least_one)
{
uint8_t c;
if (at_least_one) {
@@ -830,7 +830,7 @@ read_0_9(SerdReader reader, Ref str, bool at_least_one)
// | ([0-9])+ exponent )
// [16] integer ::= ( '-' | '+' ) ? [0-9]+
static bool
-read_number(SerdReader reader, Node* dest)
+read_number(SerdReader* reader, Node* dest)
{
#define XSD_DECIMAL NS_XSD "decimal"
#define XSD_DOUBLE NS_XSD "double"
@@ -883,7 +883,7 @@ except:
// [25] resource ::= uriref | qname
static bool
-read_resource(SerdReader reader, Node* dest)
+read_resource(SerdReader* reader, Node* dest)
{
switch (peek_byte(reader)) {
case '<':
@@ -898,7 +898,7 @@ read_resource(SerdReader reader, Node* dest)
// [14] literal ::= quotedString ( '@' language )? | datatypeSerdString
// | integer | double | decimal | boolean
static bool
-read_literal(SerdReader reader, Node* dest)
+read_literal(SerdReader* reader, Node* dest)
{
Ref str = 0;
Node datatype = INTERNAL_NODE_NULL;
@@ -934,14 +934,14 @@ except:
// [12] predicate ::= resource
static bool
-read_predicate(SerdReader reader, Node* dest)
+read_predicate(SerdReader* reader, Node* dest)
{
return read_resource(reader, dest);
}
// [9] verb ::= predicate | 'a'
static bool
-read_verb(SerdReader reader, Node* dest)
+read_verb(SerdReader* reader, Node* dest)
{
uint8_t pre[2];
peek_string(reader, pre, 2);
@@ -962,7 +962,7 @@ read_verb(SerdReader reader, Node* dest)
// [26] nodeID ::= '_:' name
static Ref
-read_nodeID(SerdReader reader)
+read_nodeID(SerdReader* reader)
{
eat_byte(reader, '_');
eat_byte(reader, ':');
@@ -971,7 +971,7 @@ read_nodeID(SerdReader reader)
}
static Ref
-blank_id(SerdReader reader)
+blank_id(SerdReader* reader)
{
const char* prefix = reader->blank_prefix
? (const char*)reader->blank_prefix
@@ -987,7 +987,7 @@ blank_id(SerdReader reader)
// Impl: [21] blank ::= nodeID | '[ ws* ]'
// | '[' ws* predicateObjectList ws* ']' | collection
static bool
-read_blank(SerdReader reader, ReadContext ctx, Node* dest)
+read_blank(SerdReader* reader, ReadContext ctx, Node* dest)
{
switch (peek_byte(reader)) {
case '_':
@@ -1047,7 +1047,7 @@ is_object_end(const uint8_t c)
// Recurses, calling statement_sink for every statement encountered.
// Leaves stack in original calling state (i.e. pops everything it pushes).
static bool
-read_object(SerdReader reader, ReadContext ctx)
+read_object(SerdReader* reader, ReadContext ctx)
{
static const char* const XSD_BOOLEAN = NS_XSD "boolean";
static const size_t XSD_BOOLEAN_LEN = 40;
@@ -1122,7 +1122,7 @@ except:
// Spec: [8] objectList ::= object ( ',' object )*
// Impl: [8] objectList ::= object ( ws* ',' ws* object )*
static bool
-read_objectList(SerdReader reader, ReadContext ctx)
+read_objectList(SerdReader* reader, ReadContext ctx)
{
TRY_RET(read_object(reader, ctx));
read_ws_star(reader);
@@ -1140,7 +1140,7 @@ read_objectList(SerdReader reader, ReadContext ctx)
// Impl: [7] predicateObjectList ::= verb ws+ objectList
// (ws* ';' ws* verb ws+ objectList)* (';')?
static bool
-read_predicateObjectList(SerdReader reader, ReadContext ctx)
+read_predicateObjectList(SerdReader* reader, ReadContext ctx)
{
if (reader->eof) {
return false;
@@ -1178,7 +1178,7 @@ except:
/** Recursive helper for read_collection. */
static bool
-read_collection_rec(SerdReader reader, ReadContext ctx)
+read_collection_rec(SerdReader* reader, ReadContext ctx)
{
read_ws_star(reader);
if (peek_byte(reader) == ')') {
@@ -1205,7 +1205,7 @@ read_collection_rec(SerdReader reader, ReadContext ctx)
// [22] itemList ::= object+
// [23] collection ::= '(' itemList? ')'
static bool
-read_collection(SerdReader reader, ReadContext ctx, Node* dest)
+read_collection(SerdReader* reader, ReadContext ctx, Node* dest)
{
TRY_RET(eat_byte(reader, '('));
read_ws_star(reader);
@@ -1228,7 +1228,7 @@ read_collection(SerdReader reader, ReadContext ctx, Node* dest)
// [11] subject ::= resource | blank
static Node
-read_subject(SerdReader reader, ReadContext ctx)
+read_subject(SerdReader* reader, ReadContext ctx)
{
Node subject = INTERNAL_NODE_NULL;
switch (peek_byte(reader)) {
@@ -1244,7 +1244,7 @@ read_subject(SerdReader reader, ReadContext ctx)
// Spec: [6] triples ::= subject predicateObjectList
// Impl: [6] triples ::= subject ws+ predicateObjectList
static bool
-read_triples(SerdReader reader, ReadContext ctx)
+read_triples(SerdReader* reader, ReadContext ctx)
{
const Node subject = read_subject(reader, ctx);
bool ret = false;
@@ -1260,7 +1260,7 @@ read_triples(SerdReader reader, ReadContext ctx)
// [5] base ::= '@base' ws+ uriref
static bool
-read_base(SerdReader reader)
+read_base(SerdReader* reader)
{
// `@' is already eaten in read_directive
eat_string(reader, "base", 4);
@@ -1276,7 +1276,7 @@ read_base(SerdReader reader)
// Spec: [4] prefixID ::= '@prefix' ws+ prefixName? ':' uriref
// Impl: [4] prefixID ::= '@prefix' ws+ prefixName? ':' ws* uriref
static bool
-read_prefixID(SerdReader reader)
+read_prefixID(SerdReader* reader)
{
// `@' is already eaten in read_directive
eat_string(reader, "prefix", 6);
@@ -1301,7 +1301,7 @@ except:
// [3] directive ::= prefixID | base
static bool
-read_directive(SerdReader reader)
+read_directive(SerdReader* reader)
{
eat_byte(reader, '@');
switch (peek_byte(reader)) {
@@ -1317,7 +1317,7 @@ read_directive(SerdReader reader)
// Spec: [1] statement ::= directive '.' | triples '.' | ws+
// Impl: [1] statement ::= directive ws* '.' | triples ws* '.' | ws+
static bool
-read_statement(SerdReader reader)
+read_statement(SerdReader* reader)
{
ReadContext ctx = { 0, 0, 0 };
read_ws_star(reader);
@@ -1338,7 +1338,7 @@ read_statement(SerdReader reader)
// [1] turtleDoc ::= statement
static bool
-read_turtleDoc(SerdReader reader)
+read_turtleDoc(SerdReader* reader)
{
while (!reader->eof) {
TRY_RET(read_statement(reader));
@@ -1347,7 +1347,7 @@ read_turtleDoc(SerdReader reader)
}
SERD_API
-SerdReader
+SerdReader*
serd_reader_new(SerdSyntax syntax,
void* handle,
SerdBaseSink base_sink,
@@ -1356,7 +1356,7 @@ serd_reader_new(SerdSyntax syntax,
SerdEndSink end_sink)
{
const Cursor cur = { NULL, 0, 0 };
- SerdReader me = malloc(sizeof(struct SerdReaderImpl));
+ SerdReader* me = malloc(sizeof(struct SerdReaderImpl));
me->handle = handle;
me->base_sink = base_sink;
me->prefix_sink = prefix_sink;
@@ -1387,23 +1387,22 @@ serd_reader_new(SerdSyntax syntax,
SERD_API
void
-serd_reader_free(SerdReader reader)
+serd_reader_free(SerdReader* reader)
{
- SerdReader const me = (SerdReader)reader;
- pop_string(me, me->rdf_nil.value);
- pop_string(me, me->rdf_rest.value);
- pop_string(me, me->rdf_first.value);
+ pop_string(reader, reader->rdf_nil.value);
+ pop_string(reader, reader->rdf_rest.value);
+ pop_string(reader, reader->rdf_first.value);
#ifdef SERD_STACK_CHECK
- free(me->alloc_stack);
+ free(reader->alloc_stack);
#endif
- free(me->stack.buf);
- free(me);
+ free(reader->stack.buf);
+ free(reader);
}
SERD_API
void
-serd_reader_set_blank_prefix(SerdReader reader,
+serd_reader_set_blank_prefix(SerdReader* reader,
const uint8_t* prefix)
{
reader->blank_prefix = prefix;
@@ -1411,7 +1410,7 @@ serd_reader_set_blank_prefix(SerdReader reader,
SERD_API
bool
-serd_reader_read_file(SerdReader me, FILE* file, const uint8_t* name)
+serd_reader_read_file(SerdReader* me, FILE* file, const uint8_t* name)
{
const Cursor cur = { name, 1, 1 };
me->fd = file;
@@ -1438,7 +1437,7 @@ serd_reader_read_file(SerdReader me, FILE* file, const uint8_t* name)
SERD_API
bool
-serd_reader_read_string(SerdReader me, const uint8_t* utf8)
+serd_reader_read_string(SerdReader* me, const uint8_t* utf8)
{
const Cursor cur = { (const uint8_t*)"(string)", 1, 1 };
@@ -1455,12 +1454,12 @@ serd_reader_read_string(SerdReader me, const uint8_t* utf8)
}
SERD_API
-SerdReadState
-serd_read_state_new(SerdEnv env,
+SerdReadState*
+serd_read_state_new(SerdEnv* env,
const uint8_t* base_uri_str)
{
- SerdReadState state = malloc(sizeof(struct SerdReadStateImpl));
- SerdURI base_base_uri = SERD_URI_NULL;
+ SerdReadState* state = malloc(sizeof(struct SerdReadStateImpl));
+ SerdURI base_base_uri = SERD_URI_NULL;
state->env = env;
state->base_uri_node = serd_node_new_uri_from_string(
base_uri_str, &base_base_uri, &state->base_uri);
@@ -1469,7 +1468,7 @@ serd_read_state_new(SerdEnv env,
SERD_API
void
-serd_read_state_free(SerdReadState state)
+serd_read_state_free(SerdReadState* state)
{
serd_node_free(&state->base_uri_node);
free(state);
@@ -1477,7 +1476,7 @@ serd_read_state_free(SerdReadState state)
SERD_API
SerdNode
-serd_read_state_expand(SerdReadState state,
+serd_read_state_expand(SerdReadState* state,
const SerdNode* node)
{
if (node->type == SERD_CURIE) {
@@ -1501,8 +1500,8 @@ serd_read_state_expand(SerdReadState state,
SERD_API
SerdNode
-serd_read_state_get_base_uri(SerdReadState state,
- SerdURI* out)
+serd_read_state_get_base_uri(SerdReadState* state,
+ SerdURI* out)
{
*out = state->base_uri;
return state->base_uri_node;
@@ -1510,7 +1509,7 @@ serd_read_state_get_base_uri(SerdReadState state,
SERD_API
bool
-serd_read_state_set_base_uri(SerdReadState state,
+serd_read_state_set_base_uri(SerdReadState* state,
const SerdNode* uri_node)
{
// Resolve base URI and create a new node and URI for it
@@ -1530,7 +1529,7 @@ serd_read_state_set_base_uri(SerdReadState state,
SERD_API
bool
-serd_read_state_set_prefix(SerdReadState state,
+serd_read_state_set_prefix(SerdReadState* state,
const SerdNode* name,
const SerdNode* uri_node)
{
diff --git a/src/serdi.c b/src/serdi.c
index 1b033a10..7df0d363 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -22,9 +22,9 @@
#include "serd-config.h"
typedef struct {
- SerdEnv env;
- SerdReadState read_state;
- SerdWriter writer;
+ SerdEnv* env;
+ SerdReadState* read_state;
+ SerdWriter* writer;
} State;
static bool
@@ -197,8 +197,8 @@ main(int argc, char** argv)
fprintf(stderr, "invalid base URI `%s'\n", base_uri_str);
}
- FILE* out_fd = stdout;
- SerdEnv env = serd_env_new();
+ FILE* out_fd = stdout;
+ SerdEnv* env = serd_env_new();
SerdStyle output_style = SERD_STYLE_RESOLVED;
if (output_syntax == SERD_NTRIPLES) {
@@ -207,16 +207,16 @@ main(int argc, char** argv)
output_style |= SERD_STYLE_ABBREVIATED;
}
- SerdReadState read_state = serd_read_state_new(env, base_uri_str);
+ SerdReadState* read_state = serd_read_state_new(env, base_uri_str);
serd_read_state_get_base_uri(read_state, &base_uri);
- SerdWriter writer = serd_writer_new(
+ SerdWriter* writer = serd_writer_new(
output_syntax, output_style, env, &base_uri, file_sink, out_fd);
State state = { env, read_state, writer };
- SerdReader reader = serd_reader_new(
+ SerdReader* reader = serd_reader_new(
SERD_TURTLE, &state,
event_base, event_prefix, event_statement, event_end);
diff --git a/src/writer.c b/src/writer.c
index b87ad1b0..f6077773 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -37,7 +37,7 @@ static const WriteContext WRITE_CONTEXT_NULL = {
struct SerdWriterImpl {
SerdSyntax syntax;
SerdStyle style;
- SerdEnv env;
+ SerdEnv* env;
SerdURI base_uri;
SerdStack anon_stack;
SerdSink sink;
@@ -53,7 +53,7 @@ typedef enum {
} TextContext;
static inline WriteContext*
-anon_stack_top(SerdWriter writer)
+anon_stack_top(SerdWriter* writer)
{
assert(!serd_stack_is_empty(&writer->anon_stack));
return (WriteContext*)(writer->anon_stack.buf
@@ -61,7 +61,7 @@ anon_stack_top(SerdWriter writer)
}
static bool
-write_text(SerdWriter writer, TextContext ctx,
+write_text(SerdWriter* writer, TextContext ctx,
const uint8_t* utf8, size_t n_bytes, uint8_t terminator)
{
char escape[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -142,7 +142,7 @@ write_text(SerdWriter writer, TextContext ctx,
}
static void
-serd_writer_write_delim(SerdWriter writer, const uint8_t delim)
+serd_writer_write_delim(SerdWriter* writer, const uint8_t delim)
{
switch (delim) {
case '\n':
@@ -159,7 +159,7 @@ serd_writer_write_delim(SerdWriter writer, const uint8_t delim)
}
static void
-reset_context(SerdWriter writer)
+reset_context(SerdWriter* writer)
{
if (writer->context.graph.buf)
serd_node_free(&writer->context.graph);
@@ -171,7 +171,7 @@ reset_context(SerdWriter writer)
}
static bool
-write_node(SerdWriter writer,
+write_node(SerdWriter* writer,
const SerdNode* node,
const SerdNode* datatype,
const SerdNode* lang)
@@ -276,7 +276,7 @@ write_node(SerdWriter writer,
SERD_API
bool
-serd_writer_write_statement(SerdWriter writer,
+serd_writer_write_statement(SerdWriter* writer,
const SerdNode* graph,
const SerdNode* subject,
const SerdNode* predicate,
@@ -367,7 +367,7 @@ serd_writer_write_statement(SerdWriter writer,
SERD_API
bool
-serd_writer_end_anon(SerdWriter writer,
+serd_writer_end_anon(SerdWriter* writer,
const SerdNode* node)
{
if (writer->syntax == SERD_NTRIPLES) {
@@ -392,7 +392,7 @@ serd_writer_end_anon(SerdWriter writer,
SERD_API
void
-serd_writer_finish(SerdWriter writer)
+serd_writer_finish(SerdWriter* writer)
{
if (writer->context.subject.buf) {
writer->sink(" .\n", 3, writer->stream);
@@ -401,16 +401,16 @@ serd_writer_finish(SerdWriter writer)
}
SERD_API
-SerdWriter
+SerdWriter*
serd_writer_new(SerdSyntax syntax,
SerdStyle style,
- SerdEnv env,
+ SerdEnv* env,
const SerdURI* base_uri,
SerdSink sink,
void* stream)
{
const WriteContext context = WRITE_CONTEXT_NULL;
- SerdWriter writer = malloc(sizeof(struct SerdWriterImpl));
+ SerdWriter* writer = malloc(sizeof(struct SerdWriterImpl));
writer->syntax = syntax;
writer->style = style;
writer->env = env;
@@ -425,7 +425,7 @@ serd_writer_new(SerdSyntax syntax,
SERD_API
void
-serd_writer_set_base_uri(SerdWriter writer,
+serd_writer_set_base_uri(SerdWriter* writer,
const SerdURI* uri)
{
writer->base_uri = *uri;
@@ -443,7 +443,7 @@ serd_writer_set_base_uri(SerdWriter writer,
SERD_API
bool
-serd_writer_set_prefix(SerdWriter writer,
+serd_writer_set_prefix(SerdWriter* writer,
const SerdNode* name,
const SerdNode* uri)
{
@@ -464,9 +464,9 @@ serd_writer_set_prefix(SerdWriter writer,
SERD_API
void
-serd_writer_free(SerdWriter writer)
+serd_writer_free(SerdWriter* writer)
{
- SerdWriter const me = (SerdWriter)writer;
+ SerdWriter* const me = (SerdWriter*)writer;
serd_writer_finish(me);
serd_stack_free(&writer->anon_stack);
free(me);