summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-04 02:44:07 +0000
committerDavid Robillard <d@drobilla.net>2011-02-04 02:44:07 +0000
commitcc61578f0f1417aba3c6d147d164bc644541372b (patch)
treedae833664026ff4de6e158ce4b4f038cbd8d18cd
parentb0c49632a5ee21d4ea35d0ae6160910fd35d68f3 (diff)
downloadlilv-cc61578f0f1417aba3c6d147d164bc644541372b.tar.gz
lilv-cc61578f0f1417aba3c6d147d164bc644541372b.tar.bz2
lilv-cc61578f0f1417aba3c6d147d164bc644541372b.zip
Replace use of raptor (for raptor_sequence) with glib.
SLV2 now depends only on serd, sord, and glib. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2903 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--slv2.pc.in4
-rw-r--r--src/collections.c20
-rw-r--r--src/plugin.c19
-rw-r--r--src/pluginclass.c9
-rw-r--r--src/plugins.c12
-rw-r--r--src/pluginui.c2
-rw-r--r--src/port.c4
-rw-r--r--src/query.c4
-rw-r--r--src/scalepoint.c2
-rw-r--r--src/slv2_internal.h4
-rw-r--r--src/value.c2
-rw-r--r--src/world.c34
-rw-r--r--wscript9
13 files changed, 64 insertions, 61 deletions
diff --git a/slv2.pc.in b/slv2.pc.in
index 9059029..aa20727 100644
--- a/slv2.pc.in
+++ b/slv2.pc.in
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: libslv2
Version: @SLV2_VERSION@
Description: Convenience library for hosts to simplify LV2 plugin support
-Libs: @SORD_LIBS@ @RAPTOR_LIBS@ -L${libdir} -lslv2
-Cflags: @SORD_CFLAGS@ @RAPTOR_CFLAGS@ -I${includedir}
+Libs: @GLIB_LIBS@ @SORD_LIBS@ -L${libdir} -lslv2
+Cflags: @GLIB_CFLAGS@ @SORD_CFLAGS@ -I${includedir}
diff --git a/src/collections.c b/src/collections.c
index fc9e332..4ea14fd 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -30,7 +30,7 @@
CollType \
prefix ## _new() \
{ \
- return raptor_new_sequence((void (*)(void*))free_func, NULL); \
+ return g_ptr_array_new_with_free_func((GDestroyNotify)free_func); \
} \
\
\
@@ -38,24 +38,24 @@ void \
prefix ## _free(CollType coll) \
{ \
if (coll) \
- raptor_free_sequence(coll); \
+ g_ptr_array_unref((GPtrArray*)coll); \
} \
\
\
unsigned \
prefix ## _size(CollType coll) \
{ \
- return (coll ? raptor_sequence_size(coll) : 0); \
+ return (coll ? ((GPtrArray*)coll)->len : 0); \
} \
\
\
ElemType \
prefix ## _get_at(CollType coll, unsigned index) \
{ \
- if (!coll || index > INT_MAX) \
+ if (!coll || index >= ((GPtrArray*)coll)->len) \
return NULL; \
else \
- return (ElemType)raptor_sequence_get_at(coll, (int)index); \
+ return (ElemType)g_ptr_array_index((GPtrArray*)coll, (int)index); \
}
SLV2_COLLECTION_IMPL(SLV2PluginClasses, SLV2PluginClass,
@@ -75,13 +75,13 @@ slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, SLV2Value uri)
// good old fashioned binary search
int lower = 0;
- int upper = raptor_sequence_size(list) - 1;
+ int upper = ((GPtrArray*)list)->len - 1;
int i;
while (upper >= lower) {
i = lower + ((upper - lower) / 2);
- SLV2PluginClass p = raptor_sequence_get_at(list, i);
+ SLV2PluginClass p = g_ptr_array_index(((GPtrArray*)list), i);
const int cmp = strcmp(slv2_value_as_uri(slv2_plugin_class_get_uri(p)),
slv2_value_as_uri(uri));
@@ -113,7 +113,7 @@ void
slv2_values_set_at(SLV2Values list, unsigned index, void* value)
{
if (index <= INT_MAX)
- raptor_sequence_set_at(list, index, value);
+ ((GPtrArray*)list)->pdata[index] = value;
}
/* **** PLUGIN UIS **** */
@@ -124,13 +124,13 @@ slv2_uis_get_by_uri(SLV2UIs list, SLV2Value uri)
// good old fashioned binary search
int lower = 0;
- int upper = raptor_sequence_size(list) - 1;
+ int upper = ((GPtrArray*)list)->len - 1;
int i;
while (upper >= lower) {
i = lower + ((upper - lower) / 2);
- SLV2UI ui = raptor_sequence_get_at(list, i);
+ SLV2UI ui = g_ptr_array_index((GPtrArray*)list, i);
const int cmp = strcmp(slv2_value_as_uri(slv2_ui_get_uri(ui)),
slv2_value_as_uri(uri));
diff --git a/src/plugin.c b/src/plugin.c
index 3244692..aa4a7a4 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -112,7 +112,7 @@ slv2_plugin_query_node(SLV2Plugin p, SLV2Node subject, SLV2Node predicate)
SLV2Node node = slv2_match_object(results);
SLV2Value value = slv2_value_new_from_node(p->world, node);
if (value)
- raptor_sequence_push(result, value);
+ g_ptr_array_add(result, value);
}
slv2_match_end(results);
@@ -207,7 +207,7 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p)
FOREACH_MATCH(types) {
SLV2Node type = slv2_match_object(types);
if (sord_node_get_type(type) == SORD_URI) {
- raptor_sequence_push(
+ g_ptr_array_add(
this_port->classes,
slv2_value_new_from_node(p->world, type));
} else {
@@ -651,14 +651,13 @@ slv2_plugin_get_supported_features(SLV2Plugin p)
SLV2Values result = slv2_values_new();
unsigned n_optional = slv2_values_size(optional);
unsigned n_required = slv2_values_size(required);
- unsigned i = 0;
- for ( ; i < n_optional; ++i)
- slv2_values_set_at(result, i, raptor_sequence_pop(optional));
- for ( ; i < n_optional + n_required; ++i)
- slv2_values_set_at(result, i, raptor_sequence_pop(required));
+ for (unsigned i = 0 ; i < n_optional; ++i)
+ g_ptr_array_add(result, slv2_values_get_at(optional, i));
+ for (unsigned i = 0 ; i < n_required; ++i)
+ g_ptr_array_add(result, slv2_values_get_at(required, i));
- slv2_values_free(optional);
- slv2_values_free(required);
+ free(((GPtrArray*)optional)->pdata);
+ free(((GPtrArray*)required)->pdata);
return result;
}
@@ -801,7 +800,7 @@ slv2_plugin_get_uis(SLV2Plugin p)
type,
binary);
- raptor_sequence_push(result, slv2_ui);
+ g_ptr_array_add(result, slv2_ui);
}
slv2_match_end(uis);
diff --git a/src/pluginclass.c b/src/pluginclass.c
index b98413f..e588595 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -82,13 +82,14 @@ SLV2PluginClasses
slv2_plugin_class_get_children(SLV2PluginClass plugin_class)
{
// Returned list doesn't own categories
- SLV2PluginClasses result = raptor_new_sequence(NULL, NULL);
+ SLV2PluginClasses result = g_ptr_array_new();
- for (int i = 0; i < raptor_sequence_size(plugin_class->world->plugin_classes); ++i) {
- SLV2PluginClass c = raptor_sequence_get_at(plugin_class->world->plugin_classes, i);
+ for (unsigned i = 0; i < ((GPtrArray*)plugin_class->world->plugin_classes)->len; ++i) {
+ SLV2PluginClass c = g_ptr_array_index(
+ (GPtrArray*)plugin_class->world->plugin_classes, i);
SLV2Value parent = slv2_plugin_class_get_parent_uri(c);
if (parent && slv2_value_equals(slv2_plugin_class_get_uri(plugin_class), parent))
- raptor_sequence_push(result, c);
+ g_ptr_array_add(result, c);
}
return result;
diff --git a/src/plugins.c b/src/plugins.c
index 5a91ab4..a8c7e81 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -31,20 +31,20 @@
SLV2Plugins
slv2_plugins_new()
{
- return raptor_new_sequence(NULL, NULL);
+ return g_ptr_array_new();
}
void
slv2_plugins_free(SLV2World world, SLV2Plugins list)
{
if (list && list != world->plugins)
- raptor_free_sequence(list);
+ g_ptr_array_unref(list);
}
unsigned
slv2_plugins_size(SLV2Plugins list)
{
- return (list ? raptor_sequence_size(list) : 0);
+ return (list ? ((GPtrArray*)list)->len : 0);
}
SLV2Plugin
@@ -53,13 +53,13 @@ slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri)
// good old fashioned binary search
int lower = 0;
- int upper = raptor_sequence_size(list) - 1;
+ int upper = ((GPtrArray*)list)->len - 1;
int i;
while (upper >= lower) {
i = lower + ((upper - lower) / 2);
- SLV2Plugin p = raptor_sequence_get_at(list, i);
+ SLV2Plugin p = g_ptr_array_index((GPtrArray*)list, i);
const int cmp = strcmp(slv2_value_as_uri(slv2_plugin_get_uri(p)),
slv2_value_as_uri(uri));
@@ -81,6 +81,6 @@ slv2_plugins_get_at(SLV2Plugins list, unsigned index)
if (index > INT_MAX)
return NULL;
else
- return (SLV2Plugin)raptor_sequence_get_at(list, (int)index);
+ return (SLV2Plugin)g_ptr_array_index((GPtrArray*)list, (int)index);
}
diff --git a/src/pluginui.c b/src/pluginui.c
index 3167b92..08490b7 100644
--- a/src/pluginui.c
+++ b/src/pluginui.c
@@ -50,7 +50,7 @@ slv2_ui_new(SLV2World world,
free(bundle);
ui->classes = slv2_values_new();
- raptor_sequence_push(ui->classes, type_uri);
+ g_ptr_array_add(ui->classes, type_uri);
return ui;
}
diff --git a/src/port.c b/src/port.c
index e60f176..bb3c5af 100644
--- a/src/port.c
+++ b/src/port.c
@@ -139,7 +139,7 @@ slv2_values_from_stream_objects(SLV2Plugin p, SLV2Matches stream)
SLV2Values values = slv2_values_new();
FOREACH_MATCH(stream) {
- raptor_sequence_push(
+ g_ptr_array_add(
values,
slv2_value_new_from_node(
p->world,
@@ -321,7 +321,7 @@ slv2_port_get_scale_points(SLV2Plugin p,
slv2_node_copy(p->world->rdfs_label_node));
if (value && label) {
- raptor_sequence_push(ret, slv2_scale_point_new(value, label));
+ g_ptr_array_add(ret, slv2_scale_point_new(value, label));
}
}
slv2_match_end(points);
diff --git a/src/query.c b/src/query.c
index 9f331da..71ed613 100644
--- a/src/query.c
+++ b/src/query.c
@@ -50,7 +50,7 @@ slv2_values_from_stream_i18n(SLV2Plugin p,
const char* lang = sord_literal_get_lang(value);
if (lang) {
if (!strcmp(lang, slv2_get_lang())) {
- raptor_sequence_push(
+ g_ptr_array_add(
values, slv2_value_new_string(
p->world, sord_node_get_string(value)));
}
@@ -65,7 +65,7 @@ slv2_values_from_stream_i18n(SLV2Plugin p,
if (slv2_values_size(values) == 0) {
// No value with a matching language, use untranslated default
if (nolang) {
- raptor_sequence_push(
+ g_ptr_array_add(
values, slv2_value_new_string(
p->world, sord_node_get_string(nolang)));
} else {
diff --git a/src/scalepoint.c b/src/scalepoint.c
index a960d36..39c5a37 100644
--- a/src/scalepoint.c
+++ b/src/scalepoint.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <raptor.h>
+#include <glib.h>
#include "slv2/scalepoint.h"
#include "slv2/types.h"
#include "slv2/value.h"
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 6be329a..3d18906 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -30,7 +30,7 @@ extern "C" {
#include <stdint.h>
#include <stdlib.h>
#include <inttypes.h>
-#include <raptor.h>
+#include <glib.h>
#include "serd/serd.h"
#include "sord/sord.h"
#include "slv2/types.h"
@@ -100,7 +100,7 @@ struct _SLV2Plugin {
SLV2Value binary_uri; ///< lv2:binary
SLV2Value dynman_uri; ///< dynamic manifest binary
SLV2PluginClass plugin_class;
- raptor_sequence* data_uris; ///< rdfs::seeAlso
+ GPtrArray* data_uris; ///< rdfs::seeAlso
SLV2Port* ports;
uint32_t num_ports;
bool loaded;
diff --git a/src/value.c b/src/value.c
index 07fd630..8e63edc 100644
--- a/src/value.c
+++ b/src/value.c
@@ -22,7 +22,7 @@
#include <string.h>
#include <assert.h>
#include <locale.h>
-#include <raptor.h>
+#include <glib.h>
#include "slv2/types.h"
#include "slv2/value.h"
#include "slv2_internal.h"
diff --git a/src/world.c b/src/world.c
index d340191..4c9fce8 100644
--- a/src/world.c
+++ b/src/world.c
@@ -134,12 +134,12 @@ slv2_world_free(SLV2World world)
slv2_node_free(world->xsd_integer_node);
slv2_node_free(world->xsd_decimal_node);
- for (int i = 0; i < raptor_sequence_size(world->plugins); ++i)
- slv2_plugin_free(raptor_sequence_get_at(world->plugins, i));
- raptor_free_sequence(world->plugins);
+ for (unsigned i = 0; i < ((GPtrArray*)world->plugins)->len; ++i)
+ slv2_plugin_free(g_ptr_array_index((GPtrArray*)world->plugins, i));
+ g_ptr_array_unref(world->plugins);
world->plugins = NULL;
- raptor_free_sequence(world->plugin_classes);
+ g_ptr_array_unref(world->plugin_classes);
world->plugin_classes = NULL;
sord_free(world->model);
@@ -348,8 +348,8 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
SLV2Plugin plugin = slv2_plugin_new(world, plugin_uri, bundle_uri);
// Add manifest as plugin data file (as if it were rdfs:seeAlso)
- raptor_sequence_push(plugin->data_uris,
- slv2_value_new_uri(world, (const char*)manifest_uri.buf));
+ g_ptr_array_add(plugin->data_uris,
+ slv2_value_new_uri(world, (const char*)manifest_uri.buf));
// Add all plugin data files (rdfs:seeAlso)
SLV2Matches files = slv2_world_find_statements(
@@ -360,13 +360,13 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
NULL);
FOREACH_MATCH(files) {
SLV2Node file_node = slv2_match_object(files);
- raptor_sequence_push(plugin->data_uris,
- slv2_value_new_from_node(world, file_node));
+ g_ptr_array_add(plugin->data_uris,
+ slv2_value_new_from_node(world, file_node));
}
// Add plugin to world plugin list (FIXME: slow, use real data structure)
- raptor_sequence_push(world->plugins, plugin);
- raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri);
+ g_ptr_array_add(world->plugins, plugin);
+ g_ptr_array_sort(world->plugins, slv2_plugin_compare_by_uri);
}
slv2_match_end(plug_results);
@@ -542,11 +542,12 @@ slv2_world_load_plugin_classes(SLV2World world)
slv2_match_end(labels);
SLV2PluginClasses classes = world->plugin_classes;
- const unsigned n_classes = raptor_sequence_size(classes);
+ const unsigned n_classes = ((GPtrArray*)classes)->len;
#ifndef NDEBUG
if (n_classes > 0) {
// Class results are in increasing sorted order
- SLV2PluginClass prev = raptor_sequence_get_at(classes, n_classes - 1);
+ SLV2PluginClass prev = g_ptr_array_index((GPtrArray*)classes,
+ n_classes - 1);
assert(strcmp(
slv2_value_as_string(slv2_plugin_class_get_uri(prev)),
(const char*)sord_node_get_string(class_node)) < 0);
@@ -556,7 +557,7 @@ slv2_world_load_plugin_classes(SLV2World world)
world, parent_node, class_node, (const char*)label);
if (pclass) {
- raptor_sequence_push(classes, pclass);
+ g_ptr_array_add(classes, pclass);
}
slv2_node_free(parent_node);
@@ -661,10 +662,11 @@ slv2_world_get_plugins_by_filter(SLV2World world, bool (*include)(SLV2Plugin))
{
SLV2Plugins result = slv2_plugins_new();
- for (int i = 0; i < raptor_sequence_size(world->plugins); ++i) {
- SLV2Plugin p = raptor_sequence_get_at(world->plugins, i);
+ const unsigned n = slv2_plugins_size(world->plugins);
+ for (unsigned i = 0; i < n; ++i) {
+ SLV2Plugin p = slv2_plugins_get_at(world->plugins, i);
if (include(p))
- raptor_sequence_push(result, p);
+ g_ptr_array_add(result, p);
}
return result;
diff --git a/wscript b/wscript
index 19904ae..9adf0aa 100644
--- a/wscript
+++ b/wscript
@@ -59,7 +59,8 @@ def configure(conf):
autowaf.display_header('SLV2 Configuration')
conf.check_tool('compiler_cc')
autowaf.check_pkg(conf, 'lv2core', uselib_store='LV2CORE', mandatory=True)
- autowaf.check_pkg(conf, 'raptor', uselib_store='RAPTOR', mandatory=True)
+ autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB',
+ atleast_version='2.0.0', mandatory=True)
autowaf.check_pkg(conf, 'serd', uselib_store='SERD',
atleast_version='0.1.0', mandatory=True)
autowaf.check_pkg(conf, 'sord', uselib_store='SORD',
@@ -109,7 +110,7 @@ def build(bld):
bld.install_files('${INCLUDEDIR}/slv2', bld.path.ant_glob('slv2/*.h'))
# Pkgconfig file
- autowaf.build_pc(bld, 'SLV2', SLV2_VERSION, ['SORD','RAPTOR'])
+ autowaf.build_pc(bld, 'SLV2', SLV2_VERSION, ['SORD','GLIB'])
lib_source = '''
src/collections.c
@@ -138,7 +139,7 @@ def build(bld):
obj.install_path = '${LIBDIR}'
obj.cflags = [ '-fvisibility=hidden', '-DSLV2_SHARED', '-DSLV2_INTERNAL' ]
obj.linkflags = [ '-ldl' ]
- autowaf.use_lib(bld, obj, 'SORD SERD LV2CORE RAPTOR')
+ autowaf.use_lib(bld, obj, 'SORD SERD LV2CORE GLIB')
if bld.env['BUILD_TESTS']:
# Static library (for unit test code coverage)
@@ -149,7 +150,7 @@ def build(bld):
obj.target = 'slv2_static'
obj.install_path = ''
obj.cflags = [ '-fprofile-arcs', '-ftest-coverage' ]
- autowaf.use_lib(bld, obj, 'SORD SERD LV2CORE RAPTOR')
+ autowaf.use_lib(bld, obj, 'SORD SERD LV2CORE GLIB')
# Unit tests
for i in tests.split():