diff --git a/http/http_request.c b/http/http_request.c
index 23d9395..88045fb 100644
--- a/http/http_request.c
+++ b/http/http_request.c
@@ -318,18 +318,18 @@ s_tag * http_request_buf_parse (s_tag *req, s_buf *buf)
" buf_read_until_str_into_file");
goto restore;
}
- upload.type = TAG_STRUCT;
- if (! struct_init(&upload.data.struct_, sym_Upload))
+ upload.type = TAG_PSTRUCT;
+ if (! pstruct_init(&upload.data.pstruct, sym_Upload))
goto restore;
- if (! struct_allocate(&upload.data.struct_))
+ if (! struct_allocate(upload.data.pstruct))
goto restore;
- if (! struct_set(&upload.data.struct_, sym_1("filename"),
+ if (! struct_set(upload.data.pstruct, sym_1("filename"),
&filename))
goto restore;
- if (! struct_set(&upload.data.struct_, sym_1("size"),
+ if (! struct_set(upload.data.pstruct, sym_1("size"),
&size))
goto restore;
- if (! struct_set(&upload.data.struct_, sym_1("tmp_path"),
+ if (! struct_set(upload.data.pstruct, sym_1("tmp_path"),
&path))
goto restore;
tmp_req.body.data.list =
@@ -389,13 +389,13 @@ s_tag * http_request_buf_parse (s_tag *req, s_buf *buf)
tmp_req.body = body;
}
}
- if (! tag_init_struct(&tmp, sym_1("HTTP.Request")))
+ if (! tag_init_pstruct(&tmp, sym_1("HTTP.Request")))
goto restore;
- if (! struct_allocate(&tmp.data.struct_)) {
+ if (! struct_allocate(tmp.data.pstruct)) {
tag_void(&tmp);
goto restore;
}
- *((s_http_request *) tmp.data.struct_.data) = tmp_req;
+ *((s_http_request *) tmp.data.pstruct->data) = tmp_req;
goto clean;
restore:
list_delete_all(multipart_headers);
diff --git a/http/http_response.c b/http/http_response.c
index b6fec9a..624e1b9 100644
--- a/http/http_response.c
+++ b/http/http_response.c
@@ -238,7 +238,7 @@ sw http_response_buf_write (const s_http_response *response,
result += r;
}
else if (type == &g_sym_Buf) {
- in = response->body.data.struct_.data;
+ in = response->body.data.pstruct->data;
while (buf_refill(in, in->size) > 0) {
err_inspect_buf(in);
if (! buf_read_to_str(in, &str))
diff --git a/libkc3/struct.c b/libkc3/struct.c
index 17d1130..83c06ab 100644
--- a/libkc3/struct.c
+++ b/libkc3/struct.c
@@ -428,6 +428,22 @@ s_struct * struct_new_type (s_struct_type *st)
return s;
}
+s_struct * struct_new_with_data (const s_sym *module, void *data,
+ bool free_data)
+{
+ s_struct *s;
+ assert(module);
+ assert(data);
+ s = alloc(sizeof(s_struct));
+ if (! s)
+ return NULL;
+ if (! struct_init_with_data(s, module, data, free_data)) {
+ free(s);
+ return NULL;
+ }
+ return s;
+}
+
uw * struct_offset (const s_struct *s, const s_sym * const *key,
uw *dest)
{
diff --git a/test/inspect_test.c b/test/inspect_test.c
index 7aac858..d414eff 100644
--- a/test/inspect_test.c
+++ b/test/inspect_test.c
@@ -20,11 +20,12 @@
#include "../libkc3/inspect.h"
#include "../libkc3/integer.h"
#include "../libkc3/list.h"
+#include "../libkc3/pstruct.h"
#include "../libkc3/ratio.h"
#include "../libkc3/str.h"
+#include "../libkc3/struct.h"
#include "../libkc3/sym.h"
#include "../libkc3/tag.h"
-#include "../libkc3/struct.h"
#include "../libkc3/tuple.h"
#include "../libkc3/var.h"
#include "test.h"
@@ -145,16 +146,16 @@
do { \
s_pretty pretty = {0}; \
s_str result; \
- s_struct struct_test = {0}; \
+ p_struct struct_test = NULL; \
assert(test); \
test_context("inspect_struct(" # test ") -> " # expected); \
- TEST_EQ(struct_init_1(&struct_test, (test)), &struct_test); \
- TEST_EQ(inspect_struct(&struct_test, &result), &result); \
+ TEST_EQ(pstruct_init_1(&struct_test, (test)), &struct_test); \
+ TEST_EQ(inspect_struct(struct_test, &result), &result); \
TEST_STRNCMP(result.ptr.p, (expected), result.size); \
- TEST_EQ(buf_inspect_struct_size(&pretty, &struct_test), \
+ TEST_EQ(buf_inspect_struct_size(&pretty, struct_test), \
strlen(expected)); \
str_clean(&result); \
- struct_clean(&struct_test); \
+ pstruct_clean(&struct_test); \
test_context(NULL); \
} while (0)
diff --git a/window/sdl2/demo/earth.c b/window/sdl2/demo/earth.c
index c50ae68..16c6086 100644
--- a/window/sdl2/demo/earth.c
+++ b/window/sdl2/demo/earth.c
@@ -50,13 +50,14 @@ bool earth_load (s_sequence *seq)
if (! tag_map(&seq->tag, 3))
return false;
map = &seq->tag.data.map;
- tag_init_sym( map->key + 0, sym_1("camera"));
- tag_init_ptr_free( map->value + 0, camera);
- tag_init_sym( map->key + 1, sym_1("camera_rot_x_speed"));
- tag_init_f64( map->value + 1, 0.01);
- tag_init_sym( map->key + 2, sym_1("sphere"));
- tag_init_struct_with_data(map->value + 2, sym_1("GL.Sphere"),
- sphere, false);
+ tag_init_sym( map->key + 0, sym_1("camera"));
+ tag_init_ptr_free( map->value + 0, camera);
+ tag_init_sym( map->key + 1,
+ sym_1("camera_rot_x_speed"));
+ tag_init_f64( map->value + 1, 0.01);
+ tag_init_sym( map->key + 2, sym_1("sphere"));
+ tag_init_pstruct_with_data(map->value + 2, sym_1("GL.Sphere"),
+ sphere, false);
return true;
}
@@ -78,13 +79,13 @@ bool earth_render (s_sequence *seq)
map = &seq->tag.data.map;
if (map->value[0].type != TAG_PTR_FREE ||
map->value[1].type != TAG_F64 ||
- map->value[2].type != TAG_STRUCT) {
+ map->value[2].type != TAG_PSTRUCT) {
err_puts("earth_render: invalid map");
return false;
}
camera = map->value[0].data.ptr_free.p;
camera_rot_x_speed = &map->value[1].data.f64;
- sphere = map->value[2].data.struct_.data;
+ sphere = map->value[2].data.pstruct->data;
gl_camera_set_aspect_ratio(camera, window->w, window->h);
camera->rotation.x += seq->dt * (*camera_rot_x_speed) *
M_PI * 2.0f;
diff --git a/window/sdl2/kubz b/window/sdl2/kubz
index 36df94a..c2731bc 160000
--- a/window/sdl2/kubz
+++ b/window/sdl2/kubz
@@ -1 +1 @@
-Subproject commit 36df94af87af73435edd441ded193b5862c6ca53
+Subproject commit c2731bcdc39f7798a2f2daca041e1d82c0fc8ac2