summaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-03 22:34:04 -0600
committersanine <sanine.not@pm.me>2023-02-03 22:34:04 -0600
commitea512c3b1d2d85ff76aa7d4979c73dd7f1217757 (patch)
treec5bd7d5151a86ae4a54a3241fe745c0e2dd64d58 /src/geometry
parent0710a40e50d12cd731b0372d79d0ccdfbaee10d4 (diff)
begin refactor with bison xml parser
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/geometry.c36
-rw-r--r--src/geometry/geometry.h3
-rw-r--r--src/geometry/geometry.test.c30
3 files changed, 0 insertions, 69 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c
index 7046f1e..ba1ca58 100644
--- a/src/geometry/geometry.c
+++ b/src/geometry/geometry.c
@@ -1,41 +1,5 @@
#include <string.h>
#include <kalmia.h>
-#include <ezxml.h>
#include "util/util.h"
#include "geometry.h"
-
-
-int kai_parse_float_array(struct ka_float_array_t *dest, ezxml_t src)
-{
- /* get count */
- const char *count = ezxml_attr(src, "count");
- if (count == NULL) {
- fprintf(stderr, "[kalmia] ERROR: required \"count\" parameter not present for float_array\n");
- return -1;
- }
- char *end;
- dest->count = strtol(count, &end, 10);
-
- /* get id, if present */
- const char *id = ezxml_attr(src, "id");
- if (id != NULL) {
- size_t id_len = strlen(id) + 1;
- dest->id = kai_alloc(sizeof(char) * id_len, "float_array id");
- if (dest->id == NULL) {
- return -1;
- }
- strncpy(dest->id, id, id_len);
- }
- else {
- dest->id = NULL;
- }
-
- /* parse floats */
- dest->data = kai_alloc(sizeof(ka_real_t) * dest->count, "float_array data");
- if (dest->data == NULL) {
- free(dest->id);
- return -1;
- }
- kai_text_to_reals(dest->data, ezxml_txt(src), dest->count);
-}
diff --git a/src/geometry/geometry.h b/src/geometry/geometry.h
index 6268e3b..da089c1 100644
--- a/src/geometry/geometry.h
+++ b/src/geometry/geometry.h
@@ -2,8 +2,5 @@
#define KALMIA_GEOMETRY_H
#include <kalmia.h>
-#include <ezxml.h>
-
-int kai_parse_float_array(struct ka_float_array_t *dest, ezxml_t src);
#endif
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c
index bb06aeb..fe4421e 100644
--- a/src/geometry/geometry.test.c
+++ b/src/geometry/geometry.test.c
@@ -1,7 +1,6 @@
#include <string.h>
#include <kalmia.h>
-#include <ezxml.h>
#include "geometry.h"
#include "test/test.h"
@@ -9,34 +8,5 @@
LILY_FILE_BEGIN(geometry_suite)
-LILY_TEST("parse float array")
-{
- char str[1024];
- strncpy(
- str,
- "<float_array id=\"sequence\" count=\"5\">\n"
- " -0.5 -0.25 0 0.25 0.5\n"
- "</float_array>",
- 1024
- );
-
- ezxml_t tag = ezxml_parse_str(str, strlen(str)+1);
-
- struct ka_float_array_t float_array;
- kai_parse_float_array(&float_array, tag);
-
- CHECK_EQS(float_array.id, "sequence");
- REQUIRE_EQ(float_array.count, 5, "%ul");
- REQUIRE_NEQ(float_array.data, NULL, "%p");
-
- CHECK_EQ(float_array.data[0], -0.50, "%f");
- CHECK_EQ(float_array.data[1], -0.25, "%f");
- CHECK_EQ(float_array.data[2], 0.00, "%f");
- CHECK_EQ(float_array.data[3], 0.25, "%f");
- CHECK_EQ(float_array.data[4], 0.50, "%f");
-}
-#include LILY_PUSH_TEST()
-
-
#define LILY_FILE_END
#include LILY_REGISTER_TESTS()