summaryrefslogtreecommitdiffstats
path: root/src/collections.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-03-08 00:54:23 +0000
committerDavid Robillard <d@drobilla.net>2011-03-08 00:54:23 +0000
commita9bbabe7ff2d9ca96ab047ccb86c2698cfb2d7b3 (patch)
tree4d124d439d59aa7da04f818a000a2f966e63503b /src/collections.c
parent27341a1b6bb661114184f93fadaf534d890e8498 (diff)
downloadlilv-a9bbabe7ff2d9ca96ab047ccb86c2698cfb2d7b3.tar.gz
lilv-a9bbabe7ff2d9ca96ab047ccb86c2698cfb2d7b3.tar.bz2
lilv-a9bbabe7ff2d9ca96ab047ccb86c2698cfb2d7b3.zip
Use the same data structure for all collections (fix ticket #650).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3054 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/collections.c')
-rw-r--r--src/collections.c68
1 files changed, 20 insertions, 48 deletions
diff --git a/src/collections.c b/src/collections.c
index 85f4391..43c8af7 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -27,47 +27,6 @@
#include "slv2_internal.h"
-/* ARRAYS */
-
-#define SLV2_ARRAY_IMPL(CollType, ElemType, prefix, free_func) \
-\
-CollType \
-prefix ## _new() \
-{ \
- return g_ptr_array_new_with_free_func((GDestroyNotify)free_func); \
-} \
-\
-SLV2_API \
-void \
-prefix ## _free(CollType coll) \
-{ \
- if (coll) \
- g_ptr_array_unref((GPtrArray*)coll); \
-} \
-\
-SLV2_API \
-unsigned \
-prefix ## _size(CollType coll) \
-{ \
- return (coll ? ((GPtrArray*)coll)->len : 0); \
-} \
-\
-SLV2_API \
-ElemType \
-prefix ## _get_at(CollType coll, unsigned index) \
-{ \
- if (!coll || index >= ((GPtrArray*)coll)->len) \
- return NULL; \
- else \
- return (ElemType)g_ptr_array_index((GPtrArray*)coll, (int)index); \
-}
-
-SLV2_ARRAY_IMPL(SLV2ScalePoints, SLV2ScalePoint,
- slv2_scale_points, &slv2_scale_point_free)
-SLV2_ARRAY_IMPL(SLV2Values, SLV2Value,
- slv2_values, &slv2_value_free)
-
-
/* SEQUENCE */
#define SLV2_SEQUENCE_IMPL(CollType, ElemType, prefix, free_func) \
@@ -103,21 +62,34 @@ prefix ## _get_at(CollType coll, unsigned index) \
GSequenceIter* i = g_sequence_get_iter_at_pos((GSequence*)coll, (int)index); \
return (ElemType)g_sequence_get(i); \
} \
-} \
-\
-SLV2_API \
-ElemType \
-prefix ## _get_by_uri(CollType coll, SLV2Value uri) \
-{ \
- return (ElemType)slv2_sequence_get_by_uri(coll, uri); \
}
+SLV2_SEQUENCE_IMPL(SLV2ScalePoints, SLV2ScalePoint,
+ slv2_scale_points, &slv2_scale_point_free)
+
+SLV2_SEQUENCE_IMPL(SLV2Values, SLV2Value,
+ slv2_values, &slv2_value_free)
+
SLV2_SEQUENCE_IMPL(SLV2PluginClasses, SLV2PluginClass,
slv2_plugin_classes, &slv2_plugin_class_free)
SLV2_SEQUENCE_IMPL(SLV2UIs, SLV2UI,
slv2_uis, &slv2_ui_free)
+SLV2_API
+SLV2PluginClass
+slv2_plugin_classes_get_by_uri(SLV2PluginClasses coll, SLV2Value uri)
+{
+ return (SLV2PluginClass)slv2_sequence_get_by_uri(coll, uri);
+}
+
+SLV2_API
+SLV2UI
+slv2_uis_get_by_uri(SLV2UIs coll, SLV2Value uri)
+{
+ return (SLV2UIs)slv2_sequence_get_by_uri(coll, uri);
+}
+
/* VALUES */