diff options
author | David Robillard <d@drobilla.net> | 2018-12-30 13:52:33 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | 6133cdbc7d1615de2bfc2ee9f8082a09890bd72b (patch) | |
tree | 289490b1c7f1b59bffbbc4da3d8433467d5a63a5 /src | |
parent | cd0f6e585a02b26eb42e760fe8fa8b70612cc009 (diff) | |
download | serd-6133cdbc7d1615de2bfc2ee9f8082a09890bd72b.tar.gz serd-6133cdbc7d1615de2bfc2ee9f8082a09890bd72b.tar.bz2 serd-6133cdbc7d1615de2bfc2ee9f8082a09890bd72b.zip |
Use simpler names for statement flags
Diffstat (limited to 'src')
-rw-r--r-- | src/n3.c | 8 | ||||
-rw-r--r-- | src/writer.c | 32 |
2 files changed, 19 insertions, 21 deletions
@@ -981,9 +981,9 @@ read_anon(SerdReader* reader, ReadContext ctx, bool subject, SerdNode** dest) bool empty = false; eat_byte_safe(reader, '['); if ((empty = peek_delim(reader, ']'))) { - *ctx.flags |= (subject) ? SERD_EMPTY_S : SERD_ANON_O_BEGIN; + *ctx.flags |= (subject) ? SERD_EMPTY_S : SERD_ANON_O; } else { - *ctx.flags |= (subject) ? SERD_ANON_S_BEGIN : SERD_ANON_O_BEGIN; + *ctx.flags |= (subject) ? SERD_ANON_S : SERD_ANON_O; if (peek_delim(reader, '=')) { if (!(*dest = read_blankName(reader)) || !eat_delim(reader, ';')) { @@ -1191,10 +1191,10 @@ read_collection(SerdReader* reader, ReadContext ctx, SerdNode** dest) *dest = end ? reader->rdf_nil : blank_id(reader); if (ctx.subject) { // subject predicate _:head - *ctx.flags |= (end ? 0 : SERD_LIST_O_BEGIN); + *ctx.flags |= (end ? 0 : SERD_LIST_O); TRY(st, emit_statement(reader, ctx, *dest)); } else { - *ctx.flags |= (end ? 0 : SERD_LIST_S_BEGIN); + *ctx.flags |= (end ? 0 : SERD_LIST_S); } if (end) { diff --git a/src/writer.c b/src/writer.c index 132cf028..02f331bc 100644 --- a/src/writer.c +++ b/src/writer.c @@ -478,8 +478,8 @@ is_inline_start(const SerdWriter* writer, SerdStatementFlags flags) { return (supports_abbrev(writer) && - ((field == SERD_SUBJECT && (flags & SERD_ANON_S_BEGIN)) || - (field == SERD_OBJECT && (flags & SERD_ANON_O_BEGIN)))); + ((field == SERD_SUBJECT && (flags & SERD_ANON_S)) || + (field == SERD_OBJECT && (flags & SERD_ANON_O)))); } static bool @@ -655,8 +655,8 @@ write_blank(SerdWriter* const writer, if (supports_abbrev(writer)) { if (is_inline_start(writer, field, flags)) { return write_sep(writer, SEP_ANON_BEGIN); - } else if ((field == SERD_SUBJECT && (flags & SERD_LIST_S_BEGIN)) || - (field == SERD_OBJECT && (flags & SERD_LIST_O_BEGIN))) { + } else if ((field == SERD_SUBJECT && (flags & SERD_LIST_S)) || + (field == SERD_OBJECT && (flags & SERD_LIST_O))) { return write_sep(writer, SEP_LIST_BEGIN); } else if (field == SERD_SUBJECT && (flags & SERD_EMPTY_S)) { writer->last_sep = SEP_NONE; // Treat "[]" like anode @@ -737,10 +737,8 @@ serd_writer_write_statement(SerdWriter* writer, SerdStatementFlags flags, const SerdStatement* statement) { - assert(!((flags & SERD_EMPTY_S) && (flags & SERD_ANON_S_BEGIN))); - assert(!((flags & SERD_EMPTY_S) && (flags & SERD_LIST_S_BEGIN))); - assert(!((flags & SERD_ANON_S_BEGIN) && (flags & SERD_LIST_S_BEGIN))); - assert(!((flags & SERD_ANON_O_BEGIN) && (flags & SERD_LIST_O_BEGIN))); + assert(!((flags & SERD_ANON_S) && (flags & SERD_LIST_S))); + assert(!((flags & SERD_ANON_O) && (flags & SERD_LIST_O))); const SerdNode* const subject = serd_statement_subject(statement); const SerdNode* const predicate = serd_statement_predicate(statement); @@ -803,7 +801,7 @@ serd_writer_write_statement(SerdWriter* writer, if (serd_node_equals(predicate, writer->context.predicate)) { // Abbreviate S P if (!writer->context.indented_object && - !(flags & (SERD_ANON_O_BEGIN | SERD_LIST_O_BEGIN))) { + !(flags & (SERD_ANON_O | SERD_LIST_O))) { ++writer->indent; writer->context.indented_object = true; } @@ -840,9 +838,9 @@ serd_writer_write_statement(SerdWriter* writer, if (serd_stack_is_empty(&writer->anon_stack)) { write_node(writer, subject, SERD_SUBJECT, flags); - if (!(flags & (SERD_ANON_S_BEGIN | SERD_LIST_S_BEGIN))) { + if (!(flags & (SERD_ANON_S | SERD_LIST_S))) { write_sep(writer, SEP_S_P); - } else if (flags & SERD_ANON_S_BEGIN) { + } else if (flags & SERD_ANON_S) { write_sep(writer, SEP_ANON_S_P); } } else { @@ -852,21 +850,21 @@ serd_writer_write_statement(SerdWriter* writer, reset_context(writer, false); serd_node_set(&writer->context.subject, subject); - if (!(flags & SERD_LIST_S_BEGIN)) { + if (!(flags & SERD_LIST_S)) { write_pred(writer, flags, predicate); } write_node(writer, object, SERD_OBJECT, flags); } - if (flags & SERD_LIST_S_BEGIN) { + if (flags & SERD_LIST_S) { const WriteContext ctx = {CTX_LIST, serd_node_copy(graph), serd_node_copy(subject), NULL, false}; push_context(writer, ctx); - } if (flags & SERD_LIST_O_BEGIN) { + } if (flags & SERD_LIST_O) { const WriteContext ctx = {CTX_LIST, serd_node_copy(graph), serd_node_copy(object), @@ -875,9 +873,9 @@ serd_writer_write_statement(SerdWriter* writer, push_context(writer, ctx); } - if (flags & (SERD_ANON_S_BEGIN | SERD_ANON_O_BEGIN)) { - const bool is_list = flags & (SERD_LIST_S_BEGIN | SERD_LIST_O_BEGIN); - const bool is_subject = flags & SERD_ANON_S_BEGIN; + if (flags & (SERD_ANON_S | SERD_ANON_O)) { + const bool is_list = flags & (SERD_LIST_S | SERD_LIST_O); + const bool is_subject = flags & SERD_ANON_S; const WriteContext ctx = {is_list ? CTX_LIST : CTX_BLANK, serd_node_copy(graph), |