diff options
author | David Robillard <d@drobilla.net> | 2011-04-29 19:23:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-29 19:23:28 +0000 |
commit | f89cead131a61c0b58bc4e706df339db3f1b9965 (patch) | |
tree | 5a73f4de7c8ac3ff2891614ba5e3649bbd22494b /src/lilv_internal.h | |
parent | 4546e878c0cf6bd40b9af31e4a704141daa1c76c (diff) | |
download | lilv-f89cead131a61c0b58bc4e706df339db3f1b9965.tar.gz lilv-f89cead131a61c0b58bc4e706df339db3f1b9965.tar.bz2 lilv-f89cead131a61c0b58bc4e706df339db3f1b9965.zip |
Tidy.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3238 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/lilv_internal.h')
-rw-r--r-- | src/lilv_internal.h | 298 |
1 files changed, 122 insertions, 176 deletions
diff --git a/src/lilv_internal.h b/src/lilv_internal.h index 32c3420..caa5fbc 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -55,163 +55,65 @@ static inline char* dlerror(void) { return "Unknown error"; } #define LILV_NS_XSD "http://www.w3.org/2001/XMLSchema#" #define LILV_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" -#define FOREACH_MATCH(iter) \ - for (; !sord_iter_end(iter); sord_iter_next(iter)) - -static inline const SordNode* -lilv_match_subject(SordIter* iter) { - SordQuad tup; - sord_iter_get(iter, tup); - return tup[SORD_SUBJECT]; -} - -static inline const SordNode* -lilv_match_object(SordIter* iter) { - SordQuad tup; - sord_iter_get(iter, tup); - return tup[SORD_OBJECT]; -} +/* + * + * Types + * + */ -static inline void -lilv_match_end(SordIter* iter) -{ - sord_iter_free(iter); -} +typedef struct LilvSpecImpl LilvSpec; -/* ********* PORT ********* */ +typedef void LilvCollection; -/** Reference to a port on some plugin. */ struct LilvPortImpl { - uint32_t index; ///< lv2:index - LilvNode* symbol; ///< lv2:symbol - LilvNodes* classes; ///< rdf:type + uint32_t index; ///< lv2:index + LilvNode* symbol; ///< lv2:symbol + LilvNodes* classes; ///< rdf:type }; -LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol); -void lilv_port_free(LilvPort* port); - -/* ********* Spec ********* */ struct LilvSpecImpl { - SordNode* spec; - SordNode* bundle; + SordNode* spec; + SordNode* bundle; LilvNodes* data_uris; }; -typedef struct LilvSpecImpl LilvSpec; - -/* ********* Plugin ********* */ - -/** Header of an LilvPlugin, LilvPluginClass, or LilvUI. - * Any of these structs may be safely casted to LilvHeader, which is used to - * implement sequences without code duplication (see lilv_sequence_get_by_uri). - */ +/** + Header of an LilvPlugin, LilvPluginClass, or LilvUI. + Any of these structs may be safely casted to LilvHeader, which is used to + implement sequences without code duplication (see lilv_sequence_get_by_uri). +*/ struct LilvHeader { LilvWorld* world; - LilvNode* uri; + LilvNode* uri; }; -/** Record of an installed/available plugin. - * - * A simple reference to a plugin somewhere on the system. This just holds - * paths of relevant files, the actual data therein isn't loaded into memory. - */ struct LilvPluginImpl { LilvWorld* world; - LilvNode* plugin_uri; - LilvNode* bundle_uri; ///< Bundle directory plugin was loaded from - LilvNode* binary_uri; ///< lv2:binary - LilvNode* dynman_uri; ///< dynamic manifest binary + LilvNode* plugin_uri; + LilvNode* bundle_uri; ///< Bundle plugin was loaded from + LilvNode* binary_uri; ///< lv2:binary + LilvNode* dynman_uri; ///< dynamic manifest binary const LilvPluginClass* plugin_class; - LilvNodes* data_uris; ///< rdfs::seeAlso + LilvNodes* data_uris; ///< rdfs::seeAlso LilvPort** ports; uint32_t num_ports; bool loaded; bool replaced; }; -LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri); -void lilv_plugin_load_if_necessary(const LilvPlugin* p); -void lilv_plugin_free(LilvPlugin* plugin); - -LilvNode* -lilv_plugin_get_unique(const LilvPlugin* p, - const SordNode* subject, - const SordNode* predicate); - -/* ********* Plugins ********* */ - -typedef void LilvCollection; - -LilvPlugins* -lilv_plugins_new(); - - -/** - Increment @a i to point at the next element in the collection. -*/ -LilvIter* -lilv_iter_next(LilvIter* i); - -/** - Return true iff @a i is at the end of the collection. -*/ -bool -lilv_iter_end(LilvIter* i); - -LilvIter* -lilv_collection_begin(const LilvCollection* collection); - -void* -lilv_collection_get(const LilvCollection* collection, - const LilvIter* i); - -/** - Free @a collection. -*/ -void -lilv_collection_free(LilvCollection* collection); - -/** - Get the number of elements in @a collection. -*/ -unsigned -lilv_collection_size(const LilvCollection* collection); - -LilvNodes* -lilv_nodes_new(void); - -LilvScalePoints* -lilv_scale_points_new(void); - struct LilvPluginClassImpl { LilvWorld* world; - LilvNode* uri; - LilvNode* parent_uri; - LilvNode* label; + LilvNode* uri; + LilvNode* parent_uri; + LilvNode* label; }; -LilvPluginClass* lilv_plugin_class_new(LilvWorld* world, - const SordNode* parent_uri, - const SordNode* uri, - const char* label); - -void lilv_plugin_class_free(LilvPluginClass* plugin_class); - -/* ********* Plugin Classes ********* */ - -LilvPluginClasses* lilv_plugin_classes_new(); -void lilv_plugin_classes_free(); - -/* ********* World ********* */ - typedef struct { bool dyn_manifest; bool filter_language; } LilvOptions; -/** Model of LV2 (RDF) data loaded from bundles. - */ struct LilvWorldImpl { SordWorld* world; SordModel* model; @@ -245,41 +147,14 @@ struct LilvWorldImpl { SordNode* xsd_decimal_node; SordNode* xsd_double_node; SordNode* xsd_integer_node; - LilvNode* doap_name_val; - LilvNode* lv2_name_val; - LilvNode* lv2_optionalFeature_val; - LilvNode* lv2_requiredFeature_val; + LilvNode* doap_name_val; + LilvNode* lv2_name_val; + LilvNode* lv2_optionalFeature_val; + LilvNode* lv2_requiredFeature_val; LilvOptions opt; }; -const uint8_t* -lilv_world_blank_node_prefix(LilvWorld* world); -void -lilv_world_load_file(LilvWorld* world, const char* file_uri); - -/* ********* Plugin UI ********* */ - -struct LilvUIImpl { - LilvWorld* world; - LilvNode* uri; - LilvNode* bundle_uri; - LilvNode* binary_uri; - LilvNodes* classes; -}; - -LilvUIs* lilv_uis_new(); - -LilvUI* -lilv_ui_new(LilvWorld* world, - LilvNode* uri, - LilvNode* type_uri, - LilvNode* binary_uri); - -void lilv_ui_free(LilvUI* ui); - -/* ********* Value ********* */ - -typedef enum _LilvNodeType { +typedef enum { LILV_VALUE_URI, LILV_VALUE_STRING, LILV_VALUE_INT, @@ -297,15 +172,75 @@ struct LilvNodeImpl { bool bool_val; SordNode* uri_val; } val; - LilvNodeType type; + LilvNodeType type; +}; + +struct LilvScalePointImpl { + LilvNode* value; + LilvNode* label; }; -LilvNode* lilv_node_new(LilvWorld* world, LilvNodeType type, const char* val); -LilvNode* lilv_node_new_from_node(LilvWorld* world, const SordNode* node); -const SordNode* lilv_node_as_node(const LilvNode* value); +struct LilvUIImpl { + LilvWorld* world; + LilvNode* uri; + LilvNode* bundle_uri; + LilvNode* binary_uri; + LilvNodes* classes; +}; + +/* + * + * Functions + * + */ + +LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol); +void lilv_port_free(LilvPort* port); + +LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri); +void lilv_plugin_load_if_necessary(const LilvPlugin* p); +void lilv_plugin_free(LilvPlugin* plugin); +LilvNode* lilv_plugin_get_unique(const LilvPlugin* p, + const SordNode* subject, + const SordNode* predicate); + +LilvIter* lilv_iter_next(LilvIter* i); +bool lilv_iter_end(LilvIter* i); + +void lilv_collection_free(LilvCollection* collection); +unsigned lilv_collection_size(const LilvCollection* collection); +LilvIter* lilv_collection_begin(const LilvCollection* collection); +void* lilv_collection_get(const LilvCollection* collection, + const LilvIter* i); + +LilvPluginClass* lilv_plugin_class_new(LilvWorld* world, + const SordNode* parent_uri, + const SordNode* uri, + const char* label); + +void lilv_plugin_class_free(LilvPluginClass* plugin_class); + +LilvNodes* lilv_nodes_new(void); +LilvPlugins* lilv_plugins_new(void); +LilvScalePoints* lilv_scale_points_new(void); +LilvPluginClasses* lilv_plugin_classes_new(void); +LilvUIs* lilv_uis_new(void); + +const uint8_t* lilv_world_blank_node_prefix(LilvWorld* world); +void lilv_world_load_file(LilvWorld* world, const char* file_uri); -int -lilv_header_compare_by_uri(const void* a, const void* b, void* user_data); +LilvUI* lilv_ui_new(LilvWorld* world, + LilvNode* uri, + LilvNode* type_uri, + LilvNode* binary_uri); + +void lilv_ui_free(LilvUI* ui); + +LilvNode* lilv_node_new(LilvWorld* world, LilvNodeType type, const char* val); +LilvNode* lilv_node_new_from_node(LilvWorld* world, const SordNode* node); +const SordNode* lilv_node_as_node(const LilvNode* value); + +int lilv_header_compare_by_uri(const void* a, const void* b, void* user_data); static inline void lilv_sequence_insert(GSequence* seq, void* value) @@ -321,18 +256,9 @@ lilv_array_append(GSequence* seq, void* value) { struct LilvHeader* lilv_sequence_get_by_uri(const GSequence* seq, const LilvNode* uri); -/* ********* Scale Points ********* */ - -struct LilvScalePointImpl { - LilvNode* value; - LilvNode* label; -}; - LilvScalePoint* lilv_scale_point_new(LilvNode* value, LilvNode* label); void lilv_scale_point_free(LilvScalePoint* point); -/* ********* Query Results ********* */ - SordIter* lilv_world_query(LilvWorld* world, const SordNode* subject, @@ -345,6 +271,29 @@ lilv_world_query_values(LilvWorld* world, const SordNode* predicate, const SordNode* object); +#define FOREACH_MATCH(iter) \ + for (; !sord_iter_end(iter); sord_iter_next(iter)) + +static inline const SordNode* +lilv_match_subject(SordIter* iter) { + SordQuad tup; + sord_iter_get(iter, tup); + return tup[SORD_SUBJECT]; +} + +static inline const SordNode* +lilv_match_object(SordIter* iter) { + SordQuad tup; + sord_iter_get(iter, tup); + return tup[SORD_OBJECT]; +} + +static inline void +lilv_match_end(SordIter* iter) +{ + sord_iter_free(iter); +} + static inline bool lilv_matches_next(SordIter* matches) { return sord_iter_next(matches); } @@ -356,13 +305,11 @@ static inline bool lilv_matches_end(SordIter* matches) { LilvNodes* lilv_nodes_from_stream_objects(LilvWorld* w, SordIter* stream); -/* ********* Utilities ********* */ - char* lilv_strjoin(const char* first, ...); char* lilv_strdup(const char* str); -char* lilv_get_lang(); +char* lilv_get_lang(void); -typedef void (*VoidFunc)(); +typedef void (*VoidFunc)(void); /** dlsym wrapper to return a function pointer (without annoying warning) */ static inline VoidFunc @@ -373,7 +320,6 @@ lilv_dlfunc(void* handle, const char* symbol) return dlfunc(handle, symbol); } -/* ********* Dynamic Manifest ********* */ #ifdef LILV_DYN_MANIFEST static const LV2_Feature* const dman_features = { NULL }; #endif |