From 2370d86f35ff41ae94c5c45deef1e6a6dac0052c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 May 2018 11:14:32 +0200 Subject: Clean up includes and improve source file separation --- src/byte_sink.h | 8 +++++--- src/byte_source.c | 4 +++- src/byte_source.h | 5 +++-- src/env.c | 8 +++++--- src/n3.c | 13 +++++++++---- src/node.c | 9 ++++++--- src/node.h | 4 +++- src/reader.c | 14 ++++++++------ src/reader.h | 9 +++++++-- src/serd_internal.h | 3 --- src/serdi.c | 14 ++++++-------- src/stack.h | 4 ++-- src/string.c | 5 ++++- src/string_utils.h | 5 +++++ src/system.c | 1 - src/uri.c | 9 ++++++--- src/uri_utils.h | 6 ++++++ src/world.c | 5 ++--- src/world.h | 5 ++++- src/writer.c | 18 +++++++++++------- tests/serd_test.c | 3 ++- 21 files changed, 97 insertions(+), 55 deletions(-) diff --git a/src/byte_sink.h b/src/byte_sink.h index 0d825020..4425f91f 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -17,12 +17,14 @@ #ifndef SERD_BYTE_SINK_H #define SERD_BYTE_SINK_H -#include -#include +#include "serd_internal.h" +#include "system.h" #include "serd/serd.h" -#include "system.h" +#include +#include +#include typedef struct SerdByteSinkImpl { SerdWriteFunc sink; diff --git a/src/byte_source.c b/src/byte_source.c index 5fdfb3b1..b9e9ff4b 100644 --- a/src/byte_source.c +++ b/src/byte_source.c @@ -15,10 +15,12 @@ */ #include "byte_source.h" + #include "system.h" -#include "serd_internal.h" +#include "serd/serd.h" +#include #include #include diff --git a/src/byte_source.h b/src/byte_source.h index 7a04db8d..1cb0cfd1 100644 --- a/src/byte_source.h +++ b/src/byte_source.h @@ -17,11 +17,12 @@ #ifndef SERD_BYTE_SOURCE_H #define SERD_BYTE_SOURCE_H -#include "serd_internal.h" +#include "serd/serd.h" #include +#include #include -#include +#include typedef int (*SerdStreamCloseFunc)(void*); diff --git a/src/env.c b/src/env.c index a43993f1..bd312b9d 100644 --- a/src/env.c +++ b/src/env.c @@ -14,13 +14,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_internal.h" +#include "node.h" + +#include "serd/serd.h" +#include +#include #include #include -#include "node.h" - typedef struct { SerdNode* name; SerdNode* uri; diff --git a/src/n3.c b/src/n3.c index 97e61b7c..5b081aed 100644 --- a/src/n3.c +++ b/src/n3.c @@ -14,19 +14,24 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "byte_source.h" +#include "node.h" +#include "reader.h" #include "serd_internal.h" +#include "stack.h" +#include "string_utils.h" +#include "uri_utils.h" + +#include "serd/serd.h" #include #include +#include #include #include #include #include -#include "reader.h" -#include "string_utils.h" -#include "uri_utils.h" - #define TRY_THROW(exp) if (!(exp)) goto except; #define TRY_RET(exp) if (!(exp)) return 0; diff --git a/src/node.c b/src/node.c index 68a451f2..87dde842 100644 --- a/src/node.c +++ b/src/node.c @@ -14,17 +14,20 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "node.h" + #include "serd_internal.h" +#include "string_utils.h" #include #include #include +#include +#include +#include #include #include -#include "node.h" -#include "string_utils.h" - #ifdef _WIN32 # ifndef isnan # define isnan(x) _isnan(x) diff --git a/src/node.h b/src/node.h index 090faf0c..e39702a5 100644 --- a/src/node.h +++ b/src/node.h @@ -17,7 +17,9 @@ #ifndef SERD_NODE_H #define SERD_NODE_H -#include "serd_internal.h" +#include "serd/serd.h" + +#include struct SerdNodeImpl { size_t n_bytes; /**< Size in bytes (not including null) */ diff --git a/src/reader.c b/src/reader.c index 3a6c346c..aa36a681 100644 --- a/src/reader.c +++ b/src/reader.c @@ -15,20 +15,22 @@ */ #include "reader.h" + +#include "byte_source.h" +#include "node.h" +#include "serd/serd.h" #include "serd_internal.h" +#include "stack.h" +#include "system.h" +#include "world.h" -#include #include #include -#include +#include #include #include #include -#include "reader.h" -#include "system.h" -#include "world.h" - static SerdStatus serd_reader_prepare(SerdReader* reader); int diff --git a/src/reader.h b/src/reader.h index f8116949..4ca8f882 100644 --- a/src/reader.h +++ b/src/reader.h @@ -17,12 +17,17 @@ #ifndef SERD_READER_H #define SERD_READER_H -#include "serd_internal.h" - #include "byte_source.h" #include "node.h" #include "stack.h" +#include "serd/serd.h" + +#include +#include +#include +#include + #ifdef SERD_STACK_CHECK # define SERD_STACK_ASSERT_TOP(reader, ref) \ assert(ref == reader->allocs[reader->n_allocs - 1]); diff --git a/src/serd_internal.h b/src/serd_internal.h index 911d296f..fda651ae 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -17,9 +17,6 @@ #ifndef SERD_INTERNAL_H #define SERD_INTERNAL_H -#include "serd/serd.h" -#include "serd_config.h" - #define NS_XSD "http://www.w3.org/2001/XMLSchema#" #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" diff --git a/src/serdi.c b/src/serdi.c index 1272a70b..6a1c6d29 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -14,22 +14,20 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_internal.h" +#include "string_utils.h" +#include "system.h" + +#include "serd/serd.h" #ifdef _WIN32 #include #include #endif -#include -#include -#include +#include +#include #include -#include "string_utils.h" -#include "system.h" -#include "world.h" - #define SERDI_ERROR(msg) fprintf(stderr, "serdi: " msg); #define SERDI_ERRORF(fmt, ...) fprintf(stderr, "serdi: " fmt, __VA_ARGS__); diff --git a/src/stack.h b/src/stack.h index a7b86933..a3e79b11 100644 --- a/src/stack.h +++ b/src/stack.h @@ -17,10 +17,10 @@ #ifndef SERD_STACK_H #define SERD_STACK_H -#include "serd_internal.h" - #include +#include #include +#include #include /** An offset to start the stack at. Note 0 is reserved for NULL. */ diff --git a/src/string.c b/src/string.c index 0d2c502e..f3e9dc28 100644 --- a/src/string.c +++ b/src/string.c @@ -14,10 +14,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_internal.h" +#include "string.h" + +#include "serd/serd.h" #include "string_utils.h" #include +#include #include void diff --git a/src/string_utils.h b/src/string_utils.h index c9252e8f..1accc805 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -17,8 +17,13 @@ #ifndef SERD_STRING_UTILS_H #define SERD_STRING_UTILS_H +#include "serd/serd.h" + #include #include +#include +#include +#include #include /** Unicode replacement character in UTF-8 */ diff --git a/src/system.c b/src/system.c index cf26bb37..1af179f5 100644 --- a/src/system.c +++ b/src/system.c @@ -19,7 +19,6 @@ #include "system.h" #include "serd_config.h" -#include "serd_internal.h" #include diff --git a/src/uri.c b/src/uri.c index e8631ea8..b4f5beb2 100644 --- a/src/uri.c +++ b/src/uri.c @@ -14,13 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_internal.h" +#include "string_utils.h" +#include "uri_utils.h" + +#include "serd/serd.h" +#include +#include #include #include -#include "uri_utils.h" - char* serd_file_uri_parse(const char* uri, char** hostname) { diff --git a/src/uri_utils.h b/src/uri_utils.h index 844c6903..2da27211 100644 --- a/src/uri_utils.h +++ b/src/uri_utils.h @@ -19,6 +19,12 @@ #include "string_utils.h" +#include "serd/serd.h" + +#include +#include +#include + static inline bool slice_equals(const SerdStringView* a, const SerdStringView* b) { diff --git a/src/world.c b/src/world.c index 49a84d42..f95accf4 100644 --- a/src/world.c +++ b/src/world.c @@ -16,7 +16,8 @@ #define _POSIX_C_SOURCE 200809L /* for posix_fadvise */ -#include "serd_internal.h" +#include "world.h" + #include "serd_config.h" #include @@ -28,8 +29,6 @@ # include #endif -#include "world.h" - FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode) { diff --git a/src/world.h b/src/world.h index aeea70c2..0aaea8fc 100644 --- a/src/world.h +++ b/src/world.h @@ -17,7 +17,10 @@ #ifndef SERD_WORLD_H #define SERD_WORLD_H -#include "serd_internal.h" +#include "serd/serd.h" + +#include +#include struct SerdWorldImpl { SerdErrorSink error_sink; diff --git a/src/writer.c b/src/writer.c index fce383b5..2273b415 100644 --- a/src/writer.c +++ b/src/writer.c @@ -14,20 +14,24 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_internal.h" - -#include -#include -#include -#include - #include "byte_sink.h" #include "node.h" +#include "serd_internal.h" #include "stack.h" #include "string_utils.h" +#include "system.h" #include "uri_utils.h" #include "world.h" +#include "serd/serd.h" + +#include +#include +#include +#include +#include +#include + typedef struct { SerdNode* graph; SerdNode* subject; diff --git a/tests/serd_test.c b/tests/serd_test.c index be4afe19..13a14000 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -19,7 +19,8 @@ #include #include #include -#include +#include +#include #include #include #include -- cgit v1.2.1