From 6eb1fa15a06ab7de08e33add1540a45b83c5f0d8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Jul 2021 20:47:51 -0400 Subject: Add SerdWorld for shared library state --- src/writer.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/writer.c') diff --git a/src/writer.c b/src/writer.c index 5c05e244..f39363aa 100644 --- a/src/writer.c +++ b/src/writer.c @@ -23,6 +23,7 @@ #include "serd/string_view.h" #include "serd/syntax.h" #include "serd/uri.h" +#include "serd/world.h" #include "serd/writer.h" #include @@ -125,6 +126,7 @@ static const SepRule rules[] = { #undef SEP_EACH struct SerdWriterImpl { + SerdWorld* world; SerdSink iface; SerdSyntax syntax; SerdWriterFlags flags; @@ -133,8 +135,6 @@ struct SerdWriterImpl { SerdURIView root_uri; SerdStack anon_stack; SerdByteSink byte_sink; - SerdErrorFunc error_func; - void* error_handle; WriteContext context; char* bprefix; size_t bprefix_len; @@ -192,8 +192,8 @@ w_err(SerdWriter* writer, SerdStatus st, const char* fmt, ...) va_list args; // NOLINT(cppcoreguidelines-init-variables) va_start(args, fmt); - const SerdError e = {st, "", 0, 0, fmt, &args}; - serd_error(writer->error_func, writer->error_handle, &e); + const SerdError e = {st, NULL, 0, 0, fmt, &args}; + serd_error(writer->world, &e); va_end(args); return st; } @@ -1142,7 +1142,8 @@ serd_writer_finish(SerdWriter* writer) } SerdWriter* -serd_writer_new(SerdSyntax syntax, +serd_writer_new(SerdWorld* world, + SerdSyntax syntax, SerdWriterFlags flags, SerdEnv* env, SerdWriteFunc ssink, @@ -1151,6 +1152,7 @@ serd_writer_new(SerdSyntax syntax, const WriteContext context = WRITE_CONTEXT_NULL; SerdWriter* writer = (SerdWriter*)calloc(1, sizeof(SerdWriter)); + writer->world = world; writer->syntax = syntax; writer->flags = flags; writer->env = env; @@ -1170,15 +1172,6 @@ serd_writer_new(SerdSyntax syntax, return writer; } -void -serd_writer_set_error_sink(SerdWriter* writer, - SerdErrorFunc error_func, - void* error_handle) -{ - writer->error_func = error_func; - writer->error_handle = error_handle; -} - void serd_writer_chop_blank_prefix(SerdWriter* writer, const char* prefix) { -- cgit v1.2.1