summaryrefslogtreecommitdiff
path: root/src/geometry/geometry.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-05 22:37:09 -0600
committersanine <sanine.not@pm.me>2023-02-05 22:37:09 -0600
commit287dcb62f19d0cf55c8f179bf4b36a7a66c7737a (patch)
tree7457b5536093f3dccb5fedf6ed35163ffa5a8cdc /src/geometry/geometry.c
parent24d7f717b76a3c6fba44e32c2816f2ce612a2f2c (diff)
implement kai_read_input_*()
Diffstat (limited to 'src/geometry/geometry.c')
-rw-r--r--src/geometry/geometry.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c
index 2405ae9..0bc8602 100644
--- a/src/geometry/geometry.c
+++ b/src/geometry/geometry.c
@@ -156,3 +156,52 @@ void kai_release_source(struct ka_source_t s)
kai_release_float_array(s.float_array);
kai_release_accessor(s.accessor);
}
+
+
+int kai_read_input_unshared(struct ka_input_t *dest, struct kai_tag_t *src)
+{
+ CHECK_TAG_TYPE("input");
+
+ char *semantic = kai_tag_attr_to_dup(src, "semantic");
+ if (semantic == NULL) { return -1; }
+ char *source = kai_tag_attr_to_dup(src, "source");
+ if (source == NULL) { free(semantic); return -1; }
+
+ dest->shared = false;
+ dest->offset = 0;
+ dest->semantic = semantic;
+ dest->source = source;
+ dest->set = 0;
+
+ return 0;
+}
+
+int kai_read_input_shared(struct ka_input_t *dest, struct kai_tag_t *src)
+{
+ int result = kai_read_input_unshared(dest, src);
+ if (result != 0) { return result; }
+
+ long offset = kai_tag_attr_to_long(src, "offset", -1);
+ if (offset == -1) { return -1; }
+
+ dest->shared = true;
+ dest->offset = offset;
+
+ long set = kai_tag_attr_to_long(src, "set", -1);
+ if (set != -1) {
+ dest->use_set = true;
+ dest->set = set;
+ }
+ else {
+ dest->use_set = false;
+ }
+
+ return 0;
+}
+
+void kai_release_input(struct ka_input_t i)
+{
+ free(i.semantic);
+ free(i.source);
+}
+