diff --git a/event/event.c b/event/event.c
index 0575bee..5367c67 100644
--- a/event/event.c
+++ b/event/event.c
@@ -91,8 +91,8 @@ struct event_base * kc3_event_base_new (void)
}
struct event * kc3_event_new (struct event_base **event_base, s32 fd,
- const s_list * const *events,
- const s_callable *callback, s_tag *arg)
+ const s_list * const *events,
+ p_callable *callback, s_tag *arg)
{
const s_list *e;
struct event *ev;
@@ -127,7 +127,7 @@ struct event * kc3_event_new (struct event_base **event_base, s32 fd,
return ev;
invalid_event_list:
err_write_1("kc3_event_new: invalid event list: ");
- err_inspect_list(events);
+ err_inspect_list(*events);
assert(! "kc3_event_new: invalid event list");
return NULL;
}
diff --git a/event/event.h b/event/event.h
index df5258b..2dfb230 100644
--- a/event/event.h
+++ b/event/event.h
@@ -21,7 +21,7 @@ void kc3_event_delete (struct event *ev);
struct event * kc3_event_new (struct event_base **event_base,
s32 fd,
const s_list * const *events,
- const s_callable *callback,
+ p_callable *callback,
s_tag *arg);
/* Operators. */
diff --git a/http/http_request.c b/http/http_request.c
index 51c0255..f617f47 100644
--- a/http/http_request.c
+++ b/http/http_request.c
@@ -118,7 +118,7 @@ s_tag * http_request_buf_parse (s_tag *req, s_buf *buf)
err_inspect_tag(&body);
err_write_1("\n");
}
- if (alist_get((const s_list * const *) &body.data.list,
+ if (alist_get(body.data.list,
&method_key, &method_value)) {
http_request_method_from_str(&method_value.data.str,
&tmp_req.method);
@@ -205,7 +205,7 @@ sw http_request_buf_write (s_http_request *req, s_buf *buf)
err_puts("http_request_buf_write: invalid protocol: \"\"");
return -1;
}
- if (! list_is_alist((const s_list * const *) &req->headers)) {
+ if (! list_is_alist(req->headers)) {
err_puts("http_request_buf_write: invalid headers: not an AList");
return -1;
}
diff --git a/http/http_response.c b/http/http_response.c
index 010f7a4..78190b6 100644
--- a/http/http_response.c
+++ b/http/http_response.c
@@ -153,7 +153,7 @@ sw http_response_buf_write (const s_http_response *response,
tag_clean(&default_messages);
return -1;
}
- if (alist_get((const s_list * const *) &default_messages.data.list,
+ if (alist_get(default_messages.data.list,
&tag_code, &tag_message)) {
if (tag_message.type != TAG_STR) {
err_puts("http_response_buf_write: invalid default message:"
@@ -383,7 +383,7 @@ s_tag * http_response_find_header (const s_http_response *res,
}
s_http_response * http_response_init_copy (s_http_response *res,
- const s_http_response *src)
+ s_http_response *src)
{
s_http_response tmp = {0};
if (! str_init_copy(&tmp.protocol, &src->protocol))
@@ -391,8 +391,7 @@ s_http_response * http_response_init_copy (s_http_response *res,
tmp.code = src->code;
if (! str_init_copy(&tmp.message, &src->message))
goto clean;
- if (! list_init_copy(&tmp.headers,
- (const s_list * const *) &src->headers))
+ if (! list_init_copy(&tmp.headers, &src->headers))
goto clean;
if (! tag_init_copy(&tmp.body, &src->body))
goto clean;
@@ -403,7 +402,7 @@ s_http_response * http_response_init_copy (s_http_response *res,
return NULL;
}
-s_http_response * http_response_set_header (const s_http_response *res,
+s_http_response * http_response_set_header (s_http_response *res,
const s_str *key,
const s_str *value,
s_http_response *dest)
diff --git a/http/http_response.h b/http/http_response.h
index b28aff9..899e526 100644
--- a/http/http_response.h
+++ b/http/http_response.h
@@ -19,14 +19,16 @@
after use. */
void http_response_clean (s_http_response *res);
s_http_response * http_response_init_copy (s_http_response *res,
- const s_http_response *src);
+ s_http_response *src);
/* Observers. */
sw http_response_buf_write (const s_http_response *res,
s_buf *buf, bool send_body);
s_tag * http_response_find_header (const s_http_response *res,
const s_str *key);
-s_http_response * http_response_set_header (const s_http_response *res,
+
+/* Operators. */
+s_http_response * http_response_set_header (s_http_response *res,
const s_str *key,
const s_str *value,
s_http_response *dest);
diff --git a/http/mime_type.c b/http/mime_type.c
index 1749c67..b3ed039 100644
--- a/http/mime_type.c
+++ b/http/mime_type.c
@@ -17,7 +17,7 @@ const s_sym ** http_mime_type (const s_str *ext, const s_sym **dest)
{
s_facts_cursor cursor;
const s_sym *default_mime_type;
- const s_fact *fact = NULL;
+ s_fact *fact = NULL;
s_tag tag_ext = {0};
s_tag tag_mime_type_sym;
s_tag tag_mime_type_value;
@@ -122,8 +122,7 @@ bool http_mime_type_buf_parse_type (s_buf *buf)
return false;
}
-bool http_mime_type_def (const s_tag *ext,
- const s_sym * const *mime_type)
+bool http_mime_type_def (s_tag *ext, const s_sym * const *mime_type)
{
s_tag tag_mime_type_sym;
s_tag tag_mime_type_value;
diff --git a/http/mime_type.h b/http/mime_type.h
index 5660bcf..a503602 100644
--- a/http/mime_type.h
+++ b/http/mime_type.h
@@ -18,7 +18,7 @@
const s_sym ** http_mime_type (const s_str *ext, const s_sym **dest);
bool http_mime_type_buf_parse (s_buf *buf);
bool http_mime_type_buf_parse_type (s_buf *buf);
-bool http_mime_type_def (const s_tag *ext,
+bool http_mime_type_def (s_tag *ext,
const s_sym * const *mime_type);
bool http_mime_type_load (s_str *path);
diff --git a/libkc3/array.h b/libkc3/array.h
index 247712c..1da980e 100644
--- a/libkc3/array.h
+++ b/libkc3/array.h
@@ -35,8 +35,7 @@ s_tag * array_data_tag (const s_array *a,
/* Operators */
s_tag * array_access (s_array *a, s_list *key, s_tag *dest);
s_array * array_allocate (s_array *a);
-s_array * array_data_set (s_array *a, const uw *address,
- void *data);
+s_array * array_data_set (s_array *a, const uw *address, void *data);
s_array * array_free (s_array *a);
#endif /* LIBKC3_ARRAY_H */
diff --git a/libkc3/list_init.h b/libkc3/list_init.h
index 0ff3989..32b2fe1 100644
--- a/libkc3/list_init.h
+++ b/libkc3/list_init.h
@@ -23,6 +23,9 @@ s_list * list_init_array_copy (s_list *list, const s_array *a,
s_list *next);
s_list * list_init_bool (s_list *list, bool b, s_list *next);
s_list * list_init_call (s_list *list, s_list *next);
+s_list * list_init_callable (s_list *list, s_list *next);
+s_list * list_init_callable_copy (s_list *list, p_callable *src,
+ s_list *next);
s_list * list_init_character (s_list *list, character c, s_list *next);
s_list * list_init_complex (s_list *list, s_complex *c, s_list *next);
@@ -110,6 +113,8 @@ s_list * list_new_array (const s_sym *type, uw dimension,
s_list * list_new_array_copy (const s_array *a, s_list *next);
s_list * list_new_bool (bool b, s_list *next);
s_list * list_new_call (s_list *next);
+s_list * list_new_callable (s_list *next);
+s_list * list_new_callable_copy (p_callable *src, s_list *next);
s_list * list_new_character (character c, s_list *next);
s_list * list_new_complex (s_complex *c, s_list *next);
diff --git a/libkc3/tag.c b/libkc3/tag.c
index 7c66090..1477db8 100644
--- a/libkc3/tag.c
+++ b/libkc3/tag.c
@@ -375,6 +375,28 @@ s_tag * tag_init_call_cast (s_tag *tag, const s_sym *type)
return tag;
}
+s_tag * tag_init_callable (s_tag *tag)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_CALL;
+ if (! p_callable_init(&tmp.data.callable))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_init_callable_copy (s_tag *tag, p_callable *src)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_CALL;
+ if (! p_callable_init_copy(&tmp.data.callable, src))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_init_cast (s_tag *tag, const s_sym * const *type,
s_tag *src)
{
diff --git a/libkc3/tag_init.h b/libkc3/tag_init.h
index 5e6b9ec..bbcdb7d 100644
--- a/libkc3/tag_init.h
+++ b/libkc3/tag_init.h
@@ -21,6 +21,8 @@ s_tag * tag_init_array (s_tag *tag, const s_sym *type, uw dimension,
s_tag * tag_init_array_copy (s_tag *tag, const s_array *a);
s_tag * tag_init_bool (s_tag *tag, bool b);
s_tag * tag_init_call (s_tag *tag);
+s_tag * tag_init_callable (s_tag *tag);
+s_tag * tag_init_callable_copy (s_tag *tag, p_callable *src);
s_tag * tag_init_character (s_tag *tag, character c);
s_tag * tag_init_copy (s_tag *tag, s_tag *src);
s_tag * tag_init_complex (s_tag *tag, s_complex *c);
@@ -92,6 +94,8 @@ s_tag * tag_new_array (const s_sym *type, uw dimension,
s_tag * tag_new_array_copy (const s_array *a);
s_tag * tag_new_bool (bool b);
s_tag * tag_new_call (void);
+s_tag * tag_new_callable (void);
+s_tag * tag_new_callable_copy (p_callable *src);
s_tag * tag_new_character (character c);
s_tag * tag_new_copy (s_tag *src);
s_tag * tag_new_complex (s_complex *c);
@@ -156,6 +160,8 @@ s_tag * tag_array (s_tag *tag, const s_sym *type, uw dimension,
s_tag * tag_array_copy (s_tag *tag, const s_array *a);
s_tag * tag_bool (s_tag *tag, bool b);
s_tag * tag_call (s_tag *tag);
+s_tag * tag_callable (s_tag *tag);
+s_tag * tag_callable_copy (s_tag *tag, p_callable *src);
s_tag * tag_character (s_tag *tag, character c);
s_tag * tag_copy (s_tag *tag, s_tag *src);
s_tag * tag_complex (s_tag *tag, s_complex *c);
diff --git a/libkc3/tag_init.rb b/libkc3/tag_init.rb
index 20ed991..2811da2 100644
--- a/libkc3/tag_init.rb
+++ b/libkc3/tag_init.rb
@@ -301,9 +301,9 @@ class TagInitList
TagInit.new("bool", "TAG_BOOL", :init_mode_direct,
[Arg.new("bool", "b")]),
TagInit.new("call", "TAG_CALL", :init_mode_init, []),
- TagInit.new("callable", "TAG_CALLABLE", :init_mode_init, []),
- TagInit.new("callable", "copy", "TAG_CALLABLE", :init_mode_init,
- []),
+ TagInitProto.new("callable", "TAG_CALLABLE", :init_mode_init, []),
+ TagInitProto.new("callable", "copy", "TAG_CALLABLE", :init_mode_init,
+ [Arg.new("p_callable *", "src")]),
TagInit.new("character", "TAG_CHARACTER", :init_mode_direct,
[Arg.new("character", "c")]),
TagInitProto.new("copy", nil, :init_mode_none,
diff --git a/test/facts_cursor_test.c b/test/facts_cursor_test.c
index 593deb9..6c133f6 100644
--- a/test/facts_cursor_test.c
+++ b/test/facts_cursor_test.c
@@ -112,7 +112,7 @@ TEST_CASE_END(facts_cursor_init)
TEST_CASE(facts_cursor_next)
{
s_facts_cursor cursor;
- const s_fact *cursor_fact;
+ s_fact *cursor_fact;
uw i = 0;
char *p[24] = {
"-0x10000000000000000",
diff --git a/test/facts_test.c b/test/facts_test.c
index 8d36fe6..fa26e1c 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -77,7 +77,7 @@ TEST_CASE(facts_add)
"-0x10000000000000000",
NULL
};
- const s_fact *pf;
+ s_fact *pf;
s_fact fact[24];
s_facts facts;
facts_init(&facts);
@@ -156,7 +156,7 @@ TEST_CASE_END(facts_dump_file)
TEST_CASE(facts_find)
{
bool b;
- const s_fact *f;
+ s_fact *f;
uw i = 0;
char *p[24] = {
"\"a\"",
@@ -186,7 +186,7 @@ TEST_CASE(facts_find)
};
s_fact fact[24];
s_facts facts;
- const s_fact *pf;
+ s_fact *pf;
facts_init(&facts);
while (p[i]) {
fact_test_init_1(fact + i, p[i]);
@@ -232,7 +232,7 @@ TEST_CASE_END(facts_init_clean)
TEST_CASE(facts_load)
{
- const s_fact *f;
+ s_fact *f;
uw i = 0;
char *p[24] = {
"\"a\"",
@@ -402,7 +402,7 @@ TEST_CASE_END(facts_new_delete)
TEST_CASE(facts_open_file)
{
bool b;
- const s_fact *f;
+ s_fact *f;
uw i = 0;
char *p[24] = {
"\"a\"",
diff --git a/test/facts_with_test.c b/test/facts_with_test.c
index 3ff11cd..6c9e9a3 100644
--- a/test/facts_with_test.c
+++ b/test/facts_with_test.c
@@ -31,7 +31,7 @@ void facts_with_test (void)
TEST_CASE(facts_with_)
{
s_facts_with_cursor cursor;
- const s_fact *f;
+ s_fact *f;
s_fact fact;
s_facts facts;
sw i = 0;
@@ -232,7 +232,7 @@ TEST_CASE_END(facts_with_)
TEST_CASE(facts_with_tags)
{
s_facts_cursor cursor;
- const s_fact *f;
+ s_fact *f;
s_fact fact;
s_facts facts;
sw i = 0;
diff --git a/window/cairo/demo/flies.c b/window/cairo/demo/flies.c
index 2fa8471..b5f03a1 100644
--- a/window/cairo/demo/flies.c
+++ b/window/cairo/demo/flies.c
@@ -46,7 +46,7 @@ static void fly_init (s_map *map)
board = &map->value[0].data.array;
in = &map->value[1].data.uw;
t = &map->value[3].data.f64;
- array_data_set(board, address, &g_board_item_fly);
+ array_data_set(board, address, (void *) &g_board_item_fly);
*t = 0.0;
(*in)++;
}
@@ -77,7 +77,7 @@ bool flies_load (s_sequence *seq)
j = 0;
while (j < BOARD_SIZE) {
address[1] = j;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
j++;
}
i++;
@@ -86,40 +86,40 @@ bool flies_load (s_sequence *seq)
while (i < BOARD_SIZE) {
address[0] = i;
address[1] = 0;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[1] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[0] = 0;
address[1] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[0] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
address[0] = BOARD_SIZE / 2;
address[1] = 0;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
address[1] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
address[1] = BOARD_SIZE / 2;
i = 1;
while (i <= BOARD_SIZE / 2) {
address[0] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
address[0] = BOARD_SIZE / 2;
j = BOARD_SIZE / 4;
while (j < BOARD_SIZE / 2) {
address[1] = j;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
j++;
}
address[1] = BOARD_SIZE * 3 / 4;
i = BOARD_SIZE / 4;
while (i < BOARD_SIZE - 1) {
address[0] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
fly_init(map);
@@ -230,7 +230,7 @@ bool flies_render (s_sequence *seq)
cr, 0, 0);
if (address[0] == BOARD_SIZE / 2 &&
address[1] == BOARD_SIZE - 1) {
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
(*fly_out)++;
fly_init(map);
break;
@@ -277,8 +277,9 @@ bool flies_render (s_sequence *seq)
fly_address)) &&
*board_item == g_board_item_space) {
array_data_set(board, fly_prev_address,
- &g_board_item_space);
- array_data_set(board, fly_address, &g_board_item_fly);
+ (void *) &g_board_item_space);
+ array_data_set(board, fly_address,
+ (void *) &g_board_item_fly);
direction_prev = direction;
break;
}
@@ -290,7 +291,8 @@ bool flies_render (s_sequence *seq)
}
*fly_time += 1;
if (*fly_time > FLY_TIME_MAX) {
- array_data_set(board, fly_address, &g_board_item_dead_fly);
+ array_data_set(board, fly_address,
+ (void *) &g_board_item_dead_fly);
fly_init(map);
}
break;
diff --git a/window/sdl2/demo/flies.c b/window/sdl2/demo/flies.c
index bfb3751..28a24c0 100644
--- a/window/sdl2/demo/flies.c
+++ b/window/sdl2/demo/flies.c
@@ -51,7 +51,7 @@ static void fly_init (s_map *map)
board = &map->value[0].data.array;
in = &map->value[1].data.uw;
t = &map->value[3].data.f64;
- array_data_set(board, address, &g_board_item_fly);
+ array_data_set(board, address, (void *) &g_board_item_fly);
*t = 0.0;
(*in)++;
}
@@ -82,7 +82,7 @@ bool flies_load (s_sequence *seq)
j = 0;
while (j < BOARD_SIZE) {
address[1] = j;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
j++;
}
i++;
@@ -91,40 +91,40 @@ bool flies_load (s_sequence *seq)
while (i < BOARD_SIZE) {
address[0] = i;
address[1] = 0;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[1] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[0] = 0;
address[1] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
address[0] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
address[0] = BOARD_SIZE / 2;
address[1] = 0;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
address[1] = BOARD_SIZE - 1;
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address, (void *) &g_board_item_space);
address[1] = BOARD_SIZE / 2;
i = 1;
while (i <= BOARD_SIZE / 2) {
address[0] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
address[0] = BOARD_SIZE / 2;
j = BOARD_SIZE / 4;
while (j < BOARD_SIZE / 2) {
address[1] = j;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
j++;
}
address[1] = BOARD_SIZE * 3 / 4;
i = BOARD_SIZE / 4;
while (i < BOARD_SIZE - 1) {
address[0] = i;
- array_data_set(board, address, &g_board_item_block);
+ array_data_set(board, address, (void *) &g_board_item_block);
i++;
}
fly_init(map);
@@ -241,7 +241,8 @@ bool flies_render (s_sequence *seq)
case BOARD_ITEM_BLOCK:
gl_ortho_bind_texture(&g_ortho, 0);
gl_ortho_color(&g_ortho, 0.0f, 0.0f, 1.0f, 1.0f);
- gl_ortho_rect(&g_ortho, 0, 0, board_item_w + 1.0, board_item_h + 1.0);
+ gl_ortho_rect(&g_ortho, 0, 0, board_item_w + 1.0,
+ board_item_h + 1.0);
gl_ortho_color(&g_ortho, 1.0f, 1.0f, 1.0f, 1.0f);
break;
case BOARD_ITEM_FLY:
@@ -253,7 +254,8 @@ bool flies_render (s_sequence *seq)
fly_scale, 1.0);
gl_ortho_update_model_matrix(&g_ortho);
gl_ortho_bind_texture(&g_ortho,
- gl_sprite_texture(&g_sprite_fly, 0));
+ gl_sprite_texture(&g_sprite_fly,
+ 0));
gl_ortho_color(&g_ortho, 1.0f, 1.0f, 1.0f, 1.0f);
gl_ortho_rect(&g_ortho, 0, 0, g_sprite_fly.pt_w,
g_sprite_fly.pt_h);
@@ -261,7 +263,8 @@ bool flies_render (s_sequence *seq)
} g_ortho.model_matrix = matrix_2;
if (address[0] == BOARD_SIZE / 2 &&
address[1] == BOARD_SIZE - 1) {
- array_data_set(board, address, &g_board_item_space);
+ array_data_set(board, address,
+ (void *) &g_board_item_space);
(*fly_out)++;
fly_init(map);
break;
@@ -308,8 +311,9 @@ bool flies_render (s_sequence *seq)
fly_address)) &&
*board_item == g_board_item_space) {
array_data_set(board, fly_prev_address,
- &g_board_item_space);
- array_data_set(board, fly_address, &g_board_item_fly);
+ (void *) &g_board_item_space);
+ array_data_set(board, fly_address,
+ (void *) &g_board_item_fly);
direction_prev = direction;
break;
}
@@ -321,7 +325,8 @@ bool flies_render (s_sequence *seq)
}
*fly_time += 1;
if (*fly_time > FLY_TIME_MAX) {
- array_data_set(board, fly_address, &g_board_item_dead_fly);
+ array_data_set(board, fly_address,
+ (void *) &g_board_item_dead_fly);
fly_init(map);
}
break;