diff options
author | David Robillard <d@drobilla.net> | 2021-03-01 13:24:02 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 15:33:54 -0500 |
commit | da8e12fcbccf4558d4d524d7a6f659ea2ffc0ea2 (patch) | |
tree | 18ccddb7bc2ad526bcab4195220d23ac31a6f300 | |
parent | 6cdd2b1e6f4ac37682ee20dca32441f88c92bcfa (diff) | |
download | serd-da8e12fcbccf4558d4d524d7a6f659ea2ffc0ea2.tar.gz serd-da8e12fcbccf4558d4d524d7a6f659ea2ffc0ea2.tar.bz2 serd-da8e12fcbccf4558d4d524d7a6f659ea2ffc0ea2.zip |
Rename function types for consistency
-rw-r--r-- | include/serd/serd.h | 44 | ||||
-rw-r--r-- | src/env.c | 2 | ||||
-rw-r--r-- | src/n3.c | 12 | ||||
-rw-r--r-- | src/reader.c | 26 | ||||
-rw-r--r-- | src/reader.h | 10 | ||||
-rw-r--r-- | src/serd_internal.h | 6 | ||||
-rw-r--r-- | src/serdi.c | 8 | ||||
-rw-r--r-- | src/writer.c | 8 |
8 files changed, 58 insertions, 58 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h index 74d3104a..7bccfc76 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -557,37 +557,37 @@ typedef struct { } SerdError; /** - Sink (callback) for errors. + Callback function for errors. @param handle Handle for user data. @param error Error description. */ -typedef SerdStatus (*SerdErrorSink)(void* SERD_NULLABLE handle, +typedef SerdStatus (*SerdErrorFunc)(void* SERD_NULLABLE handle, const SerdError* SERD_NONNULL error); /** - Sink (callback) for base URI changes. + Sink function for base URI changes. Called whenever the base URI of the serialisation changes. */ -typedef SerdStatus (*SerdBaseSink)(void* SERD_NULLABLE handle, +typedef SerdStatus (*SerdBaseFunc)(void* SERD_NULLABLE handle, const SerdNode* SERD_NONNULL uri); /** - Sink (callback) for namespace definitions. + Sink function for namespace definitions. Called whenever a prefix is defined in the serialisation. */ -typedef SerdStatus (*SerdPrefixSink)(void* SERD_NULLABLE handle, +typedef SerdStatus (*SerdPrefixFunc)(void* SERD_NULLABLE handle, const SerdNode* SERD_NONNULL name, const SerdNode* SERD_NONNULL uri); /** - Sink (callback) for statements. + Sink function for statements. Called for every RDF statement in the serialisation. */ -typedef SerdStatus (*SerdStatementSink)( +typedef SerdStatus (*SerdStatementFunc)( void* SERD_NULLABLE handle, SerdStatementFlags flags, const SerdNode* SERD_NULLABLE graph, @@ -598,13 +598,13 @@ typedef SerdStatus (*SerdStatementSink)( const SerdNode* SERD_NULLABLE object_lang); /** - Sink (callback) for anonymous node end markers. + Sink function for anonymous node end markers. - This is called to indicate that the anonymous node with the given - `value` will no longer be referred to by any future statements - (i.e. the anonymous serialisation of the node is finished). + This is called to indicate that the anonymous node with the given `value` + will no longer be referred to by any future statements (so the anonymous + node is finished). */ -typedef SerdStatus (*SerdEndSink)(void* SERD_NULLABLE handle, +typedef SerdStatus (*SerdEndFunc)(void* SERD_NULLABLE handle, const SerdNode* SERD_NONNULL node); /** @@ -693,7 +693,7 @@ serd_env_expand_node(const SerdEnv* SERD_NULLABLE env, SERD_API void serd_env_foreach(const SerdEnv* SERD_NONNULL env, - SerdPrefixSink SERD_NONNULL func, + SerdPrefixFunc SERD_NONNULL func, void* SERD_NULLABLE handle); /** @@ -711,10 +711,10 @@ SerdReader* SERD_ALLOCATED serd_reader_new(SerdSyntax syntax, void* SERD_NULLABLE handle, void (*SERD_NULLABLE free_handle)(void* SERD_NULLABLE), - SerdBaseSink SERD_NULLABLE base_sink, - SerdPrefixSink SERD_NULLABLE prefix_sink, - SerdStatementSink SERD_NULLABLE statement_sink, - SerdEndSink SERD_NULLABLE end_sink); + SerdBaseFunc SERD_NULLABLE base_func, + SerdPrefixFunc SERD_NULLABLE prefix_func, + SerdStatementFunc SERD_NULLABLE statement_func, + SerdEndFunc SERD_NULLABLE end_func); /** Enable or disable strict parsing. @@ -730,13 +730,13 @@ serd_reader_set_strict(SerdReader* SERD_NONNULL reader, bool strict); /** Set a function to be called when errors occur during reading. - The `error_sink` will be called with `handle` as its first argument. If + The `error_func` will be called with `handle` as its first argument. If no error function is set, errors are printed to stderr in GCC style. */ SERD_API void serd_reader_set_error_sink(SerdReader* SERD_NONNULL reader, - SerdErrorSink SERD_NULLABLE error_sink, + SerdErrorFunc SERD_NULLABLE error_func, void* SERD_NULLABLE error_handle); /// Return the `handle` passed to serd_reader_new() @@ -937,13 +937,13 @@ serd_buffer_sink_finish(SerdBuffer* SERD_NONNULL stream); /** Set a function to be called when errors occur during writing. - The `error_sink` will be called with `handle` as its first argument. If + The `error_func` will be called with `handle` as its first argument. If no error function is set, errors are printed to stderr. */ SERD_API void serd_writer_set_error_sink(SerdWriter* SERD_NONNULL writer, - SerdErrorSink SERD_NONNULL error_sink, + SerdErrorFunc SERD_NONNULL error_func, void* SERD_NULLABLE error_handle); /** @@ -259,7 +259,7 @@ serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node) void serd_env_foreach(const SerdEnv* const env, - const SerdPrefixSink func, + const SerdPrefixFunc func, void* const handle) { for (size_t i = 0; i < env->n_prefixes; ++i) { @@ -1093,8 +1093,8 @@ read_anon(SerdReader* const reader, } read_ws_star(reader); - if (reader->end_sink) { - reader->end_sink(reader->handle, deref(reader, *dest)); + if (reader->end_func) { + reader->end_func(reader->handle, deref(reader, *dest)); } *ctx.flags = old_flags; @@ -1445,8 +1445,8 @@ read_base(SerdReader* const reader, const bool sparql, const bool token) Ref uri = 0; TRY(st, read_IRIREF(reader, &uri)); - if (reader->base_sink) { - TRY(st, reader->base_sink(reader->handle, deref(reader, uri))); + if (reader->base_func) { + TRY(st, reader->base_func(reader->handle, deref(reader, uri))); } pop_node(reader, uri); @@ -1485,8 +1485,8 @@ read_prefixID(SerdReader* const reader, const bool sparql, const bool token) Ref uri = 0; TRY(st, read_IRIREF(reader, &uri)); - if (reader->prefix_sink) { - st = reader->prefix_sink( + if (reader->prefix_func) { + st = reader->prefix_func( reader->handle, deref(reader, name), deref(reader, uri)); } diff --git a/src/reader.c b/src/reader.c index a0f9f6c1..b2fc0038 100644 --- a/src/reader.c +++ b/src/reader.c @@ -36,7 +36,7 @@ r_err(SerdReader* const reader, const SerdStatus st, const char* const fmt, ...) va_start(args, fmt); const Cursor* const cur = &reader->source.cur; const SerdError e = {st, cur->filename, cur->line, cur->col, fmt, &args}; - serd_error(reader->error_sink, reader->error_handle, &e); + serd_error(reader->error_func, reader->error_handle, &e); va_end(args); return st; } @@ -158,9 +158,9 @@ emit_statement(SerdReader* const reader, graph = &reader->default_graph; } - const SerdStatus st = !reader->statement_sink + const SerdStatus st = !reader->statement_func ? SERD_SUCCESS - : reader->statement_sink(reader->handle, + : reader->statement_func(reader->handle, *ctx.flags, graph, deref(reader, ctx.subject), @@ -190,18 +190,18 @@ SerdReader* serd_reader_new(const SerdSyntax syntax, void* const handle, void (*const free_handle)(void*), - const SerdBaseSink base_sink, - const SerdPrefixSink prefix_sink, - const SerdStatementSink statement_sink, - const SerdEndSink end_sink) + const SerdBaseFunc base_func, + const SerdPrefixFunc prefix_func, + const SerdStatementFunc statement_func, + const SerdEndFunc end_func) { SerdReader* me = (SerdReader*)calloc(1, sizeof(SerdReader)); me->handle = handle; me->free_handle = free_handle; - me->base_sink = base_sink; - me->prefix_sink = prefix_sink; - me->statement_sink = statement_sink; - me->end_sink = end_sink; + me->base_func = base_func; + me->prefix_func = prefix_func; + me->statement_func = statement_func; + me->end_func = end_func; me->default_graph = SERD_NODE_NULL; me->stack = serd_stack_new(SERD_PAGE_SIZE); me->syntax = syntax; @@ -223,10 +223,10 @@ serd_reader_set_strict(SerdReader* const reader, const bool strict) void serd_reader_set_error_sink(SerdReader* const reader, - const SerdErrorSink error_sink, + const SerdErrorFunc error_func, void* const error_handle) { - reader->error_sink = error_sink; + reader->error_func = error_func; reader->error_handle = error_handle; } diff --git a/src/reader.h b/src/reader.h index 4896bf80..ae248410 100644 --- a/src/reader.h +++ b/src/reader.h @@ -58,11 +58,11 @@ typedef struct { struct SerdReaderImpl { void* handle; void (*free_handle)(void* ptr); - SerdBaseSink base_sink; - SerdPrefixSink prefix_sink; - SerdStatementSink statement_sink; - SerdEndSink end_sink; - SerdErrorSink error_sink; + SerdBaseFunc base_func; + SerdPrefixFunc prefix_func; + SerdStatementFunc statement_func; + SerdEndFunc end_func; + SerdErrorFunc error_func; void* error_handle; Ref rdf_first; Ref rdf_rest; diff --git a/src/serd_internal.h b/src/serd_internal.h index 139e6659..e16a2c12 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -33,10 +33,10 @@ /* Error reporting */ static inline void -serd_error(SerdErrorSink error_sink, void* handle, const SerdError* e) +serd_error(SerdErrorFunc error_func, void* handle, const SerdError* e) { - if (error_sink) { - error_sink(handle, e); + if (error_func) { + error_func(handle, e); } else { fprintf(stderr, "error: %s:%u:%u: ", e->filename, e->line, e->col); vfprintf(stderr, e->fmt, *e->args); diff --git a/src/serdi.c b/src/serdi.c index cda8aa21..f713f327 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -333,10 +333,10 @@ main(int argc, char** argv) serd_reader_new(input_syntax, writer, NULL, - (SerdBaseSink)serd_writer_set_base_uri, - (SerdPrefixSink)serd_writer_set_prefix, - (SerdStatementSink)serd_writer_write_statement, - (SerdEndSink)serd_writer_end_anon); + (SerdBaseFunc)serd_writer_set_base_uri, + (SerdPrefixFunc)serd_writer_set_prefix, + (SerdStatementFunc)serd_writer_write_statement, + (SerdEndFunc)serd_writer_end_anon); serd_reader_set_strict(reader, !lax); if (quiet) { diff --git a/src/writer.c b/src/writer.c index 82447826..9e345470 100644 --- a/src/writer.c +++ b/src/writer.c @@ -100,7 +100,7 @@ struct SerdWriterImpl { SerdURIView base_uri; SerdStack anon_stack; SerdByteSink byte_sink; - SerdErrorSink error_sink; + SerdErrorFunc error_func; void* error_handle; WriteContext context; SerdNode list_subj; @@ -146,7 +146,7 @@ w_err(SerdWriter* writer, SerdStatus st, const char* fmt, ...) va_list args; va_start(args, fmt); const SerdError e = {st, "", 0, 0, fmt, &args}; - serd_error(writer->error_sink, writer->error_handle, &e); + serd_error(writer->error_func, writer->error_handle, &e); va_end(args); } @@ -963,10 +963,10 @@ serd_writer_new(SerdSyntax syntax, void serd_writer_set_error_sink(SerdWriter* writer, - SerdErrorSink error_sink, + SerdErrorFunc error_func, void* error_handle) { - writer->error_sink = error_sink; + writer->error_func = error_func; writer->error_handle = error_handle; } |