From 1ba558a9c92cd61f05a695dcd2e6f75215c0c584 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 5 Feb 2023 13:18:12 -0600 Subject: begin implementing kai_read_source() --- include/kalmia.h | 8 ++++++++ src/geometry/geometry.c | 11 +++++++++++ src/geometry/geometry.h | 1 + src/geometry/geometry.test.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/include/kalmia.h b/include/kalmia.h index 06a555b..a9ae7a8 100644 --- a/include/kalmia.h +++ b/include/kalmia.h @@ -91,5 +91,13 @@ struct ka_accessor_t { struct ka_param_t *param; }; +struct ka_source_t { + char *id; /* required */ + char *name; + + struct ka_float_array_t float_array; + struct ka_accessor_t accessor; +}; + #endif diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index c3eb40c..42e7970 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -98,3 +98,14 @@ int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src) return 0; } + + +int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src) +{ + CHECK_TAG_TYPE("source"); + + char *id = kai_tag_attr_to_dup(src, "id"); + if (id == NULL) { return -1; } + + return 0; +} diff --git a/src/geometry/geometry.h b/src/geometry/geometry.h index daa883d..a0c122c 100644 --- a/src/geometry/geometry.h +++ b/src/geometry/geometry.h @@ -7,5 +7,6 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src); int kai_read_param(struct ka_param_t *dest, struct kai_tag_t *src); int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src); +int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src); #endif diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index 2c172f2..fd1f379 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -178,5 +178,50 @@ LILY_TEST("parse accessor") #include LILY_PUSH_TEST() +LILY_TEST("fail to read non-source tag") +{ + struct kai_tag_t *t = kai_parse_string( + "" + ); + + struct ka_source_t source; + int result = kai_read_source(&source, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("fail to read source tag with no specified id") +{ + struct kai_tag_t *t = kai_parse_string( + "" + ); + + struct ka_source_t source; + int result = kai_read_source(&source, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("read source correctly") +{ + struct kai_tag_t *t = kai_parse_string( + "" + " 0.0" + " " + " " + " " + " " + " " + "" + ); +} + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() -- cgit v1.2.1