aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/serd/serd.h10
-rw-r--r--src/n3.c8
-rw-r--r--src/writer.c33
3 files changed, 24 insertions, 27 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 3d06c4a0..f5ee9022 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -132,11 +132,11 @@ typedef enum {
/// Flags indicating inline abbreviation information for a statement
typedef enum {
- SERD_EMPTY_S = 1u << 0u, ///< Empty blank node subject
- SERD_ANON_S_BEGIN = 1u << 1u, ///< Start of anonymous subject
- SERD_ANON_O_BEGIN = 1u << 2u, ///< Start of anonymous object
- SERD_LIST_S_BEGIN = 1u << 3u, ///< Start of list subject
- SERD_LIST_O_BEGIN = 1u << 4u, ///< Start of list object
+ SERD_EMPTY_S = 1u << 0u, ///< Empty blank node subject
+ SERD_ANON_S = 1u << 1u, ///< Start of anonymous subject
+ SERD_ANON_O = 1u << 2u, ///< Start of anonymous object
+ SERD_LIST_S = 1u << 3u, ///< Start of list subject
+ SERD_LIST_O = 1u << 4u ///< Start of list object
} SerdStatementFlag;
/// Bitwise OR of SerdStatementFlag values
diff --git a/src/n3.c b/src/n3.c
index 7c0d2f4f..97757c64 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1036,9 +1036,9 @@ read_anon(SerdReader* reader, ReadContext ctx, bool subject, SerdNode** dest)
const bool empty = peek_delim(reader, ']');
if (subject) {
- *ctx.flags |= empty ? SERD_EMPTY_S : SERD_ANON_S_BEGIN;
+ *ctx.flags |= empty ? SERD_EMPTY_S : SERD_ANON_S;
} else {
- *ctx.flags |= SERD_ANON_O_BEGIN;
+ *ctx.flags |= SERD_ANON_O;
if (peek_delim(reader, '=')) {
if (!(*dest = read_blankName(reader)) || !eat_delim(reader, ';')) {
return SERD_ERR_BAD_SYNTAX;
@@ -1279,10 +1279,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 31c8c0a1..8632b0b5 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -558,8 +558,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
@@ -749,8 +749,8 @@ write_blank(SerdWriter* const writer,
return write_sep(writer, SEP_ANON_BEGIN);
}
- if ((field == SERD_SUBJECT && (flags & SERD_LIST_S_BEGIN)) ||
- (field == SERD_OBJECT && (flags & SERD_LIST_O_BEGIN))) {
+ if ((field == SERD_SUBJECT && (flags & SERD_LIST_S)) ||
+ (field == SERD_OBJECT && (flags & SERD_LIST_O))) {
return write_sep(writer, SEP_LIST_BEGIN);
}
@@ -833,10 +833,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)));
SerdStatus st = SERD_SUCCESS;
const SerdNode* const subject = serd_statement_subject(statement);
@@ -902,7 +900,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;
}
@@ -939,9 +937,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 {
@@ -951,7 +949,7 @@ 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);
}
@@ -959,8 +957,8 @@ serd_writer_write_statement(SerdWriter* writer,
}
// Push context for anonymous or list subject if necessary
- if (flags & (SERD_ANON_S_BEGIN | SERD_LIST_S_BEGIN)) {
- const bool is_list = (flags & SERD_LIST_S_BEGIN);
+ if (flags & (SERD_ANON_S | SERD_LIST_S)) {
+ const bool is_list = (flags & SERD_LIST_S);
const WriteContext ctx = {is_list ? CTX_LIST : CTX_BLANK,
serd_node_copy(graph),
@@ -973,8 +971,8 @@ serd_writer_write_statement(SerdWriter* writer,
}
// Push context for anonymous or list object if necessary
- if (flags & (SERD_ANON_O_BEGIN | SERD_LIST_O_BEGIN)) {
- const bool is_list = (flags & SERD_LIST_O_BEGIN);
+ if (flags & (SERD_ANON_O | SERD_LIST_O)) {
+ const bool is_list = (flags & SERD_LIST_O);
const WriteContext ctx = {is_list ? CTX_LIST : CTX_BLANK,
serd_node_copy(graph),
@@ -986,8 +984,7 @@ serd_writer_write_statement(SerdWriter* writer,
}
}
- if (!(flags & (SERD_ANON_S_BEGIN | SERD_LIST_S_BEGIN | SERD_ANON_O_BEGIN |
- SERD_LIST_O_BEGIN))) {
+ if (!(flags & (SERD_ANON_S | SERD_LIST_S | SERD_ANON_O | SERD_LIST_O))) {
// Update current context to this statement
serd_node_set(&writer->context.graph, graph);
serd_node_set(&writer->context.subject, subject);