diff options
author | David Robillard <d@drobilla.net> | 2011-11-09 02:14:18 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-11-09 02:14:18 +0000 |
commit | ea8e4e2982328a1941bbe6bbdc96f954598a1174 (patch) | |
tree | 5a645bcc97b6c3f0cc502fff3c1cdff2c9305a1d | |
parent | c43aed97c6b874a80fd5a9f759e651953bcec1f9 (diff) | |
download | lv2-ea8e4e2982328a1941bbe6bbdc96f954598a1174.tar.xz |
Rename Object to Thing.
Add definition of Message.
-rw-r--r-- | ext/atom.lv2/atom-helpers.h | 94 | ||||
-rw-r--r-- | ext/atom.lv2/atom.h | 4 | ||||
-rw-r--r-- | ext/atom.lv2/atom.ttl | 50 | ||||
-rw-r--r-- | ext/atom.lv2/forge.h | 4 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 8 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler_ui.c | 12 |
6 files changed, 94 insertions, 78 deletions
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.: <pre> - 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... } </pre> */ -#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 @@ <http://lv2plug.in/ns/ext/atom> 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 <atom-buffer.h> ; doap:release [ doap:revision "0.2" ; @@ -163,7 +163,7 @@ char str[] = "<http://example.org/foo> a <http://example.org/Thi </pre> """ . -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 <code>size</code>.</p> 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 <a href="#Object">Object</a>. An -LV2_Atom_Property has an <a href="#ID">ID</a> <code>key</code> and +LV2_Atom_Property has an <a href="#URID">URID</a> <code>key</code> and <a href="#Atom">Atom</a> <code>value</code>. """ . -atom:Object +atom:Thing a rdfs:Class ; rdfs:subClassOf atom:Atom ; - rdfs:label "Object" ; + rdfs:label "Thing" ; lv2:documentation """ -<p>Abstract base class for an "Object", i.e. an <a href="#Atom">Atom</a> with a +<p>Abstract base class for a "Thing", i.e. an <a href="#Atom">Atom</a> with a number of <a href="#Property">properties</a>. An LV2_Object is an unsigned 32-bit integer <code>context</code> and <code>id</code> followed by a sequence of LV2_Atom_Property .</p> @@ -260,7 +260,7 @@ LV2_URI_Map_Feature::uri_to_id() with <code>map = NULL</code>, and may be 0 (the default context).</p> <p>Note this is an abstract class, i.e. no Atom can exist with <code>type = -uri_to_id(atom:Object)</code>. An Object is either a <a +uri_to_id(atom:Thing)</code>. An Object is either a <a href="#Resource">Resource</a> or a <a href="#Blank">Blank</a>, but the <code>body</code> 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.</p> atom:Resource a rdfs:Class ; - rdfs:subClassOf atom:Object ; + rdfs:subClassOf atom:Thing ; lv2:documentation """ An <a href="#Object">Object</a> where <code>id</code> is the URI of the resource mapped to an <a href="#ID">ID</a>. @@ -277,7 +277,7 @@ URI of the resource mapped to an <a href="#ID">ID</a>. atom:Blank a rdfs:Class ; - rdfs:subClassOf atom:Object ; + rdfs:subClassOf atom:Thing ; lv2:documentation """ An <a href="#Object">Object</a> where <code>id</code> 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, <code>id</code> is NOT an <a href="ID">ID</a>. """ . +atom:Message + a rdfs:Class ; + rdfs:subClassOf atom:Thing ; + lv2:documentation """ +A <a href="#Thing"> where <code>id</code> 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 <code>id</code> 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 (<code>size = 1</code>)" . +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; } diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 5a00e64..ecebc12 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -277,14 +277,14 @@ run(LV2_Handle instance, plugin->play = true; } } else if (ev->body.type == plugin->atom_message_id) { - const LV2_Object* msg = (LV2_Object*)&ev->body; + const LV2_Thing* msg = (LV2_Thing*)&ev->body; if (msg->id == plugin->set_message_id) { const LV2_Atom* filename = NULL; - LV2_Object_Query q[] = { + LV2_Thing_Query q[] = { { plugin->filename_key_id, &filename }, - LV2_OBJECT_QUERY_END + LV2_THING_QUERY_END }; - lv2_object_query(msg, q); + lv2_thing_query(msg, q); if (filename) { memcpy(plugin->pending_samp->filepath, diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c index 24a79aa..f8cc560 100644 --- a/plugins/eg-sampler.lv2/sampler_ui.c +++ b/plugins/eg-sampler.lv2/sampler_ui.c @@ -73,13 +73,13 @@ on_load_clicked(GtkWidget* widget, gtk_widget_destroy(dialog); uint8_t msg_buf[4096]; - LV2_Object* msg = (LV2_Object*)msg_buf; + LV2_Thing* msg = (LV2_Thing*)msg_buf; lv2_atom_forge_set_message(ui->forge, msg, uri_to_id(ui, SET_MESSAGE_URI)); - lv2_object_append(msg, - uri_to_id(ui, FILENAME_URI), - uri_to_id(ui, NS_ATOM "String"), - filename_len, - filename); + lv2_thing_append(msg, + uri_to_id(ui, FILENAME_URI), + uri_to_id(ui, NS_ATOM "String"), + filename_len, + filename); ui->write(ui->controller, 0, sizeof(LV2_Atom) + msg->size, uri_to_id(ui, NS_ATOM "atomTransfer"), |