summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-03-10 07:20:34 +0000
committerDavid Robillard <d@drobilla.net>2011-03-10 07:20:34 +0000
commit4f0ea64bf84fc2532e5104fc1bc5d6ccf76d3fff (patch)
tree4fc91a5c6fb37f1267587513d216feee2787972c
parent509579ed2b7a99b2056136a3faafa7ef11d3a57d (diff)
downloadlilv-4f0ea64bf84fc2532e5104fc1bc5d6ccf76d3fff.tar.gz
lilv-4f0ea64bf84fc2532e5104fc1bc5d6ccf76d3fff.tar.bz2
lilv-4f0ea64bf84fc2532e5104fc1bc5d6ccf76d3fff.zip
Hide as many collection details as possible while keeping generic iterator / SLV2_FOREACH API.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3064 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--slv2/slv2.h219
-rw-r--r--src/collections.c68
-rw-r--r--src/slv2_internal.h33
-rw-r--r--wscript2
4 files changed, 187 insertions, 135 deletions
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 2434561..c3019a4 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -54,7 +54,11 @@
#endif
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
- #define SLV2_DEPRECATED __attribute__((__deprecated__))
+ #ifdef SLV2_INTERNAL
+ #define SLV2_DEPRECATED
+ #else
+ #define SLV2_DEPRECATED __attribute__((__deprecated__))
+ #endif
#else
#define SLV2_DEPRECATED
#endif
@@ -326,42 +330,9 @@ slv2_iter_end(SLV2Iter i);
typedef void* SLV2Collection;
-/**
- Free @a collection.
-*/
-SLV2_API
-void
-slv2_collection_free(SLV2Collection collection);
-
-/**
- Get the number of elements in @a collection.
-*/
-SLV2_API
-unsigned
-slv2_collection_size(SLV2Collection collection);
-
-/**
- Get an element from @a collection by index.
-
- @a index has no significance other than as an index into @a collection.
-
- Any @a index not less than the size of the collection will return NULL,
- so all elements in a collection can be enumerated by repeated calls
- to this function starting with @a index = 0.
-
- Note this function is a search, and not constant time.
- This function is deprecated, use iterators instead.
-
- @return NULL if @a index is out of range.
-*/
-SLV2_API
-void*
-slv2_collection_get_at(SLV2Collection collection,
- unsigned index);
-
SLV2_API
SLV2Iter
-slv2_collection_begin(SLV2Plugins plugins);
+slv2_collection_begin(SLV2Collection collection);
SLV2_API
void*
@@ -375,26 +346,26 @@ slv2_collection_get(SLV2Collection collection,
/* SLV2PluginClasses */
-static inline void
-slv2_plugin_classes_free(SLV2PluginClasses collection) {
- slv2_collection_free(collection);
-}
+SLV2_API
+void
+slv2_plugin_classes_free(SLV2PluginClasses collection);
-static inline unsigned
-slv2_plugin_classes_size(SLV2PluginClasses collection) {
- return slv2_collection_size(collection);
-}
+SLV2_API
+unsigned
+slv2_plugin_classes_size(SLV2PluginClasses collection);
-static inline SLV2PluginClass
-slv2_plugin_classes_get(SLV2PluginClasses collection, SLV2Iter i) {
- return (SLV2PluginClass)slv2_collection_get(collection, i);
-}
+SLV2_API
+SLV2Iter
+slv2_plugin_classes_begin(SLV2PluginClasses collection);
+
+SLV2_API
+SLV2PluginClass
+slv2_plugin_classes_get(SLV2PluginClasses collection, SLV2Iter i);
SLV2_DEPRECATED
-static inline SLV2PluginClass
-slv2_plugin_classes_get_at(SLV2PluginClasses collection, unsigned index) {
- return (SLV2PluginClass)slv2_collection_get_at(collection, index);
-}
+SLV2_API
+SLV2PluginClass
+slv2_plugin_classes_get_at(SLV2PluginClasses collection, unsigned index);
/* SLV2ScalePoints */
@@ -402,59 +373,49 @@ SLV2_API
SLV2ScalePoints
slv2_scale_points_new(void);
-static inline void
-slv2_scale_points_free(SLV2ScalePoints collection) {
- slv2_collection_free(collection);
-}
+SLV2_API
+void
+slv2_scale_points_free(SLV2ScalePoints collection);
-static inline unsigned
-slv2_scale_points_size(SLV2ScalePoints collection) {
- return slv2_collection_size(collection);
-}
+SLV2_API
+unsigned
+slv2_scale_points_size(SLV2ScalePoints collection);
-static inline SLV2Iter
-slv2_scale_points_begin(SLV2ScalePoints collection) {
- return slv2_collection_begin(collection);
-}
+SLV2_API
+SLV2Iter
+slv2_scale_points_begin(SLV2ScalePoints collection);
-static inline SLV2ScalePoint
-slv2_scale_points_get(SLV2ScalePoints collection, SLV2Iter i) {
- return (SLV2ScalePoint)slv2_collection_get(collection, i);
-}
+SLV2_API
+SLV2ScalePoint
+slv2_scale_points_get(SLV2ScalePoints collection, SLV2Iter i);
SLV2_DEPRECATED
-static inline SLV2ScalePoint
-slv2_scale_points_get_at(SLV2ScalePoints collection, unsigned index) {
- return (SLV2ScalePoint)slv2_collection_get_at(collection, index);
-}
+SLV2_API
+SLV2ScalePoint
+slv2_scale_points_get_at(SLV2ScalePoints collection, unsigned index);
/* UIs */
-static inline void
-slv2_uis_free(SLV2UIs collection) {
- slv2_collection_free(collection);
-}
+SLV2_API
+void
+slv2_uis_free(SLV2UIs collection);
-static inline unsigned
-slv2_uis_size(SLV2UIs collection) {
- return slv2_collection_size(collection);
-}
+SLV2_API
+unsigned
+slv2_uis_size(SLV2UIs collection);
-static inline SLV2Iter
-slv2_uis_begin(SLV2UIs collection) {
- return slv2_collection_begin(collection);
-}
+SLV2_API
+SLV2Iter
+slv2_uis_begin(SLV2UIs collection);
-static inline SLV2UI
-slv2_uis_get(SLV2UIs collection, SLV2Iter i) {
- return (SLV2UI)slv2_collection_get(collection, i);
-}
+SLV2_API
+SLV2UI
+slv2_uis_get(SLV2UIs collection, SLV2Iter i);
SLV2_DEPRECATED
-static inline SLV2UI
-slv2_uis_get_at(SLV2UIs collection, unsigned index) {
- return (SLV2UI)slv2_collection_get_at(collection, index);
-}
+SLV2_API
+SLV2UI
+slv2_uis_get_at(SLV2UIs collection, unsigned index);
/* Values */
@@ -462,67 +423,57 @@ SLV2_API
SLV2ScalePoints
slv2_values_new(void);
-static inline void
-slv2_values_free(SLV2Values collection) {
- slv2_collection_free(collection);
-}
+SLV2_API
+void
+slv2_values_free(SLV2Values collection);
-static inline unsigned
-slv2_values_size(SLV2Values collection) {
- return slv2_collection_size(collection);
-}
+SLV2_API
+unsigned
+slv2_values_size(SLV2Values collection);
-static inline SLV2Iter
-slv2_values_begin(SLV2Values collection) {
- return slv2_collection_begin(collection);
-}
+SLV2_API
+SLV2Iter
+slv2_values_begin(SLV2Values collection);
-static inline SLV2Value
-slv2_values_get(SLV2Values collection, SLV2Iter i) {
- return (SLV2Value)slv2_collection_get(collection, i);
-}
+SLV2_API
+SLV2Value
+slv2_values_get(SLV2Values collection, SLV2Iter i);
-static inline SLV2Value
-slv2_values_get_first(SLV2Values collection) {
- return (SLV2Value)slv2_collection_get(collection, slv2_collection_begin(collection));
-}
+SLV2_API
+SLV2Value
+slv2_values_get_first(SLV2Values collection);
SLV2_DEPRECATED
-static inline SLV2Value
-slv2_values_get_at(SLV2Values collection, unsigned index) {
- return (SLV2Value)slv2_collection_get_at(collection, index);
-}
+SLV2_API
+SLV2Value
+slv2_values_get_at(SLV2Values collection, unsigned index);
/* Plugins */
-static inline unsigned
-slv2_plugins_size(SLV2Plugins collection) {
- return slv2_collection_size(collection);
-}
+SLV2_API
+unsigned
+slv2_plugins_size(SLV2Plugins collection);
-static inline SLV2Iter
-slv2_plugins_begin(SLV2Plugins collection) {
- return slv2_collection_begin(collection);
-}
+SLV2_API
+SLV2Iter
+slv2_plugins_begin(SLV2Plugins collection);
-static inline SLV2Plugin
-slv2_plugins_get(SLV2Plugins collection, SLV2Iter i) {
- return (SLV2Plugin)slv2_collection_get(collection, i);
-}
+SLV2_API
+SLV2Plugin
+slv2_plugins_get(SLV2Plugins collection, SLV2Iter i);
SLV2_DEPRECATED
-static inline SLV2Plugin
-slv2_plugins_get_at(SLV2Plugins collection, unsigned index) {
- return (SLV2Plugin)slv2_collection_get_at(collection, index);
-}
+SLV2_API
+SLV2Plugin
+slv2_plugins_get_at(SLV2Plugins collection, unsigned index);
/**
This function is deprecated, it does nothing.
*/
SLV2_DEPRECATED
-static inline void
-slv2_plugins_free(SLV2World world, SLV2Plugins plugins) {
-}
+SLV2_API
+void
+slv2_plugins_free(SLV2World world, SLV2Plugins plugins);
/**
Get a plugin from @a plugins by URI.
diff --git a/src/collections.c b/src/collections.c
index bdbf640..4c3ae5e 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -165,3 +165,71 @@ slv2_iter_end(SLV2Iter i)
{
return !i || g_sequence_iter_is_end((GSequenceIter*)i);
}
+
+#define SLV2_COLLECTION_IMPL(prefix, CT, ET) \
+SLV2_API \
+unsigned \
+prefix##_size(CT collection) { \
+ return slv2_collection_size(collection); \
+} \
+\
+SLV2_API \
+SLV2Iter \
+prefix##_begin(CT collection) { \
+ return slv2_collection_begin(collection); \
+} \
+\
+SLV2_API \
+ET \
+prefix##_get(CT collection, SLV2Iter i) { \
+ return (ET)slv2_collection_get(collection, i); \
+} \
+\
+SLV2_DEPRECATED \
+SLV2_API \
+ET \
+prefix##_get_at(CT collection, unsigned index) { \
+ return (ET)slv2_collection_get_at(collection, index); \
+}
+
+SLV2_COLLECTION_IMPL(slv2_plugin_classes, SLV2PluginClasses, SLV2PluginClass)
+SLV2_COLLECTION_IMPL(slv2_scale_points, SLV2ScalePoints, SLV2ScalePoint)
+SLV2_COLLECTION_IMPL(slv2_uis, SLV2UIs, SLV2UI)
+SLV2_COLLECTION_IMPL(slv2_values, SLV2Values, SLV2Value)
+SLV2_COLLECTION_IMPL(slv2_plugins, SLV2Plugins, SLV2Plugin)
+
+SLV2_API
+void
+slv2_plugin_classes_free(SLV2PluginClasses collection) {
+ slv2_collection_free(collection);
+}
+
+SLV2_API
+void
+slv2_scale_points_free(SLV2ScalePoints collection) {
+ slv2_collection_free(collection);
+}
+
+SLV2_API
+void
+slv2_uis_free(SLV2UIs collection) {
+ slv2_collection_free(collection);
+}
+
+SLV2_API
+void
+slv2_values_free(SLV2Values collection) {
+ slv2_collection_free(collection);
+}
+
+SLV2_API
+void
+slv2_plugins_free(SLV2World world, SLV2Plugins plugins){
+}
+
+SLV2_API
+SLV2Value
+slv2_values_get_first(SLV2Values collection) {
+ return (SLV2Value)slv2_collection_get(collection,
+ slv2_collection_begin(collection));
+}
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index f800a68..b1f223f 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -140,6 +140,39 @@ slv2_plugin_get_unique(SLV2Plugin p,
SLV2Plugins
slv2_plugins_new();
+/**
+ Free @a collection.
+*/
+SLV2_API
+void
+slv2_collection_free(SLV2Collection collection);
+
+/**
+ Get the number of elements in @a collection.
+*/
+SLV2_API
+unsigned
+slv2_collection_size(SLV2Collection collection);
+
+/**
+ Get an element from @a collection by index.
+
+ @a index has no significance other than as an index into @a collection.
+
+ Any @a index not less than the size of the collection will return NULL,
+ so all elements in a collection can be enumerated by repeated calls
+ to this function starting with @a index = 0.
+
+ Note this function is a search, and not constant time.
+ This function is deprecated, use iterators instead.
+
+ @return NULL if @a index is out of range.
+*/
+SLV2_DEPRECATED
+SLV2_API
+void*
+slv2_collection_get_at(SLV2Collection collection,
+ unsigned index);
/* ********* Instance ********* */
diff --git a/wscript b/wscript
index 8109b1c..a23b7b5 100644
--- a/wscript
+++ b/wscript
@@ -213,7 +213,7 @@ def build(bld):
obj.name = 'libslv2_static'
obj.target = 'slv2_static'
obj.install_path = ''
- obj.cflags = [ '-fprofile-arcs', '-ftest-coverage' ]
+ obj.cflags = [ '-fprofile-arcs', '-ftest-coverage', '-DSLV2_INTERNAL' ]
obj.linkflags = [ '-ldl' ]
autowaf.use_lib(bld, obj, 'SORD SERD LV2CORE GLIB SUIL')