diff options
author | sanine <sanine.not@pm.me> | 2023-02-04 11:35:47 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-02-04 11:35:47 -0600 |
commit | 059a70686c49d591fd7a193493745a7bc172cbca (patch) | |
tree | 543634d6406c8204b74399175bed43b3a5eb55ff /src/geometry/geometry.c | |
parent | 0bb180e4ddeebf6d219a38b862ce3e8238f99c54 (diff) |
implement kai_read_param() and upgrade lily-test version
Diffstat (limited to 'src/geometry/geometry.c')
-rw-r--r-- | src/geometry/geometry.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index ad23853..6f6cbae 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -6,12 +6,16 @@ #include "geometry.h" +/* macro to ensure tag type matches what we expect */ +#define CHECK_TAG_TYPE(expected) \ +if (strcmp(src->type, expected) != 0) { \ + return -1; \ +} + + int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) { - if (strcmp(src->type, "float_array") != 0) { - /* incorrect tag type */ - return -1; - } + CHECK_TAG_TYPE("float_array"); long count = kai_tag_attr_to_long(src, "count", -1); if (count == -1) { @@ -30,3 +34,21 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) return 0; } + + +int kai_read_param(struct ka_param_t *dest, struct kai_tag_t *src) +{ + CHECK_TAG_TYPE("param"); + + char *type = kai_tag_attr_to_dup(src, "type"); + if (type == NULL) { + return -1; + } + + dest->name = kai_tag_attr_to_dup(src, "name"); + dest->sid = kai_tag_attr_to_dup(src, "sid"); + dest->type = type; + dest->semantic = kai_tag_attr_to_dup(src, "semantic"); + + return 0; +} |