aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/ext/atom/forge.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-18 23:12:49 +0000
committerDavid Robillard <d@drobilla.net>2012-02-18 23:12:49 +0000
commit9977d659105937112587e7eb68c59fae7169d945 (patch)
treebb702e76f01b79050a4cbf7cb7b8052e21d84fc6 /lv2/lv2plug.in/ns/ext/atom/forge.h
parent12c86dfba742f1ac3585846f52d5039e9854861c (diff)
downloadlv2-9977d659105937112587e7eb68c59fae7169d945.tar.xz
Remove state:Path and use new atom:Path instead.
Remove suggestion to use file URIs in plugins, which is much too tedious. If plugins use standard atom types, hosts should be able to map paths in any way (which they may need to regardless). Unfortunately it's slightly less pretty in Turtle to have a special path type rather than a (possibly relative) URI. Factor out common write_set_filename_msg in sampler example. Establish common URI define convention LV2_EXTNAME__URILOCALNAME and define all URIs in state, message, and atom.
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/atom/forge.h')
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/forge.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/lv2/lv2plug.in/ns/ext/atom/forge.h b/lv2/lv2plug.in/ns/ext/atom/forge.h
index 4db9638..06f24f5 100644
--- a/lv2/lv2plug.in/ns/ext/atom/forge.h
+++ b/lv2/lv2plug.in/ns/ext/atom/forge.h
@@ -85,6 +85,7 @@ typedef struct {
LV2_URID Int32;
LV2_URID Int64;
LV2_URID Literal;
+ LV2_URID Path;
LV2_URID Property;
LV2_URID Resource;
LV2_URID Sequence;
@@ -172,6 +173,7 @@ lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
forge->Int32 = map->map(map->handle, LV2_ATOM_URI "#Int32");
forge->Int64 = map->map(map->handle, LV2_ATOM_URI "#Int64");
forge->Literal = map->map(map->handle, LV2_ATOM_URI "#Literal");
+ forge->Path = map->map(map->handle, LV2_ATOM_URI "#Path");
forge->Property = map->map(map->handle, LV2_ATOM_URI "#Property");
forge->Resource = map->map(map->handle, LV2_ATOM_URI "#Resource");
forge->Sequence = map->map(map->handle, LV2_ATOM_URI "#Sequence");
@@ -322,13 +324,31 @@ lv2_atom_forge_uri(LV2_Atom_Forge* forge,
const LV2_Atom_String a = { { forge->URI, len + 1 } };
LV2_Atom_String* out = (LV2_Atom_String*)
lv2_atom_forge_write_nopad(forge, &a, sizeof(a));
- if (!out) {
- return NULL;
+ if (out) {
+ if (!lv2_atom_forge_string_body(forge, uri, len)) {
+ out->atom.type = 0;
+ out->atom.size = 0;
+ out = NULL;
+ }
}
- if (!lv2_atom_forge_string_body(forge, uri, len)) {
- out->atom.type = 0;
- out->atom.size = 0;
- return NULL;
+ return out;
+}
+
+/** Write an atom:Path. Note that @p path need not be NULL terminated. */
+static inline LV2_Atom_String*
+lv2_atom_forge_path(LV2_Atom_Forge* forge,
+ const uint8_t* path,
+ size_t len)
+{
+ const LV2_Atom_String a = { { forge->Path, len + 1 } };
+ LV2_Atom_String* out = (LV2_Atom_String*)
+ lv2_atom_forge_write_nopad(forge, &a, sizeof(a));
+ if (out) {
+ if (!lv2_atom_forge_string_body(forge, path, len)) {
+ out->atom.type = 0;
+ out->atom.size = 0;
+ out = NULL;
+ }
}
return out;
}