From ea48658a1d2f35a7bb88b31841e3ec45f29a604c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 27 Oct 2010 01:31:16 +0000 Subject: Add atom:BlankID atom type (for references to local anonymous objects). Simplify object iteration API. --- ext/atom.lv2/atom-helpers.h | 13 +++++-------- ext/atom.lv2/atom.ttl | 13 ++++++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'ext/atom.lv2') diff --git a/ext/atom.lv2/atom-helpers.h b/ext/atom.lv2/atom-helpers.h index 5c98a3f..787d0c7 100644 --- a/ext/atom.lv2/atom-helpers.h +++ b/ext/atom.lv2/atom-helpers.h @@ -48,9 +48,9 @@ typedef LV2_Atom_Property* LV2_Object_Iter; /** Get an iterator pointing to @a prop in some LV2_Object */ static inline LV2_Object_Iter -lv2_object_get_iter(LV2_Atom_Property* prop) +lv2_object_begin(LV2_Atom* obj) { - return (LV2_Object_Iter)prop; + return (LV2_Object_Iter)(((LV2_Object*)obj->body)->properties); } /** Return true iff @a iter has reached the end of @a object */ @@ -94,7 +94,7 @@ lv2_object_iter_get(LV2_Object_Iter iter) * */ #define LV2_OBJECT_FOREACH(obj, iter) \ - for (LV2_Object_Iter (iter) = lv2_object_get_iter((LV2_Atom_Property*)(obj)->body); \ + for (LV2_Object_Iter (iter) = lv2_object_begin(obj); \ !lv2_object_iter_is_end(obj, (iter)); \ (iter) = lv2_object_iter_next(iter)) @@ -149,10 +149,8 @@ lv2_atom_is_a(LV2_Atom* object, return true; if (object->type == atom_Object) { - for (LV2_Object_Iter i = lv2_object_get_iter((LV2_Atom_Property*)object->body); - !lv2_object_iter_is_end(object, i); - i = lv2_object_iter_next(i)) { - LV2_Atom_Property* prop = lv2_object_iter_get(i); + LV2_OBJECT_FOREACH(object, o) { + LV2_Atom_Property* prop = lv2_object_iter_get(o); if (prop->key == rdf_type) { if (prop->value.type == atom_URIInt) { const uint32_t object_type = *(uint32_t*)prop->value.body; @@ -161,7 +159,6 @@ lv2_atom_is_a(LV2_Atom* object, } else { fprintf(stderr, "error: rdf:type is not a URIInt\n"); } - } } } diff --git a/ext/atom.lv2/atom.ttl b/ext/atom.lv2/atom.ttl index 186268c..7702d21 100644 --- a/ext/atom.lv2/atom.ttl +++ b/ext/atom.lv2/atom.ttl @@ -165,7 +165,7 @@ char str[] = "<http://example.org/foo> a <http://example.org/Thing& atom:ID a rdfs:Class ; rdfs:subClassOf atom:Atom ; - rdfs:label "Integer ID mapped from a URI" ; + rdfs:label "Integer ID mapped from a URI" ; rdfs:comment """ An unsigned 32-bit integer mapped from a URI using the URI Map extension's @@ -174,6 +174,17 @@ with map = NULL. """ . +atom:BlankID a rdfs:Class ; + rdfs:subClassOf atom:Atom ; + rdfs:label "Integer ID for a blank node" ; + rdfs:comment """ +An unsigned 32-bit integer identifier for a blank node. A BlankID is only +meaningful within a limited scope (e.g. the Atom in which it appears), and +MUST NOT be used as a global identifier. In particular, a BlankID is NOT an +ID, and can not be mapped to/from a URI. +""" . + + atom:Vector a rdfs:Class ; rdfs:subClassOf atom:Atom ; rdfs:label "Vector" ; -- cgit v1.2.1