From ea8e4e2982328a1941bbe6bbdc96f954598a1174 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 9 Nov 2011 02:14:18 +0000 Subject: Rename Object to Thing. Add definition of Message. --- ext/atom.lv2/atom-helpers.h | 94 ++++++++++++++++++++++----------------------- ext/atom.lv2/atom.h | 4 +- ext/atom.lv2/atom.ttl | 50 ++++++++++++++++-------- ext/atom.lv2/forge.h | 4 +- 4 files changed, 84 insertions(+), 68 deletions(-) (limited to 'ext') diff --git a/ext/atom.lv2/atom-helpers.h b/ext/atom.lv2/atom-helpers.h index 9d48a29..0a19d25 100644 --- a/ext/atom.lv2/atom-helpers.h +++ b/ext/atom.lv2/atom-helpers.h @@ -34,92 +34,92 @@ #include "lv2/lv2plug.in/ns/ext/atom/atom.h" -typedef LV2_Atom_Property* LV2_Object_Iter; +typedef LV2_Atom_Property* LV2_Thing_Iter; -/** Get an iterator pointing to @c prop in some LV2_Object */ -static inline LV2_Object_Iter -lv2_object_begin(const LV2_Object* obj) +/** Get an iterator pointing to @c prop in some LV2_Thing */ +static inline LV2_Thing_Iter +lv2_thing_begin(const LV2_Thing* obj) { - return (LV2_Object_Iter)(obj->properties); + return (LV2_Thing_Iter)(obj->properties); } -/** Return true iff @c iter has reached the end of @c object */ +/** Return true iff @c iter has reached the end of @c thing */ static inline bool -lv2_object_iter_is_end(const LV2_Object* obj, LV2_Object_Iter iter) +lv2_thing_iter_is_end(const LV2_Thing* obj, LV2_Thing_Iter iter) { return (uint8_t*)iter >= ((uint8_t*)obj + sizeof(LV2_Atom) + obj->size); } /** Return true iff @c l points to the same property as @c r */ static inline bool -lv2_object_iter_equals(const LV2_Object_Iter l, const LV2_Object_Iter r) +lv2_thing_iter_equals(const LV2_Thing_Iter l, const LV2_Thing_Iter r) { return l == r; } /** Return an iterator to the property following @c iter */ -static inline LV2_Object_Iter -lv2_object_iter_next(const LV2_Object_Iter iter) +static inline LV2_Thing_Iter +lv2_thing_iter_next(const LV2_Thing_Iter iter) { - return (LV2_Object_Iter)((uint8_t*)iter - + sizeof(LV2_Atom_Property) - + lv2_atom_pad_size(iter->value.size)); + return (LV2_Thing_Iter)((uint8_t*)iter + + sizeof(LV2_Atom_Property) + + lv2_atom_pad_size(iter->value.size)); } /** Return the property pointed to by @c iter */ static inline LV2_Atom_Property* -lv2_object_iter_get(LV2_Object_Iter iter) +lv2_thing_iter_get(LV2_Thing_Iter iter) { return (LV2_Atom_Property*)iter; } /** - A macro for iterating over all properties of an Object. - @param obj The object to iterate over + A macro for iterating over all properties of an Thing. + @param obj The thing to iterate over @param iter The name of the iterator This macro is used similarly to a for loop (which it expands to), e.g.:
-   LV2_OBJECT_FOREACH(object, i) {
-       LV2_Atom_Property* prop = lv2_object_iter_get(i);
-       // Do things with prop here...
+   LV2_THING_FOREACH(thing, i) {
+   LV2_Atom_Property* prop = lv2_thing_iter_get(i);
+   // Do things with prop here...
    }
    
*/ -#define LV2_OBJECT_FOREACH(obj, iter) \ - for (LV2_Object_Iter (iter) = lv2_object_begin(obj); \ - !lv2_object_iter_is_end(obj, (iter)); \ - (iter) = lv2_object_iter_next(iter)) +#define LV2_THING_FOREACH(thing, iter) \ + for (LV2_Thing_Iter (iter) = lv2_thing_begin(thing); \ + !lv2_thing_iter_is_end(thing, (iter)); \ + (iter) = lv2_thing_iter_next(iter)) /** - Append a Property body to an Atom that contains properties (e.g. atom:Object). - @param object Pointer to the atom that contains the property to add. object.size - must be valid, but object.type is ignored. + Append a Property body to an Atom that contains properties (e.g. atom:Thing). + @param thing Pointer to the atom that contains the property to add. thing.size + must be valid, but thing.type is ignored. @param key The key of the new property @param value_type The type of the new value @param value_size The size of the new value @param value_body Pointer to the new value's data @return a pointer to the new LV2_Atom_Property in @c body. - This function will write the property body (not including an LV2_Object + This function will write the property body (not including an LV2_Thing header) at lv2_atom_pad_size(body + size). Thus, it can be used with any Atom type that contains headerless 32-bit aligned properties. */ static inline LV2_Atom_Property* -lv2_object_append(LV2_Object* object, - uint32_t key, - uint32_t value_type, - uint32_t value_size, - const void* value_body) +lv2_thing_append(LV2_Thing* thing, + uint32_t key, + uint32_t value_type, + uint32_t value_size, + const void* value_body) { - object->size = lv2_atom_pad_size(object->size); + thing->size = lv2_atom_pad_size(thing->size); LV2_Atom_Property* prop = (LV2_Atom_Property*)( - (uint8_t*)object + sizeof(LV2_Atom) + object->size); + (uint8_t*)thing + sizeof(LV2_Atom) + thing->size); prop->key = key; prop->value.type = value_type; prop->value.size = value_size; memcpy(prop->value.body, value_body, value_size); - object->size += sizeof(LV2_Atom_Property) + value_size; + thing->size += sizeof(LV2_Atom_Property) + value_size; return prop; } @@ -130,36 +130,36 @@ lv2_atom_is_null(LV2_Atom* atom) return !atom || (atom->type == 0 && atom->size == 0); } -/** A single entry in an Object query. */ +/** A single entry in an Thing query. */ typedef struct { uint32_t key; /**< Key to query (input set by user) */ const LV2_Atom** value; /**< Found value (output set by query function) */ -} LV2_Object_Query; +} LV2_Thing_Query; -static const LV2_Object_Query LV2_OBJECT_QUERY_END = { 0, NULL }; +static const LV2_Thing_Query LV2_THING_QUERY_END = { 0, NULL }; /** - "Query" an object, getting a pointer to the values for various keys. + "Query" an thing, getting a pointer to the values for various keys. The value pointer of each item in @c query will be set to the location of - the corresponding value in @c object. Every value pointer in @c query MUST - be initialised to NULL. This function reads @c object in a single linear - sweep. By allocating @c query on the stack, objects can be "queried" + the corresponding value in @c thing. Every value pointer in @c query MUST + be initialised to NULL. This function reads @c thing in a single linear + sweep. By allocating @c query on the stack, things can be "queried" quickly without allocating any memory. This function is realtime safe. */ static inline int -lv2_object_query(const LV2_Object* object, LV2_Object_Query* query) +lv2_thing_query(const LV2_Thing* thing, LV2_Thing_Query* query) { int matches = 0; int n_queries = 0; /* Count number of query keys so we can short-circuit when done */ - for (LV2_Object_Query* q = query; q->key; ++q) + for (LV2_Thing_Query* q = query; q->key; ++q) ++n_queries; - LV2_OBJECT_FOREACH(object, o) { - const LV2_Atom_Property* prop = lv2_object_iter_get(o); - for (LV2_Object_Query* q = query; q->key; ++q) { + LV2_THING_FOREACH(thing, o) { + const LV2_Atom_Property* prop = lv2_thing_iter_get(o); + for (LV2_Thing_Query* q = query; q->key; ++q) { if (q->key == prop->key && !*q->value) { *q->value = &prop->value; if (++matches == n_queries) diff --git a/ext/atom.lv2/atom.h b/ext/atom.lv2/atom.h index d617435..4b57040 100644 --- a/ext/atom.lv2/atom.h +++ b/ext/atom.lv2/atom.h @@ -107,7 +107,7 @@ typedef struct _LV2_Atom_Property { } LV2_Atom_Property; /** - An atom:Object (atom:Resource or atom:Blank). + An atom:Thing (Resource, Blank, or Message). This type may safely be cast to LV2_Atom. */ typedef struct { @@ -116,7 +116,7 @@ typedef struct { uint32_t context; /**< ID of context graph, or 0 for default */ uint32_t id; /**< URID (for Resource) or blank ID (for Blank) */ uint8_t properties[]; /**< Sequence of LV2_Atom_Property */ -} LV2_Object; +} LV2_Thing; /** An Event (a timestamped Atom). diff --git a/ext/atom.lv2/atom.ttl b/ext/atom.lv2/atom.ttl index d999518..547d6d5 100644 --- a/ext/atom.lv2/atom.ttl +++ b/ext/atom.lv2/atom.ttl @@ -24,7 +24,7 @@ a lv2:Specification ; doap:name "LV2 Atom" ; - doap:shortdesc "A generic value container and several data types." ; + doap:shortdesc "A generic value container and several data types." ; rdfs:seeAlso ; doap:release [ doap:revision "0.2" ; @@ -163,7 +163,7 @@ char str[] = "<http://example.org/foo> a <http://example.org/Thi """ . -atom:ID +atom:URID a rdfs:Class ; rdfs:subClassOf atom:Atom ; rdfs:label "Integer ID mapped from a URI" ; @@ -180,8 +180,8 @@ atom:BlankID lv2:documentation """ 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. +MUST NOT be used as a global identifier. In particular, a BlankID is NOT a +URID, and can not be mapped to/from a URI. """ . atom:Vector @@ -237,19 +237,19 @@ and size.

atom:Property a rdfs:Class ; rdfs:subClassOf atom:Atom ; - rdfs:label "Property of an Object" ; + rdfs:label "Property of a Thing" ; lv2:documentation """ A single property of some Object. An -LV2_Atom_Property has an ID key and +LV2_Atom_Property has an URID key and Atom value. """ . -atom:Object +atom:Thing a rdfs:Class ; rdfs:subClassOf atom:Atom ; - rdfs:label "Object" ; + rdfs:label "Thing" ; lv2:documentation """ -

Abstract base class for an "Object", i.e. an Atom with a +

Abstract base class for a "Thing", i.e. an Atom with a number of properties. An LV2_Object is an unsigned 32-bit integer context and id followed by a sequence of LV2_Atom_Property .

@@ -260,7 +260,7 @@ LV2_URI_Map_Feature::uri_to_id() with map = NULL, and may be 0 (the default context).

Note this is an abstract class, i.e. no Atom can exist with type = -uri_to_id(atom:Object). An Object is either a . An Object is either a Resource or a Blank, but the body always has the same binary format, LV2_Object. Thus, both named and anonymous objects can be handled with common code using only a 64-bit @@ -269,7 +269,7 @@ header for both.

atom:Resource a rdfs:Class ; - rdfs:subClassOf atom:Object ; + rdfs:subClassOf atom:Thing ; lv2:documentation """ An Object where id is the URI of the resource mapped to an ID. @@ -277,7 +277,7 @@ URI of the resource mapped to an ID. atom:Blank a rdfs:Class ; - rdfs:subClassOf atom:Object ; + rdfs:subClassOf atom:Thing ; lv2:documentation """ An Object where id is the blank node ID of the object, which is only meaningful within a certain limited scope @@ -285,6 +285,18 @@ the object, which is only meaningful within a certain limited scope In particular, id is NOT an ID. """ . +atom:Message + a rdfs:Class ; + rdfs:subClassOf atom:Thing ; + lv2:documentation """ +A where id is a message type ID. Conceptually, +a Message is identical to a Blank, but is a distinct type with a single type +field to allow simple and fast dispatch by handling code. + +A Message may be serialised as a Blank by adding an rdf:type property with the +value id unmapped to a URI. +""" . + atom:Model a rdfs:Class ; rdfs:subClassOf atom:Atom ; @@ -296,7 +308,6 @@ simply a sequence of objects. atom:Event a rdfs:Class ; - rdfs:subClassOf atom:Atom ; rdfs:label "Event" ; lv2:documentation """ An atom with a time stamp header prepended, typically for sample accurate @@ -313,14 +324,19 @@ atom:Byte rdfs:subClassOf atom:Atom ; rdfs:label "Byte (size = 1)" . +atom:Number + a rdfs:Class ; + rdfs:subClassOf atom:Atom ; + rdfs:label "Number (abstract class)." . + atom:Int32 a rdfs:Class ; - rdfs:subClassOf atom:Atom ; + rdfs:subClassOf atom:Number ; rdfs:label "Signed 32-bit integer" . atom:Int64 a rdfs:Class ; - rdfs:subClassOf atom:Atom ; + rdfs:subClassOf atom:Number ; rdfs:label "Signed 64-bit integer" . atom:Bool @@ -330,12 +346,12 @@ atom:Bool atom:Float a rdfs:Class ; - rdfs:subClassOf atom:Atom ; + rdfs:subClassOf atom:Number ; rdfs:label "32-bit IEEE-754 floating point number" . atom:Double a rdfs:Class ; - rdfs:subClassOf atom:Atom ; + rdfs:subClassOf atom:Number ; rdfs:label "64-bit IEEE-754 floating point number" . atom:blobSupport diff --git a/ext/atom.lv2/forge.h b/ext/atom.lv2/forge.h index f1ffb03..b42b384 100644 --- a/ext/atom.lv2/forge.h +++ b/ext/atom.lv2/forge.h @@ -59,11 +59,11 @@ lv2_atom_forge_make_id(LV2_Atom_Forge* forge, uint32_t id) static inline void lv2_atom_forge_set_message(LV2_Atom_Forge* forge, - LV2_Object* msg, + LV2_Thing* msg, uint32_t id) { msg->type = forge->Message; - msg->size = sizeof(LV2_Object) - sizeof(LV2_Atom); + msg->size = sizeof(LV2_Thing) - sizeof(LV2_Atom); msg->context = 0; msg->id = id; } -- cgit v1.2.1