summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/collections.c91
-rw-r--r--src/lilv_internal.h272
-rw-r--r--src/plugin.c223
-rw-r--r--src/pluginclass.c37
-rw-r--r--src/plugininstance.c33
-rw-r--r--src/pluginui.c46
-rw-r--r--src/port.c122
-rw-r--r--src/query.c30
-rw-r--r--src/scalepoint.c17
-rw-r--r--src/util.c2
-rw-r--r--src/value.c84
-rw-r--r--src/world.c122
12 files changed, 527 insertions, 552 deletions
diff --git a/src/collections.c b/src/collections.c
index 9111835..58207f9 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -20,59 +20,59 @@
/* Generic collection functions */
-static inline LilvCollection
+static inline LilvCollection*
lilv_collection_new(GDestroyNotify destructor)
{
return g_sequence_new(destructor);
}
void
-lilv_collection_free(LilvCollection coll)
+lilv_collection_free(LilvCollection* coll)
{
if (coll)
g_sequence_free((GSequence*)coll);
}
unsigned
-lilv_collection_size(LilvCollection coll)
+lilv_collection_size(const LilvCollection* coll)
{
return (coll ? g_sequence_get_length((GSequence*)coll) : 0);
}
-LilvIter
-lilv_collection_begin(LilvCollection collection)
+LilvIter*
+lilv_collection_begin(const LilvCollection* collection)
{
- return collection ? g_sequence_get_begin_iter(collection) : NULL;
+ return collection ? g_sequence_get_begin_iter((LilvCollection*)collection) : NULL;
}
void*
-lilv_collection_get(LilvCollection collection,
- LilvIter i)
+lilv_collection_get(const LilvCollection* collection,
+ const LilvIter* i)
{
return g_sequence_get((GSequenceIter*)i);
}
/* Constructors */
-LilvScalePoints
+LilvScalePoints*
lilv_scale_points_new(void)
{
return lilv_collection_new((GDestroyNotify)lilv_scale_point_free);
}
-LilvValues
+LilvValues*
lilv_values_new(void)
{
return lilv_collection_new((GDestroyNotify)lilv_value_free);
}
-LilvUIs
+LilvUIs*
lilv_uis_new(void)
{
return lilv_collection_new((GDestroyNotify)lilv_ui_free);
}
-LilvPluginClasses
+LilvPluginClasses*
lilv_plugin_classes_new(void)
{
return lilv_collection_new((GDestroyNotify)lilv_plugin_class_free);
@@ -81,39 +81,39 @@ lilv_plugin_classes_new(void)
/* URI based accessors (for collections of things with URIs) */
LILV_API
-LilvPluginClass
-lilv_plugin_classes_get_by_uri(LilvPluginClasses coll, LilvValue uri)
+const LilvPluginClass*
+lilv_plugin_classes_get_by_uri(const LilvPluginClasses* coll, const LilvValue* uri)
{
- return (LilvPluginClass)lilv_sequence_get_by_uri(coll, uri);
+ return (LilvPluginClass*)lilv_sequence_get_by_uri(coll, uri);
}
LILV_API
-LilvUI
-lilv_uis_get_by_uri(LilvUIs coll, LilvValue uri)
+const LilvUI*
+lilv_uis_get_by_uri(const LilvUIs* coll, const LilvValue* uri)
{
- return (LilvUIs)lilv_sequence_get_by_uri(coll, uri);
+ return (LilvUI*)lilv_sequence_get_by_uri((LilvUIs*)coll, uri);
}
/* Plugins */
-LilvPlugins
+LilvPlugins*
lilv_plugins_new()
{
return g_sequence_new(NULL);
}
LILV_API
-LilvPlugin
-lilv_plugins_get_by_uri(LilvPlugins list, LilvValue uri)
+const LilvPlugin*
+lilv_plugins_get_by_uri(const LilvPlugins* list, const LilvValue* uri)
{
- return (LilvPlugin)lilv_sequence_get_by_uri(list, uri);
+ return (LilvPlugin*)lilv_sequence_get_by_uri((LilvPlugins*)list, uri);
}
/* Values */
LILV_API
bool
-lilv_values_contains(LilvValues list, LilvValue value)
+lilv_values_contains(const LilvValues* list, const LilvValue* value)
{
LILV_FOREACH(values, i, list)
if (lilv_value_equals(lilv_values_get(list, i), value))
@@ -124,14 +124,14 @@ lilv_values_contains(LilvValues list, LilvValue value)
/* Iterator */
-LilvIter
-lilv_iter_next(LilvIter i)
+LilvIter*
+lilv_iter_next(LilvIter* i)
{
return g_sequence_iter_next((GSequenceIter*)i);
}
bool
-lilv_iter_end(LilvIter i)
+lilv_iter_end(LilvIter* i)
{
return !i || g_sequence_iter_is_end((GSequenceIter*)i);
}
@@ -139,31 +139,31 @@ lilv_iter_end(LilvIter i)
#define LILV_COLLECTION_IMPL(prefix, CT, ET) \
LILV_API \
unsigned \
-prefix##_size(CT collection) { \
+prefix##_size(const CT* collection) { \
return lilv_collection_size(collection); \
} \
\
LILV_API \
-LilvIter \
-prefix##_begin(CT collection) { \
+LilvIter* \
+prefix##_begin(const CT* collection) { \
return lilv_collection_begin(collection); \
} \
\
LILV_API \
-ET \
-prefix##_get(CT collection, LilvIter i) { \
- return (ET)lilv_collection_get(collection, i); \
+const ET* \
+prefix##_get(const CT* collection, LilvIter* i) { \
+ return (ET*)lilv_collection_get(collection, i); \
} \
\
LILV_API \
-LilvIter \
-prefix##_next(CT collection, LilvIter i) { \
+LilvIter* \
+prefix##_next(const CT* collection, LilvIter* i) { \
return lilv_iter_next(i); \
} \
\
LILV_API \
bool \
-prefix##_is_end(CT collection, LilvIter i) { \
+prefix##_is_end(const CT* collection, LilvIter* i) { \
return lilv_iter_end(i); \
}
@@ -175,36 +175,31 @@ LILV_COLLECTION_IMPL(lilv_plugins, LilvPlugins, LilvPlugin)
LILV_API
void
-lilv_plugin_classes_free(LilvPluginClasses collection) {
+lilv_plugin_classes_free(LilvPluginClasses* collection) {
lilv_collection_free(collection);
}
LILV_API
void
-lilv_scale_points_free(LilvScalePoints collection) {
+lilv_scale_points_free(LilvScalePoints* collection) {
lilv_collection_free(collection);
}
LILV_API
void
-lilv_uis_free(LilvUIs collection) {
+lilv_uis_free(LilvUIs* collection) {
lilv_collection_free(collection);
}
LILV_API
void
-lilv_values_free(LilvValues collection) {
+lilv_values_free(LilvValues* collection) {
lilv_collection_free(collection);
}
LILV_API
-void
-lilv_plugins_free(LilvWorld world, LilvPlugins plugins){
-}
-
-LILV_API
-LilvValue
-lilv_values_get_first(LilvValues collection) {
- return (LilvValue)lilv_collection_get(collection,
- lilv_collection_begin(collection));
+LilvValue*
+lilv_values_get_first(const LilvValues* collection) {
+ return (LilvValue*)lilv_collection_get(collection,
+ lilv_collection_begin(collection));
}
diff --git a/src/lilv_internal.h b/src/lilv_internal.h
index f856508..841dbba 100644
--- a/src/lilv_internal.h
+++ b/src/lilv_internal.h
@@ -85,34 +85,34 @@ lilv_match_end(LilvMatches iter)
/* ********* PORT ********* */
/** Reference to a port on some plugin. */
-struct _LilvPort {
- uint32_t index; ///< lv2:index
- LilvValue symbol; ///< lv2:symbol
- LilvValues classes; ///< rdf:type
+struct LilvPortImpl {
+ uint32_t index; ///< lv2:index
+ LilvValue* symbol; ///< lv2:symbol
+ LilvValues* classes; ///< rdf:type
};
-LilvPort lilv_port_new(LilvWorld world, uint32_t index, const char* symbol);
-void lilv_port_free(LilvPort port);
+LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol);
+void lilv_port_free(LilvPort* port);
/* ********* Spec ********* */
-struct _LilvSpec {
- SordNode* spec;
- SordNode* bundle;
- LilvValues data_uris;
+struct LilvSpecImpl {
+ SordNode* spec;
+ SordNode* bundle;
+ LilvValues* data_uris;
};
-typedef struct _LilvSpec* LilvSpec;
+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
+ * 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 {
- struct _LilvWorld* world;
- LilvValue uri;
+struct LilvHeader {
+ LilvWorld* world;
+ LilvValue* uri;
};
/** Record of an installed/available plugin.
@@ -120,102 +120,92 @@ struct _LilvHeader {
* 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 _LilvPlugin {
- struct _LilvWorld* world;
- LilvValue plugin_uri;
- LilvValue bundle_uri; ///< Bundle directory plugin was loaded from
- LilvValue binary_uri; ///< lv2:binary
- LilvValue dynman_uri; ///< dynamic manifest binary
- LilvPluginClass plugin_class;
- LilvValues data_uris; ///< rdfs::seeAlso
- LilvPort* ports;
- uint32_t num_ports;
- bool loaded;
- bool replaced;
+struct LilvPluginImpl {
+ LilvWorld* world;
+ LilvValue* plugin_uri;
+ LilvValue* bundle_uri; ///< Bundle directory plugin was loaded from
+ LilvValue* binary_uri; ///< lv2:binary
+ LilvValue* dynman_uri; ///< dynamic manifest binary
+ const LilvPluginClass* plugin_class;
+ LilvValues* data_uris; ///< rdfs::seeAlso
+ LilvPort** ports;
+ uint32_t num_ports;
+ bool loaded;
+ bool replaced;
};
-LilvPlugin lilv_plugin_new(LilvWorld world, LilvValue uri, LilvValue bundle_uri);
-void lilv_plugin_load_if_necessary(LilvPlugin p);
-void lilv_plugin_free(LilvPlugin plugin);
+LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri);
+void lilv_plugin_load_if_necessary(const LilvPlugin* p);
+void lilv_plugin_free(LilvPlugin* plugin);
-LilvValue
-lilv_plugin_get_unique(LilvPlugin p,
- LilvNode subject,
- LilvNode predicate);
+LilvValue*
+lilv_plugin_get_unique(const LilvPlugin* p,
+ LilvNode subject,
+ LilvNode predicate);
/* ********* Plugins ********* */
-typedef void* LilvCollection;
+typedef void LilvCollection;
-LilvPlugins
+LilvPlugins*
lilv_plugins_new();
/**
Increment @a i to point at the next element in the collection.
*/
-LilvIter
-lilv_iter_next(LilvIter i);
+LilvIter*
+lilv_iter_next(LilvIter* i);
/**
Return true iff @a i is at the end of the collection.
*/
bool
-lilv_iter_end(LilvIter i);
+lilv_iter_end(LilvIter* i);
-LilvIter
-lilv_collection_begin(LilvCollection collection);
+LilvIter*
+lilv_collection_begin(const LilvCollection* collection);
void*
-lilv_collection_get(LilvCollection collection,
- LilvIter i);
+lilv_collection_get(const LilvCollection* collection,
+ const LilvIter* i);
/**
Free @a collection.
*/
void
-lilv_collection_free(LilvCollection collection);
+lilv_collection_free(LilvCollection* collection);
/**
Get the number of elements in @a collection.
*/
unsigned
-lilv_collection_size(LilvCollection collection);
+lilv_collection_size(const LilvCollection* collection);
-LilvValues
+LilvValues*
lilv_values_new(void);
-LilvScalePoints
+LilvScalePoints*
lilv_scale_points_new(void);
-
-/* ********* Instance ********* */
-
-/** Pimpl portion of LilvInstance */
-struct _LilvInstanceImpl {
- void* lib_handle;
-};
-
-/* ********* Plugin Class ********* */
-
-struct _LilvPluginClass {
- struct _LilvWorld* world;
- LilvValue uri;
- LilvValue parent_uri;
- LilvValue label;
+struct LilvPluginClassImpl {
+ LilvWorld* world;
+ LilvValue* uri;
+ LilvValue* parent_uri;
+ LilvValue* label;
};
-LilvPluginClass lilv_plugin_class_new(LilvWorld world,
- LilvNode parent_uri,
- LilvNode uri,
- const char* label);
+LilvPluginClass* lilv_plugin_class_new(LilvWorld* world,
+ LilvNode parent_uri,
+ LilvNode uri,
+ const char* label);
-void lilv_plugin_class_free(LilvPluginClass plugin_class);
+void lilv_plugin_class_free(LilvPluginClass* plugin_class);
/* ********* Plugin Classes ********* */
-LilvPluginClasses lilv_plugin_classes_new();
-void lilv_plugin_classes_free();
+LilvPluginClasses* lilv_plugin_classes_new();
+void lilv_plugin_classes_free();
/* ********* World ********* */
@@ -226,69 +216,69 @@ typedef struct {
/** Model of LV2 (RDF) data loaded from bundles.
*/
-struct _LilvWorld {
- SordWorld* world;
- SordModel* model;
- SerdReader* reader;
- SerdEnv* namespaces;
- unsigned n_read_files;
- LilvPluginClass lv2_plugin_class;
- LilvPluginClasses plugin_classes;
- GSList* specs;
- LilvPlugins plugins;
- SordNode* dc_replaces_node;
- SordNode* dyn_manifest_node;
- SordNode* lv2_specification_node;
- SordNode* lv2_plugin_node;
- SordNode* lv2_binary_node;
- SordNode* lv2_default_node;
- SordNode* lv2_minimum_node;
- SordNode* lv2_maximum_node;
- SordNode* lv2_port_node;
- SordNode* lv2_portproperty_node;
- SordNode* lv2_reportslatency_node;
- SordNode* lv2_index_node;
- SordNode* lv2_symbol_node;
- SordNode* rdf_a_node;
- SordNode* rdf_value_node;
- SordNode* rdfs_class_node;
- SordNode* rdfs_label_node;
- SordNode* rdfs_seealso_node;
- SordNode* rdfs_subclassof_node;
- SordNode* lilv_dmanifest_node;
- SordNode* xsd_boolean_node;
- SordNode* xsd_decimal_node;
- SordNode* xsd_double_node;
- SordNode* xsd_integer_node;
- LilvValue doap_name_val;
- LilvValue lv2_name_val;
- LilvOptions opt;
+struct LilvWorldImpl {
+ SordWorld* world;
+ SordModel* model;
+ SerdReader* reader;
+ SerdEnv* namespaces;
+ unsigned n_read_files;
+ LilvPluginClass* lv2_plugin_class;
+ LilvPluginClasses* plugin_classes;
+ GSList* specs;
+ LilvPlugins* plugins;
+ SordNode* dc_replaces_node;
+ SordNode* dyn_manifest_node;
+ SordNode* lv2_specification_node;
+ SordNode* lv2_plugin_node;
+ SordNode* lv2_binary_node;
+ SordNode* lv2_default_node;
+ SordNode* lv2_minimum_node;
+ SordNode* lv2_maximum_node;
+ SordNode* lv2_port_node;
+ SordNode* lv2_portproperty_node;
+ SordNode* lv2_reportslatency_node;
+ SordNode* lv2_index_node;
+ SordNode* lv2_symbol_node;
+ SordNode* rdf_a_node;
+ SordNode* rdf_value_node;
+ SordNode* rdfs_class_node;
+ SordNode* rdfs_label_node;
+ SordNode* rdfs_seealso_node;
+ SordNode* rdfs_subclassof_node;
+ SordNode* lilv_dmanifest_node;
+ SordNode* xsd_boolean_node;
+ SordNode* xsd_decimal_node;
+ SordNode* xsd_double_node;
+ SordNode* xsd_integer_node;
+ LilvValue* doap_name_val;
+ LilvValue* lv2_name_val;
+ LilvOptions opt;
};
const uint8_t*
-lilv_world_blank_node_prefix(LilvWorld world);
+lilv_world_blank_node_prefix(LilvWorld* world);
void
-lilv_world_load_file(LilvWorld world, const char* file_uri);
+lilv_world_load_file(LilvWorld* world, const char* file_uri);
/* ********* Plugin UI ********* */
-struct _LilvUI {
- struct _LilvWorld* world;
- LilvValue uri;
- LilvValue bundle_uri;
- LilvValue binary_uri;
- LilvValues classes;
+struct LilvUIImpl {
+ LilvWorld* world;
+ LilvValue* uri;
+ LilvValue* bundle_uri;
+ LilvValue* binary_uri;
+ LilvValues* classes;
};
-LilvUIs lilv_uis_new();
+LilvUIs* lilv_uis_new();
-LilvUI
-lilv_ui_new(LilvWorld world,
- LilvValue uri,
- LilvValue type_uri,
- LilvValue binary_uri);
+LilvUI*
+lilv_ui_new(LilvWorld* world,
+ LilvValue* uri,
+ LilvValue* type_uri,
+ LilvValue* binary_uri);
-void lilv_ui_free(LilvUI ui);
+void lilv_ui_free(LilvUI* ui);
/* ********* Value ********* */
@@ -302,8 +292,8 @@ typedef enum _LilvValueType {
LILV_VALUE_BLANK
} LilvValueType;
-struct _LilvValue {
- LilvWorld world;
+struct LilvValueImpl {
+ LilvWorld* world;
char* str_val; ///< always present
union {
int int_val;
@@ -314,9 +304,9 @@ struct _LilvValue {
LilvValueType type;
};
-LilvValue lilv_value_new(LilvWorld world, LilvValueType type, const char* val);
-LilvValue lilv_value_new_from_node(LilvWorld world, LilvNode node);
-LilvNode lilv_value_as_node(LilvValue value);
+LilvValue* lilv_value_new(LilvWorld* world, LilvValueType type, const char* val);
+LilvValue* lilv_value_new_from_node(LilvWorld* world, LilvNode node);
+LilvNode lilv_value_as_node(const LilvValue* value);
int
lilv_header_compare_by_uri(const void* a, const void* b, void* user_data);
@@ -332,33 +322,33 @@ lilv_array_append(GSequence* seq, void* value) {
g_sequence_append(seq, value);
}
-struct _LilvHeader*
-lilv_sequence_get_by_uri(GSequence* seq, LilvValue uri);
+struct LilvHeader*
+lilv_sequence_get_by_uri(const GSequence* seq, const LilvValue* uri);
static inline SordNode* lilv_node_copy(LilvNode node) {
return sord_node_copy(node);
}
-static inline void lilv_node_free(LilvWorld world, SordNode* node) {
+static inline void lilv_node_free(LilvWorld* world, SordNode* node) {
sord_node_free(world->world, node);
}
/* ********* Scale Points ********* */
-struct _LilvScalePoint {
- LilvValue value;
- LilvValue label;
+struct LilvScalePointImpl {
+ LilvValue* value;
+ LilvValue* label;
};
-LilvScalePoint lilv_scale_point_new(LilvValue value, LilvValue label);
-void lilv_scale_point_free(LilvScalePoint point);
+LilvScalePoint* lilv_scale_point_new(LilvValue* value, LilvValue* label);
+void lilv_scale_point_free(LilvScalePoint* point);
/* ********* Query Results ********* */
-LilvMatches lilv_plugin_find_statements(LilvPlugin plugin,
- LilvNode subject,
- LilvNode predicate,
- LilvNode object);
+LilvMatches lilv_plugin_find_statements(const LilvPlugin* plugin,
+ LilvNode subject,
+ LilvNode predicate,
+ LilvNode object);
static inline bool lilv_matches_next(LilvMatches matches) {
return sord_iter_next(matches);
@@ -368,15 +358,15 @@ static inline bool lilv_matches_end(LilvMatches matches) {
return sord_iter_end(matches);
}
-LilvValues lilv_values_from_stream_objects(LilvPlugin p,
- LilvMatches stream);
+LilvValues* lilv_values_from_stream_objects(const LilvPlugin* p,
+ LilvMatches stream);
/* ********* Utilities ********* */
char* lilv_strjoin(const char* first, ...);
char* lilv_strdup(const char* str);
char* lilv_get_lang();
-uint8_t* lilv_qname_expand(LilvPlugin p, const char* qname);
+uint8_t* lilv_qname_expand(const LilvPlugin* p, const char* qname);
typedef void (*VoidFunc)();
diff --git a/src/plugin.c b/src/plugin.c
index 6ba6676..b03205c 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -29,11 +29,11 @@
#define NS_FOAF (const uint8_t*)"http://xmlns.com/foaf/0.1/"
/** Ownership of @a uri is taken */
-LilvPlugin
-lilv_plugin_new(LilvWorld world, LilvValue uri, LilvValue bundle_uri)
+LilvPlugin*
+lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri)
{
assert(bundle_uri);
- struct _LilvPlugin* plugin = malloc(sizeof(struct _LilvPlugin));
+ LilvPlugin* plugin = malloc(sizeof(struct LilvPluginImpl));
plugin->world = world;
plugin->plugin_uri = uri;
plugin->bundle_uri = bundle_uri;
@@ -52,7 +52,7 @@ lilv_plugin_new(LilvWorld world, LilvValue uri, LilvValue bundle_uri)
}
void
-lilv_plugin_free(LilvPlugin p)
+lilv_plugin_free(LilvPlugin* p)
{
lilv_value_free(p->plugin_uri);
p->plugin_uri = NULL;
@@ -81,8 +81,8 @@ lilv_plugin_free(LilvPlugin p)
free(p);
}
-static LilvValues
-lilv_plugin_query_node(LilvPlugin p, LilvNode subject, LilvNode predicate)
+static LilvValues*
+lilv_plugin_query_node(const LilvPlugin* p, LilvNode subject, LilvNode predicate)
{
lilv_plugin_load_if_necessary(p);
// <subject> <predicate> ?value
@@ -94,10 +94,10 @@ lilv_plugin_query_node(LilvPlugin p, LilvNode subject, LilvNode predicate)
return NULL;
}
- LilvValues result = lilv_values_new();
+ LilvValues* result = lilv_values_new();
FOREACH_MATCH(results) {
- LilvNode node = lilv_match_object(results);
- LilvValue value = lilv_value_new_from_node(p->world, node);
+ LilvNode node = lilv_match_object(results);
+ LilvValue* value = lilv_value_new_from_node(p->world, node);
if (value)
lilv_array_append(result, value);
}
@@ -106,38 +106,38 @@ lilv_plugin_query_node(LilvPlugin p, LilvNode subject, LilvNode predicate)
return result;
}
-LilvValue
-lilv_plugin_get_unique(LilvPlugin p, LilvNode subject, LilvNode predicate)
+LilvValue*
+lilv_plugin_get_unique(const LilvPlugin* p, LilvNode subject, LilvNode predicate)
{
- LilvValues values = lilv_plugin_query_node(p, subject, predicate);
+ LilvValues* values = lilv_plugin_query_node(p, subject, predicate);
if (!values || lilv_values_size(values) != 1) {
LILV_ERRORF("Port does not have exactly one `%s' property\n",
sord_node_get_string(predicate));
return NULL;
}
- LilvValue ret = lilv_value_duplicate(lilv_values_get_first(values));
+ LilvValue* ret = lilv_value_duplicate(lilv_values_get_first(values));
lilv_values_free(values);
return ret;
}
-static LilvValue
-lilv_plugin_get_one(LilvPlugin p, LilvNode subject, LilvNode predicate)
+static LilvValue*
+lilv_plugin_get_one(const LilvPlugin* p, LilvNode subject, LilvNode predicate)
{
- LilvValues values = lilv_plugin_query_node(p, subject, predicate);
+ LilvValues* values = lilv_plugin_query_node(p, subject, predicate);
if (!values) {
return NULL;
}
- LilvValue ret = lilv_value_duplicate(lilv_values_get_first(values));
+ LilvValue* ret = lilv_value_duplicate(lilv_values_get_first(values));
lilv_values_free(values);
return ret;
}
static void
-lilv_plugin_load(LilvPlugin p)
+lilv_plugin_load(LilvPlugin* p)
{
// Parse all the plugin's data files into RDF model
LILV_FOREACH(values, i, p->data_uris) {
- LilvValue data_uri_val = lilv_values_get(p->data_uris, i);
+ const LilvValue* data_uri_val = lilv_values_get(p->data_uris, i);
sord_read_file(p->world->model,
sord_node_get_string(data_uri_val->val.uri_val),
p->bundle_uri->val.uri_val,
@@ -190,8 +190,9 @@ lilv_plugin_load(LilvPlugin p)
}
static void
-lilv_plugin_load_ports_if_necessary(LilvPlugin p)
+lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
{
+ LilvPlugin* p = (LilvPlugin*)const_p;
if (!p->loaded)
lilv_plugin_load(p);
@@ -206,9 +207,9 @@ lilv_plugin_load_ports_if_necessary(LilvPlugin p)
NULL);
FOREACH_MATCH(ports) {
- LilvValue index = NULL;
- LilvNode port = lilv_match_object(ports);
- LilvValue symbol = lilv_plugin_get_unique(
+ LilvValue* index = NULL;
+ LilvNode port = lilv_match_object(ports);
+ LilvValue* symbol = lilv_plugin_get_unique(
p, port, p->world->lv2_symbol_node);
if (!lilv_value_is_string(symbol)) {
@@ -225,14 +226,14 @@ lilv_plugin_load_ports_if_necessary(LilvPlugin p)
goto error;
}
- uint32_t this_index = lilv_value_as_int(index);
- LilvPort this_port = NULL;
+ uint32_t this_index = lilv_value_as_int(index);
+ LilvPort* this_port = NULL;
if (p->num_ports > this_index) {
this_port = p->ports[this_index];
} else {
p->ports = realloc(p->ports, (this_index + 1) * sizeof(LilvPort*));
memset(p->ports + p->num_ports, '\0',
- (this_index - p->num_ports) * sizeof(LilvPort));
+ (this_index - p->num_ports) * sizeof(LilvPort*));
p->num_ports = this_index + 1;
}
@@ -276,15 +277,15 @@ lilv_plugin_load_ports_if_necessary(LilvPlugin p)
}
void
-lilv_plugin_load_if_necessary(LilvPlugin p)
+lilv_plugin_load_if_necessary(const LilvPlugin* p)
{
if (!p->loaded)
- lilv_plugin_load(p);
+ lilv_plugin_load((LilvPlugin*)p);
}
LILV_API
-LilvValue
-lilv_plugin_get_uri(LilvPlugin p)
+const LilvValue*
+lilv_plugin_get_uri(const LilvPlugin* p)
{
assert(p);
assert(p->plugin_uri);
@@ -292,8 +293,8 @@ lilv_plugin_get_uri(LilvPlugin p)
}
LILV_API
-LilvValue
-lilv_plugin_get_bundle_uri(LilvPlugin p)
+const LilvValue*
+lilv_plugin_get_bundle_uri(const LilvPlugin* p)
{
assert(p);
assert(p->bundle_uri);
@@ -301,9 +302,10 @@ lilv_plugin_get_bundle_uri(LilvPlugin p)
}
LILV_API
-LilvValue
-lilv_plugin_get_library_uri(LilvPlugin p)
+const LilvValue*
+lilv_plugin_get_library_uri(const LilvPlugin* const_p)
{
+ LilvPlugin* p = (LilvPlugin*)const_p;
lilv_plugin_load_if_necessary(p);
if (!p->binary_uri) {
// <plugin> lv2:binary ?binary
@@ -329,16 +331,17 @@ lilv_plugin_get_library_uri(LilvPlugin p)
}
LILV_API
-LilvValues
-lilv_plugin_get_data_uris(LilvPlugin p)
+const LilvValues*
+lilv_plugin_get_data_uris(const LilvPlugin* p)
{
return p->data_uris;
}
LILV_API
-LilvPluginClass
-lilv_plugin_get_class(LilvPlugin p)
+const LilvPluginClass*
+lilv_plugin_get_class(const LilvPlugin* const_p)
{
+ LilvPlugin* p = (LilvPlugin*)const_p;
lilv_plugin_load_if_necessary(p);
if (!p->plugin_class) {
// <plugin> a ?class
@@ -353,14 +356,14 @@ lilv_plugin_get_class(LilvPlugin p)
continue;
}
- LilvValue class = lilv_value_new_from_node(p->world, class_node);
+ LilvValue* class = lilv_value_new_from_node(p->world, class_node);
if ( ! lilv_value_equals(class, p->world->lv2_plugin_class->uri)) {
- LilvPluginClass plugin_class = lilv_plugin_classes_get_by_uri(
+ const LilvPluginClass* plugin_class = lilv_plugin_classes_get_by_uri(
p->world->plugin_classes, class);
if (plugin_class) {
- p->plugin_class = plugin_class;
+ ((LilvPlugin*)p)->plugin_class = plugin_class;
lilv_value_free(class);
break;
}
@@ -378,9 +381,9 @@ lilv_plugin_get_class(LilvPlugin p)
LILV_API
bool
-lilv_plugin_verify(LilvPlugin plugin)
+lilv_plugin_verify(const LilvPlugin* plugin)
{
- LilvValues results = lilv_plugin_get_value_by_qname(plugin, "rdf:type");
+ LilvValues* results = lilv_plugin_get_value_by_qname(plugin, "rdf:type");
if (!results) {
return false;
}
@@ -408,15 +411,15 @@ lilv_plugin_verify(LilvPlugin plugin)
}
LILV_API
-LilvValue
-lilv_plugin_get_name(LilvPlugin plugin)
+LilvValue*
+lilv_plugin_get_name(const LilvPlugin* plugin)
{
- LilvValues results = lilv_plugin_get_value(plugin,
- plugin->world->doap_name_val);
+ LilvValues* results = lilv_plugin_get_value(plugin,
+ plugin->world->doap_name_val);
- LilvValue ret = NULL;
+ LilvValue* ret = NULL;
if (results) {
- LilvValue val = lilv_values_get_first(results);
+ LilvValue* val = lilv_values_get_first(results);
if (lilv_value_is_string(val))
ret = lilv_value_duplicate(val);
lilv_values_free(results);
@@ -430,24 +433,24 @@ lilv_plugin_get_name(LilvPlugin plugin)
}
LILV_API
-LilvValues
-lilv_plugin_get_value(LilvPlugin p,
- LilvValue predicate)
+LilvValues*
+lilv_plugin_get_value(const LilvPlugin* p,
+ const LilvValue* predicate)
{
return lilv_plugin_get_value_for_subject(p, p->plugin_uri, predicate);
}
LILV_API
-LilvValues
-lilv_plugin_get_value_by_qname(LilvPlugin p,
+LilvValues*
+lilv_plugin_get_value_by_qname(const LilvPlugin* p,
const char* predicate)
{
char* pred_uri = (char*)lilv_qname_expand(p, predicate);
if (!pred_uri) {
return NULL;
}
- LilvValue pred_value = lilv_value_new_uri(p->world, pred_uri);
- LilvValues ret = lilv_plugin_get_value(p, pred_value);
+ LilvValue* pred_value = lilv_value_new_uri(p->world, pred_uri);
+ LilvValues* ret = lilv_plugin_get_value(p, pred_value);
lilv_value_free(pred_value);
free(pred_uri);
@@ -455,10 +458,10 @@ lilv_plugin_get_value_by_qname(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_plugin_get_value_for_subject(LilvPlugin p,
- LilvValue subject,
- LilvValue predicate)
+LilvValues*
+lilv_plugin_get_value_for_subject(const LilvPlugin* p,
+ const LilvValue* subject,
+ const LilvValue* predicate)
{
if ( ! lilv_value_is_uri(subject) && ! lilv_value_is_blank(subject)) {
LILV_ERROR("Subject is not a resource\n");
@@ -474,9 +477,9 @@ lilv_plugin_get_value_for_subject(LilvPlugin p,
: sord_new_blank(p->world->world,
(const uint8_t*)lilv_value_as_blank(subject));
- LilvValues ret = lilv_plugin_query_node(p,
- subject_node,
- predicate->val.uri_val);
+ LilvValues* ret = lilv_plugin_query_node(p,
+ subject_node,
+ predicate->val.uri_val);
lilv_node_free(p->world, subject_node);
return ret;
@@ -484,7 +487,7 @@ lilv_plugin_get_value_for_subject(LilvPlugin p,
LILV_API
uint32_t
-lilv_plugin_get_num_ports(LilvPlugin p)
+lilv_plugin_get_num_ports(const LilvPlugin* p)
{
lilv_plugin_load_ports_if_necessary(p);
return p->num_ports;
@@ -492,14 +495,14 @@ lilv_plugin_get_num_ports(LilvPlugin p)
LILV_API
void
-lilv_plugin_get_port_ranges_float(LilvPlugin p,
- float* min_values,
- float* max_values,
- float* def_values)
+lilv_plugin_get_port_ranges_float(const LilvPlugin* p,
+ float* min_values,
+ float* max_values,
+ float* def_values)
{
lilv_plugin_load_ports_if_necessary(p);
for (uint32_t i = 0; i < p->num_ports; ++i) {
- LilvValue def, min, max;
+ LilvValue *def, *min, *max;
lilv_port_get_range(p, p->ports[i], &def, &min, &max);
if (min_values)
@@ -519,8 +522,8 @@ lilv_plugin_get_port_ranges_float(LilvPlugin p,
LILV_API
uint32_t
-lilv_plugin_get_num_ports_of_class(LilvPlugin p,
- LilvValue class_1, ...)
+lilv_plugin_get_num_ports_of_class(const LilvPlugin* p,
+ const LilvValue* class_1, ...)
{
lilv_plugin_load_ports_if_necessary(p);
@@ -528,14 +531,14 @@ lilv_plugin_get_num_ports_of_class(LilvPlugin p,
va_list args;
for (unsigned i = 0; i < p->num_ports; ++i) {
- LilvPort port = p->ports[i];
+ LilvPort* port = p->ports[i];
if (!port || !lilv_port_is_a(p, port, class_1))
continue;
va_start(args, class_1);
bool matches = true;
- for (LilvValue class_i = NULL; (class_i = va_arg(args, LilvValue)) != NULL ; ) {
+ for (LilvValue* class_i = NULL; (class_i = va_arg(args, LilvValue*)) != NULL ; ) {
if (!lilv_port_is_a(p, port, class_i)) {
va_end(args);
matches = false;
@@ -554,7 +557,7 @@ lilv_plugin_get_num_ports_of_class(LilvPlugin p,
LILV_API
bool
-lilv_plugin_has_latency(LilvPlugin p)
+lilv_plugin_has_latency(const LilvPlugin* p)
{
LilvMatches ports = lilv_plugin_find_statements(
p,
@@ -584,7 +587,7 @@ lilv_plugin_has_latency(LilvPlugin p)
LILV_API
uint32_t
-lilv_plugin_get_latency_port_index(LilvPlugin p)
+lilv_plugin_get_latency_port_index(const LilvPlugin* p)
{
LilvMatches ports = lilv_plugin_find_statements(
p,
@@ -601,7 +604,7 @@ lilv_plugin_get_latency_port_index(LilvPlugin p)
p->world->lv2_portproperty_node,
p->world->lv2_reportslatency_node);
if (!lilv_matches_end(reports_latency)) {
- LilvValue index = lilv_plugin_get_unique(
+ LilvValue* index = lilv_plugin_get_unique(
p, port, p->world->lv2_index_node);
ret = lilv_value_as_int(index);
@@ -618,10 +621,10 @@ lilv_plugin_get_latency_port_index(LilvPlugin p)
LILV_API
bool
-lilv_plugin_has_feature(LilvPlugin p,
- LilvValue feature)
+lilv_plugin_has_feature(const LilvPlugin* p,
+ const LilvValue* feature)
{
- LilvValues features = lilv_plugin_get_supported_features(p);
+ LilvValues* features = lilv_plugin_get_supported_features(p);
const bool ret = features && feature && lilv_values_contains(features, feature);
@@ -630,12 +633,12 @@ lilv_plugin_has_feature(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_plugin_get_supported_features(LilvPlugin p)
+LilvValues*
+lilv_plugin_get_supported_features(const LilvPlugin* p)
{
- LilvValues optional = lilv_plugin_get_optional_features(p);
- LilvValues required = lilv_plugin_get_required_features(p);
- LilvValues result = lilv_values_new();
+ LilvValues* optional = lilv_plugin_get_optional_features(p);
+ LilvValues* required = lilv_plugin_get_required_features(p);
+ LilvValues* result = lilv_values_new();
LILV_FOREACH(values, i, optional)
lilv_array_append(
@@ -651,23 +654,23 @@ lilv_plugin_get_supported_features(LilvPlugin p)
}
LILV_API
-LilvValues
-lilv_plugin_get_optional_features(LilvPlugin p)
+LilvValues*
+lilv_plugin_get_optional_features(const LilvPlugin* p)
{
return lilv_plugin_get_value_by_qname(p, "lv2:optionalFeature");
}
LILV_API
-LilvValues
-lilv_plugin_get_required_features(LilvPlugin p)
+LilvValues*
+lilv_plugin_get_required_features(const LilvPlugin* p)
{
return lilv_plugin_get_value_by_qname(p, "lv2:requiredFeature");
}
LILV_API
-LilvPort
-lilv_plugin_get_port_by_index(LilvPlugin p,
- uint32_t index)
+const LilvPort*
+lilv_plugin_get_port_by_index(const LilvPlugin* p,
+ uint32_t index)
{
lilv_plugin_load_ports_if_necessary(p);
if (index < p->num_ports)
@@ -677,13 +680,13 @@ lilv_plugin_get_port_by_index(LilvPlugin p,
}
LILV_API
-LilvPort
-lilv_plugin_get_port_by_symbol(LilvPlugin p,
- LilvValue symbol)
+const LilvPort*
+lilv_plugin_get_port_by_symbol(const LilvPlugin* p,
+ const LilvValue* symbol)
{
lilv_plugin_load_ports_if_necessary(p);
for (uint32_t i = 0; i < p->num_ports; ++i) {
- LilvPort port = p->ports[i];
+ LilvPort* port = p->ports[i];
if (lilv_value_equals(port->symbol, symbol))
return port;
}
@@ -692,7 +695,7 @@ lilv_plugin_get_port_by_symbol(LilvPlugin p,
}
static LilvNode
-lilv_plugin_get_author(LilvPlugin p)
+lilv_plugin_get_author(const LilvPlugin* p)
{
SordNode* doap_maintainer = sord_new_uri(
p->world->world, NS_DOAP "maintainer");
@@ -716,8 +719,8 @@ lilv_plugin_get_author(LilvPlugin p)
}
LILV_API
-LilvValue
-lilv_plugin_get_author_name(LilvPlugin plugin)
+LilvValue*
+lilv_plugin_get_author_name(const LilvPlugin* plugin)
{
LilvNode author = lilv_plugin_get_author(plugin);
if (author) {
@@ -729,8 +732,8 @@ lilv_plugin_get_author_name(LilvPlugin plugin)
}
LILV_API
-LilvValue
-lilv_plugin_get_author_email(LilvPlugin plugin)
+LilvValue*
+lilv_plugin_get_author_email(const LilvPlugin* plugin)
{
LilvNode author = lilv_plugin_get_author(plugin);
if (author) {
@@ -742,8 +745,8 @@ lilv_plugin_get_author_email(LilvPlugin plugin)
}
LILV_API
-LilvValue
-lilv_plugin_get_author_homepage(LilvPlugin plugin)
+LilvValue*
+lilv_plugin_get_author_homepage(const LilvPlugin* plugin)
{
LilvNode author = lilv_plugin_get_author(plugin);
if (author) {
@@ -756,19 +759,19 @@ lilv_plugin_get_author_homepage(LilvPlugin plugin)
LILV_API
bool
-lilv_plugin_is_replaced(LilvPlugin plugin)
+lilv_plugin_is_replaced(const LilvPlugin* plugin)
{
return plugin->replaced;
}
LILV_API
-LilvUIs
-lilv_plugin_get_uis(LilvPlugin p)
+LilvUIs*
+lilv_plugin_get_uis(const LilvPlugin* p)
{
SordNode* ui_ui_node = sord_new_uri(p->world->world, NS_UI "ui");
SordNode* ui_binary_node = sord_new_uri(p->world->world, NS_UI "binary");
- LilvUIs result = lilv_uis_new();
+ LilvUIs* result = lilv_uis_new();
LilvMatches uis = lilv_plugin_find_statements(
p,
p->plugin_uri->val.uri_val,
@@ -776,9 +779,9 @@ lilv_plugin_get_uis(LilvPlugin p)
NULL);
FOREACH_MATCH(uis) {
- LilvNode ui = lilv_match_object(uis);
- LilvValue type = lilv_plugin_get_unique(p, ui, p->world->rdf_a_node);
- LilvValue binary = lilv_plugin_get_unique(p, ui, ui_binary_node);
+ LilvNode ui = lilv_match_object(uis);
+ LilvValue* type = lilv_plugin_get_unique(p, ui, p->world->rdf_a_node);
+ LilvValue* binary = lilv_plugin_get_unique(p, ui, ui_binary_node);
if (sord_node_get_type(ui) != SORD_URI
|| !lilv_value_is_uri(type)
@@ -789,7 +792,7 @@ lilv_plugin_get_uis(LilvPlugin p)
continue;
}
- LilvUI lilv_ui = lilv_ui_new(
+ LilvUI* lilv_ui = lilv_ui_new(
p->world,
lilv_value_new_from_node(p->world, ui),
type,
diff --git a/src/pluginclass.c b/src/pluginclass.c
index 7144cad..010f99e 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -22,8 +22,8 @@
#include "lilv_internal.h"
-LilvPluginClass
-lilv_plugin_class_new(LilvWorld world,
+LilvPluginClass*
+lilv_plugin_class_new(LilvWorld* world,
LilvNode parent_node,
LilvNode uri,
const char* label)
@@ -31,7 +31,7 @@ lilv_plugin_class_new(LilvWorld world,
if (parent_node && sord_node_get_type(parent_node) != SORD_URI) {
return NULL; // Not an LV2 plugin superclass (FIXME: discover properly)
}
- LilvPluginClass pc = (LilvPluginClass)malloc(sizeof(struct _LilvPluginClass));
+ LilvPluginClass* pc = malloc(sizeof(struct LilvPluginClassImpl));
pc->world = world;
pc->uri = lilv_value_new_from_node(world, uri);
pc->label = lilv_value_new(world, LILV_VALUE_STRING, label);
@@ -42,7 +42,7 @@ lilv_plugin_class_new(LilvWorld world,
}
void
-lilv_plugin_class_free(LilvPluginClass plugin_class)
+lilv_plugin_class_free(LilvPluginClass* plugin_class)
{
assert(plugin_class->uri);
lilv_value_free(plugin_class->uri);
@@ -52,8 +52,8 @@ lilv_plugin_class_free(LilvPluginClass plugin_class)
}
LILV_API
-LilvValue
-lilv_plugin_class_get_parent_uri(LilvPluginClass plugin_class)
+const LilvValue*
+lilv_plugin_class_get_parent_uri(const LilvPluginClass* plugin_class)
{
if (plugin_class->parent_uri)
return plugin_class->parent_uri;
@@ -62,35 +62,36 @@ lilv_plugin_class_get_parent_uri(LilvPluginClass plugin_class)
}
LILV_API
-LilvValue
-lilv_plugin_class_get_uri(LilvPluginClass plugin_class)
+const LilvValue*
+lilv_plugin_class_get_uri(const LilvPluginClass* plugin_class)
{
assert(plugin_class->uri);
return plugin_class->uri;
}
LILV_API
-LilvValue
-lilv_plugin_class_get_label(LilvPluginClass plugin_class)
+const LilvValue*
+lilv_plugin_class_get_label(const LilvPluginClass* plugin_class)
{
return plugin_class->label;
}
LILV_API
-LilvPluginClasses
-lilv_plugin_class_get_children(LilvPluginClass plugin_class)
+LilvPluginClasses*
+lilv_plugin_class_get_children(const LilvPluginClass* plugin_class)
{
// Returned list doesn't own categories
- LilvPluginClasses all = plugin_class->world->plugin_classes;
- LilvPluginClasses result = g_sequence_new(NULL);
+ LilvPluginClasses* all = plugin_class->world->plugin_classes;
+ LilvPluginClasses* result = g_sequence_new(NULL);
for (GSequenceIter* i = g_sequence_get_begin_iter(all);
i != g_sequence_get_end_iter(all);
i = g_sequence_iter_next(i)) {
- LilvPluginClass c = g_sequence_get(i);
- LilvValue parent = lilv_plugin_class_get_parent_uri(c);
- if (parent && lilv_value_equals(lilv_plugin_class_get_uri(plugin_class), parent))
- lilv_sequence_insert(result, c);
+ const LilvPluginClass* c = g_sequence_get(i);
+ const LilvValue* parent = lilv_plugin_class_get_parent_uri(c);
+ if (parent && lilv_value_equals(lilv_plugin_class_get_uri(plugin_class),
+ parent))
+ lilv_sequence_insert(result, (LilvPluginClass*)c);
}
return result;
diff --git a/src/plugininstance.c b/src/plugininstance.c
index e77f7a8..55e0f99 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -24,12 +24,12 @@
#include "lilv_internal.h"
LILV_API
-LilvInstance
-lilv_plugin_instantiate(LilvPlugin plugin,
+LilvInstance*
+lilv_plugin_instantiate(const LilvPlugin* plugin,
double sample_rate,
const LV2_Feature*const* features)
{
- struct _Instance* result = NULL;
+ LilvInstance* result = NULL;
const LV2_Feature** local_features = NULL;
if (features == NULL) {
@@ -73,9 +73,9 @@ lilv_plugin_instantiate(LilvPlugin plugin,
break; // return NULL
} else {
// Parse bundle URI to use as base URI
- const LilvValue bundle_uri = lilv_plugin_get_bundle_uri(plugin);
- const char* bundle_uri_str = lilv_value_as_uri(bundle_uri);
- SerdURI base_uri;
+ const LilvValue* bundle_uri = lilv_plugin_get_bundle_uri(plugin);
+ const char* bundle_uri_str = lilv_value_as_uri(bundle_uri);
+ SerdURI base_uri;
if (!serd_uri_parse((const uint8_t*)bundle_uri_str, &base_uri)) {
dlclose(lib);
break;
@@ -94,13 +94,11 @@ lilv_plugin_instantiate(LilvPlugin plugin,
if (!strcmp((const char*)abs_uri_node.buf,
lilv_value_as_uri(lilv_plugin_get_uri(plugin)))) {
// Create LilvInstance to return
- result = malloc(sizeof(struct _Instance));
+ result = malloc(sizeof(struct LilvInstanceImpl));
result->lv2_descriptor = ld;
result->lv2_handle = ld->instantiate(ld, sample_rate, (char*)bundle_path,
(features) ? features : local_features);
- struct _LilvInstanceImpl* impl = malloc(sizeof(struct _LilvInstanceImpl));
- impl->lib_handle = lib;
- result->pimpl = impl;
+ result->pimpl = lib;
serd_node_free(&abs_uri_node);
break;
} else {
@@ -131,18 +129,15 @@ lilv_plugin_instantiate(LilvPlugin plugin,
LILV_API
void
-lilv_instance_free(LilvInstance instance)
+lilv_instance_free(LilvInstance* instance)
{
if (!instance)
return;
- struct _Instance* i = (struct _Instance*)instance;
- i->lv2_descriptor->cleanup(i->lv2_handle);
- i->lv2_descriptor = NULL;
- dlclose(i->pimpl->lib_handle);
- i->pimpl->lib_handle = NULL;
- free(i->pimpl);
- i->pimpl = NULL;
- free(i);
+ instance->lv2_descriptor->cleanup(instance->lv2_handle);
+ instance->lv2_descriptor = NULL;
+ dlclose(instance->pimpl);
+ instance->pimpl = NULL;
+ free(instance);
}
diff --git a/src/pluginui.c b/src/pluginui.c
index b8e9db1..b6fa60a 100644
--- a/src/pluginui.c
+++ b/src/pluginui.c
@@ -22,17 +22,17 @@
#include "lilv_internal.h"
-LilvUI
-lilv_ui_new(LilvWorld world,
- LilvValue uri,
- LilvValue type_uri,
- LilvValue binary_uri)
+LilvUI*
+lilv_ui_new(LilvWorld* world,
+ LilvValue* uri,
+ LilvValue* type_uri,
+ LilvValue* binary_uri)
{
assert(uri);
assert(type_uri);
assert(binary_uri);
- struct _LilvUI* ui = malloc(sizeof(struct _LilvUI));
+ LilvUI* ui = malloc(sizeof(struct LilvUIImpl));
ui->world = world;
ui->uri = uri;
ui->binary_uri = binary_uri;
@@ -51,7 +51,7 @@ lilv_ui_new(LilvWorld world,
}
void
-lilv_ui_free(LilvUI ui)
+lilv_ui_free(LilvUI* ui)
{
lilv_value_free(ui->uri);
ui->uri = NULL;
@@ -68,8 +68,8 @@ lilv_ui_free(LilvUI ui)
}
LILV_API
-LilvValue
-lilv_ui_get_uri(LilvUI ui)
+const LilvValue*
+lilv_ui_get_uri(const LilvUI* ui)
{
assert(ui);
assert(ui->uri);
@@ -78,17 +78,17 @@ lilv_ui_get_uri(LilvUI ui)
LILV_API
unsigned
-lilv_ui_is_supported(LilvUI ui,
+lilv_ui_is_supported(const LilvUI* ui,
LilvUISupportedFunc supported_func,
- LilvValue container_type,
- LilvValue* ui_type)
+ const LilvValue* container_type,
+ const LilvValue** ui_type)
{
#ifdef HAVE_SUIL
- LilvValues classes = lilv_ui_get_classes(ui);
+ const LilvValues* classes = lilv_ui_get_classes(ui);
LILV_FOREACH(values, c, classes) {
- LilvValue type = lilv_values_get(classes, c);
- const unsigned q = supported_func(lilv_value_as_uri(container_type),
- lilv_value_as_uri(type));
+ const LilvValue* type = lilv_values_get(classes, c);
+ const unsigned q = supported_func(lilv_value_as_uri(container_type),
+ lilv_value_as_uri(type));
if (q) {
if (ui_type) {
*ui_type = lilv_value_duplicate(type);
@@ -101,22 +101,22 @@ lilv_ui_is_supported(LilvUI ui,
}
LILV_API
-LilvValues
-lilv_ui_get_classes(LilvUI ui)
+const LilvValues*
+lilv_ui_get_classes(const LilvUI* ui)
{
return ui->classes;
}
LILV_API
bool
-lilv_ui_is_a(LilvUI ui, LilvValue ui_class_uri)
+lilv_ui_is_a(const LilvUI* ui, const LilvValue* ui_class_uri)
{
return lilv_values_contains(ui->classes, ui_class_uri);
}
LILV_API
-LilvValue
-lilv_ui_get_bundle_uri(LilvUI ui)
+const LilvValue*
+lilv_ui_get_bundle_uri(const LilvUI* ui)
{
assert(ui);
assert(ui->bundle_uri);
@@ -124,8 +124,8 @@ lilv_ui_get_bundle_uri(LilvUI ui)
}
LILV_API
-LilvValue
-lilv_ui_get_binary_uri(LilvUI ui)
+const LilvValue*
+lilv_ui_get_binary_uri(const LilvUI* ui)
{
assert(ui);
assert(ui->binary_uri);
diff --git a/src/port.c b/src/port.c
index 6be5d7e..3f4d871 100644
--- a/src/port.c
+++ b/src/port.c
@@ -24,10 +24,10 @@
#include "lilv_internal.h"
-LilvPort
-lilv_port_new(LilvWorld world, uint32_t index, const char* symbol)
+LilvPort*
+lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol)
{
- struct _LilvPort* port = malloc(sizeof(struct _LilvPort));
+ LilvPort* port = malloc(sizeof(struct LilvPortImpl));
port->index = index;
port->symbol = lilv_value_new(world, LILV_VALUE_STRING, symbol);
port->classes = lilv_values_new();
@@ -35,7 +35,7 @@ lilv_port_new(LilvWorld world, uint32_t index, const char* symbol)
}
void
-lilv_port_free(LilvPort port)
+lilv_port_free(LilvPort* port)
{
lilv_values_free(port->classes);
lilv_value_free(port->symbol);
@@ -44,9 +44,9 @@ lilv_port_free(LilvPort port)
LILV_API
bool
-lilv_port_is_a(LilvPlugin plugin,
- LilvPort port,
- LilvValue port_class)
+lilv_port_is_a(const LilvPlugin* plugin,
+ const LilvPort* port,
+ const LilvValue* port_class)
{
LILV_FOREACH(values, i, port->classes)
if (lilv_value_equals(lilv_values_get(port->classes, i), port_class))
@@ -56,8 +56,8 @@ lilv_port_is_a(LilvPlugin plugin,
}
static LilvNode
-lilv_port_get_node(LilvPlugin p,
- LilvPort port)
+lilv_port_get_node(const LilvPlugin* p,
+ const LilvPort* port)
{
LilvMatches ports = lilv_plugin_find_statements(
p,
@@ -66,8 +66,8 @@ lilv_port_get_node(LilvPlugin p,
NULL);
LilvNode ret = NULL;
FOREACH_MATCH(ports) {
- LilvNode node = lilv_match_object(ports);
- LilvValue symbol = lilv_plugin_get_unique(
+ LilvNode node = lilv_match_object(ports);
+ LilvValue* symbol = lilv_plugin_get_unique(
p,
node,
p->world->lv2_symbol_node);
@@ -88,9 +88,9 @@ lilv_port_get_node(LilvPlugin p,
LILV_API
bool
-lilv_port_has_property(LilvPlugin p,
- LilvPort port,
- LilvValue property)
+lilv_port_has_property(const LilvPlugin* p,
+ const LilvPort* port,
+ const LilvValue* property)
{
assert(property);
LilvNode port_node = lilv_port_get_node(p, port);
@@ -107,9 +107,9 @@ lilv_port_has_property(LilvPlugin p,
LILV_API
bool
-lilv_port_supports_event(LilvPlugin p,
- LilvPort port,
- LilvValue event)
+lilv_port_supports_event(const LilvPlugin* p,
+ const LilvPort* port,
+ const LilvValue* event)
{
#define NS_EV (const uint8_t*)"http://lv2plug.in/ns/ext/event#"
@@ -127,10 +127,10 @@ lilv_port_supports_event(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_port_get_value_by_qname(LilvPlugin p,
- LilvPort port,
- const char* predicate)
+LilvValues*
+lilv_port_get_value_by_qname(const LilvPlugin* p,
+ const LilvPort* port,
+ const char* predicate)
{
assert(predicate);
uint8_t* pred_uri = lilv_qname_expand(p, predicate);
@@ -149,10 +149,10 @@ lilv_port_get_value_by_qname(LilvPlugin p,
return lilv_values_from_stream_objects(p, results);
}
-static LilvValues
-lilv_port_get_value_by_node(LilvPlugin p,
- LilvPort port,
- LilvNode predicate)
+static LilvValues*
+lilv_port_get_value_by_node(const LilvPlugin* p,
+ const LilvPort* port,
+ LilvNode predicate)
{
assert(sord_node_get_type(predicate) == SORD_URI);
@@ -167,10 +167,10 @@ lilv_port_get_value_by_node(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_port_get_value(LilvPlugin p,
- LilvPort port,
- LilvValue predicate)
+LilvValues*
+lilv_port_get_value(const LilvPlugin* p,
+ const LilvPort* port,
+ const LilvValue* predicate)
{
if ( ! lilv_value_is_uri(predicate)) {
LILV_ERROR("Predicate is not a URI\n");
@@ -183,24 +183,24 @@ lilv_port_get_value(LilvPlugin p,
}
LILV_API
-LilvValue
-lilv_port_get_symbol(LilvPlugin p,
- LilvPort port)
+const LilvValue*
+lilv_port_get_symbol(const LilvPlugin* p,
+ const LilvPort* port)
{
return port->symbol;
}
LILV_API
-LilvValue
-lilv_port_get_name(LilvPlugin p,
- LilvPort port)
+LilvValue*
+lilv_port_get_name(const LilvPlugin* p,
+ const LilvPort* port)
{
- LilvValues results = lilv_port_get_value(p, port,
- p->world->lv2_name_val);
+ LilvValues* results = lilv_port_get_value(p, port,
+ p->world->lv2_name_val);
- LilvValue ret = NULL;
+ LilvValue* ret = NULL;
if (results) {
- LilvValue val = lilv_values_get_first(results);
+ LilvValue* val = lilv_values_get_first(results);
if (lilv_value_is_string(val))
ret = lilv_value_duplicate(val);
lilv_values_free(results);
@@ -214,23 +214,23 @@ lilv_port_get_name(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_port_get_classes(LilvPlugin p,
- LilvPort port)
+const LilvValues*
+lilv_port_get_classes(const LilvPlugin* p,
+ const LilvPort* port)
{
return port->classes;
}
LILV_API
void
-lilv_port_get_range(LilvPlugin p,
- LilvPort port,
- LilvValue* def,
- LilvValue* min,
- LilvValue* max)
+lilv_port_get_range(const LilvPlugin* p,
+ const LilvPort* port,
+ LilvValue** def,
+ LilvValue** min,
+ LilvValue** max)
{
if (def) {
- LilvValues defaults = lilv_port_get_value_by_node(
+ LilvValues* defaults = lilv_port_get_value_by_node(
p, port, p->world->lv2_default_node);
*def = defaults
? lilv_value_duplicate(lilv_values_get_first(defaults))
@@ -238,7 +238,7 @@ lilv_port_get_range(LilvPlugin p,
lilv_values_free(defaults);
}
if (min) {
- LilvValues minimums = lilv_port_get_value_by_node(
+ LilvValues* minimums = lilv_port_get_value_by_node(
p, port, p->world->lv2_minimum_node);
*min = minimums
? lilv_value_duplicate(lilv_values_get_first(minimums))
@@ -246,7 +246,7 @@ lilv_port_get_range(LilvPlugin p,
lilv_values_free(minimums);
}
if (max) {
- LilvValues maximums = lilv_port_get_value_by_node(
+ LilvValues* maximums = lilv_port_get_value_by_node(
p, port, p->world->lv2_maximum_node);
*max = maximums
? lilv_value_duplicate(lilv_values_get_first(maximums))
@@ -256,9 +256,9 @@ lilv_port_get_range(LilvPlugin p,
}
LILV_API
-LilvScalePoints
-lilv_port_get_scale_points(LilvPlugin p,
- LilvPort port)
+LilvScalePoints*
+lilv_port_get_scale_points(const LilvPlugin* p,
+ const LilvPort* port)
{
LilvNode port_node = lilv_port_get_node(p, port);
LilvMatches points = lilv_plugin_find_statements(
@@ -267,19 +267,19 @@ lilv_port_get_scale_points(LilvPlugin p,
sord_new_uri(p->world->world, LILV_NS_LV2 "scalePoint"),
NULL);
- LilvScalePoints ret = NULL;
+ LilvScalePoints* ret = NULL;
if (!lilv_matches_end(points))
ret = lilv_scale_points_new();
FOREACH_MATCH(points) {
LilvNode point = lilv_match_object(points);
- LilvValue value = lilv_plugin_get_unique(
+ LilvValue* value = lilv_plugin_get_unique(
p,
point,
p->world->rdf_value_node);
- LilvValue label = lilv_plugin_get_unique(
+ LilvValue* label = lilv_plugin_get_unique(
p,
point,
p->world->rdfs_label_node);
@@ -295,13 +295,13 @@ lilv_port_get_scale_points(LilvPlugin p,
}
LILV_API
-LilvValues
-lilv_port_get_properties(LilvPlugin p,
- LilvPort port)
+LilvValues*
+lilv_port_get_properties(const LilvPlugin* p,
+ const LilvPort* port)
{
- LilvValue pred = lilv_value_new_from_node(
+ LilvValue* pred = lilv_value_new_from_node(
p->world, p->world->lv2_portproperty_node);
- LilvValues ret = lilv_port_get_value(p, port, pred);
+ LilvValues* ret = lilv_port_get_value(p, port, pred);
lilv_value_free(pred);
return ret;
}
diff --git a/src/query.c b/src/query.c
index b82256c..d84a20f 100644
--- a/src/query.c
+++ b/src/query.c
@@ -24,10 +24,10 @@
#include "lilv_internal.h"
LilvMatches
-lilv_plugin_find_statements(LilvPlugin plugin,
- LilvNode subject,
- LilvNode predicate,
- LilvNode object)
+lilv_plugin_find_statements(const LilvPlugin* plugin,
+ LilvNode subject,
+ LilvNode predicate,
+ LilvNode object)
{
lilv_plugin_load_if_necessary(plugin);
SordQuad pat = { subject, predicate, object, NULL };
@@ -64,14 +64,14 @@ lilv_lang_matches(const char* a, const char* b)
return LILV_LANG_MATCH_NONE;
}
-LilvValues
-lilv_values_from_stream_objects_i18n(LilvPlugin p,
- LilvMatches stream)
+LilvValues*
+lilv_values_from_stream_objects_i18n(const LilvPlugin* p,
+ LilvMatches stream)
{
- LilvValues values = lilv_values_new();
- LilvNode nolang = NULL; // Untranslated value
- LilvNode partial = NULL; // Partial language match
- char* syslang = lilv_get_lang();
+ LilvValues* values = lilv_values_new();
+ LilvNode nolang = NULL; // Untranslated value
+ LilvNode partial = NULL; // Partial language match
+ char* syslang = lilv_get_lang();
FOREACH_MATCH(stream) {
LilvNode value = lilv_match_object(stream);
if (sord_node_get_type(value) == SORD_LITERAL) {
@@ -127,9 +127,9 @@ lilv_values_from_stream_objects_i18n(LilvPlugin p,
return values;
}
-LilvValues
-lilv_values_from_stream_objects(LilvPlugin p,
- LilvMatches stream)
+LilvValues*
+lilv_values_from_stream_objects(const LilvPlugin* p,
+ LilvMatches stream)
{
if (lilv_matches_end(stream)) {
lilv_match_end(stream);
@@ -137,7 +137,7 @@ lilv_values_from_stream_objects(LilvPlugin p,
} else if (p->world->opt.filter_language) {
return lilv_values_from_stream_objects_i18n(p, stream);
} else {
- LilvValues values = lilv_values_new();
+ LilvValues* values = lilv_values_new();
FOREACH_MATCH(stream) {
lilv_array_append(
values,
diff --git a/src/scalepoint.c b/src/scalepoint.c
index aa27d04..0f3c7f6 100644
--- a/src/scalepoint.c
+++ b/src/scalepoint.c
@@ -17,17 +17,18 @@
#include "lilv_internal.h"
/** Ownership of value and label is taken */
-LilvScalePoint
-lilv_scale_point_new(LilvValue value, LilvValue label)
+LilvScalePoint*
+lilv_scale_point_new(LilvValue* value, LilvValue* label)
{
- LilvScalePoint point = (LilvScalePoint)malloc(sizeof(struct _LilvScalePoint));
+ LilvScalePoint* point = (LilvScalePoint*)malloc(
+ sizeof(struct LilvScalePointImpl));
point->value = value;
point->label = label;
return point;
}
void
-lilv_scale_point_free(LilvScalePoint point)
+lilv_scale_point_free(LilvScalePoint* point)
{
lilv_value_free(point->value);
lilv_value_free(point->label);
@@ -35,15 +36,15 @@ lilv_scale_point_free(LilvScalePoint point)
}
LILV_API
-LilvValue
-lilv_scale_point_get_value(LilvScalePoint p)
+const LilvValue*
+lilv_scale_point_get_value(const LilvScalePoint* p)
{
return p->value;
}
LILV_API
-LilvValue
-lilv_scale_point_get_label(LilvScalePoint p)
+const LilvValue*
+lilv_scale_point_get_label(const LilvScalePoint* p)
{
return p->label;
}
diff --git a/src/util.c b/src/util.c
index a1689a4..0603a7a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -112,7 +112,7 @@ lilv_get_lang()
}
uint8_t*
-lilv_qname_expand(LilvPlugin p, const char* qname)
+lilv_qname_expand(const LilvPlugin* p, const char* qname)
{
const size_t qname_len = strlen(qname);
SerdNode qname_node = { (const uint8_t*)qname,
diff --git a/src/value.c b/src/value.c
index 991f681..3ede347 100644
--- a/src/value.c
+++ b/src/value.c
@@ -26,7 +26,7 @@
#include "lilv_internal.h"
static void
-lilv_value_set_numerics_from_string(LilvValue val)
+lilv_value_set_numerics_from_string(LilvValue* val)
{
char* locale;
char* endptr;
@@ -64,10 +64,10 @@ lilv_value_set_numerics_from_string(LilvValue val)
* automatically called from here to avoid overhead and imprecision when the
* exact string value is known.
*/
-LilvValue
-lilv_value_new(LilvWorld world, LilvValueType type, const char* str)
+LilvValue*
+lilv_value_new(LilvWorld* world, LilvValueType type, const char* str)
{
- LilvValue val = (LilvValue)malloc(sizeof(struct _LilvValue));
+ LilvValue* val = malloc(sizeof(struct LilvValueImpl));
val->world = world;
val->type = type;
@@ -91,17 +91,17 @@ lilv_value_new(LilvWorld world, LilvValueType type, const char* str)
}
/** Create a new LilvValue from @a node, or return NULL if impossible */
-LilvValue
-lilv_value_new_from_node(LilvWorld world, const SordNode* node)
+LilvValue*
+lilv_value_new_from_node(LilvWorld* world, const SordNode* node)
{
- LilvValue result = NULL;
+ LilvValue* result = NULL;
SordNode* datatype_uri = NULL;
LilvValueType type = LILV_VALUE_STRING;
switch (sord_node_get_type(node)) {
case SORD_URI:
type = LILV_VALUE_URI;
- result = (LilvValue)malloc(sizeof(struct _LilvValue));
+ result = malloc(sizeof(struct LilvValueImpl));
result->world = world;
result->type = LILV_VALUE_URI;
result->val.uri_val = lilv_node_copy(node);
@@ -142,58 +142,58 @@ lilv_value_new_from_node(LilvWorld world, const SordNode* node)
}
LILV_API
-LilvValue
-lilv_value_new_uri(LilvWorld world, const char* uri)
+LilvValue*
+lilv_value_new_uri(LilvWorld* world, const char* uri)
{
return lilv_value_new(world, LILV_VALUE_URI, uri);
}
LILV_API
-LilvValue
-lilv_value_new_string(LilvWorld world, const char* str)
+LilvValue*
+lilv_value_new_string(LilvWorld* world, const char* str)
{
return lilv_value_new(world, LILV_VALUE_STRING, str);
}
LILV_API
-LilvValue
-lilv_value_new_int(LilvWorld world, int val)
+LilvValue*
+lilv_value_new_int(LilvWorld* world, int val)
{
char str[32];
snprintf(str, sizeof(str), "%d", val);
- LilvValue ret = lilv_value_new(world, LILV_VALUE_INT, str);
+ LilvValue* ret = lilv_value_new(world, LILV_VALUE_INT, str);
ret->val.int_val = val;
return ret;
}
LILV_API
-LilvValue
-lilv_value_new_float(LilvWorld world, float val)
+LilvValue*
+lilv_value_new_float(LilvWorld* world, float val)
{
char str[32];
snprintf(str, sizeof(str), "%f", val);
- LilvValue ret = lilv_value_new(world, LILV_VALUE_FLOAT, str);
+ LilvValue* ret = lilv_value_new(world, LILV_VALUE_FLOAT, str);
ret->val.float_val = val;
return ret;
}
LILV_API
-LilvValue
-lilv_value_new_bool(LilvWorld world, bool val)
+LilvValue*
+lilv_value_new_bool(LilvWorld* world, bool val)
{
- LilvValue ret = lilv_value_new(world, LILV_VALUE_BOOL, val ? "true" : "false");
+ LilvValue* ret = lilv_value_new(world, LILV_VALUE_BOOL, val ? "true" : "false");
ret->val.bool_val = val;
return ret;
}
LILV_API
-LilvValue
-lilv_value_duplicate(LilvValue val)
+LilvValue*
+lilv_value_duplicate(const LilvValue* val)
{
if (val == NULL)
- return val;
+ return NULL;
- LilvValue result = (LilvValue)malloc(sizeof(struct _LilvValue));
+ LilvValue* result = malloc(sizeof(struct LilvValueImpl));
result->world = val->world;
result->type = val->type;
@@ -210,7 +210,7 @@ lilv_value_duplicate(LilvValue val)
LILV_API
void
-lilv_value_free(LilvValue val)
+lilv_value_free(LilvValue* val)
{
if (val) {
if (val->type == LILV_VALUE_URI) {
@@ -224,7 +224,7 @@ lilv_value_free(LilvValue val)
LILV_API
bool
-lilv_value_equals(LilvValue value, LilvValue other)
+lilv_value_equals(const LilvValue* value, const LilvValue* other)
{
if (value == NULL && other == NULL)
return true;
@@ -253,7 +253,7 @@ lilv_value_equals(LilvValue value, LilvValue other)
LILV_API
char*
-lilv_value_get_turtle_token(LilvValue value)
+lilv_value_get_turtle_token(const LilvValue* value)
{
size_t len = 0;
char* result = NULL;
@@ -303,21 +303,21 @@ lilv_value_get_turtle_token(LilvValue value)
LILV_API
bool
-lilv_value_is_uri(LilvValue value)
+lilv_value_is_uri(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_URI);
}
LILV_API
const char*
-lilv_value_as_uri(LilvValue value)
+lilv_value_as_uri(const LilvValue* value)
{
assert(lilv_value_is_uri(value));
return value->str_val;
}
LilvNode
-lilv_value_as_node(LilvValue value)
+lilv_value_as_node(const LilvValue* value)
{
assert(lilv_value_is_uri(value));
return value->val.uri_val;
@@ -325,14 +325,14 @@ lilv_value_as_node(LilvValue value)
LILV_API
bool
-lilv_value_is_blank(LilvValue value)
+lilv_value_is_blank(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_BLANK);
}
LILV_API
const char*
-lilv_value_as_blank(LilvValue value)
+lilv_value_as_blank(const LilvValue* value)
{
assert(lilv_value_is_blank(value));
return value->str_val;
@@ -340,7 +340,7 @@ lilv_value_as_blank(LilvValue value)
LILV_API
bool
-lilv_value_is_literal(LilvValue value)
+lilv_value_is_literal(const LilvValue* value)
{
if (!value)
return false;
@@ -357,28 +357,28 @@ lilv_value_is_literal(LilvValue value)
LILV_API
bool
-lilv_value_is_string(LilvValue value)
+lilv_value_is_string(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_STRING);
}
LILV_API
const char*
-lilv_value_as_string(LilvValue value)
+lilv_value_as_string(const LilvValue* value)
{
return value->str_val;
}
LILV_API
bool
-lilv_value_is_int(LilvValue value)
+lilv_value_is_int(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_INT);
}
LILV_API
int
-lilv_value_as_int(LilvValue value)
+lilv_value_as_int(const LilvValue* value)
{
assert(value);
assert(lilv_value_is_int(value));
@@ -387,14 +387,14 @@ lilv_value_as_int(LilvValue value)
LILV_API
bool
-lilv_value_is_float(LilvValue value)
+lilv_value_is_float(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_FLOAT);
}
LILV_API
float
-lilv_value_as_float(LilvValue value)
+lilv_value_as_float(const LilvValue* value)
{
assert(lilv_value_is_float(value) || lilv_value_is_int(value));
if (lilv_value_is_float(value))
@@ -405,14 +405,14 @@ lilv_value_as_float(LilvValue value)
LILV_API
bool
-lilv_value_is_bool(LilvValue value)
+lilv_value_is_bool(const LilvValue* value)
{
return (value && value->type == LILV_VALUE_BOOL);
}
LILV_API
bool
-lilv_value_as_bool(LilvValue value)
+lilv_value_as_bool(const LilvValue* value)
{
assert(value);
assert(lilv_value_is_bool(value));
diff --git a/src/world.c b/src/world.c
index 133185b..92f3ddc 100644
--- a/src/world.c
+++ b/src/world.c
@@ -29,7 +29,7 @@
#include "lilv_internal.h"
static void
-lilv_world_set_prefix(LilvWorld world, const char* name, const char* uri)
+lilv_world_set_prefix(LilvWorld* world, const char* name, const char* uri)
{
const SerdNode name_node = serd_node_from_string(SERD_LITERAL,
(const uint8_t*)name);
@@ -39,10 +39,10 @@ lilv_world_set_prefix(LilvWorld world, const char* name, const char* uri)
}
LILV_API
-LilvWorld
+LilvWorld*
lilv_world_new()
{
- LilvWorld world = (LilvWorld)malloc(sizeof(struct _LilvWorld));
+ LilvWorld* world = malloc(sizeof(struct LilvWorldImpl));
world->world = sord_world_new();
if (!world->world)
@@ -115,7 +115,7 @@ fail:
LILV_API
void
-lilv_world_free(LilvWorld world)
+lilv_world_free(LilvWorld* world)
{
lilv_plugin_class_free(world->lv2_plugin_class);
world->lv2_plugin_class = NULL;
@@ -148,7 +148,7 @@ lilv_world_free(LilvWorld world)
lilv_value_free(world->lv2_name_val);
for (GSList* l = world->specs; l; l = l->next) {
- LilvSpec spec = (LilvSpec)l->data;
+ LilvSpec* spec = (LilvSpec*)l->data;
lilv_node_free(world, spec->spec);
lilv_node_free(world, spec->bundle);
lilv_values_free(spec->data_uris);
@@ -158,8 +158,8 @@ lilv_world_free(LilvWorld world)
world->specs = NULL;
LILV_FOREACH(plugins, i, world->plugins) {
- LilvPlugin p = lilv_plugins_get(world->plugins, i);
- lilv_plugin_free(p);
+ const LilvPlugin* p = lilv_plugins_get(world->plugins, i);
+ lilv_plugin_free((LilvPlugin*)p);
}
g_sequence_free(world->plugins);
world->plugins = NULL;
@@ -180,9 +180,9 @@ lilv_world_free(LilvWorld world)
LILV_API
void
-lilv_world_set_option(LilvWorld world,
- const char* option,
- const LilvValue value)
+lilv_world_set_option(LilvWorld* world,
+ const char* option,
+ const LilvValue* value)
{
if (!strcmp(option, LILV_OPTION_DYN_MANIFEST)) {
if (lilv_value_is_bool(value)) {
@@ -199,7 +199,7 @@ lilv_world_set_option(LilvWorld world,
}
static LilvMatches
-lilv_world_find_statements(LilvWorld world,
+lilv_world_find_statements(LilvWorld* world,
SordModel* model,
LilvNode subject,
LilvNode predicate,
@@ -224,7 +224,7 @@ lilv_new_uri_relative_to_base(const uint8_t* uri_str,
}
const uint8_t*
-lilv_world_blank_node_prefix(LilvWorld world)
+lilv_world_blank_node_prefix(LilvWorld* world)
{
static char str[32];
snprintf(str, sizeof(str), "%d", world->n_read_files++);
@@ -235,36 +235,37 @@ lilv_world_blank_node_prefix(LilvWorld world)
int
lilv_header_compare_by_uri(const void* a, const void* b, void* user_data)
{
- const struct _LilvHeader* const header_a = (const struct _LilvHeader*)a;
- const struct _LilvHeader* const header_b = (const struct _LilvHeader*)b;
+ const struct LilvHeader* const header_a = (const struct LilvHeader*)a;
+ const struct LilvHeader* const header_b = (const struct LilvHeader*)b;
return strcmp(lilv_value_as_uri(header_a->uri),
lilv_value_as_uri(header_b->uri));
}
/** Get an element of a sequence of any object with an LilvHeader by URI. */
-struct _LilvHeader*
-lilv_sequence_get_by_uri(GSequence* seq,
- LilvValue uri)
+struct LilvHeader*
+lilv_sequence_get_by_uri(const GSequence* const_seq,
+ const LilvValue* uri)
{
- struct _LilvHeader key = { NULL, uri };
- GSequenceIter* i = g_sequence_search(
+ GSequence* seq = (GSequence*)const_seq;
+ struct LilvHeader key = { NULL, (LilvValue*)uri };
+ GSequenceIter* i = g_sequence_search(
seq, &key, lilv_header_compare_by_uri, NULL);
// i points to where plugin would be inserted (not necessarily a match)
if (!g_sequence_iter_is_end(i)) {
- LilvPlugin p = g_sequence_get(i);
+ LilvPlugin* p = g_sequence_get(i);
if (lilv_value_equals(lilv_plugin_get_uri(p), uri)) {
- return (struct _LilvHeader*)p;
+ return (struct LilvHeader*)p;
}
}
if (!g_sequence_iter_is_begin(i)) {
// Check if i is just past a match
i = g_sequence_iter_prev(i);
- LilvPlugin p = g_sequence_get(i);
+ LilvPlugin* p = g_sequence_get(i);
if (lilv_value_equals(lilv_plugin_get_uri(p), uri)) {
- return (struct _LilvHeader*)p;
+ return (struct LilvHeader*)p;
}
}
@@ -272,11 +273,11 @@ lilv_sequence_get_by_uri(GSequence* seq,
}
static void
-lilv_world_add_spec(LilvWorld world,
+lilv_world_add_spec(LilvWorld* world,
LilvNode specification_node,
LilvNode bundle_node)
{
- LilvSpec spec = malloc(sizeof(struct _LilvSpec));
+ LilvSpec* spec = malloc(sizeof(struct LilvSpecImpl));
spec->spec = lilv_node_copy(specification_node);
spec->bundle = lilv_node_copy(bundle_node);
spec->data_uris = lilv_values_new();
@@ -300,15 +301,15 @@ lilv_world_add_spec(LilvWorld world,
}
static void
-lilv_world_add_plugin(LilvWorld world,
- LilvNode plugin_node,
- SerdNode* manifest_uri,
- LilvNode dyn_manifest_lib,
- LilvNode bundle_node)
+lilv_world_add_plugin(LilvWorld* world,
+ LilvNode plugin_node,
+ SerdNode* manifest_uri,
+ LilvNode dyn_manifest_lib,
+ LilvNode bundle_node)
{
- LilvValue plugin_uri = lilv_value_new_from_node(world, plugin_node);
+ LilvValue* plugin_uri = lilv_value_new_from_node(world, plugin_node);
- LilvPlugin last = lilv_plugins_get_by_uri(world->plugins, plugin_uri);
+ const LilvPlugin* last = lilv_plugins_get_by_uri(world->plugins, plugin_uri);
if (last) {
LILV_ERRORF("Duplicate plugin <%s>\n", lilv_value_as_uri(plugin_uri));
LILV_ERRORF("... found in %s\n", lilv_value_as_string(
@@ -319,8 +320,8 @@ lilv_world_add_plugin(LilvWorld world,
}
// Create LilvPlugin
- LilvValue bundle_uri = lilv_value_new_from_node(world, bundle_node);
- LilvPlugin plugin = lilv_plugin_new(world, plugin_uri, bundle_uri);
+ LilvValue* bundle_uri = lilv_value_new_from_node(world, bundle_node);
+ LilvPlugin* plugin = lilv_plugin_new(world, plugin_uri, bundle_uri);
// Add manifest as plugin data file (as if it were rdfs:seeAlso)
lilv_array_append(plugin->data_uris,
@@ -350,7 +351,7 @@ lilv_world_add_plugin(LilvWorld world,
}
static void
-lilv_world_load_dyn_manifest(LilvWorld world,
+lilv_world_load_dyn_manifest(LilvWorld* world,
SordNode* bundle_node,
SerdNode manifest_uri)
{
@@ -455,7 +456,7 @@ lilv_world_load_dyn_manifest(LilvWorld world,
LILV_API
void
-lilv_world_load_bundle(LilvWorld world, LilvValue bundle_uri)
+lilv_world_load_bundle(LilvWorld* world, LilvValue* bundle_uri)
{
if (!lilv_value_is_uri(bundle_uri)) {
LILV_ERROR("Bundle 'URI' is not a URI\n");
@@ -534,7 +535,7 @@ expand(const char* path)
/** Load all bundles in the directory at @a dir_path. */
static void
-lilv_world_load_directory(LilvWorld world, const char* dir_path)
+lilv_world_load_directory(LilvWorld* world, const char* dir_path)
{
char* path = expand(dir_path);
if (!path) {
@@ -568,7 +569,7 @@ lilv_world_load_directory(LilvWorld world, const char* dir_path)
DIR* const bundle_dir = opendir(uri + file_scheme_len);
if (bundle_dir) {
closedir(bundle_dir);
- LilvValue uri_val = lilv_value_new_uri(world, uri);
+ LilvValue* uri_val = lilv_value_new_uri(world, uri);
lilv_world_load_bundle(world, uri_val);
lilv_value_free(uri_val);
} else {
@@ -605,7 +606,7 @@ first_path_sep(const char* path)
* parent directories of bundles, not a list of bundle directories).
*/
static void
-lilv_world_load_path(LilvWorld world,
+lilv_world_load_path(LilvWorld* world,
const char* lv2_path)
{
while (lv2_path[0] != '\0') {
@@ -626,12 +627,12 @@ lilv_world_load_path(LilvWorld world,
}
static void
-lilv_world_load_specifications(LilvWorld world)
+lilv_world_load_specifications(LilvWorld* world)
{
for (GSList* l = world->specs; l; l = l->next) {
- LilvSpec spec = (LilvSpec)l->data;
+ LilvSpec* spec = (LilvSpec*)l->data;
LILV_FOREACH(values, f, spec->data_uris) {
- LilvValue file = lilv_collection_get(spec->data_uris, f);
+ LilvValue* file = lilv_collection_get(spec->data_uris, f);
sord_read_file(world->model,
(const uint8_t*)lilv_value_as_uri(file),
NULL,
@@ -641,7 +642,7 @@ lilv_world_load_specifications(LilvWorld world)
}
static void
-lilv_world_load_plugin_classes(LilvWorld world)
+lilv_world_load_plugin_classes(LilvWorld* world)
{
/* FIXME: This loads all classes, not just lv2:Plugin subclasses.
However, if the host gets all the classes via lilv_plugin_class_get_children
@@ -696,8 +697,8 @@ lilv_world_load_plugin_classes(LilvWorld world)
const uint8_t* label = (const uint8_t*)sord_node_get_string(label_node);
lilv_match_end(labels);
- LilvPluginClasses classes = world->plugin_classes;
- LilvPluginClass pclass = lilv_plugin_class_new(
+ LilvPluginClasses* classes = world->plugin_classes;
+ LilvPluginClass* pclass = lilv_plugin_class_new(
world, parent_node, class_node, (const char*)label);
if (pclass) {
@@ -709,7 +710,7 @@ lilv_world_load_plugin_classes(LilvWorld world)
LILV_API
void
-lilv_world_load_all(LilvWorld world)
+lilv_world_load_all(LilvWorld* world)
{
const char* lv2_path = getenv("LV2_PATH");
if (!lv2_path)
@@ -719,8 +720,8 @@ lilv_world_load_all(LilvWorld world)
lilv_world_load_path(world, lv2_path);
LILV_FOREACH(plugins, p, world->plugins) {
- LilvPlugin plugin = lilv_collection_get(world->plugins, p);
- LilvValue plugin_uri = lilv_plugin_get_uri(plugin);
+ const LilvPlugin* plugin = lilv_collection_get(world->plugins, p);
+ const LilvValue* plugin_uri = lilv_plugin_get_uri(plugin);
// ?new dc:replaces plugin
LilvMatches replacement = lilv_world_find_statements(
@@ -733,7 +734,7 @@ lilv_world_load_all(LilvWorld world)
/* TODO: Check if replacement is actually a known plugin,
though this is expensive...
*/
- plugin->replaced = true;
+ ((LilvPlugin*)plugin)->replaced = true;
}
lilv_match_end(replacement);
}
@@ -744,33 +745,22 @@ lilv_world_load_all(LilvWorld world)
}
LILV_API
-LilvPluginClass
-lilv_world_get_plugin_class(LilvWorld world)
+const LilvPluginClass*
+lilv_world_get_plugin_class(const LilvWorld* world)
{
return world->lv2_plugin_class;
}
LILV_API
-LilvPluginClasses
-lilv_world_get_plugin_classes(LilvWorld world)
+const LilvPluginClasses*
+lilv_world_get_plugin_classes(const LilvWorld* world)
{
return world->plugin_classes;
}
LILV_API
-LilvPlugins
-lilv_world_get_all_plugins(LilvWorld world)
+const LilvPlugins*
+lilv_world_get_all_plugins(const LilvWorld* world)
{
return world->plugins;
}
-
-LILV_API
-LilvPlugin
-lilv_world_get_plugin_by_uri_string(LilvWorld world,
- const char* uri)
-{
- LilvValue uri_val = lilv_value_new_uri(world, uri);
- LilvPlugin plugin = lilv_plugins_get_by_uri(world->plugins, uri_val);
- lilv_value_free(uri_val);
- return plugin;
-}