aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/ext/atom
diff options
context:
space:
mode:
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/atom')
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/atom-test.c37
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/atom.h31
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/atom.ttl26
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/forge.h32
4 files changed, 100 insertions, 26 deletions
diff --git a/lv2/lv2plug.in/ns/ext/atom/atom-test.c b/lv2/lv2plug.in/ns/ext/atom/atom-test.c
index 2cc0da9..2011f68 100644
--- a/lv2/lv2plug.in/ns/ext/atom/atom-test.c
+++ b/lv2/lv2plug.in/ns/ext/atom/atom-test.c
@@ -72,16 +72,17 @@ main()
LV2_URID eg_four = urid_map(NULL, "http://example.org/four");
LV2_URID eg_true = urid_map(NULL, "http://example.org/true");
LV2_URID eg_false = urid_map(NULL, "http://example.org/false");
+ LV2_URID eg_path = urid_map(NULL, "http://example.org/path");
LV2_URID eg_uri = urid_map(NULL, "http://example.org/uri");
LV2_URID eg_urid = urid_map(NULL, "http://example.org/urid");
LV2_URID eg_string = urid_map(NULL, "http://example.org/string");
LV2_URID eg_literal = urid_map(NULL, "http://example.org/literal");
LV2_URID eg_tuple = urid_map(NULL, "http://example.org/tuple");
LV2_URID eg_vector = urid_map(NULL, "http://example.org/vector");
- LV2_URID eg_seq = urid_map(NULL, "http://example.org/seq");
+ LV2_URID eg_seq = urid_map(NULL, "http: //example.org/seq");
#define BUF_SIZE 1024
-#define NUM_PROPS 13
+#define NUM_PROPS 14
uint8_t buf[BUF_SIZE];
lv2_atom_forge_set_buffer(&forge, buf, BUF_SIZE);
@@ -132,15 +133,26 @@ main()
return test_fail("%ld != 0 (false)\n", f->value);
}
+ // eg_path = (Path)"/foo/bar"
+ const uint8_t* pstr = (const uint8_t*)"/foo/bar";
+ const size_t pstr_len = strlen((const char*)pstr);
+ lv2_atom_forge_property_head(&forge, eg_path, 0);
+ LV2_Atom_String* path = lv2_atom_forge_uri(&forge, pstr, pstr_len);
+ uint8_t* pbody = (uint8_t*)LV2_ATOM_BODY(path);
+ if (strcmp((const char*)pbody, (const char*)pstr)) {
+ return test_fail("%s != \"%s\"\n",
+ (const char*)pbody, (const char*)pstr);
+ }
+
// eg_uri = (URI)"http://example.org/value"
const uint8_t* ustr = (const uint8_t*)"http://example.org/value";
const size_t ustr_len = strlen((const char*)ustr);
lv2_atom_forge_property_head(&forge, eg_uri, 0);
- LV2_Atom_String* uri = lv2_atom_forge_uri(&forge, ustr, ustr_len);
- uint8_t* body = (uint8_t*)LV2_ATOM_BODY(uri);
- if (strcmp((const char*)body, (const char*)ustr)) {
+ LV2_Atom_String* uri = lv2_atom_forge_uri(&forge, ustr, ustr_len);
+ uint8_t* ubody = (uint8_t*)LV2_ATOM_BODY(uri);
+ if (strcmp((const char*)ubody, (const char*)ustr)) {
return test_fail("%s != \"%s\"\n",
- (const char*)body, (const char*)ustr);
+ (const char*)ubody, (const char*)ustr);
}
// eg_urid = (URID)"http://example.org/value"
@@ -157,7 +169,7 @@ main()
&forge, (const uint8_t*)"hello", strlen("hello"));
uint8_t* sbody = (uint8_t*)LV2_ATOM_BODY(string);
if (strcmp((const char*)sbody, "hello")) {
- return test_fail("%s != \"hello\"\n", (const char*)body);
+ return test_fail("%s != \"hello\"\n", (const char*)sbody);
}
// eg_literal = (Literal)"hello"@fr
@@ -165,9 +177,9 @@ main()
LV2_Atom_Literal* literal = lv2_atom_forge_literal(
&forge, (const uint8_t*)"bonjour", strlen("bonjour"),
0, urid_map(NULL, "http://lexvo.org/id/term/fr"));
- body = (uint8_t*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal);
- if (strcmp((const char*)body, "bonjour")) {
- return test_fail("%s != \"bonjour\"\n", (const char*)body);
+ uint8_t* lbody = (uint8_t*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal);
+ if (strcmp((const char*)lbody, "bonjour")) {
+ return test_fail("%s != \"bonjour\"\n", (const char*)lbody);
}
// eg_tuple = "foo",true
@@ -267,6 +279,7 @@ main()
const LV2_Atom* four;
const LV2_Atom* affirmative;
const LV2_Atom* negative;
+ const LV2_Atom* path;
const LV2_Atom* uri;
const LV2_Atom* urid;
const LV2_Atom* string;
@@ -285,6 +298,7 @@ main()
{ eg_four, &matches.four },
{ eg_true, &matches.affirmative },
{ eg_false, &matches.negative },
+ { eg_path, &matches.path },
{ eg_uri, &matches.uri },
{ eg_urid, &matches.urid },
{ eg_string, &matches.string },
@@ -312,6 +326,8 @@ main()
return test_fail("Bad match true\n");
} else if (!lv2_atom_equals((LV2_Atom*)f, matches.negative)) {
return test_fail("Bad match false\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)path, matches.path)) {
+ return test_fail("Bad match path\n");
} else if (!lv2_atom_equals((LV2_Atom*)uri, matches.uri)) {
return test_fail("Bad match URI\n");
} else if (!lv2_atom_equals((LV2_Atom*)string, matches.string)) {
@@ -333,6 +349,7 @@ main()
eg_four, &matches.four,
eg_true, &matches.affirmative,
eg_false, &matches.negative,
+ eg_path, &matches.path,
eg_uri, &matches.uri,
eg_urid, &matches.urid,
eg_string, &matches.string,
diff --git a/lv2/lv2plug.in/ns/ext/atom/atom.h b/lv2/lv2plug.in/ns/ext/atom/atom.h
index 66f0490..f45ba74 100644
--- a/lv2/lv2plug.in/ns/ext/atom/atom.h
+++ b/lv2/lv2plug.in/ns/ext/atom/atom.h
@@ -27,6 +27,37 @@
#define LV2_ATOM_URI "http://lv2plug.in/ns/ext/atom"
+#define LV2_ATOM__Atom LV2_ATOM_URI "#Atom"
+#define LV2_ATOM__Bang LV2_ATOM_URI "#Bang"
+#define LV2_ATOM__Number LV2_ATOM_URI "#Number"
+#define LV2_ATOM__Int32 LV2_ATOM_URI "#Int32"
+#define LV2_ATOM__Int64 LV2_ATOM_URI "#Int64"
+#define LV2_ATOM__Float LV2_ATOM_URI "#Float"
+#define LV2_ATOM__Double LV2_ATOM_URI "#Double"
+#define LV2_ATOM__Bool LV2_ATOM_URI "#Bool"
+#define LV2_ATOM__String LV2_ATOM_URI "#String"
+#define LV2_ATOM__Literal LV2_ATOM_URI "#Literal"
+#define LV2_ATOM__Path LV2_ATOM_URI "#Path"
+#define LV2_ATOM__URI LV2_ATOM_URI "#URI"
+#define LV2_ATOM__URID LV2_ATOM_URI "#URID"
+#define LV2_ATOM__Vector LV2_ATOM_URI "#Vector"
+#define LV2_ATOM__Tuple LV2_ATOM_URI "#Tuple"
+#define LV2_ATOM__Property LV2_ATOM_URI "#Property"
+#define LV2_ATOM__Object LV2_ATOM_URI "#Object"
+#define LV2_ATOM__Resource LV2_ATOM_URI "#Resource"
+#define LV2_ATOM__Blank LV2_ATOM_URI "#Blank"
+#define LV2_ATOM__TimeUnit LV2_ATOM_URI "#TimeUnit"
+#define LV2_ATOM__AudioFrames LV2_ATOM_URI "#AudioFrames"
+#define LV2_ATOM__Beats LV2_ATOM_URI "#Beats"
+#define LV2_ATOM__Event LV2_ATOM_URI "#Event"
+#define LV2_ATOM__Sequence LV2_ATOM_URI "#Sequence"
+#define LV2_ATOM__AtomPort LV2_ATOM_URI "#AtomPort"
+#define LV2_ATOM__ValuePort LV2_ATOM_URI "#ValuePort"
+#define LV2_ATOM__MessagePort LV2_ATOM_URI "#MessagePort"
+#define LV2_ATOM__bufferType LV2_ATOM_URI "#bufferType"
+#define LV2_ATOM__supports LV2_ATOM_URI "#supports"
+#define LV2_ATOM__eventTransfer LV2_ATOM_URI "#eventTransfer"
+
#define LV2_ATOM_REFERENCE_TYPE 0
#include <stdint.h>
diff --git a/lv2/lv2plug.in/ns/ext/atom/atom.ttl b/lv2/lv2plug.in/ns/ext/atom/atom.ttl
index 70a1252..677a159 100644
--- a/lv2/lv2plug.in/ns/ext/atom/atom.ttl
+++ b/lv2/lv2plug.in/ns/ext/atom/atom.ttl
@@ -218,22 +218,28 @@ void set_to_turtle_string(LV2_Atom_Literal* lit, const char* ttl) {
</pre>
""" .
+atom:Path
+ a rdfs:Class ;
+ rdfs:subClassOf atom:String ;
+ rdfs:label "File path string" ;
+ lv2:documentation """
+<p>A local file path string. This is identical in format to atom:String,
+except the string is a path. Since the ability to distinguish paths from plain
+strings is often necessary, paths MUST NOT be transmitted as atom:String.</p>
+""" .
+
atom:URI
a rdfs:Class ;
rdfs:subClassOf atom:String ;
rdfs:label "URI string" ;
lv2:documentation """
<p>A URI string. This is identical in format to atom:String, except the string
-is a URI. This is occasionally useful when a URI is needed but mapping it is
-inappropriate. URIs should never be expressed as atom:String, because this
-makes it impossible to distinguish URIs from arbitrary strings, which makes
-functionality like mapping or rewriting URIs impossible. Similarly, there is
-deliberately no atom type for filesystem paths. To refer to a filename, use a
-complete file URI, with hostname if at all possible. This allows hosts to
-properly handle paths in situations like serialisation or network
-transmission.</p>
-
-<p>Pedantically, this is an <q>IRI</q>, since UTF-8 characters are allowed.</p>
+is a URI. This is useful when a URI is needed but mapping is inappropriate.
+Since the ability to distinguish URIs from plain strings is often necessary,
+URIs MUST NOT be transmitted as atom:String.</p>
+
+<p>This is not strictly a URI, since UTF-8 is allowed. Escaping and related
+issues issues are the host's responsibility.</p>
""" .
atom:URID
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;
}