diff --git a/config.subr b/config.subr
index 79d3bf4..60d1db9 100644
--- a/config.subr
+++ b/config.subr
@@ -71,7 +71,7 @@ config_have_stat_mtim() {
echo " struct stat tmp;" >> "$OUT_C"
echo " tmp.st_mtim.tv_sec = 0;" >> "$OUT_C"
echo " tmp.st_mtim.tv_nsec = 0;" >> "$OUT_C"
- echo " return 0;" >> "$OUT_C"
+ echo " return tmp.st_mtim.tv_sec + tmp.st_mtim.tv_nsec;" >> "$OUT_C"
echo "}" >> "$OUT_C"
if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" -o "$OUT"; then
echo "#define HAVE_STAT_MTIM 1" >> "${CONFIG_H}"
diff --git a/lib/c3/0.1/gl/sphere.facts b/lib/c3/0.1/gl/sphere.facts
new file mode 100644
index 0000000..714fc2b
--- /dev/null
+++ b/lib/c3/0.1/gl/sphere.facts
@@ -0,0 +1,6 @@
+%{module: C3.Facts.Dump,
+ version: 1}
+replace {GL.Sphere, :is_a, :module}
+replace {GL.Sphere, :defstruct, [segments_u: (Uw) 3,
+ segments_v: (Uw) 2,
+ vertex: (PtrFree) 0 ]}
diff --git a/lib/c3/0.1/list.facts b/lib/c3/0.1/list.facts
index ea05f14..75d8a22 100644
--- a/lib/c3/0.1/list.facts
+++ b/lib/c3/0.1/list.facts
@@ -4,7 +4,7 @@ add {List, :is_a, :module}
add {List, :symbol, List.cast}
add {List, :symbol, List.map}
add {List, :symbol, List.reverse}
-replace {List.cast, :cfn, cfn :list "list_cast" (:tag, :&result)}
+replace {List.cast, :cfn, cfn List "list_cast" (Tag, Result)}
replace {List.map, :fn, fn {
([], _) {
[]
diff --git a/libc3/array.c b/libc3/array.c
index 84d5f28..58a2321 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -151,6 +151,8 @@ s_array * array_init (s_array *a, const s_sym *type, uw dimension,
uw i = 0;
uw item_size;
assert(a);
+ assert(type);
+ assert(sym_is_module(type));
assert(dimension);
assert(dimensions);
if (! dimension) {
diff --git a/libc3/buf.c b/libc3/buf.c
index a887c13..0e8c041 100644
--- a/libc3/buf.c
+++ b/libc3/buf.c
@@ -280,6 +280,30 @@ sw buf_peek_1 (s_buf *buf, const s8 *p)
return buf_peek_str(buf, &stra);
}
+sw buf_peek_next_character_utf8 (s_buf *buf, character *c)
+{
+ sw r;
+ sw result = 0;
+ s_buf_save save;
+ character tmp;
+ assert(buf);
+ assert(c);
+ buf_save_init(buf, &save);
+ if ((r = buf_read_character_utf8(buf, &tmp)) <= 0)
+ goto clean;
+ result += r;
+ if ((r = buf_peek_character_utf8(buf, &tmp)) <= 0)
+ goto restore;
+ result += r;
+ *c = tmp;
+ r = result;
+ restore:
+ buf_save_restore_rpos(buf, &save);
+ clean:
+ buf_save_clean(buf, &save);
+ return r;
+}
+
sw buf_peek_character_utf8 (s_buf *buf, character *c)
{
assert(buf);
diff --git a/libc3/buf.h b/libc3/buf.h
index a284aa3..eb5e8e3 100644
--- a/libc3/buf.h
+++ b/libc3/buf.h
@@ -52,6 +52,7 @@ sw buf_peek_1 (s_buf *buf, const s8 *p);
sw buf_peek_character_utf8 (s_buf *buf, character *p);
sw buf_peek_f32 (s_buf *buf, f32 *p);
sw buf_peek_f64 (s_buf *buf, f64 *p);
+sw buf_peek_next_character_utf8 (s_buf *buf, character *p);
sw buf_peek_s8 (s_buf *buf, s8 *p);
sw buf_peek_s16 (s_buf *buf, s16 *p);
sw buf_peek_s32 (s_buf *buf, s32 *p);
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 688f060..4395d65 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1288,8 +1288,13 @@ sw buf_inspect_map (s_buf *buf, const s_map *map)
while (i < map->count) {
k = map->key + i;
if (k->type == TAG_SYM) {
- if ((r = buf_write_1(buf, k->data.sym->str.ptr.ps8)) < 0)
- return r;
+ if (sym_has_reserved_characters(k->data.sym)) {
+ if ((r = buf_write_str(buf, &k->data.sym->str)) < 0)
+ return r;
+ }
+ else
+ if ((r = buf_write_1(buf, k->data.sym->str.ptr.ps8)) < 0)
+ return r;
result += r;
if ((r = buf_write_1(buf, ": ")) < 0)
return r;
@@ -1350,36 +1355,49 @@ sw buf_inspect_ptag_size (const p_tag *ptag)
return result;
}
-sw buf_inspect_ptr (s_buf *buf, const s_ptr *ptr)
+sw buf_inspect_ptr (s_buf *buf, const u_ptr_w *ptr)
{
sw r;
sw result = 0;
assert(buf);
- if ((r = buf_write_1(buf, "(")) < 0)
+ if ((r = buf_write_1(buf, "(Ptr) ")) < 0)
return r;
result += r;
- if ((r = buf_inspect_sym(buf, ptr->type)) < 0)
+ if ((r = buf_inspect_uw_hexadecimal(buf, (uw *) &ptr->p)) < 0)
return r;
result += r;
- if ((r = buf_write_1(buf, " *) ")) < 0)
+ return result;
+}
+
+sw buf_inspect_ptr_free (s_buf *buf, const u_ptr_w *ptr_free)
+{
+ sw r;
+ sw result = 0;
+ assert(buf);
+ if ((r = buf_write_1(buf, "(PtrFree) ")) < 0)
return r;
result += r;
- if ((r = buf_inspect_uw_hexadecimal(buf, (uw *) ptr->p)) < 0)
+ r = buf_inspect_uw_hexadecimal(buf, (uw *) &ptr_free->p);
+ if (r < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_ptr_size (const s_ptr *ptr)
+sw buf_inspect_ptr_free_size (const u_ptr_w *ptr)
{
- sw r;
- sw result = 0;
+ sw result;
(void) ptr;
- result += strlen("(");
- if ((r = buf_inspect_sym_size(ptr->type)) < 0)
- return r;
- result += r;
- result += strlen(" *) ");
+ result = strlen("(PtrFree) ");
+ result += sizeof(uw) / 4;
+ return result;
+}
+
+sw buf_inspect_ptr_size (const u_ptr_w *ptr)
+{
+ sw result;
+ (void) ptr;
+ result = strlen("(Ptr) ");
result += sizeof(uw) / 4;
return result;
}
@@ -1661,6 +1679,71 @@ sw buf_inspect_str_size (const s_str *str)
return size;
}
+sw buf_inspect_struct (s_buf *buf, const s_struct *s)
+{
+ f_buf_inspect buf_inspect;
+ uw i = 0;
+ s_tag *k;
+ sw r;
+ sw result = 0;
+ assert(buf);
+ assert(s);
+ assert(sym_is_module(s->type.module));
+ if ((r = buf_write_1(buf, "%")) < 0)
+ return r;
+ result += r;
+ if (! sym_is_module(s->type.module))
+ return -1;
+ if (sym_has_reserved_characters(s->type.module)) {
+ if ((r = buf_write_str(buf, &s->type.module->str)) < 0)
+ return r;
+ }
+ else
+ if ((r = buf_write_1(buf, s->type.module->str.ptr.ps8)) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1(buf, "{")) < 0)
+ return r;
+ result += r;
+ while (i < s->type.map.count) {
+ k = s->type.map.key + i;
+ assert(k->type == TAG_SYM);
+ if (sym_has_reserved_characters(k->data.sym)) {
+ if ((r = buf_write_str(buf, &k->data.sym->str)) < 0)
+ return r;
+ }
+ else
+ if ((r = buf_write_1(buf, k->data.sym->str.ptr.ps8)) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1(buf, ": ")) < 0)
+ return r;
+ result += r;
+ buf_inspect = tag_type_to_buf_inspect(s->type.map.value[i].type);
+ if ((r = buf_inspect(buf, (s8 *) s->data + s->type.offset[i])) < 0)
+ return r;
+ result += r;
+ i++;
+ if (i < s->type.map.count) {
+ if ((r = buf_write_1(buf, ", ")) < 0)
+ return r;
+ result += r;
+ }
+ }
+ if ((r = buf_write_1(buf, "}")) < 0)
+ return r;
+ result += r;
+ return result;
+}
+
+sw buf_inspect_struct_size (const s_struct *s)
+{
+ assert(s);
+ assert(! "buf_inspect_struct_size: not implemented");
+ (void) s;
+ return -1;
+}
+
sw buf_inspect_sym (s_buf *buf, const s_sym *x)
{
sw r;
@@ -1739,6 +1822,8 @@ sw buf_inspect_tag (s_buf *buf, const s_tag *tag)
case TAG_MAP: return buf_inspect_map(buf, &tag->data.map);
case TAG_PTAG: return buf_inspect_ptag(buf, &tag->data.ptag);
case TAG_PTR: return buf_inspect_ptr(buf, &tag->data.ptr);
+ case TAG_PTR_FREE:
+ return buf_inspect_ptr_free(buf, &tag->data.ptr_free);
case TAG_QUOTE: return buf_inspect_quote(buf, &tag->data.quote);
case TAG_S8: return buf_inspect_s8(buf, &tag->data.s8);
case TAG_S16: return buf_inspect_s16(buf, &tag->data.s16);
@@ -1746,6 +1831,7 @@ sw buf_inspect_tag (s_buf *buf, const s_tag *tag)
case TAG_S64: return buf_inspect_s64(buf, &tag->data.s64);
case TAG_SW: return buf_inspect_sw(buf, &tag->data.sw);
case TAG_STR: return buf_inspect_str(buf, &tag->data.str);
+ case TAG_STRUCT: return buf_inspect_struct(buf, &tag->data.struct_);
case TAG_SYM: return buf_inspect_sym(buf, tag->data.sym);
case TAG_TUPLE: return buf_inspect_tuple(buf, &tag->data.tuple);
case TAG_U8: return buf_inspect_u8(buf, &tag->data.u8);
@@ -1783,6 +1869,8 @@ sw buf_inspect_tag_size (const s_tag *tag)
case TAG_MAP: return buf_inspect_map_size(&tag->data.map);
case TAG_PTAG: return buf_inspect_ptag_size(&tag->data.ptag);
case TAG_PTR: return buf_inspect_ptr_size(&tag->data.ptr);
+ case TAG_PTR_FREE:
+ return buf_inspect_ptr_free_size(&tag->data.ptr_free);
case TAG_QUOTE: return buf_inspect_quote_size(&tag->data.quote);
case TAG_S8: return buf_inspect_s8_size(&tag->data.s8);
case TAG_S16: return buf_inspect_s16_size(&tag->data.s16);
@@ -1790,6 +1878,7 @@ sw buf_inspect_tag_size (const s_tag *tag)
case TAG_S64: return buf_inspect_s64_size(&tag->data.s64);
case TAG_SW: return buf_inspect_sw_size(&tag->data.sw);
case TAG_STR: return buf_inspect_str_size(&tag->data.str);
+ case TAG_STRUCT: return buf_inspect_struct_size(&tag->data.struct_);
case TAG_SYM: return buf_inspect_sym_size(tag->data.sym);
case TAG_TUPLE: return buf_inspect_tuple_size(&tag->data.tuple);
case TAG_U8: return buf_inspect_u8_size(&tag->data.u8);
@@ -1839,7 +1928,9 @@ sw buf_inspect_tag_type (s_buf *buf, e_tag_type type)
case TAG_PTAG:
return buf_write_1(buf, "Ptag");
case TAG_PTR:
- return buf_write_1(buf, "Void*");
+ return buf_write_1(buf, "Ptr");
+ case TAG_PTR_FREE:
+ return buf_write_1(buf, "PtrFree");
case TAG_QUOTE:
return buf_write_1(buf, "Quote");
case TAG_S8:
@@ -1854,6 +1945,8 @@ sw buf_inspect_tag_type (s_buf *buf, e_tag_type type)
return buf_write_1(buf, "Sw");
case TAG_STR:
return buf_write_1(buf, "Str");
+ case TAG_STRUCT:
+ return buf_write_1(buf, "Struct");
case TAG_SYM:
return buf_write_1(buf, "Sym");
case TAG_TUPLE:
@@ -1910,7 +2003,9 @@ sw buf_inspect_tag_type_size (e_tag_type type)
case TAG_PTAG:
return strlen("Ptag");
case TAG_PTR:
- return strlen("Void*");
+ return strlen("Ptr");
+ case TAG_PTR_FREE:
+ return strlen("PtrFree");
case TAG_QUOTE:
return strlen("Quote");
case TAG_S8:
@@ -1925,6 +2020,8 @@ sw buf_inspect_tag_type_size (e_tag_type type)
return strlen("Sw");
case TAG_STR:
return strlen("Str");
+ case TAG_STRUCT:
+ return strlen("Struct");
case TAG_SYM:
return strlen("Sym");
case TAG_TUPLE:
diff --git a/libc3/buf_inspect.h b/libc3/buf_inspect.h
index bd17036..96e21a8 100644
--- a/libc3/buf_inspect.h
+++ b/libc3/buf_inspect.h
@@ -104,8 +104,10 @@ sw buf_inspect_paren_sym (s_buf *buf, const s_sym *sym);
sw buf_inspect_paren_sym_size (const s_sym *sym);
sw buf_inspect_ptag (s_buf *buf, const p_tag *ptag);
sw buf_inspect_ptag_size (const p_tag *ptag);
-sw buf_inspect_ptr (s_buf *buf, const s_ptr *ptr);
-sw buf_inspect_ptr_size (const s_ptr *ptr);
+sw buf_inspect_ptr (s_buf *buf, const u_ptr_w *ptr);
+sw buf_inspect_ptr_free (s_buf *buf, const u_ptr_w *ptr_free);
+sw buf_inspect_ptr_free_size (const u_ptr_w *ptr_free);
+sw buf_inspect_ptr_size (const u_ptr_w *ptr);
sw buf_inspect_quote (s_buf *buf, const s_quote *quote);
sw buf_inspect_quote_size (const s_quote *quote);
BUF_INSPECT_S_PROTOTYPES(8);
@@ -121,6 +123,8 @@ sw buf_inspect_str_character_size (const character *c);
sw buf_inspect_str_reserved (s_buf *buf, const s_str *str);
sw buf_inspect_str_reserved_size (const s_str *str);
sw buf_inspect_str_size (const s_str *str);
+sw buf_inspect_struct (s_buf *buf, const s_struct *s);
+sw buf_inspect_struct_size (const s_struct *s);
sw buf_inspect_sym (s_buf *buf, const s_sym *sym);
sw buf_inspect_sym_reserved (s_buf *buf, const s_sym *sym);
sw buf_inspect_sym_reserved_size (const s_sym *sym);
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 306c6fb..c7779a9 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -32,6 +32,7 @@
#include "map.h"
#include "operator.h"
#include "str.h"
+#include "struct.h"
#include "sym.h"
#include "tag.h"
#include "tuple.h"
@@ -2128,24 +2129,31 @@ sw buf_parse_module_name (s_buf *buf, const s_sym **dest)
buf_init_alloc(&tmp, SYM_MAX);
if ((r = buf_parse_sym(buf, &sym)) <= 0)
goto clean;
+ if (! sym_is_module(sym)) {
+ r = 0;
+ goto restore;
+ }
result += r;
if ((r = buf_inspect_sym(&tmp, sym)) < 0)
goto clean;
save.rpos = buf->rpos;
while ((r = buf_read_1(buf, ".")) > 0 &&
- (r = buf_parse_sym(buf, &sym)) > 0) {
+ (r = buf_parse_sym(buf, &sym)) > 0 &&
+ sym_is_module(sym)) {
result += r + 1;
save.rpos = buf->rpos;
if ((r = buf_write_1(&tmp, ".")) < 0 ||
(r = buf_inspect_sym(&tmp, sym)) < 0)
goto clean;
}
- if ((r = buf_peek_1(buf, ".")) <= 0)
- buf_save_restore_rpos(buf, &save);
+ buf_save_restore_rpos(buf, &save);
buf_read_to_str(&tmp, &str);
*dest = str_to_sym(&str);
str_clean(&str);
r = result;
+ goto clean;
+ restore:
+ buf_save_restore_rpos(buf, &save);
clean:
buf_save_clean(buf, &save);
buf_clean(&tmp);
@@ -2207,7 +2215,7 @@ sw buf_parse_ptag (s_buf *buf, p_tag *dest)
return -1;
}
-sw buf_parse_ptr (s_buf *buf, s_ptr *dest)
+sw buf_parse_ptr (s_buf *buf, u_ptr_w *dest)
{
(void) buf;
(void) dest;
@@ -2216,6 +2224,15 @@ sw buf_parse_ptr (s_buf *buf, s_ptr *dest)
return -1;
}
+sw buf_parse_ptr_free (s_buf *buf, u_ptr_w *dest)
+{
+ (void) buf;
+ (void) dest;
+ assert(! "buf_parse_ptr_free: not implemented");
+ err_puts("buf_parse_ptr_free: not implemented");
+ return -1;
+}
+
sw buf_parse_quote (s_buf *buf, s_quote *dest)
{
s_quote quote;
@@ -2441,6 +2458,97 @@ sw buf_parse_str_u8 (s_buf *buf, u8 *dest)
return r;
}
+sw buf_parse_struct (s_buf *buf, s_struct *dest)
+{
+ s_list *keys = NULL;
+ s_list **keys_end;
+ const s_sym *module;
+ sw r;
+ sw result = 0;
+ s_buf_save save;
+ s_list *values = NULL;
+ s_list **values_end;
+ assert(buf);
+ assert(dest);
+ buf_save_init(buf, &save);
+ if ((r = buf_read_1(buf, "%")) <= 0)
+ goto clean;
+ result += r;
+ if ((r = buf_parse_module_name(buf, &module)) <= 0)
+ goto restore;
+ result += r;
+ if ((r = buf_read_1(buf, "{")) <= 0)
+ goto restore;
+ result += r;
+ keys = NULL;
+ keys_end = &keys;
+ values = NULL;
+ values_end = &values;
+ if ((r = buf_parse_comments(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_ignore_spaces(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_read_1(buf, "}")) < 0)
+ goto restore;
+ result += r;
+ while (r == 0) {
+ *keys_end = list_new(NULL);
+ if ((r = buf_parse_map_key(buf, &(*keys_end)->tag)) <= 0)
+ goto restore;
+ result += r;
+ keys_end = &(*keys_end)->next.data.list;
+ if ((r = buf_parse_comments(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_ignore_spaces(buf)) < 0)
+ goto restore;
+ result += r;
+ *values_end = list_new(NULL);
+ if ((r = buf_parse_tag(buf, &(*values_end)->tag)) <= 0)
+ goto restore;
+ result += r;
+ values_end = &(*values_end)->next.data.list;
+ if ((r = buf_parse_comments(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_ignore_spaces(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_read_1(buf, "}")) < 0)
+ goto restore;
+ result += r;
+ if (r == 0) {
+ if ((r = buf_read_1(buf, ",")) <= 0)
+ goto restore;
+ result += r;
+ if ((r = buf_parse_comments(buf)) < 0)
+ goto restore;
+ result += r;
+ if ((r = buf_ignore_spaces(buf)) < 0)
+ goto restore;
+ result += r;
+ r = 0;
+ }
+ }
+ if (! struct_init_from_lists(dest, module, keys, values)) {
+ r = 0;
+ goto restore;
+ }
+ r = result;
+ list_delete_all(keys);
+ list_delete_all(values);
+ goto clean;
+ restore:
+ list_delete_all(keys);
+ list_delete_all(values);
+ buf_save_restore_rpos(buf, &save);
+ clean:
+ buf_save_clean(buf, &save);
+ return r;
+}
+
sw buf_parse_sym (s_buf *buf, const s_sym **dest)
{
character c;
@@ -2485,8 +2593,18 @@ sw buf_parse_sym (s_buf *buf, const s_sym **dest)
goto clean;
}
result += csize;
- while ((r = buf_peek_character_utf8(buf, &c)) > 0 &&
- ! sym_character_is_reserved(c)) {
+ while (1) {
+ if ((r = buf_peek_character_utf8(buf, &c)) <= 0)
+ break;
+ if (c == '.') {
+ if ((r = buf_peek_next_character_utf8(buf, &c)) <= 0)
+ goto restore;
+ if (! character_is_uppercase(c))
+ break;
+ r = 1;
+ }
+ else if (sym_character_is_reserved(c))
+ break;
csize = r;
if ((r = buf_xfer(&tmp, buf, csize)) < 0)
goto restore;
@@ -2723,6 +2841,16 @@ sw buf_parse_tag_map (s_buf *buf, s_tag *dest)
return r;
}
+sw buf_parse_tag_module_name (s_buf *buf, s_tag *dest)
+{
+ sw r;
+ assert(buf);
+ assert(dest);
+ if ((r = buf_parse_module_name(buf, &dest->data.sym)) > 0)
+ dest->type = TAG_SYM;
+ return r;
+}
+
sw buf_parse_tag_number (s_buf *buf, s_tag *dest)
{
sw r;
@@ -2763,6 +2891,7 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
(r = buf_parse_tag_quote(buf, dest)) != 0 ||
(r = buf_parse_tag_cfn(buf, dest)) != 0 ||
(r = buf_parse_tag_fn(buf, dest)) != 0 ||
+ //(r = buf_parse_tag_module_name(buf, dest)) != 0 ||
(r = buf_parse_tag_ident(buf, dest)) != 0 ||
(r = buf_parse_tag_list(buf, dest)) != 0 ||
(r = buf_parse_tag_sym(buf, dest)) != 0)
diff --git a/libc3/buf_parse.h b/libc3/buf_parse.h
index 1838e5f..6365e3e 100644
--- a/libc3/buf_parse.h
+++ b/libc3/buf_parse.h
@@ -89,12 +89,14 @@ sw buf_parse_module_name (s_buf *buf, const s_sym **dest);
sw buf_parse_new_tag (s_buf *buf, s_tag **dest);
sw buf_parse_paren_sym (s_buf *buf, const s_sym **dest);
sw buf_parse_ptag (s_buf *buf, p_tag *dest);
-sw buf_parse_ptr (s_buf *buf, s_ptr *dest);
+sw buf_parse_ptr (s_buf *buf, u_ptr_w *dest);
+sw buf_parse_ptr_free (s_buf *buf, u_ptr_w *dest);
sw buf_parse_quote (s_buf *buf, s_quote *dest);
sw buf_parse_str (s_buf *buf, s_str *dest);
sw buf_parse_str_character (s_buf *buf, character *dest);
sw buf_parse_str_character_unicode (s_buf *buf, character *dest);
sw buf_parse_str_u8 (s_buf *buf, u8 *dest);
+sw buf_parse_struct (s_buf *buf, s_struct *dest);
sw buf_parse_sym (s_buf *buf, const s_sym **dest);
sw buf_parse_sym_str (s_buf *buf, s_str *dest);
sw buf_parse_tag (s_buf *buf, s_tag *dest);
@@ -111,6 +113,7 @@ sw buf_parse_tag_ident (s_buf *buf, s_tag *dest);
sw buf_parse_tag_integer (s_buf *buf, s_tag *dest);
sw buf_parse_tag_list (s_buf *buf, s_tag *dest);
sw buf_parse_tag_map (s_buf *buf, s_tag *map);
+sw buf_parse_tag_module_name (s_buf *buf, s_tag *module_name);
sw buf_parse_tag_number (s_buf *buf, s_tag *dest);
sw buf_parse_tag_primary (s_buf *buf, s_tag *dest);
sw buf_parse_tag_quote (s_buf *buf, s_tag *dest);
diff --git a/libc3/c3.h b/libc3/c3.h
index cb1b623..838c405 100644
--- a/libc3/c3.h
+++ b/libc3/c3.h
@@ -70,6 +70,7 @@
#include "map.h"
#include "ptag.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "module.h"
#include "operator.h"
#include "quote.h"
@@ -79,6 +80,7 @@
#include "s64.h"
#include "sequence.h"
#include "str.h"
+#include "struct.h"
#include "sw.h"
#include "tag.h"
#include "time.h"
@@ -91,5 +93,6 @@
#include "uw.h"
#include "ucd.h"
#include "var.h"
+#include "void.h"
#endif /* LIBC3_C3_H */
diff --git a/libc3/call.c b/libc3/call.c
index ba22f09..842fc13 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -241,6 +241,9 @@ s_call * call_init_cast (s_call *call, const s_sym *type,
{
s_call tmp = {0};
assert(call);
+ assert(type);
+ assert(sym_is_module(type));
+ assert(tag);
ident_init(&tmp.ident, type, sym_1("cast"));
tmp.arguments = list_new_copy(tag, NULL);
*call = tmp;
diff --git a/libc3/character.c b/libc3/character.c
index f4d3c71..5655efc 100644
--- a/libc3/character.c
+++ b/libc3/character.c
@@ -21,7 +21,7 @@ character character_1 (const s8 *p)
s_str stra;
assert(p);
str_init_1(&stra, NULL, p);
- str_peek_character(&stra, &c);
+ str_peek_character_utf8(&stra, &c);
return c;
}
diff --git a/libc3/env.c b/libc3/env.c
index 10747a8..4bf50cd 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -148,7 +148,7 @@ bool env_eval_array_cast (s_env *env, s_array *array, const s_tag *tag,
{
s_call call;
s_tag tag_eval;
- void *data_eval;
+ const void *data_eval;
assert(env);
assert(array);
assert(tag);
@@ -160,7 +160,7 @@ bool env_eval_array_cast (s_env *env, s_array *array, const s_tag *tag,
call_clean(&call);
return false;
}
- data_eval = tag_to_pointer(&tag_eval, array->type);
+ data_eval = tag_to_const_pointer(&tag_eval, array->type);
memcpy(data, data_eval, size);
call_clean(&call);
return true;
@@ -454,6 +454,12 @@ bool env_eval_equal_tag (s_env *env, const s_tag *a, const s_tag *b,
dest->type = TAG_MAP;
return env_eval_equal_map(env, &a->data.map, &b->data.map,
&dest->data.map);
+ /*
+ case TAG_STRUCT:
+ dest->type = TAG_STRUCT;
+ return env_eval_equal_struct(env, &a->data.struct_,
+ &b->data.struct_, &dest->data.struct_);
+ */
case TAG_TUPLE:
dest->type = TAG_TUPLE;
return env_eval_equal_tuple(env, &a->data.tuple, &b->data.tuple,
@@ -470,7 +476,9 @@ bool env_eval_equal_tag (s_env *env, const s_tag *a, const s_tag *b,
case TAG_INTEGER:
case TAG_PTAG:
case TAG_PTR:
+ case TAG_PTR_FREE:
case TAG_STR:
+ case TAG_STRUCT:
case TAG_SYM:
case TAG_VAR:
if (compare_tag(a, b)) {
@@ -686,6 +694,10 @@ bool env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest)
return env_eval_map(env, &tag->data.map, dest);
case TAG_QUOTE:
return env_eval_quote(env, &tag->data.quote, dest);
+ /*
+ case TAG_STRUCT:
+ return env_eval_struct(env, &tag->data.struct_, dest);
+ */
case TAG_TUPLE:
return env_eval_tuple(env, &tag->data.tuple, dest);
case TAG_BOOL:
@@ -698,12 +710,14 @@ bool env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest)
case TAG_INTEGER:
case TAG_PTAG:
case TAG_PTR:
+ case TAG_PTR_FREE:
case TAG_S8:
case TAG_S16:
case TAG_S32:
case TAG_S64:
case TAG_SW:
case TAG_STR:
+ case TAG_STRUCT:
case TAG_SYM:
case TAG_U8:
case TAG_U16:
@@ -761,7 +775,7 @@ s_env * env_init (s_env *env, int argc, s8 **argv)
(NULL, "../../../../", list_new_str_1
(NULL, "../../../../../", list_new_str_1
(NULL, "../../../../../../", NULL))))))));
- str_init_1(&path, NULL, "lib/c3/0.1");
+ str_init_1(&path, NULL, "lib/c3/0.1/");
if (! file_search(&path, sym_1("x"), &env->module_path)) {
assert(! "env_init: module path not found");
warn("env_init: module_path not found");
@@ -882,13 +896,13 @@ bool env_module_maybe_reload (s_env *env, const s_sym *module,
{
s_str path;
bool r = true;
- s_tag tag_load_time;
+ s_tag tag_load_time = {0};
s_tag tag_mtime;
- if (! module_load_time(module, facts, &tag_load_time))
- return false;
+ module_load_time(module, facts, &tag_load_time);
if (! module_path(module, &env->module_path, &path)) {
return false;
}
+ //io_inspect_str(&path);
if (! file_mtime(&path, &tag_mtime)) {
str_clean(&path);
return false;
diff --git a/libc3/env.h b/libc3/env.h
index 055d154..34cc7f6 100644
--- a/libc3/env.h
+++ b/libc3/env.h
@@ -41,6 +41,8 @@ bool env_eval_call_fn (s_env *env, const s_call *call,
bool env_eval_call_resolve (s_env *env, s_call *call);
bool env_eval_equal_list (s_env *env, const s_list *a,
const s_list *b, s_list **dest);
+bool env_eval_equal_struct (s_env *env, const s_struct *a,
+ const s_struct *b, s_struct *dest);
bool env_eval_equal_tag (s_env *env, const s_tag *a,
const s_tag *b, s_tag *dest);
bool env_eval_equal_tuple (s_env *env, const s_tuple *a,
@@ -57,6 +59,8 @@ bool env_eval_progn (s_env *env, const s_list *program,
s_tag *dest);
bool env_eval_quote (s_env *env, const s_quote *quote,
s_tag *dest);
+bool env_eval_struct (s_env *env, const s_struct *s,
+ s_tag *dest);
bool env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest);
bool env_eval_tuple (s_env *env, const s_tuple *tuple,
s_tag *dest);
diff --git a/libc3/f32.c b/libc3/f32.c
index d2693ec..eedbac7 100644
--- a/libc3/f32.c
+++ b/libc3/f32.c
@@ -20,26 +20,14 @@
f32 f32_cast (s_tag *tag)
{
switch (tag->type) {
- case TAG_VOID:
- return 0.0f;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
return tag->data.bool ? 1.0f : 0.0f;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
return (f32) tag->data.character;
case TAG_F32:
return tag->data.f32;
case TAG_F64:
return (f32) tag->data.f64;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
return integer_to_f32(&tag->data.integer);
case TAG_SW:
@@ -62,23 +50,11 @@ f32 f32_cast (s_tag *tag)
return (f32) tag->data.u64;
case TAG_UW:
return (f32) tag->data.uw;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "f32_cast: unknown tag type");
- errx(1, "f32_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("f32_cast: cannot cast %s to f32",
- tag_type_to_string(tag->type));
+ errx(1, "f32_cast: cannot cast %s to f32",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/f64.c b/libc3/f64.c
index 6482c7f..7cca28c 100644
--- a/libc3/f64.c
+++ b/libc3/f64.c
@@ -21,26 +21,14 @@
f64 f64_cast (s_tag *tag)
{
switch (tag->type) {
- case TAG_VOID:
- return 0.0;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
return tag->data.bool ? 1.0 : 0.0;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
return (f64) tag->data.character;
case TAG_F32:
return (f64) tag->data.f32;
case TAG_F64:
return tag->data.f64;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
return integer_to_f64(&tag->data.integer);
case TAG_SW:
@@ -63,23 +51,11 @@ f64 f64_cast (s_tag *tag)
return (f64) tag->data.u64;
case TAG_UW:
return (f64) tag->data.uw;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "f64_cast: unknown tag type");
- errx(1, "f64_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("f64_cast: cannot cast %s to f64",
- tag_type_to_string(tag->type));
+ errx(1, "f64_cast: cannot cast %s to f64",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/file.c b/libc3/file.c
index fddcc6c..d7fbacb 100644
--- a/libc3/file.c
+++ b/libc3/file.c
@@ -136,6 +136,7 @@ s_str * file_search (const s_str *suffix, const s_sym *mode,
const s_list *path;
sw r;
s_buf_save save;
+ const s_str *str;
s_str tmp;
buf_init(&buf, false, PATH_MAX, buf_s);
if ((r = buf_write_str(&buf, &g_c3_env.argv0_dir)) < 0)
@@ -146,13 +147,14 @@ s_str * file_search (const s_str *suffix, const s_sym *mode,
if (path->tag.type == TAG_STR) {
buf_save_restore_rpos(&buf, &save);
buf_save_restore_wpos(&buf, &save);
- if ((r = buf_write_str(&buf, &path->tag.data.str)) < 0 ||
- (buf.ptr.ps8[buf.wpos - 1] != '/' &&
- (r = buf_write_u8(&buf, '/')) < 0) ||
+ str = &path->tag.data.str;
+ if ((r = buf_write_str(&buf, str)) < 0 ||
+ (str->ptr.ps8[str->size - 1] != '/' &&
+ (r = buf_write_1(&buf, "/")) < 0) ||
(r = buf_write_str(&buf, suffix)) < 0)
return NULL;
buf_read_to_str(&buf, &tmp);
- /* io_inspect_str(&tmp); */
+ //io_inspect_str(&tmp);
file_access(&tmp, mode, &access);
if (access) {
*dest = tmp;
diff --git a/libc3/hash.c b/libc3/hash.c
index 83610ff..07f4b01 100644
--- a/libc3/hash.c
+++ b/libc3/hash.c
@@ -17,14 +17,16 @@
#include "hash.h"
#include "list.h"
#include "str.h"
+#include "tag_type.h"
#define HASH_UPDATE_DEF(type) \
- void hash_update_##type (t_hash *hash, type x) \
+ void hash_update_##type (t_hash *hash, const type *x) \
{ \
const s8 t[] = #type; \
assert(hash); \
+ assert(x); \
hash_update(hash, t, sizeof(t)); \
- hash_update(hash, &x, sizeof(x)); \
+ hash_update(hash, x, sizeof(type)); \
}
void hash_clean (t_hash *hash)
@@ -88,16 +90,17 @@ void hash_update_array (t_hash *hash, const s_array *a)
hash_update(hash, a->data, a->size);
}
-void hash_update_bool (t_hash *hash, bool x)
+void hash_update_bool (t_hash *hash, const bool *x)
{
+ bool b;
const s8 type[] = "bool";
assert(hash);
+ assert(x);
hash_update(hash, type, sizeof(type));
- bool b = x ? 1 : 0;
+ b = x ? 1 : 0;
hash_update(hash, &b, sizeof(b));
}
-
void hash_update_call (t_hash *hash, const s_call *call)
{
const s8 type[] = "call";
@@ -105,7 +108,7 @@ void hash_update_call (t_hash *hash, const s_call *call)
assert(call);
hash_update(hash, type, sizeof(type));
hash_update_ident(hash, &call->ident);
- hash_update_list(hash, call->arguments);
+ hash_update_list(hash, (const s_list * const *) &call->arguments);
}
void hash_update_cfn (t_hash *hash, const s_cfn *cfn)
@@ -114,8 +117,8 @@ void hash_update_cfn (t_hash *hash, const s_cfn *cfn)
assert(hash);
assert(cfn);
hash_update(hash, type, sizeof(type));
- hash_update_sym(hash, cfn->name);
- hash_update_list(hash, cfn->arg_types);
+ hash_update_sym(hash, &cfn->name);
+ hash_update_list(hash, (const s_list * const *) &cfn->arg_types);
}
HASH_UPDATE_DEF(character)
@@ -144,8 +147,8 @@ void hash_update_fn (t_hash *hash, const s_fn *fn)
assert(hash);
assert(fn);
hash_update(hash, type, sizeof(type));
- hash_update_bool(hash, fn->macro);
- hash_update_bool(hash, fn->macro);
+ hash_update_bool(hash, &fn->macro);
+ hash_update_bool(hash, &fn->special_operator);
hash_update_fn_clauses(hash, fn->clauses);
}
@@ -162,11 +165,11 @@ void hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses)
count++;
f = f->next_clause;
}
- hash_update_uw(hash, count);
+ hash_update_uw(hash, &count);
f = clauses;
while (f) {
- hash_update_list(hash, f->pattern);
- hash_update_list(hash, f->algo);
+ hash_update_list(hash, (const s_list * const *) &f->pattern);
+ hash_update_list(hash, (const s_list * const *) &f->algo);
f = f->next_clause;
}
}
@@ -175,12 +178,12 @@ void hash_update_ident (t_hash *hash, const s_ident *ident)
{
assert(hash);
assert(ident);
- hash_update_u8(hash, '_');
+ hash_update_s8(hash, "_");
if (ident->module) {
- hash_update_sym(hash, ident->module);
- hash_update_u8(hash, '.');
+ hash_update_sym(hash, &ident->module);
+ hash_update_s8(hash, ".");
}
- hash_update_sym(hash, ident->sym);
+ hash_update_sym(hash, &ident->sym);
}
void hash_update_integer (t_hash *hash, const s_integer *i)
@@ -201,19 +204,23 @@ void hash_update_integer (t_hash *hash, const s_integer *i)
}
/* FIXME: circular lists */
-void hash_update_list (t_hash *hash, const s_list *list)
+void hash_update_list (t_hash *hash, const s_list * const *list)
{
uw count;
+ const s_list *l;
const s_list *last;
const s8 type[] = "list";
+ assert(hash);
+ assert(list);
+ l = *list;
hash_update(hash, type, sizeof(type));
- count = list_length(list);
- hash_update_uw(hash, count);
- if (list) {
- while (list) {
- hash_update_tag(hash, &list->tag);
- last = list;
- list = list_next(list);
+ count = list_length(l);
+ hash_update_uw(hash, &count);
+ if (l) {
+ while (l) {
+ hash_update_tag(hash, &l->tag);
+ last = l;
+ l = list_next(l);
}
hash_update_tag(hash, &last->next);
}
@@ -223,6 +230,8 @@ void hash_update_map (t_hash *hash, const s_map *map)
{
uw i = 0;
const s8 type[] = "map";
+ assert(hash);
+ assert(map);
hash_update(hash, type, strlen(type));
hash_update(hash, &map->count, sizeof(map->count));
while (i < map->count) {
@@ -232,21 +241,29 @@ void hash_update_map (t_hash *hash, const s_map *map)
}
}
-void hash_update_ptag (t_hash *hash, const p_tag ptag)
+void hash_update_ptag (t_hash *hash, const p_tag *ptag)
{
const s8 type[] = "ptag";
- hash_update(hash, type, strlen(type));
- hash_update(hash, &ptag, sizeof(ptag));
+ assert(hash);
+ assert(ptag);
+ hash_update(hash, type, sizeof(type));
+ hash_update(hash, ptag, sizeof(ptag));
}
-void hash_update_ptr (t_hash *hash, const s_ptr *ptr)
+void hash_update_ptr (t_hash *hash, const u_ptr_w *ptr)
{
const s8 type[] = "ptr";
hash_update(hash, type, strlen(type));
- hash_update(hash, &ptr->type, sizeof(e_tag_type));
hash_update(hash, &ptr->p, sizeof(void *));
}
+void hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free)
+{
+ const s8 type[] = "ptr_free";
+ hash_update(hash, type, strlen(type));
+ hash_update(hash, &ptr_free->p, sizeof(void *));
+}
+
void hash_update_quote (t_hash *hash, const s_quote *x)
{
const s8 type[] = "quote";
@@ -274,55 +291,81 @@ void hash_update_str (t_hash *hash, const s_str *str)
hash_update(hash, str->ptr.p, str->size);
}
-void hash_update_sym (t_hash *hash, const s_sym *sym)
+void hash_update_struct (t_hash *hash, const s_struct *s)
+{
+ f_hash_update hash_update_value;
+ uw i = 0;
+ s8 type[] = "struct";
+ assert(hash);
+ assert(s);
+ hash_update(hash, type, sizeof(type));
+ hash_update(hash, &s->type.map.count, sizeof(s->type.map.count));
+ while (i < s->type.map.count) {
+ hash_update_tag(hash, s->type.map.key + i);
+ hash_update_value =
+ tag_type_to_hash_update(s->type.map.value[i].type);
+ hash_update_value(hash, (s8 *) s->data + s->type.offset[i]);
+ i++;
+ }
+}
+
+void hash_update_sym (t_hash *hash, const s_sym * const *sym)
{
+ s8 type[] = "sym";
assert(hash);
assert(sym);
- hash_update_u8(hash, ':');
- hash_update_str(hash, &sym->str);
+ hash_update(hash, type, sizeof(type));
+ hash_update_str(hash, &(*sym)->str);
}
void hash_update_tag (t_hash *hash, const s_tag *tag)
{
+ u8 tag_type;
+ s8 type[] = "tag";
assert(hash);
assert(tag);
- hash_update_u64(hash, tag->type);
+ hash_update(hash, type, strlen(type));
+ tag_type = tag->type;
+ hash_update_u8(hash, &tag_type);
switch (tag->type) {
- case TAG_VOID: break;
- case TAG_ARRAY: hash_update_array(hash, &tag->data.array); break;
- case TAG_BOOL: hash_update_bool(hash, tag->data.bool); break;
- case TAG_CALL: hash_update_call(hash, &tag->data.call); break;
- case TAG_CFN: hash_update_cfn(hash, &tag->data.cfn); break;
+ case TAG_ARRAY: hash_update_array(hash, &tag->data.array); break;
+ case TAG_BOOL: hash_update_bool(hash, &tag->data.bool); break;
+ case TAG_CALL: hash_update_call(hash, &tag->data.call); break;
+ case TAG_CFN: hash_update_cfn(hash, &tag->data.cfn); break;
case TAG_CHARACTER:
- hash_update_character(hash, tag->data.character); break;
- case TAG_F32: hash_update_f32(hash, tag->data.f32); break;
- case TAG_F64: hash_update_f64(hash, tag->data.f64); break;
- case TAG_FACT: hash_update_fact(hash, &tag->data.fact); break;
- case TAG_FN: hash_update_fn(hash, &tag->data.fn); break;
- case TAG_IDENT: hash_update_ident(hash, &tag->data.ident); break;
+ hash_update_character(hash, &tag->data.character); break;
+ case TAG_F32: hash_update_f32(hash, &tag->data.f32); break;
+ case TAG_F64: hash_update_f64(hash, &tag->data.f64); break;
+ case TAG_FACT: hash_update_fact(hash, &tag->data.fact); break;
+ case TAG_FN: hash_update_fn(hash, &tag->data.fn); break;
+ case TAG_IDENT: hash_update_ident(hash, &tag->data.ident); break;
case TAG_INTEGER:
- hash_update_integer(hash, &tag->data.integer); break;
- case TAG_LIST: hash_update_list(hash, tag->data.list); break;
- case TAG_MAP: hash_update_map(hash, &tag->data.map); break;
- case TAG_PTAG: hash_update_ptag(hash, tag->data.ptag); break;
- case TAG_PTR: hash_update_ptr(hash, &tag->data.ptr); break;
- case TAG_QUOTE: hash_update_quote(hash, &tag->data.quote); break;
- case TAG_S8: hash_update_s8(hash, tag->data.s8); break;
- case TAG_S16: hash_update_s16(hash, tag->data.s16); break;
- case TAG_S32: hash_update_s32(hash, tag->data.s32); break;
- case TAG_S64: hash_update_s64(hash, tag->data.s64); break;
- case TAG_SW: hash_update_sw(hash, tag->data.sw); break;
- case TAG_STR: hash_update_str(hash, &tag->data.str); break;
- case TAG_SYM: hash_update_sym(hash, tag->data.sym); break;
- case TAG_TUPLE: hash_update_tuple(hash, &tag->data.tuple); break;
- case TAG_U8: hash_update_u8(hash, tag->data.u8); break;
- case TAG_U16: hash_update_u16(hash, tag->data.u16); break;
- case TAG_U32: hash_update_u32(hash, tag->data.u32); break;
- case TAG_U64: hash_update_u64(hash, tag->data.u64); break;
- case TAG_UW: hash_update_uw(hash, tag->data.uw); break;
- case TAG_VAR:
- assert(! "var hash update");
- errx(1, "var hash update");
+ hash_update_integer(hash, &tag->data.integer); break;
+ case TAG_LIST:
+ hash_update_list(hash, (const s_list * const *) &tag->data.list);
+ break;
+ case TAG_MAP: hash_update_map(hash, &tag->data.map); break;
+ case TAG_PTAG: hash_update_ptag(hash, &tag->data.ptag); break;
+ case TAG_PTR: hash_update_ptr(hash, &tag->data.ptr); break;
+ case TAG_PTR_FREE:
+ hash_update_ptr_free(hash, &tag->data.ptr_free); break;
+ case TAG_QUOTE: hash_update_quote(hash, &tag->data.quote); break;
+ case TAG_S8: hash_update_s8(hash, &tag->data.s8); break;
+ case TAG_S16: hash_update_s16(hash, &tag->data.s16); break;
+ case TAG_S32: hash_update_s32(hash, &tag->data.s32); break;
+ case TAG_S64: hash_update_s64(hash, &tag->data.s64); break;
+ case TAG_SW: hash_update_sw(hash, &tag->data.sw); break;
+ case TAG_STR: hash_update_str(hash, &tag->data.str); break;
+ case TAG_STRUCT: hash_update_struct(hash, &tag->data.struct_); break;
+ case TAG_SYM: hash_update_sym(hash, &tag->data.sym); break;
+ case TAG_TUPLE: hash_update_tuple(hash, &tag->data.tuple); break;
+ case TAG_U8: hash_update_u8(hash, &tag->data.u8); break;
+ case TAG_U16: hash_update_u16(hash, &tag->data.u16); break;
+ case TAG_U32: hash_update_u32(hash, &tag->data.u32); break;
+ case TAG_U64: hash_update_u64(hash, &tag->data.u64); break;
+ case TAG_UW: hash_update_uw(hash, &tag->data.uw); break;
+ case TAG_VAR: hash_update_var(hash, NULL); break;
+ case TAG_VOID: hash_update_void(hash, NULL); break;
}
}
@@ -342,3 +385,19 @@ HASH_UPDATE_DEF(u16)
HASH_UPDATE_DEF(u32)
HASH_UPDATE_DEF(u64)
HASH_UPDATE_DEF(uw)
+
+void hash_update_var (t_hash *hash, const void *x)
+{
+ s8 type[] = "var";
+ (void) x;
+ assert(hash);
+ hash_update(hash, type, strlen(type));
+}
+
+void hash_update_void (t_hash *hash, const void *x)
+{
+ s8 type[] = "void";
+ (void) x;
+ assert(hash);
+ hash_update(hash, type, strlen(type));
+}
diff --git a/libc3/hash.h b/libc3/hash.h
index d96a6ae..4a9f95d 100644
--- a/libc3/hash.h
+++ b/libc3/hash.h
@@ -16,7 +16,7 @@
#include "types.h"
#define HASH_UPDATE_PROTOTYPE(type) \
- void hash_update_##type (t_hash *hash, type x)
+ void hash_update_##type (t_hash *hash, const type *x)
void hash_clean (t_hash *hash);
void hash_init (t_hash *hash);
@@ -25,9 +25,10 @@ u64 hash_to_u64 (t_hash *hash);
void hash_update (t_hash *hash, const void *data, uw size);
void hash_update_1 (t_hash *hash, const s8 *p);
void hash_update_array (t_hash *hash, const s_array *a);
-void hash_update_bool (t_hash *hash, bool b);
+void hash_update_bool (t_hash *hash, const bool *b);
void hash_update_call (t_hash *hash, const s_call *call);
void hash_update_cfn (t_hash *hash, const s_cfn *cfn);
+HASH_UPDATE_PROTOTYPE(character);
HASH_UPDATE_PROTOTYPE(f32);
HASH_UPDATE_PROTOTYPE(f64);
void hash_update_fact (t_hash *hash, const s_fact *fact);
@@ -35,18 +36,20 @@ void hash_update_fn (t_hash *hash, const s_fn *fn);
void hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses);
void hash_update_ident (t_hash *hash, const s_ident *ident);
void hash_update_integer (t_hash *hash, const s_integer *i);
-void hash_update_list (t_hash *hash, const s_list *list);
+void hash_update_list (t_hash *hash, const s_list * const *list);
void hash_update_map (t_hash *hash, const s_map *map);
-void hash_update_ptag (t_hash *hash, const p_tag ptag);
-void hash_update_ptr (t_hash *hash, const s_ptr *ptr);
+void hash_update_ptag (t_hash *hash, const p_tag *ptag);
+void hash_update_ptr (t_hash *hash, const u_ptr_w *ptr);
+void hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free);
void hash_update_quote (t_hash *hash, const s_quote *x);
HASH_UPDATE_PROTOTYPE(s8);
HASH_UPDATE_PROTOTYPE(s16);
HASH_UPDATE_PROTOTYPE(s32);
HASH_UPDATE_PROTOTYPE(s64);
HASH_UPDATE_PROTOTYPE(sw);
-void hash_update_str (t_hash *hash, const s_str *src);
-void hash_update_sym (t_hash *hash, const s_sym *sym);
+void hash_update_str (t_hash *hash, const s_str *str);
+void hash_update_struct (t_hash *hash, const s_struct *s);
+void hash_update_sym (t_hash *hash, const s_sym * const *sym);
void hash_update_tag (t_hash *hash, const s_tag *tag);
void hash_update_tuple (t_hash *hash, const s_tuple *tuple);
HASH_UPDATE_PROTOTYPE(u8);
@@ -54,5 +57,7 @@ HASH_UPDATE_PROTOTYPE(u16);
HASH_UPDATE_PROTOTYPE(u32);
HASH_UPDATE_PROTOTYPE(u64);
HASH_UPDATE_PROTOTYPE(uw);
+void hash_update_var (t_hash *hash, const void *x);
+void hash_update_void (t_hash *hash, const void *x);
#endif /* LIBC3_HASH_H */
diff --git a/libc3/integer.c b/libc3/integer.c
index 174e008..f02cc68 100644
--- a/libc3/integer.c
+++ b/libc3/integer.c
@@ -113,26 +113,14 @@ uw integer_bytes (const s_integer *i)
s_integer * integer_cast (const s_tag *tag, s_integer *dest)
{
switch (tag->type) {
- case TAG_VOID:
- return integer_init_zero(dest);
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
return integer_init_u8(dest, tag->data.bool ? 1 : 0);
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
- return integer_init_u64(dest, tag->data.character);
+ return integer_init_u32(dest, tag->data.character);
case TAG_F32:
return integer_init_f32(dest, tag->data.f32);
case TAG_F64:
return integer_init_f64(dest, tag->data.f64);
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
return integer_copy(&tag->data.integer, dest);
case TAG_SW:
@@ -155,23 +143,11 @@ s_integer * integer_cast (const s_tag *tag, s_integer *dest)
return integer_init_u64(dest, tag->data.u64);
case TAG_UW:
return integer_init_uw(dest, tag->data.uw);
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "integer_cast: unknown tag type");
- errx(1, "integer_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("integer_cast: cannot cast %s to integer",
- tag_type_to_string(tag->type));
+ errx(1, "integer_cast: cannot cast %s to integer",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/list_init.c b/libc3/list_init.c
index 4eaffa3..aef37cf 100644
--- a/libc3/list_init.c
+++ b/libc3/list_init.c
@@ -29,8 +29,10 @@
#include "list.h"
#include "map.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "quote.h"
#include "str.h"
+#include "struct.h"
#include "tag.h"
#include "list_init.h"
#include "time.h"
@@ -183,13 +185,23 @@ s_list * list_init_map_1 (s_list *list, const s8 *p, s_list *next)
return list;
}
-s_list * list_init_ptr (s_list *list, bool free_p, const s_sym *type,
- void *p, s_list *next)
+s_list * list_init_ptr (s_list *list, void *p, s_list *next)
{
s_list tmp;
assert(list);
list_init(&tmp, next);
- if (! tag_init_ptr(&tmp.tag, free_p, type, p))
+ if (! tag_init_ptr(&tmp.tag, p))
+ return NULL;
+ *list = tmp;
+ return list;
+}
+
+s_list * list_init_ptr_free (s_list *list, void *p, s_list *next)
+{
+ s_list tmp;
+ assert(list);
+ list_init(&tmp, next);
+ if (! tag_init_ptr_free(&tmp.tag, p))
return NULL;
*list = tmp;
return list;
@@ -263,6 +275,31 @@ s_list * list_init_str_1 (s_list *list, s8 *p_free, const s8 *p,
return list;
}
+s_list * list_init_struct (s_list *list, const s_sym *module,
+ s_list *next)
+{
+ s_list tmp;
+ assert(list);
+ list_init(&tmp, next);
+ if (! tag_init_struct(&tmp.tag, module))
+ return NULL;
+ *list = tmp;
+ return list;
+}
+
+s_list * list_init_struct_with_data (s_list *list, const s_sym *module,
+ bool free_data, void *data,
+ s_list *next)
+{
+ s_list tmp;
+ assert(list);
+ list_init(&tmp, next);
+ if (! tag_init_struct_with_data(&tmp.tag, module, free_data, data))
+ return NULL;
+ *list = tmp;
+ return list;
+}
+
s_list * list_init_sw (s_list *list, sw i, s_list *next)
{
s_list tmp;
@@ -566,14 +603,26 @@ s_list * list_new_map_1 (const s8 *p, s_list *next)
return list;
}
-s_list * list_new_ptr (bool free_p, const s_sym *type, void *p,
- s_list *next)
+s_list * list_new_ptr (void *p, s_list *next)
+{
+ s_list *list;
+ list = list_new(next);
+ if (! list)
+ return NULL;
+ if (! tag_init_ptr(&list->tag, p)) {
+ free(list);
+ return NULL;
+ }
+ return list;
+}
+
+s_list * list_new_ptr_free (void *p, s_list *next)
{
s_list *list;
list = list_new(next);
if (! list)
return NULL;
- if (! tag_init_ptr(&list->tag, free_p, type, p)) {
+ if (! tag_init_ptr_free(&list->tag, p)) {
free(list);
return NULL;
}
@@ -658,6 +707,35 @@ s_list * list_new_str_1 (s8 *p_free, const s8 *p, s_list *next)
return list;
}
+s_list * list_new_struct (const s_sym *module, s_list *next)
+{
+ s_list *list;
+ list = list_new(next);
+ if (! list)
+ return NULL;
+ if (! tag_init_struct(&list->tag, module)) {
+ free(list);
+ return NULL;
+ }
+ return list;
+}
+
+s_list * list_new_struct_with_data (const s_sym *module,
+ bool free_data, void *data,
+ s_list *next)
+{
+ s_list *list;
+ list = list_new(next);
+ if (! list)
+ return NULL;
+ if (! tag_init_struct_with_data(&list->tag, module, free_data,
+ data)) {
+ free(list);
+ return NULL;
+ }
+ return list;
+}
+
s_list * list_new_sw (sw i, s_list *next)
{
s_list *list;
diff --git a/libc3/list_init.h b/libc3/list_init.h
index 86c2629..dc3aa1b 100644
--- a/libc3/list_init.h
+++ b/libc3/list_init.h
@@ -35,8 +35,8 @@ s_list * list_init_integer_zero (s_list *list, s_list *next);
s_list * list_init_map (s_list *list, uw count, s_list *next);
s_list * list_init_map_1 (s_list *list, const s8 *p, s_list *next);
-s_list * list_init_ptr (s_list *list, bool free_p, const s_sym *type,
- void *p, s_list *next);
+s_list * list_init_ptr (s_list *list, void *p, s_list *next);
+s_list * list_init_ptr_free (s_list *list, void *p, s_list *next);
s_list * list_init_s8 (s_list *list, s8 i, s_list *next);
s_list * list_init_s16 (s_list *list, s16 i, s_list *next);
s_list * list_init_s32 (s_list *list, s32 i, s_list *next);
@@ -45,6 +45,11 @@ s_list * list_init_str (s_list *list, s8 *p_free, uw size, const s8 *p,
s_list *next);
s_list * list_init_str_1 (s_list *list, s8 *p_free, const s8 *p,
s_list *next);
+s_list * list_init_struct (s_list *list, const s_sym *module,
+ s_list *next);
+s_list * list_init_struct_with_data (s_list *list, const s_sym *module,
+ bool free_data, void *data,
+ s_list *next);
s_list * list_init_sw (s_list *list, sw i, s_list *next);
s_list * list_init_sym (s_list *list, const s_sym *sym, s_list *next);
s_list * list_init_sym_1 (s_list *list, const s8 *p, s_list *next);
@@ -77,14 +82,18 @@ s_list * list_new_integer_zero (s_list *next);
s_list * list_new_map (uw count, s_list *next);
s_list * list_new_map_1 (const s8 *p, s_list *next);
-s_list * list_new_ptr (bool free_p, const s_sym *type, void *p,
- s_list *next);
+s_list * list_new_ptr (void *p, s_list *next);
+s_list * list_new_ptr_free (void *p, s_list *next);
s_list * list_new_s8 (s8 i, s_list *next);
s_list * list_new_s16 (s16 i, s_list *next);
s_list * list_new_s32 (s32 i, s_list *next);
s_list * list_new_s64 (s64 i, s_list *next);
s_list * list_new_str (s8 *p_free, uw size, const s8 *p, s_list *next);
s_list * list_new_str_1 (s8 *p_free, const s8 *p, s_list *next);
+s_list * list_new_struct (const s_sym *module, s_list *next);
+s_list * list_new_struct_with_data (const s_sym *module,
+ bool free_data, void *data,
+ s_list *next);
s_list * list_new_sw (sw i, s_list *next);
s_list * list_new_sym (const s_sym *sym, s_list *next);
s_list * list_new_sym_1 (const s8 *p, s_list *next);
@@ -117,14 +126,17 @@ s_list * list_integer_zero (s_list *list);
s_list * list_map (s_list *list, uw count);
s_list * list_map_1 (s_list *list, const s8 *p);
-s_list * list_ptr (s_list *list, bool free_p, const s_sym *type,
- void *p);
+s_list * list_ptr (s_list *list, void *p);
+s_list * list_ptr_free (s_list *list, void *p);
s_list * list_s8 (s_list *list, s8 i);
s_list * list_s16 (s_list *list, s16 i);
s_list * list_s32 (s_list *list, s32 i);
s_list * list_s64 (s_list *list, s64 i);
s_list * list_str (s_list *list, s8 *p_free, uw size, const s8 *p);
s_list * list_str_1 (s_list *list, s8 *p_free, const s8 *p);
+s_list * list_struct (s_list *list, const s_sym *module);
+s_list * list_struct_with_data (s_list *list, const s_sym *module,
+ bool free_data, void *data);
s_list * list_sw (s_list *list, sw i);
s_list * list_sym (s_list *list, const s_sym *sym);
s_list * list_sym_1 (s_list *list, const s8 *p);
diff --git a/libc3/module.c b/libc3/module.c
index 8b1c706..4d3f73a 100644
--- a/libc3/module.c
+++ b/libc3/module.c
@@ -83,7 +83,7 @@ bool module_maybe_reload (const s_sym *module, s_facts *facts)
s_str * module_path (const s_sym *module, const s_str *prefix,
s_str *dest)
{
- character b = -1;
+ character b = 0;
character c;
s_buf in;
s_buf out;
@@ -96,27 +96,28 @@ s_str * module_path (const s_sym *module, const s_str *prefix,
buf_init_alloc(&out, out_size);
if ((r = buf_write_str(&out, prefix)) < 0)
goto error;
- if ((r = buf_write_s8(&out, '/')) < 0)
- goto error;
while ((r = buf_read_character_utf8(&in, &c)) > 0) {
if (c == '.')
c = '/';
else if (character_is_uppercase(c)) {
if (character_is_lowercase(b)) {
- if ((r = buf_write_s8(&out, '_')) < 0)
+ if ((r = buf_write_1(&out, "_")) < 0)
goto error;
}
+ b = c;
c = character_to_lower(c);
}
+ else
+ b = c;
if ((r = buf_write_character_utf8(&out, c)) < 0)
goto error;
- b = c;
}
if ((r = buf_write_1(&out, FACTS_EXT)) < 0)
goto error;
return buf_to_str(&out, dest);
error:
buf_clean(&out);
+ warnx("module_path: error");
return NULL;
}
@@ -126,18 +127,23 @@ sw module_path_size (const s_sym *module, const s_str *prefix)
character c;
s_buf in;
sw r;
- sw result = 0;
+ sw result;
assert(prefix);
assert(module);
buf_init_str(&in, false, (s_str *) &module->str);
- result += prefix->size;
- result++;
+ result = prefix->size;
while ((r = buf_read_character_utf8(&in, &c)) > 0) {
- if (character_is_uppercase(c))
+ if (c == '.')
+ c = '/';
+ else if (character_is_uppercase(c)) {
if (character_is_lowercase(b))
- result += 1;
+ result += strlen("_");
+ b = c;
+ c = character_to_lower(c);
+ }
+ else
+ b = c;
result += character_utf8_size(c);
- b = c;
}
result += strlen(FACTS_EXT);
return result;
diff --git a/libc3/ptr.c b/libc3/ptr.c
index 8887862..0306f59 100644
--- a/libc3/ptr.c
+++ b/libc3/ptr.c
@@ -15,40 +15,56 @@
#include <stdlib.h>
#include "ptr.h"
-void ptr_clean (s_ptr *ptr)
+void ptr_delete (u_ptr_w *ptr)
{
assert(ptr);
- if (ptr->free)
- free(ptr->p);
+ free(ptr);
}
-void ptr_delete (s_ptr *ptr)
+u_ptr_w * ptr_init (u_ptr_w *ptr, void *p)
{
+ u_ptr_w tmp = {0};
assert(ptr);
- ptr_clean(ptr);
- free(ptr);
+ tmp.p = p;
+ *ptr = tmp;
+ return ptr;
}
-s_ptr * ptr_init (s_ptr *ptr, bool free_p, const s_sym *type, void *p)
+u_ptr_w * ptr_init_copy (u_ptr_w *ptr, const u_ptr_w *src)
{
- s_ptr tmp = {0};
+ u_ptr_w tmp = {0};
assert(ptr);
- tmp.p = p;
- tmp.type = type;
- tmp.free = free_p;
+ assert(src);
+ tmp.p = src->p;
*ptr = tmp;
return ptr;
}
-s_ptr * ptr_new (bool free_p, const s_sym *type, void *p)
+u_ptr_w * ptr_new (void *p)
+{
+ u_ptr_w *ptr;
+ ptr = calloc(1, sizeof(u_ptr_w));
+ if (! ptr) {
+ warn("ptr_new: ptr");
+ return NULL;
+ }
+ if (! ptr_init(ptr, p)) {
+ free(ptr);
+ return NULL;
+ }
+ return ptr;
+}
+
+u_ptr_w * ptr_new_copy (const u_ptr_w *src)
{
- s_ptr *ptr;
- ptr = calloc(1, sizeof(s_ptr));
+ u_ptr_w *ptr;
+ assert(src);
+ ptr = calloc(1, sizeof(u_ptr_w));
if (! ptr) {
warn("ptr_new: ptr");
return NULL;
}
- if (! ptr_init(ptr, free_p, type, p)) {
+ if (! ptr_init_copy(ptr, src)) {
free(ptr);
return NULL;
}
diff --git a/libc3/ptr.h b/libc3/ptr.h
index a45ca5a..425fac7 100644
--- a/libc3/ptr.h
+++ b/libc3/ptr.h
@@ -15,12 +15,13 @@
#include "types.h"
-/* Stack-allocation compatible functions, call ptr_clean after use. */
-void ptr_clean (s_ptr *ptr);
-s_ptr * ptr_init (s_ptr *ptr, bool free, const s_sym *type, void *p);
+/* Stack-allocation compatible functions. */
+u_ptr_w * ptr_init (u_ptr_w *ptr, void *p);
+u_ptr_w * ptr_init_copy (u_ptr_w *ptr, const u_ptr_w *src);
/* Heap-allocation functions, call ptr_delete after use. */
-void ptr_delete (s_ptr *ptr);
-s_ptr * ptr_new (bool free, const s_sym *type, void *p);
+void ptr_delete (u_ptr_w *ptr);
+u_ptr_w * ptr_new (void *p);
+u_ptr_w * ptr_new_copy (const u_ptr_w *src);
#endif /* LIBC3_PTR_H */
diff --git a/libc3/ptr_free.c b/libc3/ptr_free.c
new file mode 100644
index 0000000..27dfa1b
--- /dev/null
+++ b/libc3/ptr_free.c
@@ -0,0 +1,79 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <stdlib.h>
+#include "ptr_free.h"
+
+void ptr_free_clean (u_ptr_w *ptr_free)
+{
+ assert(ptr_free);
+ free(ptr_free->p);
+}
+
+void ptr_free_delete (u_ptr_w *ptr_free)
+{
+ assert(ptr_free);
+ ptr_free_clean(ptr_free);
+ free(ptr_free);
+}
+
+u_ptr_w * ptr_free_init (u_ptr_w *ptr_free, void *p)
+{
+ u_ptr_w tmp = {0};
+ assert(ptr_free);
+ tmp.p = p;
+ *ptr_free = tmp;
+ return ptr_free;
+}
+
+u_ptr_w * ptr_free_init_copy (u_ptr_w *ptr_free, const u_ptr_w *src)
+{
+ u_ptr_w tmp = {0};
+ assert(ptr_free);
+ assert(src);
+ tmp.p = src->p;
+ *ptr_free = tmp;
+ return ptr_free;
+}
+
+u_ptr_w * ptr_free_new (void *p)
+{
+ u_ptr_w *ptr_free;
+ ptr_free = calloc(1, sizeof(u_ptr_w));
+ if (! ptr_free) {
+ warn("ptr_free_new: ptr_free");
+ return NULL;
+ }
+ if (! ptr_free_init(ptr_free, p)) {
+ free(ptr_free);
+ return NULL;
+ }
+ return ptr_free;
+}
+
+u_ptr_w * ptr_free_new_copy (const u_ptr_w *src)
+{
+ u_ptr_w *ptr_free;
+ assert(src);
+ ptr_free = calloc(1, sizeof(u_ptr_w));
+ if (! ptr_free) {
+ warn("ptr_free_new: ptr_free");
+ return NULL;
+ }
+ if (! ptr_free_init_copy(ptr_free, src)) {
+ free(ptr_free);
+ return NULL;
+ }
+ return ptr_free;
+}
diff --git a/libc3/ptr_free.h b/libc3/ptr_free.h
new file mode 100644
index 0000000..a68e7c0
--- /dev/null
+++ b/libc3/ptr_free.h
@@ -0,0 +1,28 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef LIBC3_PTR_FREE_H
+#define LIBC3_PTR_FREE_H
+
+#include "types.h"
+
+/* Stack-allocation compatible functions, call ptr_free_clean
+ after use. */
+void ptr_free_clean (u_ptr_w *ptr_free);
+u_ptr_w * ptr_free_init (u_ptr_w *ptr_free, void *p);
+u_ptr_w * ptr_free_init_copy (u_ptr_w *ptr_free, const u_ptr_w *src);
+
+/* Heap-allocation functions, call ptr_free_delete after use. */
+void ptr_free_delete (u_ptr_w *ptr_free);
+u_ptr_w * ptr_free_new (void *p);
+
+#endif /* LIBC3_PTR_FREE_H */
diff --git a/libc3/s.c.in b/libc3/s.c.in
index e2098d3..f851338 100644
--- a/libc3/s.c.in
+++ b/libc3/s.c.in
@@ -21,18 +21,9 @@
s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (s_bits$) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest)
case TAG_F64:
*dest = (s_bits$) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_s_bits$(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest)
case TAG_UW:
*dest = (s_bits$) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "s_bits$_cast: unknown tag type");
- errx(1, "s_bits$_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("s_bits$_cast: cannot cast %s to s_bits$",
- tag_type_to_string(tag->type));
+ errx(1, "s_bits$_cast: cannot cast %s to s_bits$",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/s16.c b/libc3/s16.c
index 09720b9..9fee096 100644
--- a/libc3/s16.c
+++ b/libc3/s16.c
@@ -21,18 +21,9 @@
s16 * s16_cast (s_tag *tag, s16 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (s16) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ s16 * s16_cast (s_tag *tag, s16 *dest)
case TAG_F64:
*dest = (s16) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_s16(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ s16 * s16_cast (s_tag *tag, s16 *dest)
case TAG_UW:
*dest = (s16) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "s16_cast: unknown tag type");
- errx(1, "s16_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("s16_cast: cannot cast %s to s16",
- tag_type_to_string(tag->type));
+ errx(1, "s16_cast: cannot cast %s to s16",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/s32.c b/libc3/s32.c
index 7d11ac3..8a94b7d 100644
--- a/libc3/s32.c
+++ b/libc3/s32.c
@@ -21,18 +21,9 @@
s32 * s32_cast (s_tag *tag, s32 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (s32) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ s32 * s32_cast (s_tag *tag, s32 *dest)
case TAG_F64:
*dest = (s32) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_s32(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ s32 * s32_cast (s_tag *tag, s32 *dest)
case TAG_UW:
*dest = (s32) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "s32_cast: unknown tag type");
- errx(1, "s32_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("s32_cast: cannot cast %s to s32",
- tag_type_to_string(tag->type));
+ errx(1, "s32_cast: cannot cast %s to s32",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/s64.c b/libc3/s64.c
index f97d2c3..fa51c49 100644
--- a/libc3/s64.c
+++ b/libc3/s64.c
@@ -21,18 +21,9 @@
s64 * s64_cast (s_tag *tag, s64 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (s64) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ s64 * s64_cast (s_tag *tag, s64 *dest)
case TAG_F64:
*dest = (s64) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_s64(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ s64 * s64_cast (s_tag *tag, s64 *dest)
case TAG_UW:
*dest = (s64) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "s64_cast: unknown tag type");
- errx(1, "s64_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("s64_cast: cannot cast %s to s64",
- tag_type_to_string(tag->type));
+ errx(1, "s64_cast: cannot cast %s to s64",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/s8.c b/libc3/s8.c
index e43d5e6..d2dd590 100644
--- a/libc3/s8.c
+++ b/libc3/s8.c
@@ -21,18 +21,9 @@
s8 * s8_cast (s_tag *tag, s8 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (s8) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ s8 * s8_cast (s_tag *tag, s8 *dest)
case TAG_F64:
*dest = (s8) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_s8(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ s8 * s8_cast (s_tag *tag, s8 *dest)
case TAG_UW:
*dest = (s8) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "s8_cast: unknown tag type");
- errx(1, "s8_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("s8_cast: cannot cast %s to s8",
- tag_type_to_string(tag->type));
+ errx(1, "s8_cast: cannot cast %s to s8",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/sources.mk b/libc3/sources.mk
index 7ae53b9..068776b 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -3,59 +3,60 @@ HEADERS = \
abs.h \
arg.h \
array.h \
+ assert.h \
binding.h \
bool.h \
- buf.h \
buf_file.h \
+ buf.h \
buf_inspect.h \
- buf_inspect_s16.h \
buf_inspect_s16_binary.h \
buf_inspect_s16_decimal.h \
+ buf_inspect_s16.h \
buf_inspect_s16_hexadecimal.h \
buf_inspect_s16_octal.h \
- buf_inspect_s32.h \
buf_inspect_s32_binary.h \
buf_inspect_s32_decimal.h \
+ buf_inspect_s32.h \
buf_inspect_s32_hexadecimal.h \
buf_inspect_s32_octal.h \
- buf_inspect_s64.h \
buf_inspect_s64_binary.h \
buf_inspect_s64_decimal.h \
+ buf_inspect_s64.h \
buf_inspect_s64_hexadecimal.h \
buf_inspect_s64_octal.h \
- buf_inspect_s8.h \
buf_inspect_s8_binary.h \
buf_inspect_s8_decimal.h \
+ buf_inspect_s8.h \
buf_inspect_s8_hexadecimal.h \
buf_inspect_s8_octal.h \
- buf_inspect_sw.h \
buf_inspect_sw_binary.h \
buf_inspect_sw_decimal.h \
+ buf_inspect_sw.h \
buf_inspect_sw_hexadecimal.h \
buf_inspect_sw_octal.h \
- buf_inspect_u16.h \
buf_inspect_u16_binary.h \
buf_inspect_u16_decimal.h \
+ buf_inspect_u16.h \
buf_inspect_u16_hexadecimal.h \
buf_inspect_u16_octal.h \
- buf_inspect_u32.h \
buf_inspect_u32_binary.h \
buf_inspect_u32_decimal.h \
+ buf_inspect_u32.h \
buf_inspect_u32_hexadecimal.h \
buf_inspect_u32_octal.h \
- buf_inspect_u64.h \
buf_inspect_u64_binary.h \
buf_inspect_u64_decimal.h \
+ buf_inspect_u64.h \
buf_inspect_u64_hexadecimal.h \
buf_inspect_u64_octal.h \
- buf_inspect_u8.h \
buf_inspect_u8_binary.h \
buf_inspect_u8_decimal.h \
+ buf_inspect_u8.h \
buf_inspect_u8_hexadecimal.h \
buf_inspect_u8_octal.h \
- buf_inspect_uw.h \
buf_inspect_uw_binary.h \
buf_inspect_uw_decimal.h \
+ buf_inspect_uw.h \
buf_inspect_uw_hexadecimal.h \
buf_inspect_uw_octal.h \
buf_parse.h \
@@ -85,16 +86,16 @@ HEADERS = \
f32.h \
f64.h \
fact.h \
- facts.h \
facts_cursor.h \
- facts_spec.h \
+ facts.h \
facts_spec_cursor.h \
- facts_with.h \
+ facts_spec.h \
facts_with_cursor.h \
+ facts_with.h \
file.h \
float.h \
- fn.h \
fn_clause.h \
+ fn.h \
frame.h \
hash.h \
ident.h \
@@ -107,6 +108,7 @@ HEADERS = \
module.h \
operator.h \
ptag.h \
+ ptr_free.h \
ptr.h \
quote.h \
s16.h \
@@ -114,12 +116,12 @@ HEADERS = \
s64.h \
s8.h \
sequence.h \
- set__fact.h \
- set__tag.h \
set_cursor__fact.h \
set_cursor__tag.h \
+ set__fact.h \
set_item__fact.h \
set_item__tag.h \
+ set__tag.h \
sha1.h \
sign.h \
skiplist__fact.h \
@@ -143,6 +145,7 @@ HEADERS = \
ucd.h \
uw.h \
var.h \
+ void.h \
SOURCES = \
abs.c \
@@ -153,53 +156,53 @@ SOURCES = \
buf.c \
buf_file.c \
buf_inspect.c \
- buf_inspect_s16.c \
buf_inspect_s16_binary.c \
+ buf_inspect_s16.c \
buf_inspect_s16_decimal.c \
buf_inspect_s16_hexadecimal.c \
buf_inspect_s16_octal.c \
- buf_inspect_s32.c \
buf_inspect_s32_binary.c \
+ buf_inspect_s32.c \
buf_inspect_s32_decimal.c \
buf_inspect_s32_hexadecimal.c \
buf_inspect_s32_octal.c \
- buf_inspect_s64.c \
buf_inspect_s64_binary.c \
+ buf_inspect_s64.c \
buf_inspect_s64_decimal.c \
buf_inspect_s64_hexadecimal.c \
buf_inspect_s64_octal.c \
- buf_inspect_s8.c \
buf_inspect_s8_binary.c \
+ buf_inspect_s8.c \
buf_inspect_s8_decimal.c \
buf_inspect_s8_hexadecimal.c \
buf_inspect_s8_octal.c \
- buf_inspect_sw.c \
buf_inspect_sw_binary.c \
+ buf_inspect_sw.c \
buf_inspect_sw_decimal.c \
buf_inspect_sw_hexadecimal.c \
buf_inspect_sw_octal.c \
- buf_inspect_u16.c \
buf_inspect_u16_binary.c \
+ buf_inspect_u16.c \
buf_inspect_u16_decimal.c \
buf_inspect_u16_hexadecimal.c \
buf_inspect_u16_octal.c \
- buf_inspect_u32.c \
buf_inspect_u32_binary.c \
+ buf_inspect_u32.c \
buf_inspect_u32_decimal.c \
buf_inspect_u32_hexadecimal.c \
buf_inspect_u32_octal.c \
- buf_inspect_u64.c \
buf_inspect_u64_binary.c \
+ buf_inspect_u64.c \
buf_inspect_u64_decimal.c \
buf_inspect_u64_hexadecimal.c \
buf_inspect_u64_octal.c \
- buf_inspect_u8.c \
buf_inspect_u8_binary.c \
+ buf_inspect_u8.c \
buf_inspect_u8_decimal.c \
buf_inspect_u8_hexadecimal.c \
buf_inspect_u8_octal.c \
- buf_inspect_uw.c \
buf_inspect_uw_binary.c \
+ buf_inspect_uw.c \
buf_inspect_uw_decimal.c \
buf_inspect_uw_hexadecimal.c \
buf_inspect_uw_octal.c \
@@ -251,18 +254,19 @@ SOURCES = \
operator.c \
ptag.c \
ptr.c \
+ ptr_free.c \
quote.c \
s16.c \
s32.c \
s64.c \
s8.c \
sequence.c \
- set__fact.c \
- set__tag.c \
set_cursor__fact.c \
set_cursor__tag.c \
+ set__fact.c \
set_item__fact.c \
set_item__tag.c \
+ set__tag.c \
sign.c \
skiplist__fact.c \
skiplist_node__fact.c \
@@ -271,11 +275,11 @@ SOURCES = \
struct_type.c \
sw.c \
sym.c \
- tag.c \
tag_add.c \
tag_band.c \
tag_bor.c \
tag_bxor.c \
+ tag.c \
tag_div.c \
tag_init.c \
tag_mod.c \
@@ -294,6 +298,7 @@ SOURCES = \
ucd.c \
uw.c \
var.c \
+ void.c \
LO_SOURCES = \
abs.c \
@@ -304,53 +309,53 @@ LO_SOURCES = \
buf.c \
buf_file.c \
buf_inspect.c \
- buf_inspect_s16.c \
buf_inspect_s16_binary.c \
+ buf_inspect_s16.c \
buf_inspect_s16_decimal.c \
buf_inspect_s16_hexadecimal.c \
buf_inspect_s16_octal.c \
- buf_inspect_s32.c \
buf_inspect_s32_binary.c \
+ buf_inspect_s32.c \
buf_inspect_s32_decimal.c \
buf_inspect_s32_hexadecimal.c \
buf_inspect_s32_octal.c \
- buf_inspect_s64.c \
buf_inspect_s64_binary.c \
+ buf_inspect_s64.c \
buf_inspect_s64_decimal.c \
buf_inspect_s64_hexadecimal.c \
buf_inspect_s64_octal.c \
- buf_inspect_s8.c \
buf_inspect_s8_binary.c \
+ buf_inspect_s8.c \
buf_inspect_s8_decimal.c \
buf_inspect_s8_hexadecimal.c \
buf_inspect_s8_octal.c \
- buf_inspect_sw.c \
buf_inspect_sw_binary.c \
+ buf_inspect_sw.c \
buf_inspect_sw_decimal.c \
buf_inspect_sw_hexadecimal.c \
buf_inspect_sw_octal.c \
- buf_inspect_u16.c \
buf_inspect_u16_binary.c \
+ buf_inspect_u16.c \
buf_inspect_u16_decimal.c \
buf_inspect_u16_hexadecimal.c \
buf_inspect_u16_octal.c \
- buf_inspect_u32.c \
buf_inspect_u32_binary.c \
+ buf_inspect_u32.c \
buf_inspect_u32_decimal.c \
buf_inspect_u32_hexadecimal.c \
buf_inspect_u32_octal.c \
- buf_inspect_u64.c \
buf_inspect_u64_binary.c \
+ buf_inspect_u64.c \
buf_inspect_u64_decimal.c \
buf_inspect_u64_hexadecimal.c \
buf_inspect_u64_octal.c \
- buf_inspect_u8.c \
buf_inspect_u8_binary.c \
+ buf_inspect_u8.c \
buf_inspect_u8_decimal.c \
buf_inspect_u8_hexadecimal.c \
buf_inspect_u8_octal.c \
- buf_inspect_uw.c \
buf_inspect_uw_binary.c \
+ buf_inspect_uw.c \
buf_inspect_uw_decimal.c \
buf_inspect_uw_hexadecimal.c \
buf_inspect_uw_octal.c \
@@ -402,18 +407,19 @@ LO_SOURCES = \
operator.c \
ptag.c \
ptr.c \
+ ptr_free.c \
quote.c \
s16.c \
s32.c \
s64.c \
s8.c \
sequence.c \
- set__fact.c \
- set__tag.c \
set_cursor__fact.c \
set_cursor__tag.c \
+ set__fact.c \
set_item__fact.c \
set_item__tag.c \
+ set__tag.c \
sign.c \
skiplist__fact.c \
skiplist_node__fact.c \
@@ -422,11 +428,11 @@ LO_SOURCES = \
struct_type.c \
sw.c \
sym.c \
- tag.c \
tag_add.c \
tag_band.c \
tag_bor.c \
tag_bxor.c \
+ tag.c \
tag_div.c \
tag_init.c \
tag_mod.c \
@@ -445,6 +451,7 @@ LO_SOURCES = \
ucd.c \
uw.c \
var.c \
+ void.c \
../libtommath/bn_cutoffs.c \
../libtommath/bn_mp_2expt.c \
../libtommath/bn_mp_abs.c \
diff --git a/libc3/sources.sh b/libc3/sources.sh
index 63cbf00..228ffce 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-HEADERS='abs.h arg.h array.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_inspect_s16.h buf_inspect_s16_binary.h buf_inspect_s16_decimal.h buf_inspect_s16_hexadecimal.h buf_inspect_s16_octal.h buf_inspect_s32.h buf_inspect_s32_binary.h buf_inspect_s32_decimal.h buf_inspect_s32_hexadecimal.h buf_inspect_s32_octal.h buf_inspect_s64.h buf_inspect_s64_binary.h buf_inspect_s64_decimal.h buf_inspect_s64_hexadecimal.h buf_inspect_s64_octal.h buf_inspect_s8.h buf_inspect_s8_binary.h buf_inspect_s8_decimal.h buf_inspect_s8_hexadecimal.h buf_inspect_s8_octal.h buf_inspect_sw.h buf_inspect_sw_binary.h buf_inspect_sw_decimal.h buf_inspect_sw_hexadecimal.h buf_inspect_sw_octal.h buf_inspect_u16.h buf_inspect_u16_binary.h buf_inspect_u16_decimal.h buf_inspect_u16_hexadecimal.h buf_inspect_u16_octal.h buf_inspect_u32.h buf_inspect_u32_binary.h buf_inspect_u32_decimal.h buf_inspect_u32_hexadecimal.h buf_inspect_u32_octal.h buf_inspect_u64.h buf_inspect_u64_binary.h buf_inspect_u64_decimal.h buf_inspect_u64_hexadecimal.h buf_inspect_u64_octal.h buf_inspect_u8.h buf_inspect_u8_binary.h buf_inspect_u8_decimal.h buf_inspect_u8_hexadecimal.h buf_inspect_u8_octal.h buf_inspect_uw.h buf_inspect_uw_binary.h buf_inspect_uw_decimal.h buf_inspect_uw_hexadecimal.h buf_inspect_uw_octal.h buf_parse.h buf_parse_s16.h buf_parse_s32.h buf_parse_s64.h buf_parse_s8.h buf_parse_sw.h buf_parse_u16.h buf_parse_u32.h buf_parse_u64.h buf_parse_u8.h buf_parse_uw.h buf_save.h c3.h c3_main.h call.h ceiling.h cfn.h character.h compare.h config.h env.h error.h error_handler.h eval.h f32.h f64.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h file.h float.h fn.h fn_clause.h frame.h hash.h ident.h integer.h io.h list.h list_init.h log.h map.h module.h operator.h ptag.h ptr.h quote.h s16.h s32.h s64.h s8.h sequence.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sha1.h sign.h skiplist__fact.h skiplist_node__fact.h str.h struct.h struct_type.h sw.h sym.h tag.h tag_init.h tag_type.h time.h tuple.h type.h types.h u16.h u32.h u64.h u8.h ucd.h uw.h var.h '
-SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c list_init.c log.c map.c module.c operator.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c tag_type.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c '
-LO_SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c list_init.c log.c map.c module.c operator.c ptag.c ptr.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c struct.c struct_type.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c tag_type.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
+HEADERS='abs.h arg.h array.h assert.h binding.h bool.h buf_file.h buf.h buf_inspect.h buf_inspect_s16_binary.h buf_inspect_s16_decimal.h buf_inspect_s16.h buf_inspect_s16_hexadecimal.h buf_inspect_s16_octal.h buf_inspect_s32_binary.h buf_inspect_s32_decimal.h buf_inspect_s32.h buf_inspect_s32_hexadecimal.h buf_inspect_s32_octal.h buf_inspect_s64_binary.h buf_inspect_s64_decimal.h buf_inspect_s64.h buf_inspect_s64_hexadecimal.h buf_inspect_s64_octal.h buf_inspect_s8_binary.h buf_inspect_s8_decimal.h buf_inspect_s8.h buf_inspect_s8_hexadecimal.h buf_inspect_s8_octal.h buf_inspect_sw_binary.h buf_inspect_sw_decimal.h buf_inspect_sw.h buf_inspect_sw_hexadecimal.h buf_inspect_sw_octal.h buf_inspect_u16_binary.h buf_inspect_u16_decimal.h buf_inspect_u16.h buf_inspect_u16_hexadecimal.h buf_inspect_u16_octal.h buf_inspect_u32_binary.h buf_inspect_u32_decimal.h buf_inspect_u32.h buf_inspect_u32_hexadecimal.h buf_inspect_u32_octal.h buf_inspect_u64_binary.h buf_inspect_u64_decimal.h buf_inspect_u64.h buf_inspect_u64_hexadecimal.h buf_inspect_u64_octal.h buf_inspect_u8_binary.h buf_inspect_u8_decimal.h buf_inspect_u8.h buf_inspect_u8_hexadecimal.h buf_inspect_u8_octal.h buf_inspect_uw_binary.h buf_inspect_uw_decimal.h buf_inspect_uw.h buf_inspect_uw_hexadecimal.h buf_inspect_uw_octal.h buf_parse.h buf_parse_s16.h buf_parse_s32.h buf_parse_s64.h buf_parse_s8.h buf_parse_sw.h buf_parse_u16.h buf_parse_u32.h buf_parse_u64.h buf_parse_u8.h buf_parse_uw.h buf_save.h c3.h c3_main.h call.h ceiling.h cfn.h character.h compare.h config.h env.h error.h error_handler.h eval.h f32.h f64.h fact.h facts_cursor.h facts.h facts_spec_cursor.h facts_spec.h facts_with_cursor.h facts_with.h file.h float.h fn_clause.h fn.h frame.h hash.h ident.h integer.h io.h list.h list_init.h log.h map.h module.h operator.h ptag.h ptr_free.h ptr.h quote.h s16.h s32.h s64.h s8.h sequence.h set_cursor__fact.h set_cursor__tag.h set__fact.h set_item__fact.h set_item__tag.h set__tag.h sha1.h sign.h skiplist__fact.h skiplist_node__fact.h str.h struct.h struct_type.h sw.h sym.h tag.h tag_init.h tag_type.h time.h tuple.h type.h types.h u16.h u32.h u64.h u8.h ucd.h uw.h var.h void.h '
+SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16_binary.c buf_inspect_s16.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32_binary.c buf_inspect_s32.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64_binary.c buf_inspect_s64.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8_binary.c buf_inspect_s8.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw_binary.c buf_inspect_sw.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16_binary.c buf_inspect_u16.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32_binary.c buf_inspect_u32.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64_binary.c buf_inspect_u64.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8_binary.c buf_inspect_u8.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw_binary.c buf_inspect_uw.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c list_init.c log.c map.c module.c operator.c ptag.c ptr.c ptr_free.c quote.c s16.c s32.c s64.c s8.c sequence.c set_cursor__fact.c set_cursor__tag.c set__fact.c set_item__fact.c set_item__tag.c set__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c struct.c struct_type.c sw.c sym.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c tag_type.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c void.c '
+LO_SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16_binary.c buf_inspect_s16.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32_binary.c buf_inspect_s32.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64_binary.c buf_inspect_s64.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8_binary.c buf_inspect_s8.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw_binary.c buf_inspect_sw.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16_binary.c buf_inspect_u16.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32_binary.c buf_inspect_u32.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64_binary.c buf_inspect_u64.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8_binary.c buf_inspect_u8.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw_binary.c buf_inspect_uw.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c list_init.c log.c map.c module.c operator.c ptag.c ptr.c ptr_free.c quote.c s16.c s32.c s64.c s8.c sequence.c set_cursor__fact.c set_cursor__tag.c set__fact.c set_item__fact.c set_item__tag.c set__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c struct.c struct_type.c sw.c sym.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag.c tag_div.c tag_init.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c tag_type.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c void.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/libc3/str.c b/libc3/str.c
index 125f858..02629cb 100644
--- a/libc3/str.c
+++ b/libc3/str.c
@@ -321,7 +321,7 @@ s_str * str_new_vf (const char *fmt, va_list ap)
return dest;
}
-sw str_peek_character (const s_str *str, character *c)
+sw str_peek_character_utf8 (const s_str *str, character *c)
{
assert(str);
assert(c);
@@ -400,7 +400,7 @@ sw str_read_character_utf8 (s_str *str, character *c)
sw size;
if (str->size == 0)
return 0;
- size = str_peek_character(str, c);
+ size = str_peek_character_utf8(str, c);
if (size < 0)
return size;
str->size -= size;
diff --git a/libc3/str.h b/libc3/str.h
index f3ab4e8..d98b7c2 100644
--- a/libc3/str.h
+++ b/libc3/str.h
@@ -62,7 +62,7 @@ bool str_has_reserved_characters (const s_str *str);
s_str * str_inspect (const s_str *x, s_str *dest);
sw str_length_utf8 (const s_str *str);
sw str_peek_bool (const s_str *src, bool *p);
-sw str_peek_character (const s_str *src, character *p);
+sw str_peek_character_utf8 (const s_str *src, character *p);
sw str_peek_f32 (const s_str *src, f32 *p);
sw str_peek_f64 (const s_str *src, f64 *p);
sw str_peek_s8 (const s_str *src, s8 *p);
diff --git a/libc3/struct.c b/libc3/struct.c
index 8c38abb..ecf89c0 100644
--- a/libc3/struct.c
+++ b/libc3/struct.c
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include "env.h"
+#include "list.h"
#include "map.h"
#include "struct.h"
#include "struct_type.h"
@@ -38,10 +39,46 @@ void struct_clean (s_struct *s)
i++;
}
}
- free(data);
+ if (s->free)
+ free(data);
struct_type_clean(&s->type);
}
+void struct_delete (s_struct *s)
+{
+ assert(s);
+ struct_clean(s);
+ free(s);
+}
+
+s_struct * struct_init (s_struct *s, const s_sym *module)
+{
+ s_struct tmp = {0};
+ assert(s);
+ assert(module);
+ if (! struct_type_init_from_env(&tmp.type, module, &g_c3_env))
+ return NULL;
+ tmp.free = true;
+ tmp.data = calloc(1, tmp.type.size);
+ if (! tmp.data) {
+ warn("struct_init: data");
+ assert(! "struct_init: data: failed to allocate memory");
+ struct_type_clean(&tmp.type);
+ return NULL;
+ }
+ *s = tmp;
+ return s;
+}
+
+s_struct * struct_init_1 (s_struct *s, const s8 *p)
+{
+ assert(s);
+ assert(p);
+ (void) s;
+ (void) p;
+ return s;
+}
+
s_struct * struct_init_copy (s_struct *s, const s_struct *src)
{
f_clean clean;
@@ -88,29 +125,46 @@ s_struct * struct_init_copy (s_struct *s, const s_struct *src)
return NULL;
}
-void struct_delete (s_struct *s)
-{
- assert(s);
- struct_clean(s);
- free(s);
-}
-
-s_struct * struct_init (s_struct *s, const s_sym *module)
+s_struct * struct_init_from_lists (s_struct *s, const s_sym *module,
+ const s_list *keys,
+ const s_list *values)
{
+ const s_list *k;
+ s_struct tmp = {0};
+ const s_list *v;
assert(s);
assert(module);
- if (! struct_type_init_from_env(&s->type, module, &g_c3_env))
+ assert(list_length(keys) == list_length(values));
+ if (! struct_init(&tmp, module))
return NULL;
- s->data = calloc(s->type.size, 1);
+ k = keys;
+ v = values;
+ while (k && v) {
+ assert(k->tag.type == TAG_SYM);
+ if (k->tag.type != TAG_SYM)
+ errx(1, "struct_init_from_lists: key that is not a symbol: %s",
+ tag_type_to_string(k->tag.type));
+ if (! struct_set(&tmp, k->tag.data.sym, &v->tag))
+ errx(1, "struct_init_from_lists: struct_set(%s) failed",
+ k->tag.data.sym->str.ptr.ps8);
+ k = list_next(k);
+ v = list_next(v);
+ }
+ *s = tmp;
return s;
}
-s_struct * struct_init_1 (s_struct *s, const s8 *p)
+s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
+ bool free_data, void *data)
{
+ s_struct tmp = {0};
assert(s);
- assert(p);
- (void) s;
- (void) p;
+ assert(module);
+ if (! struct_type_init_from_env(&tmp.type, module, &g_c3_env))
+ return NULL;
+ tmp.free = free_data;
+ tmp.data = data;
+ *s = tmp;
return s;
}
@@ -145,3 +199,51 @@ s_struct * struct_new_1 (const s8 *p)
}
return s;
}
+
+s_struct * struct_new_copy (const s_struct *src)
+{
+ s_struct *s;
+ assert(src);
+ s = calloc(1, sizeof(s_struct));
+ if (! s) {
+ warn("struct_new_copy: calloc");
+ return NULL;
+ }
+ if (! struct_init_copy(s, src)) {
+ free(s);
+ return NULL;
+ }
+ return s;
+}
+
+s_struct * struct_set (s_struct *s, const s_sym *key,
+ const s_tag *value)
+{
+ f_clean clean;
+ void *data;
+ const void *data_src;
+ uw i;
+ f_init_copy init_copy;
+ e_tag_type type;
+ assert(s);
+ assert(s->type.map.count);
+ assert(key);
+ assert(value);
+ i = 0;
+ while (i < s->type.map.count) {
+ if (s->type.map.key[i].type == TAG_SYM &&
+ s->type.map.key[i].data.sym == key) {
+ type = s->type.map.value[i].type;
+ clean = tag_type_to_clean(type);
+ init_copy = tag_type_to_init_copy(type);
+ data = (s8 *) s->data + s->type.offset[i];
+ clean(data);
+ data_src = tag_to_const_pointer(value, tag_type_to_sym(type));
+ if (! init_copy(data, data_src))
+ return NULL;
+ return s;
+ }
+ i++;
+ }
+ return NULL;
+}
diff --git a/libc3/struct.h b/libc3/struct.h
index 98eb299..9eb1def 100644
--- a/libc3/struct.h
+++ b/libc3/struct.h
@@ -24,10 +24,23 @@
void struct_clean (s_struct *s);
s_struct * struct_init (s_struct *s, const s_sym *module);
s_struct * struct_init_1 (s_struct *s, const s8 *p);
+s_struct * struct_init_copy (s_struct *s, const s_struct *src);
+s_struct * struct_init_from_lists (s_struct *s, const s_sym *module,
+ const s_list *keys,
+ const s_list *values);
+s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
+ bool free_data, void *data);
/* Heap-allocation functions, call struct_delete after use. */
void struct_delete (s_struct *s);
s_struct * struct_new (const s_sym *module);
s_struct * struct_new_1 (const s8 *p);
+s_struct * struct_new_copy (const s_struct *src);
+s_struct * struct_new_with_data (const s_sym *module, bool free_data,
+ void *data);
+
+/* Operators. */
+s_struct * struct_set (s_struct *s, const s_sym *key,
+ const s_tag *value);
#endif /* LIBC3_STRUCT_H */
diff --git a/libc3/sw.c b/libc3/sw.c
index 7edc3e7..0ec8bde 100644
--- a/libc3/sw.c
+++ b/libc3/sw.c
@@ -21,18 +21,9 @@
sw * sw_cast (s_tag *tag, sw *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (sw) tag->data.character;
return dest;
@@ -42,10 +33,6 @@ sw * sw_cast (s_tag *tag, sw *dest)
case TAG_F64:
*dest = (sw) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_sw(&tag->data.integer);
return dest;
@@ -79,23 +66,11 @@ sw * sw_cast (s_tag *tag, sw *dest)
case TAG_UW:
*dest = (sw) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "sw_cast: unknown tag type");
- errx(1, "sw_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("sw_cast: cannot cast %s to sw",
- tag_type_to_string(tag->type));
+ errx(1, "sw_cast: cannot cast %s to sw",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/sym.c b/libc3/sym.c
index 561c8cc..0820139 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -83,8 +83,16 @@ bool sym_has_reserved_characters (const s_sym *sym)
sw r;
s_str stra;
str_init(&stra, NULL, sym->str.size, sym->str.ptr.p);
- while ((r = str_read_character_utf8(&stra, &c)) > 0) {
- if (sym_character_is_reserved(c))
+ while (1) {
+ if ((r = str_read_character_utf8(&stra, &c)) <= 0)
+ break;
+ if (c == '.') {
+ if ((r = str_peek_character_utf8(&stra, &c)) <= 0)
+ return true;
+ if (! character_is_uppercase(c))
+ return true;
+ }
+ else if (sym_character_is_reserved(c))
return true;
}
if (r < 0)
@@ -127,7 +135,7 @@ s_str * sym_inspect (const s_sym *sym, s_str *dest)
bool sym_is_module (const s_sym *sym)
{
character c;
- if (str_peek_character(&sym->str, &c) > 0)
+ if (str_peek_character_utf8(&sym->str, &c) > 0)
return character_is_uppercase(c);
return false;
}
@@ -216,6 +224,10 @@ f_buf_inspect sym_to_buf_inspect (const s_sym *type)
return (f_buf_inspect) buf_inspect_list;
if (type == sym_1("Ptag"))
return (f_buf_inspect) buf_inspect_ptag;
+ if (type == sym_1("Ptr"))
+ return (f_buf_inspect) buf_inspect_ptr;
+ if (type == sym_1("PtrFree"))
+ return (f_buf_inspect) buf_inspect_ptr_free;
if (type == sym_1("Quote"))
return (f_buf_inspect) buf_inspect_quote;
if (type == sym_1("Str"))
@@ -279,6 +291,10 @@ f_buf_inspect_size sym_to_buf_inspect_size (const s_sym *type)
return (f_buf_inspect_size) buf_inspect_list_size;
if (type == sym_1("Ptag"))
return (f_buf_inspect_size) buf_inspect_ptag_size;
+ if (type == sym_1("Ptr"))
+ return (f_buf_inspect_size) buf_inspect_ptr_size;
+ if (type == sym_1("PtrFree"))
+ return (f_buf_inspect_size) buf_inspect_ptr_free_size;
if (type == sym_1("Quote"))
return (f_buf_inspect_size) buf_inspect_quote_size;
if (type == sym_1("Str"))
@@ -345,7 +361,9 @@ f_clean sym_to_clean (const s_sym *type)
if (type == sym_1("Ptag"))
return NULL;
if (type == sym_1("Ptr"))
- return (f_clean) ptr_clean;
+ return NULL;
+ if (type == sym_1("PtrFree"))
+ return (f_clean) ptr_free_clean;
if (type == sym_1("Quote"))
return (f_clean) quote_clean;
if (type == sym_1("Str"))
@@ -366,70 +384,50 @@ f_clean sym_to_clean (const s_sym *type)
ffi_type * sym_to_ffi_type (const s_sym *sym, ffi_type *result_type)
{
assert(sym);
- if (sym == sym_1("Result") ||
- sym == sym_1("&result")) {
+ if (sym == sym_1("Result")) {
if (! result_type) {
err_puts("sym_to_ffi_type: invalid result type: Result");
return NULL;
}
return result_type;
}
- if (sym->str.ptr.ps8[sym->str.size - 2] == '*')
+ if (sym->str.ptr.ps8[sym->str.size - 1] == '*')
+ return &ffi_type_pointer;
+ if (sym == sym_1("Bool"))
+ return &ffi_type_uint8;
+ if (sym == sym_1("Fn"))
return &ffi_type_pointer;
- if (sym == sym_1("Integer") ||
- sym == sym_1("integer"))
+ if (sym == sym_1("Integer"))
return &ffi_type_pointer;
- if (sym == sym_1("S8") ||
- sym == sym_1("s8"))
+ if (sym == sym_1("List"))
+ return &ffi_type_pointer;
+ if (sym == sym_1("Map"))
+ return &ffi_type_pointer;
+ if (sym == sym_1("S8"))
return &ffi_type_sint8;
- if (sym == sym_1("S16") ||
- sym == sym_1("s16"))
+ if (sym == sym_1("S16"))
return &ffi_type_sint16;
- if (sym == sym_1("S32") ||
- sym == sym_1("s32"))
+ if (sym == sym_1("S32"))
return &ffi_type_sint32;
- if (sym == sym_1("S64") ||
- sym == sym_1("s64"))
+ if (sym == sym_1("S64"))
return &ffi_type_sint64;
if (sym == sym_1("Sym"))
return &ffi_type_pointer;
- if (sym == sym_1("Sw") ||
- sym == sym_1("sw"))
+ if (sym == sym_1("Sw"))
return &ffi_type_slong;
- if (sym == sym_1("Tag") ||
- sym == sym_1("tag"))
+ if (sym == sym_1("Tag"))
return &ffi_type_pointer;
- if (sym == sym_1("U8") ||
- sym == sym_1("u8") ||
- sym == sym_1("Bool") ||
- sym == sym_1("bool"))
+ if (sym == sym_1("U8"))
return &ffi_type_uint8;
- if (sym == sym_1("U16") ||
- sym == sym_1("u16"))
+ if (sym == sym_1("U16"))
return &ffi_type_uint16;
- if (sym == sym_1("U32") ||
- sym == sym_1("u32"))
+ if (sym == sym_1("U32"))
return &ffi_type_uint32;
- if (sym == sym_1("U64") ||
- sym == sym_1("u64"))
+ if (sym == sym_1("U64"))
return &ffi_type_uint64;
- if (sym == sym_1("Uw") ||
- sym == sym_1("uw"))
+ if (sym == sym_1("Uw"))
return &ffi_type_ulong;
- if (sym == sym_1("Bool") ||
- sym == sym_1("bool"))
- return &ffi_type_uchar;
- if (sym == sym_1("Fn") ||
- sym == sym_1("fn"))
- return &ffi_type_pointer;
- if (sym == sym_1("List") ||
- sym == sym_1("list"))
- return &ffi_type_pointer;
- if (sym == sym_1("Map") ||
- sym == sym_1("map"))
- return &ffi_type_pointer;
- if (sym == sym_1("Void") ||
- sym == sym_1("void"))
+ if (sym == sym_1("Void"))
return &ffi_type_void;
err_write_1("sym_to_ffi_type: unknown type: ");
err_write_1(sym->str.ptr.ps8);
@@ -507,138 +505,111 @@ bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
*dest = TAG_PTR;
return true;
}
- if (sym == sym_1("Void") ||
- sym == sym_1("void")) {
+ if (sym == sym_1("Void")) {
*dest = TAG_VOID;
return true;
}
- if (sym == sym_1("Bool") ||
- sym == sym_1("bool")) {
+ if (sym == sym_1("Bool")) {
*dest = TAG_BOOL;
return true;
}
- if (sym == sym_1("Call") ||
- sym == sym_1("call")) {
+ if (sym == sym_1("Call")) {
*dest = TAG_CALL;
return true;
}
- if (sym == sym_1("Cfn") ||
- sym == sym_1("cfn")) {
+ if (sym == sym_1("Cfn")) {
*dest = TAG_CFN;
return true;
}
- if (sym == sym_1("Character") ||
- sym == sym_1("character")) {
+ if (sym == sym_1("Character")) {
*dest = TAG_CHARACTER;
return true;
}
- if (sym == sym_1("F32") ||
- sym == sym_1("f32")) {
+ if (sym == sym_1("F32")) {
*dest = TAG_F32;
return true;
}
- if (sym == sym_1("F64") ||
- sym == sym_1("f64")) {
+ if (sym == sym_1("F64")) {
*dest = TAG_F64;
return true;
}
- if (sym == sym_1("Fn") ||
- sym == sym_1("fn")) {
+ if (sym == sym_1("Fn")) {
*dest = TAG_FN;
return true;
}
- if (sym == sym_1("Ident") ||
- sym == sym_1("ident")) {
+ if (sym == sym_1("Ident")) {
*dest = TAG_IDENT;
return true;
}
- if (sym == sym_1("Integer") ||
- sym == sym_1("integer")) {
+ if (sym == sym_1("Integer")) {
*dest = TAG_INTEGER;
return true;
}
- if (sym == sym_1("Sw") ||
- sym == sym_1("sw")) {
+ if (sym == sym_1("Sw")) {
*dest = TAG_SW;
return true;
}
- if (sym == sym_1("S64") ||
- sym == sym_1("s64")) {
+ if (sym == sym_1("S64")) {
*dest = TAG_S64;
return true;
}
- if (sym == sym_1("S32") ||
- sym == sym_1("s32")) {
+ if (sym == sym_1("S32")) {
*dest = TAG_S32;
return true;
}
- if (sym == sym_1("S16") ||
- sym == sym_1("s16")) {
+ if (sym == sym_1("S16")) {
*dest = TAG_S16;
return true;
}
- if (sym == sym_1("S8") ||
- sym == sym_1("s8")) {
+ if (sym == sym_1("S8")) {
*dest = TAG_S8;
return true;
}
- if (sym == sym_1("U8") ||
- sym == sym_1("u8")) {
+ if (sym == sym_1("U8")) {
*dest = TAG_U8;
return true;
}
- if (sym == sym_1("U16") ||
- sym == sym_1("u16")) {
+ if (sym == sym_1("U16")) {
*dest = TAG_U16;
return true;
}
- if (sym == sym_1("U32") ||
- sym == sym_1("u32")) {
+ if (sym == sym_1("U32")) {
*dest = TAG_U32;
return true;
}
- if (sym == sym_1("U64") ||
- sym == sym_1("u64")) {
+ if (sym == sym_1("U64")) {
*dest = TAG_U64;
return true;
}
- if (sym == sym_1("Uw") ||
- sym == sym_1("uw")) {
+ if (sym == sym_1("Uw")) {
*dest = TAG_UW;
return true;
}
- if (sym == sym_1("List") ||
- sym == sym_1("list")) {
+ if (sym == sym_1("List")) {
*dest = TAG_LIST;
return true;
}
- if (sym == sym_1("Ptag") ||
- sym == sym_1("ptag")) {
+ if (sym == sym_1("Ptag")) {
*dest = TAG_PTAG;
return true;
}
- if (sym == sym_1("Quote") ||
- sym == sym_1("quote")) {
+ if (sym == sym_1("Quote")) {
*dest = TAG_QUOTE;
return true;
}
- if (sym == sym_1("Str") ||
- sym == sym_1("str")) {
+ if (sym == sym_1("Str")) {
*dest = TAG_STR;
return true;
}
- if (sym == sym_1("Sym") ||
- sym == sym_1("sym")) {
+ if (sym == sym_1("Sym")) {
*dest = TAG_SYM;
return true;
}
- if (sym == sym_1("Tag") ||
- sym == sym_1("tag")) {
+ if (sym == sym_1("Tag")) {
*dest = TAG_VOID;
return true;
}
- if (sym == sym_1("Tuple") ||
- sym == sym_1("tuple")) {
+ if (sym == sym_1("Tuple")) {
*dest = TAG_TUPLE;
return true;
}
diff --git a/libc3/tag.c b/libc3/tag.c
index 9920a49..6745794 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -32,8 +32,10 @@
#include "list.h"
#include "map.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "quote.h"
#include "str.h"
+#include "struct.h"
#include "tag.h"
#include "tag_type.h"
#include "time.h"
@@ -172,17 +174,18 @@ void tag_clean (s_tag *tag)
{
assert(tag);
switch (tag->type) {
- case TAG_ARRAY: array_clean(&tag->data.array); break;
- case TAG_CALL: call_clean(&tag->data.call); break;
- case TAG_CFN: cfn_clean(&tag->data.cfn); break;
- case TAG_FN: fn_clean(&tag->data.fn); break;
- case TAG_INTEGER: integer_clean(&tag->data.integer); break;
- case TAG_LIST: list_delete_all(tag->data.list); break;
- case TAG_MAP: map_clean(&tag->data.map); break;
- case TAG_PTR: ptr_clean(&tag->data.ptr); break;
- case TAG_QUOTE: quote_clean(&tag->data.quote); break;
- case TAG_STR: str_clean(&tag->data.str); break;
- case TAG_TUPLE: tuple_clean(&tag->data.tuple); break;
+ case TAG_ARRAY: array_clean(&tag->data.array); break;
+ case TAG_CALL: call_clean(&tag->data.call); break;
+ case TAG_CFN: cfn_clean(&tag->data.cfn); break;
+ case TAG_FN: fn_clean(&tag->data.fn); break;
+ case TAG_INTEGER: integer_clean(&tag->data.integer); break;
+ case TAG_LIST: list_delete_all(tag->data.list); break;
+ case TAG_MAP: map_clean(&tag->data.map); break;
+ case TAG_PTR_FREE: ptr_free_clean(&tag->data.ptr); break;
+ case TAG_QUOTE: quote_clean(&tag->data.quote); break;
+ case TAG_STR: str_clean(&tag->data.str); break;
+ case TAG_STRUCT: struct_clean(&tag->data.struct_); break;
+ case TAG_TUPLE: tuple_clean(&tag->data.tuple); break;
case TAG_BOOL:
case TAG_CHARACTER:
case TAG_F32:
@@ -190,6 +193,7 @@ void tag_clean (s_tag *tag)
case TAG_FACT:
case TAG_IDENT:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_S8:
case TAG_S16:
case TAG_S32:
@@ -265,6 +269,9 @@ s_tag * tag_init_copy (s_tag *tag, const s_tag *src)
case TAG_STR:
str_init_copy(&tag->data.str, &src->data.str);
break;
+ case TAG_STRUCT:
+ struct_init_copy(&tag->data.struct_, &src->data.struct_);
+ break;
case TAG_TUPLE:
tuple_init_copy(&tag->data.tuple, &src->data.tuple);
break;
@@ -276,6 +283,7 @@ s_tag * tag_init_copy (s_tag *tag, const s_tag *src)
case TAG_IDENT:
case TAG_PTAG:
case TAG_PTR:
+ case TAG_PTR_FREE:
case TAG_S8:
case TAG_S16:
case TAG_S32:
@@ -633,168 +641,228 @@ sw tag_size (const s_tag *tag)
return sym_type_size(type);
}
+const void * tag_to_const_pointer (const s_tag *tag, const s_sym *type)
+{
+ e_tag_type tag_type;
+ sym_to_tag_type(type, &tag_type);
+ if (tag->type != tag_type) {
+ assert(! "tag_to_const_pointer: cannot cast");
+ errx(1, "tag_to_const_pointer: cannot cast %s to %s",
+ tag_type_to_string(tag->type),
+ type->str.ptr.ps8);
+ return NULL;
+ }
+ switch (tag->type) {
+ case TAG_ARRAY:
+ return tag->data.array.data;
+ case TAG_BOOL:
+ return &tag->data.bool;
+ case TAG_CALL:
+ return &tag->data.call;
+ case TAG_CFN:
+ return &tag->data.cfn;
+ case TAG_CHARACTER:
+ return &tag->data.character;
+ case TAG_F32:
+ return &tag->data.f32;
+ case TAG_F64:
+ return &tag->data.f64;
+ case TAG_FACT:
+ return &tag->data.fact;
+ case TAG_FN:
+ return &tag->data.fn;
+ case TAG_IDENT:
+ return &tag->data.ident;
+ case TAG_INTEGER:
+ return &tag->data.integer;
+ case TAG_SW:
+ return &tag->data.sw;
+ case TAG_S64:
+ return &tag->data.s64;
+ case TAG_S32:
+ return &tag->data.s32;
+ case TAG_S16:
+ return &tag->data.s16;
+ case TAG_S8:
+ return &tag->data.s8;
+ case TAG_U8:
+ return &tag->data.u8;
+ case TAG_U16:
+ return &tag->data.u16;
+ case TAG_U32:
+ return &tag->data.u32;
+ case TAG_U64:
+ return &tag->data.u64;
+ case TAG_UW:
+ return &tag->data.uw;
+ case TAG_LIST:
+ return &tag->data.list;
+ case TAG_MAP:
+ return &tag->data.map;
+ case TAG_PTAG:
+ return &tag->data.ptag;
+ case TAG_PTR:
+ return &tag->data.ptr.p;
+ case TAG_PTR_FREE:
+ return &tag->data.ptr_free.p;
+ case TAG_QUOTE:
+ return &tag->data.quote;
+ case TAG_STR:
+ return &tag->data.str;
+ case TAG_STRUCT:
+ return &tag->data.struct_;
+ case TAG_SYM:
+ return (void *) tag->data.sym;
+ case TAG_TUPLE:
+ return &tag->data.tuple;
+ case TAG_VAR:
+ return NULL;
+ case TAG_VOID:
+ return NULL;
+ }
+ assert(! "tag_to_const_pointer: invalid tag type");
+ errx(1, "tag_to_const_pointer: invalid tag type");
+ return NULL;
+}
+
void * tag_to_ffi_pointer (s_tag *tag, const s_sym *type)
{
- if (type == sym_1("Tag") ||
- type == sym_1("tag"))
+ if (type == sym_1("Tag"))
return tag;
switch (tag->type) {
case TAG_VOID:
- if (type == sym_1("Void") ||
- type == sym_1("void"))
+ if (type == sym_1("Void"))
return NULL;
goto invalid_type;
case TAG_ARRAY:
- if (type == sym_1("Array") ||
- type == sym_1("array"))
+ if (type == sym_1("Array"))
return tag->data.array.data;
goto invalid_type;
case TAG_BOOL:
- if (type == sym_1("Bool") ||
- type == sym_1("bool"))
+ if (type == sym_1("Bool"))
return &tag->data.bool;
goto invalid_type;
case TAG_CALL:
- if (type == sym_1("Call") ||
- type == sym_1("call"))
+ if (type == sym_1("Call"))
return &tag->data.call;
goto invalid_type;
case TAG_CFN:
- if (type == sym_1("Cfn") ||
- type == sym_1("cfn"))
+ if (type == sym_1("Cfn"))
return &tag->data.cfn;
goto invalid_type;
case TAG_CHARACTER:
- if (type == sym_1("Character") ||
- type == sym_1("character"))
+ if (type == sym_1("Character"))
return &tag->data.character;
goto invalid_type;
case TAG_F32:
- if (type == sym_1("F32") ||
- type == sym_1("f32"))
+ if (type == sym_1("F32"))
return &tag->data.f32;
goto invalid_type;
case TAG_F64:
- if (type == sym_1("f64") ||
- type == sym_1("F64"))
+ if (type == sym_1("f64"))
return &tag->data.f64;
goto invalid_type;
case TAG_FACT:
- if (type == sym_1("Fact") ||
- type == sym_1("fact"))
+ if (type == sym_1("Fact"))
return &tag->data.fact;
goto invalid_type;
case TAG_FN:
- if (type == sym_1("Fn") ||
- type == sym_1("fn"))
+ if (type == sym_1("Fn"))
return &tag->data.fn;
goto invalid_type;
case TAG_IDENT:
- if (type == sym_1("Ident") ||
- type == sym_1("ident"))
+ if (type == sym_1("Ident"))
return &tag->data.ident;
goto invalid_type;
case TAG_INTEGER:
- if (type == sym_1("Integer") ||
- type == sym_1("integer"))
+ if (type == sym_1("Integer"))
return &tag->data.integer;
goto invalid_type;
case TAG_SW:
- if (type == sym_1("Sw") ||
- type == sym_1("sw"))
+ if (type == sym_1("Sw"))
return &tag->data.sw;
goto invalid_type;
case TAG_S64:
- if (type == sym_1("S64") ||
- type == sym_1("s64"))
+ if (type == sym_1("S64"))
return &tag->data.s64;
goto invalid_type;
case TAG_S32:
- if (type == sym_1("S32") ||
- type == sym_1("s32"))
+ if (type == sym_1("S32"))
return &tag->data.s32;
goto invalid_type;
case TAG_S16:
- if (type == sym_1("S16") ||
- type == sym_1("s16"))
+ if (type == sym_1("S16"))
return &tag->data.s16;
goto invalid_type;
case TAG_S8:
- if (type == sym_1("S8") ||
- type == sym_1("s8"))
+ if (type == sym_1("S8"))
return &tag->data.s8;
goto invalid_type;
case TAG_U8:
- if (type == sym_1("U8") ||
- type == sym_1("u8"))
+ if (type == sym_1("U8"))
return &tag->data.u8;
goto invalid_type;
case TAG_U16:
- if (type == sym_1("U16") ||
- type == sym_1("u16"))
+ if (type == sym_1("U16"))
return &tag->data.u16;
goto invalid_type;
case TAG_U32:
- if (type == sym_1("U32") ||
- type == sym_1("u32"))
+ if (type == sym_1("U32"))
return &tag->data.u32;
goto invalid_type;
case TAG_U64:
- if (type == sym_1("U64") ||
- type == sym_1("u64"))
+ if (type == sym_1("U64"))
return &tag->data.u64;
goto invalid_type;
case TAG_UW:
- if (type == sym_1("Uw") ||
- type == sym_1("uw"))
+ if (type == sym_1("Uw"))
return &tag->data.uw;
goto invalid_type;
case TAG_LIST:
- if (type == sym_1("List") ||
- type == sym_1("list"))
+ if (type == sym_1("List"))
return &tag->data.list;
goto invalid_type;
case TAG_MAP:
- if (type == sym_1("Map") ||
- type == sym_1("map"))
+ if (type == sym_1("Map"))
return &tag->data.map;
goto invalid_type;
case TAG_PTAG:
- if (type == sym_1("Ptag") ||
- type == sym_1("ptag"))
+ if (type == sym_1("Ptag"))
return (void *) tag->data.ptag;
goto invalid_type;
case TAG_PTR:
- if (type->str.ptr.ps8[type->str.size - 2] == '*')
+ if (type == sym_1("Ptr"))
return &tag->data.ptr.p;
goto invalid_type;
+ case TAG_PTR_FREE:
+ if (type == sym_1("Ptr") ||
+ type == sym_1("PtrFree"))
+ return &tag->data.ptr_free.p;
+ goto invalid_type;
case TAG_QUOTE:
- if (type == sym_1("Quote") ||
- type == sym_1("quote"))
+ if (type == sym_1("Quote"))
return &tag->data.quote;
goto invalid_type;
case TAG_STR:
- if (type == sym_1("Str") ||
- type == sym_1("str"))
+ if (type == sym_1("Str"))
return &tag->data.str;
- if (type == sym_1("Char*") ||
- type == sym_1("char*"))
+ if (type == sym_1("Char*"))
return (void *) tag->data.str.ptr.ps8;
goto invalid_type;
+ case TAG_STRUCT:
+ if (type == sym_1("Struct"))
+ return &tag->data.struct_;
+ goto invalid_type;
case TAG_SYM:
- if (type == sym_1("Sym") ||
- type == sym_1("sym"))
+ if (type == sym_1("Sym"))
return (void *) &tag->data.sym;
- if (type == sym_1("Str") ||
- type == sym_1("str"))
+ if (type == sym_1("Str"))
return (void *) &tag->data.sym->str;
- if (type == sym_1("Char*") ||
- type == sym_1("char*"))
+ if (type == sym_1("Char*"))
return (void *) tag->data.sym->str.ptr.ps8;
goto invalid_type;
case TAG_TUPLE:
- if (type == sym_1("Tuple") ||
- type == sym_1("tuple"))
+ if (type == sym_1("Tuple"))
return &tag->data.tuple;
goto invalid_type;
case TAG_VAR:
@@ -874,10 +942,14 @@ void * tag_to_pointer (s_tag *tag, const s_sym *type)
return &tag->data.ptag;
case TAG_PTR:
return &tag->data.ptr.p;
+ case TAG_PTR_FREE:
+ return &tag->data.ptr_free.p;
case TAG_QUOTE:
return &tag->data.quote;
case TAG_STR:
return &tag->data.str;
+ case TAG_STRUCT:
+ return &tag->data.struct_;
case TAG_SYM:
return (void *) tag->data.sym;
case TAG_TUPLE:
@@ -893,7 +965,6 @@ void * tag_to_pointer (s_tag *tag, const s_sym *type)
tag_type_to_string(tag->type),
type->str.ptr.ps8);
return NULL;
-
}
const s_sym ** tag_type (const s_tag *tag, const s_sym **dest)
diff --git a/libc3/tag.h b/libc3/tag.h
index 9ab8bdf..989edf9 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -54,19 +54,20 @@ ffi_type tag_to_ffi_type(const s_tag *tag);
const s_sym ** tag_type (const s_tag *tag, const s_sym **type);
/* Operators. */
-s_tag * tag_1 (s_tag *tag, const s8 *p);
-s_tag * tag_integer_cast_to_s16 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_s32 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_s64 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_s8 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_u16 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_u32 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_u64 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_cast_to_u8 (const s_tag *tag, s_tag *dest);
-s_tag * tag_integer_reduce (s_tag *tag);
-s_tag * tag_list_1 (s_tag *tag, const s8 *p);
-void * tag_to_ffi_pointer (s_tag *tag, const s_sym *type);
-void * tag_to_pointer (s_tag *tag, const s_sym *type);
+s_tag * tag_1 (s_tag *tag, const s8 *p);
+s_tag * tag_integer_cast_to_s16 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_s32 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_s64 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_s8 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_u16 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_u32 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_u64 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_cast_to_u8 (const s_tag *tag, s_tag *dest);
+s_tag * tag_integer_reduce (s_tag *tag);
+s_tag * tag_list_1 (s_tag *tag, const s8 *p);
+const void * tag_to_const_pointer (const s_tag *tag, const s_sym *type);
+void * tag_to_ffi_pointer (s_tag *tag, const s_sym *type);
+void * tag_to_pointer (s_tag *tag, const s_sym *type);
/* C3 operators. */
s_tag * tag_add (const s_tag *a, const s_tag *b, s_tag *dest);
diff --git a/libc3/tag_init.c b/libc3/tag_init.c
index 346e4e8..49ecc2c 100644
--- a/libc3/tag_init.c
+++ b/libc3/tag_init.c
@@ -29,8 +29,10 @@
#include "list.h"
#include "map.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "quote.h"
#include "str.h"
+#include "struct.h"
#include "tag.h"
#include "tag_init.h"
#include "time.h"
@@ -185,13 +187,23 @@ s_tag * tag_init_map_1 (s_tag *tag, const s8 *p)
return tag;
}
-s_tag * tag_init_ptr (s_tag *tag, bool free_p, const s_sym *type,
- void *p)
+s_tag * tag_init_ptr (s_tag *tag, void *p)
{
s_tag tmp = {0};
assert(tag);
tmp.type = TAG_PTR;
- if (! ptr_init(&tmp.data.ptr, free_p, type, p))
+ if (! ptr_init(&tmp.data.ptr, p))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_init_ptr_free (s_tag *tag, void *p)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_PTR_FREE;
+ if (! ptr_free_init(&tmp.data.ptr_free, p))
return NULL;
*tag = tmp;
return tag;
@@ -259,6 +271,30 @@ s_tag * tag_init_str_1 (s_tag *tag, s8 *p_free, const s8 *p)
return tag;
}
+s_tag * tag_init_struct (s_tag *tag, const s_sym *module)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_STRUCT;
+ if (! struct_init(&tmp.data.struct_, module))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_init_struct_with_data (s_tag *tag, const s_sym *module,
+ bool free_data, void *data)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_STRUCT;
+ if (! struct_init_with_data(&tmp.data.struct_, module, free_data,
+ data))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_init_sw (s_tag *tag, sw i)
{
s_tag tmp = {0};
@@ -573,7 +609,7 @@ s_tag * tag_new_map_1 (const s8 *p)
return tag;
}
-s_tag * tag_new_ptr (bool free_p, const s_sym *type, void *p)
+s_tag * tag_new_ptr (void *p)
{
s_tag *tag;
if (! (tag = calloc(1, sizeof(s_tag)))) {
@@ -581,7 +617,22 @@ s_tag * tag_new_ptr (bool free_p, const s_sym *type, void *p)
return NULL;
}
tag->type = TAG_PTR;
- if (! ptr_init(&tag->data.ptr, free_p, type, p)) {
+ if (! ptr_init(&tag->data.ptr, p)) {
+ free(tag);
+ return NULL;
+ }
+ return tag;
+}
+
+s_tag * tag_new_ptr_free (void *p)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_ptr_free: calloc");
+ return NULL;
+ }
+ tag->type = TAG_PTR_FREE;
+ if (! ptr_free_init(&tag->data.ptr_free, p)) {
free(tag);
return NULL;
}
@@ -666,6 +717,38 @@ s_tag * tag_new_str_1 (s8 *p_free, const s8 *p)
return tag;
}
+s_tag * tag_new_struct (const s_sym *module)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_struct: calloc");
+ return NULL;
+ }
+ tag->type = TAG_STRUCT;
+ if (! struct_init(&tag->data.struct_, module)) {
+ free(tag);
+ return NULL;
+ }
+ return tag;
+}
+
+s_tag * tag_new_struct_with_data (const s_sym *module, bool free_data,
+ void *data)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_struct_with_data: calloc");
+ return NULL;
+ }
+ tag->type = TAG_STRUCT;
+ if (! struct_init_with_data(&tag->data.struct_, module, free_data,
+ data)) {
+ free(tag);
+ return NULL;
+ }
+ return tag;
+}
+
s_tag * tag_new_sw (sw i)
{
s_tag *tag;
@@ -980,13 +1063,25 @@ s_tag * tag_map_1 (s_tag *tag, const s8 *p)
return tag;
}
-s_tag * tag_ptr (s_tag *tag, bool free_p, const s_sym *type, void *p)
+s_tag * tag_ptr (s_tag *tag, void *p)
{
s_tag tmp = {0};
assert(tag);
tag_clean(tag);
tmp.type = TAG_PTR;
- if (! ptr_init(&tmp.data.ptr, free_p, type, p))
+ if (! ptr_init(&tmp.data.ptr, p))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_ptr_free (s_tag *tag, void *p)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_PTR_FREE;
+ if (! ptr_free_init(&tmp.data.ptr_free, p))
return NULL;
*tag = tmp;
return tag;
@@ -1060,6 +1155,32 @@ s_tag * tag_str_1 (s_tag *tag, s8 *p_free, const s8 *p)
return tag;
}
+s_tag * tag_struct (s_tag *tag, const s_sym *module)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_STRUCT;
+ if (! struct_init(&tmp.data.struct_, module))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_struct_with_data (s_tag *tag, const s_sym *module,
+ bool free_data, void *data)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_STRUCT;
+ if (! struct_init_with_data(&tmp.data.struct_, module, free_data,
+ data))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_sw (s_tag *tag, sw i)
{
s_tag tmp = {0};
diff --git a/libc3/tag_init.h b/libc3/tag_init.h
index c4c48b2..fc1110e 100644
--- a/libc3/tag_init.h
+++ b/libc3/tag_init.h
@@ -32,14 +32,17 @@ s_tag * tag_init_integer_zero (s_tag *tag);
s_tag * tag_init_list (s_tag *tag, s_list *list);
s_tag * tag_init_map (s_tag *tag, uw count);
s_tag * tag_init_map_1 (s_tag *tag, const s8 *p);
-s_tag * tag_init_ptr (s_tag *tag, bool free_p, const s_sym *type,
- void *p);
+s_tag * tag_init_ptr (s_tag *tag, void *p);
+s_tag * tag_init_ptr_free (s_tag *tag, void *p);
s_tag * tag_init_s8 (s_tag *tag, s8 i);
s_tag * tag_init_s16 (s_tag *tag, s16 i);
s_tag * tag_init_s32 (s_tag *tag, s32 i);
s_tag * tag_init_s64 (s_tag *tag, s64 i);
s_tag * tag_init_str (s_tag *tag, s8 *p_free, uw size, const s8 *p);
s_tag * tag_init_str_1 (s_tag *tag, s8 *p_free, const s8 *p);
+s_tag * tag_init_struct (s_tag *tag, const s_sym *module);
+s_tag * tag_init_struct_with_data (s_tag *tag, const s_sym *module,
+ bool free_data, void *data);
s_tag * tag_init_sw (s_tag *tag, sw i);
s_tag * tag_init_sym (s_tag *tag, const s_sym *sym);
s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p);
@@ -71,13 +74,17 @@ s_tag * tag_new_integer_zero (void);
s_tag * tag_new_list (s_list *list);
s_tag * tag_new_map (uw count);
s_tag * tag_new_map_1 (const s8 *p);
-s_tag * tag_new_ptr (bool free_p, const s_sym *type, void *p);
+s_tag * tag_new_ptr (void *p);
+s_tag * tag_new_ptr_free (void *p);
s_tag * tag_new_s8 (s8 i);
s_tag * tag_new_s16 (s16 i);
s_tag * tag_new_s32 (s32 i);
s_tag * tag_new_s64 (s64 i);
s_tag * tag_new_str (s8 *p_free, uw size, const s8 *p);
s_tag * tag_new_str_1 (s8 *p_free, const s8 *p);
+s_tag * tag_new_struct (const s_sym *module);
+s_tag * tag_new_struct_with_data (const s_sym *module, bool free_data,
+ void *data);
s_tag * tag_new_sw (sw i);
s_tag * tag_new_sym (const s_sym *sym);
s_tag * tag_new_sym_1 (const s8 *p);
@@ -109,13 +116,17 @@ s_tag * tag_integer_zero (s_tag *tag);
s_tag * tag_list (s_tag *tag, s_list *list);
s_tag * tag_map (s_tag *tag, uw count);
s_tag * tag_map_1 (s_tag *tag, const s8 *p);
-s_tag * tag_ptr (s_tag *tag, bool free_p, const s_sym *type, void *p);
+s_tag * tag_ptr (s_tag *tag, void *p);
+s_tag * tag_ptr_free (s_tag *tag, void *p);
s_tag * tag_s8 (s_tag *tag, s8 i);
s_tag * tag_s16 (s_tag *tag, s16 i);
s_tag * tag_s32 (s_tag *tag, s32 i);
s_tag * tag_s64 (s_tag *tag, s64 i);
s_tag * tag_str (s_tag *tag, s8 *p_free, uw size, const s8 *p);
s_tag * tag_str_1 (s_tag *tag, s8 *p_free, const s8 *p);
+s_tag * tag_struct (s_tag *tag, const s_sym *module);
+s_tag * tag_struct_with_data (s_tag *tag, const s_sym *module,
+ bool free_data, void *data);
s_tag * tag_sw (s_tag *tag, sw i);
s_tag * tag_sym (s_tag *tag, const s_sym *sym);
s_tag * tag_sym_1 (s_tag *tag, const s8 *p);
diff --git a/libc3/tag_init.rb b/libc3/tag_init.rb
index 6b23b32..5d23dc1 100644
--- a/libc3/tag_init.rb
+++ b/libc3/tag_init.rb
@@ -20,6 +20,7 @@ class TagInit
attr_reader :args_ptr
attr_reader :comma_args
attr_reader :comma_args_proto
+ attr_reader :data_name
attr_reader :first_arg_deref
attr_reader :init_mode
attr_reader :name
@@ -37,9 +38,10 @@ class TagInit
@args = ""
@args_ptr = ""
@args_proto = ""
+ @args_proto_comma = ""
@comma_args = ""
@comma_args_proto = ""
- @args_proto_comma = ""
+ @data_name = @name == "struct" ? "struct_" : @name
@args_list.each do |arg|
@first_arg_deref ||= arg.type != "const s_sym *" &&
@@ -134,7 +136,7 @@ EOF
when :init_mode_none
""
when :init_mode_init
- " if (! #{name}_init#{suffix}(#{name == "list" ? "" : "&"}tmp.data.#{name}#{comma_args}))
+ " if (! #{name}_init#{suffix}(#{name == "list" ? "" : "&"}tmp.data.#{data_name}#{comma_args}))
return NULL;
"
when :init_mode_direct
@@ -147,7 +149,7 @@ EOF
len = strlen(p);
if (! buf_init(&buf, false, len, p))
return NULL;
- if ((r = buf_parse_#{name}(&buf, &tmp.data.#{name}) < 0)
+ if ((r = buf_parse_#{name}(&buf, &tmp.data.#{data_name}) < 0)
return NULL;
else if (r != len) {
#{name}_clean(&tmp);
@@ -179,13 +181,13 @@ EOF
when :init_mode_none
""
when :init_mode_init
- " if (! #{name}_init#{suffix}(#{name == "list" ? "" : "&"}tag->data.#{name}#{comma_args})) {
+ " if (! #{name}_init#{suffix}(#{name == "list" ? "" : "&"}tag->data.#{data_name}#{comma_args})) {
free(tag);
return NULL;
}
"
when :init_mode_direct
- " tag->data.#{name} = #{first_arg_deref};
+ " tag->data.#{data_name} = #{first_arg_deref};
"
when :init_mode_buf_parse
" s_buf buf;
@@ -194,7 +196,7 @@ EOF
len = strlen(p);
if (! buf_init(&buf, false, len, p))
return NULL;
- if ((r = buf_parse_#{name}(&buf, &tmp.data.#{name}) < 0)
+ if ((r = buf_parse_#{name}(&buf, &tmp.data.#{data_name}) < 0)
return NULL;
else if (r != len) {
#{name}_clean(&tmp);
@@ -331,9 +333,9 @@ class TagInitList
[Arg.new("uw", "count")]),
TagInit1.new("map", "1", "TAG_MAP", :init_mode_init),
TagInit.new("ptr", "TAG_PTR", :init_mode_init,
- [Arg.new("bool", "free_p"),
- Arg.new("const s_sym *", "type"),
- Arg.new("void *", "p")]),
+ [Arg.new("void *", "p")]),
+ TagInit.new("ptr_free", "TAG_PTR_FREE", :init_mode_init,
+ [Arg.new("void *", "p")]),
TagInit.new("s8", "TAG_S8", :init_mode_direct,
[Arg.new("s8", "i")]),
TagInit.new("s16", "TAG_S16", :init_mode_direct,
@@ -349,6 +351,12 @@ class TagInitList
TagInit.new("str", "1", "TAG_STR", :init_mode_init,
[Arg.new("s8 *", "p_free"),
Arg.new("const s8 *", "p")]),
+ TagInit.new("struct", "TAG_STRUCT", :init_mode_init,
+ [Arg.new("const s_sym *", "module")]),
+ TagInit.new("struct", "with_data", "TAG_STRUCT", :init_mode_init,
+ [Arg.new("const s_sym *", "module"),
+ Arg.new("bool", "free_data"),
+ Arg.new("void *", "data")]),
TagInit.new("sw", "TAG_SW", :init_mode_direct,
[Arg.new("sw", "i")]),
TagInit.new("sym", "TAG_SYM", :init_mode_direct,
@@ -497,8 +505,10 @@ tag_init_c.content = <<EOF
#include "list.h"
#include "map.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "quote.h"
#include "str.h"
+#include "struct.h"
#include "tag.h"
#include "tag_init.h"
#include "time.h"
@@ -547,8 +557,10 @@ list_init_c.content = <<EOF
#include "list.h"
#include "map.h"
#include "ptr.h"
+#include "ptr_free.h"
#include "quote.h"
#include "str.h"
+#include "struct.h"
#include "tag.h"
#include "list_init.h"
#include "time.h"
diff --git a/libc3/tag_type.c b/libc3/tag_type.c
index 2dea490..0733104 100644
--- a/libc3/tag_type.c
+++ b/libc3/tag_type.c
@@ -10,12 +10,8 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
-#include <assert.h>
#include <err.h>
-#include "buf_inspect.h"
-#include "buf_parse.h"
-#include "sym.h"
-#include "tag_type.h"
+#include "c3.h"
sw tag_type_size (e_tag_type type)
{
@@ -73,11 +69,14 @@ sw tag_type_size (e_tag_type type)
case TAG_PTAG:
return sizeof(p_tag);
case TAG_PTR:
+ case TAG_PTR_FREE:
return sizeof(void *);
case TAG_QUOTE:
return sizeof(s_quote);
case TAG_STR:
return sizeof(s_str);
+ case TAG_STRUCT:
+ return sizeof(s_struct);
case TAG_SYM:
return sizeof(s_sym *);
case TAG_TUPLE:
@@ -144,10 +143,14 @@ f_buf_inspect tag_type_to_buf_inspect (e_tag_type type)
return (f_buf_inspect) buf_inspect_ptag;
case TAG_PTR:
return (f_buf_inspect) buf_inspect_ptr;
+ case TAG_PTR_FREE:
+ return (f_buf_inspect) buf_inspect_ptr_free;
case TAG_QUOTE:
return (f_buf_inspect) buf_inspect_quote;
case TAG_STR:
return (f_buf_inspect) buf_inspect_str;
+ case TAG_STRUCT:
+ return (f_buf_inspect) buf_inspect_struct;
case TAG_SYM:
return (f_buf_inspect) buf_inspect_sym;
case TAG_TUPLE:
@@ -215,10 +218,14 @@ f_buf_inspect_size tag_type_to_buf_inspect_size (e_tag_type type)
return (f_buf_inspect_size) buf_inspect_ptag_size;
case TAG_PTR:
return (f_buf_inspect_size) buf_inspect_ptr_size;
+ case TAG_PTR_FREE:
+ return (f_buf_inspect_size) buf_inspect_ptr_free_size;
case TAG_QUOTE:
return (f_buf_inspect_size) buf_inspect_quote_size;
case TAG_STR:
return (f_buf_inspect_size) buf_inspect_str_size;
+ case TAG_STRUCT:
+ return (f_buf_inspect_size) buf_inspect_struct_size;
case TAG_SYM:
return (f_buf_inspect_size) buf_inspect_sym_size;
case TAG_TUPLE:
@@ -286,10 +293,14 @@ f_buf_parse tag_type_to_buf_parse (e_tag_type type)
return (f_buf_parse) buf_parse_ptag;
case TAG_PTR:
return (f_buf_parse) buf_parse_ptr;
+ case TAG_PTR_FREE:
+ return (f_buf_parse) buf_parse_ptr_free;
case TAG_QUOTE:
return (f_buf_parse) buf_parse_quote;
case TAG_STR:
return (f_buf_parse) buf_parse_str;
+ case TAG_STRUCT:
+ return (f_buf_parse) buf_parse_struct;
case TAG_SYM:
return (f_buf_parse) buf_parse_sym;
case TAG_TUPLE:
@@ -302,6 +313,68 @@ f_buf_parse tag_type_to_buf_parse (e_tag_type type)
return NULL;
}
+f_clean tag_type_to_clean (e_tag_type type)
+{
+ switch (type) {
+ case TAG_ARRAY:
+ return (f_clean) array_clean;
+ case TAG_BOOL:
+ return NULL;
+ case TAG_CALL:
+ return (f_clean) call_clean;
+ case TAG_CFN:
+ return (f_clean) cfn_clean;
+ case TAG_CHARACTER:
+ case TAG_F32:
+ case TAG_F64:
+ case TAG_FACT:
+ return NULL;
+ case TAG_FN:
+ return (f_clean) fn_clean;
+ case TAG_IDENT:
+ return NULL;
+ case TAG_INTEGER:
+ return (f_clean) integer_clean;
+ case TAG_SW:
+ case TAG_S64:
+ case TAG_S32:
+ case TAG_S16:
+ case TAG_S8:
+ case TAG_U8:
+ case TAG_U16:
+ case TAG_U32:
+ case TAG_U64:
+ case TAG_UW:
+ return NULL;
+ case TAG_LIST:
+ return (f_clean) list_clean;
+ case TAG_MAP:
+ return (f_clean) map_clean;
+ case TAG_PTAG:
+ return NULL;
+ case TAG_PTR:
+ return NULL;
+ case TAG_PTR_FREE:
+ return (f_clean) ptr_free_clean;
+ case TAG_QUOTE:
+ return (f_clean) quote_clean;
+ case TAG_STR:
+ return (f_clean) str_clean;
+ case TAG_STRUCT:
+ return (f_clean) struct_clean;
+ case TAG_SYM:
+ return NULL;
+ case TAG_TUPLE:
+ return (f_clean) tuple_clean;
+ case TAG_VAR:
+ case TAG_VOID:
+ return NULL;
+ }
+ assert(! "tag_type_to_clean: invalid tag type");
+ err(1, "tag_type_to_clean: invalid tag type");
+ return NULL;
+}
+
ffi_type * tag_type_to_ffi_type (e_tag_type type)
{
switch (type) {
@@ -334,6 +407,7 @@ ffi_type * tag_type_to_ffi_type (e_tag_type type)
case TAG_PTAG:
return &ffi_type_pointer;
case TAG_PTR:
+ case TAG_PTR_FREE:
return &ffi_type_pointer;
case TAG_QUOTE:
return &ffi_type_pointer;
@@ -349,6 +423,8 @@ ffi_type * tag_type_to_ffi_type (e_tag_type type)
return &ffi_type_slong;
case TAG_STR:
return &ffi_type_pointer;
+ case TAG_STRUCT:
+ return &ffi_type_pointer;
case TAG_SYM:
return &ffi_type_pointer;
case TAG_TUPLE:
@@ -373,6 +449,155 @@ ffi_type * tag_type_to_ffi_type (e_tag_type type)
return &ffi_type_void;
}
+f_hash_update tag_type_to_hash_update (e_tag_type type)
+{
+ switch (type) {
+ case TAG_VOID:
+ return (f_hash_update) hash_update_void;
+ case TAG_ARRAY:
+ case TAG_BOOL:
+ return (f_hash_update) hash_update_bool;
+ case TAG_CALL:
+ return (f_hash_update) hash_update_call;
+ case TAG_CFN:
+ return (f_hash_update) hash_update_cfn;
+ case TAG_CHARACTER:
+ return (f_hash_update) hash_update_character;
+ case TAG_F32:
+ return (f_hash_update) hash_update_f32;
+ case TAG_F64:
+ return (f_hash_update) hash_update_f64;
+ case TAG_FACT:
+ return (f_hash_update) hash_update_fact;
+ case TAG_FN:
+ return (f_hash_update) hash_update_fn;
+ case TAG_IDENT:
+ return (f_hash_update) hash_update_ident;
+ case TAG_INTEGER:
+ return (f_hash_update) hash_update_integer;
+ case TAG_SW:
+ return (f_hash_update) hash_update_sw;
+ case TAG_S64:
+ return (f_hash_update) hash_update_s64;
+ case TAG_S32:
+ return (f_hash_update) hash_update_s32;
+ case TAG_S16:
+ return (f_hash_update) hash_update_s16;
+ case TAG_S8:
+ return (f_hash_update) hash_update_s8;
+ case TAG_U8:
+ return (f_hash_update) hash_update_u8;
+ case TAG_U16:
+ return (f_hash_update) hash_update_u16;
+ case TAG_U32:
+ return (f_hash_update) hash_update_u32;
+ case TAG_U64:
+ return (f_hash_update) hash_update_u64;
+ case TAG_UW:
+ return (f_hash_update) hash_update_uw;
+ case TAG_LIST:
+ return (f_hash_update) hash_update_list;
+ case TAG_MAP:
+ return (f_hash_update) hash_update_map;
+ case TAG_PTAG:
+ return (f_hash_update) hash_update_ptag;
+ case TAG_PTR:
+ return (f_hash_update) hash_update_ptr;
+ case TAG_PTR_FREE:
+ return (f_hash_update) hash_update_ptr_free;
+ case TAG_QUOTE:
+ return (f_hash_update) hash_update_quote;
+ case TAG_STR:
+ return (f_hash_update) hash_update_str;
+ case TAG_STRUCT:
+ return (f_hash_update) hash_update_struct;
+ case TAG_SYM:
+ return (f_hash_update) hash_update_sym;
+ case TAG_TUPLE:
+ return (f_hash_update) hash_update_tuple;
+ case TAG_VAR:
+ return (f_hash_update) hash_update_var;
+ }
+ assert(! "tag_type_to_hash_update: unknown tag type");
+ errx(1, "tag_type_to_hash_update: unknown tag type");
+ return NULL;
+}
+
+f_init_copy tag_type_to_init_copy (e_tag_type type)
+{
+ switch (type) {
+ case TAG_ARRAY:
+ return (f_init_copy) array_init_copy;
+ case TAG_BOOL:
+ return (f_init_copy) bool_init_copy;
+ case TAG_CALL:
+ return (f_init_copy) call_init_copy;
+ case TAG_CFN:
+ return (f_init_copy) cfn_init_copy;
+ case TAG_CHARACTER:
+ return (f_init_copy) character_init_copy;
+ case TAG_F32:
+ return (f_init_copy) f32_init_copy;
+ case TAG_F64:
+ return (f_init_copy) f64_init_copy;
+ case TAG_FACT:
+ return (f_init_copy) fact_init_copy;
+ case TAG_FN:
+ return (f_init_copy) fn_init_copy;
+ case TAG_IDENT:
+ return (f_init_copy) ident_init_copy;
+ case TAG_INTEGER:
+ return (f_init_copy) integer_init_copy;
+ case TAG_SW:
+ return (f_init_copy) sw_init_copy;
+ case TAG_S64:
+ return (f_init_copy) s64_init_copy;
+ case TAG_S32:
+ return (f_init_copy) s32_init_copy;
+ case TAG_S16:
+ return (f_init_copy) s16_init_copy;
+ case TAG_S8:
+ return (f_init_copy) s8_init_copy;
+ case TAG_U8:
+ return (f_init_copy) u8_init_copy;
+ case TAG_U16:
+ return (f_init_copy) u16_init_copy;
+ case TAG_U32:
+ return (f_init_copy) u32_init_copy;
+ case TAG_U64:
+ return (f_init_copy) u64_init_copy;
+ case TAG_UW:
+ return (f_init_copy) uw_init_copy;
+ case TAG_LIST:
+ return (f_init_copy) list_init_copy;
+ case TAG_MAP:
+ return (f_init_copy) map_init_copy;
+ case TAG_PTAG:
+ return (f_init_copy) ptag_init_copy;
+ case TAG_PTR:
+ return (f_init_copy) ptr_init_copy;
+ case TAG_PTR_FREE:
+ return (f_init_copy) ptr_free_init_copy;
+ case TAG_QUOTE:
+ return (f_init_copy) quote_init_copy;
+ case TAG_STR:
+ return (f_init_copy) str_init_copy;
+ case TAG_STRUCT:
+ return (f_init_copy) struct_init_copy;
+ case TAG_SYM:
+ return (f_init_copy) sym_init_copy;
+ case TAG_TUPLE:
+ return (f_init_copy) tuple_init_copy;
+ case TAG_VAR:
+ return (f_init_copy) var_init_copy;
+ case TAG_VOID:
+ return (f_init_copy) void_init_copy;
+ }
+ assert(! "tag_type_to_init_copy: invalid tag type");
+ err(1, "tag_type_to_init_copy: invalid tag type");
+ return NULL;
+}
+
const s8 * tag_type_to_string (e_tag_type type)
{
const s_sym *sym;
@@ -409,9 +634,11 @@ const s_sym * tag_type_to_sym (e_tag_type tag_type)
case TAG_LIST: return sym_1("List");
case TAG_MAP: return sym_1("Map");
case TAG_PTAG: return sym_1("Ptag");
- case TAG_PTR: return sym_1("Void*");
+ case TAG_PTR: return sym_1("Ptr");
+ case TAG_PTR_FREE: return sym_1("PtrFree");
case TAG_QUOTE: return sym_1("Quote");
case TAG_STR: return sym_1("Str");
+ case TAG_STRUCT: return sym_1("Struct");
case TAG_SYM: return sym_1("Sym");
case TAG_TUPLE: return sym_1("Tuple");
case TAG_VAR: return sym_1("Var");
diff --git a/libc3/tag_type.h b/libc3/tag_type.h
index 9816f78..9263519 100644
--- a/libc3/tag_type.h
+++ b/libc3/tag_type.h
@@ -22,9 +22,12 @@
#include "types.h"
sw tag_type_size (e_tag_type type);
+f_clean tag_type_to_clean (e_tag_type type);
f_buf_inspect tag_type_to_buf_inspect (e_tag_type type);
f_buf_inspect_size tag_type_to_buf_inspect_size (e_tag_type type);
f_buf_parse tag_type_to_buf_parse (e_tag_type type);
+f_hash_update tag_type_to_hash_update (e_tag_type type);
+f_init_copy tag_type_to_init_copy (e_tag_type type);
const s8 * tag_type_to_string (e_tag_type type);
const s_sym * tag_type_to_sym (e_tag_type tag_type);
diff --git a/libc3/types.h b/libc3/types.h
index 74f148a..6be11b8 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -111,8 +111,10 @@ typedef enum {
TAG_MAP,
TAG_PTAG,
TAG_PTR,
+ TAG_PTR_FREE,
TAG_QUOTE,
TAG_STR,
+ TAG_STRUCT,
TAG_SYM,
TAG_TUPLE,
TAG_VAR,
@@ -148,7 +150,6 @@ typedef struct list s_list;
typedef struct list s_list_map;
typedef struct log s_log;
typedef struct map s_map;
-typedef struct ptr s_ptr;
typedef struct quote s_quote;
typedef struct sequence s_sequence;
typedef struct str s_str;
@@ -182,6 +183,7 @@ typedef sw (* f_buf_inspect) (s_buf *buf, const void *x);
typedef sw (* f_buf_inspect_size) (const void *x);
typedef sw (* f_buf_parse) (s_buf *buf, void *dest);
typedef void (* f_clean) (void *x);
+typedef void (* f_hash_update) (t_hash *hash, const void *x);
typedef void * (* f_init_copy) (void *x, const void *src);
typedef bool (* f_sequence_load) (s_sequence *seq, void *window);
typedef bool (* f_sequence_render) (s_sequence *seq, void *window,
@@ -234,12 +236,6 @@ struct map {
s_tag *value;
};
-struct ptr {
- void *p;
- const s_sym *type;
- bool free;
-};
-
union ptr_ {
const void *p;
const s8 *ps8;
@@ -410,9 +406,11 @@ union tag_data {
s_list *list;
s_map map;
p_tag ptag;
- s_ptr ptr;
+ u_ptr_w ptr;
+ u_ptr_w ptr_free;
s_quote quote;
s_str str;
+ s_struct struct_;
const s_sym *sym;
s8 s8;
s16 s16;
diff --git a/libc3/u.c.in b/libc3/u.c.in
index 3884e48..c3b5621 100644
--- a/libc3/u.c.in
+++ b/libc3/u.c.in
@@ -20,18 +20,9 @@
u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (u_bits$) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest)
case TAG_F64:
*dest = (u_bits$) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_u_bits$(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest)
case TAG_UW:
*dest = (u_bits$) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "u_bits$_cast: unknown tag type");
- errx(1, "u_bits$_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("u_bits$_cast: cannot cast %s to u_bits$",
- tag_type_to_string(tag->type));
+ errx(1, "u_bits$_cast: cannot cast %s to u_bits$",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/u16.c b/libc3/u16.c
index 301fac6..34c762e 100644
--- a/libc3/u16.c
+++ b/libc3/u16.c
@@ -20,18 +20,9 @@
u16 * u16_cast (s_tag *tag, u16 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (u16) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ u16 * u16_cast (s_tag *tag, u16 *dest)
case TAG_F64:
*dest = (u16) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_u16(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ u16 * u16_cast (s_tag *tag, u16 *dest)
case TAG_UW:
*dest = (u16) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "u16_cast: unknown tag type");
- errx(1, "u16_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("u16_cast: cannot cast %s to u16",
- tag_type_to_string(tag->type));
+ errx(1, "u16_cast: cannot cast %s to u16",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/u32.c b/libc3/u32.c
index 7edb5dd..a22a6f6 100644
--- a/libc3/u32.c
+++ b/libc3/u32.c
@@ -20,18 +20,9 @@
u32 * u32_cast (s_tag *tag, u32 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (u32) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ u32 * u32_cast (s_tag *tag, u32 *dest)
case TAG_F64:
*dest = (u32) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_u32(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ u32 * u32_cast (s_tag *tag, u32 *dest)
case TAG_UW:
*dest = (u32) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "u32_cast: unknown tag type");
- errx(1, "u32_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("u32_cast: cannot cast %s to u32",
- tag_type_to_string(tag->type));
+ errx(1, "u32_cast: cannot cast %s to u32",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/u64.c b/libc3/u64.c
index 07ace50..410e765 100644
--- a/libc3/u64.c
+++ b/libc3/u64.c
@@ -20,18 +20,9 @@
u64 * u64_cast (s_tag *tag, u64 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (u64) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ u64 * u64_cast (s_tag *tag, u64 *dest)
case TAG_F64:
*dest = (u64) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_u64(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ u64 * u64_cast (s_tag *tag, u64 *dest)
case TAG_UW:
*dest = (u64) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "u64_cast: unknown tag type");
- errx(1, "u64_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("u64_cast: cannot cast %s to u64",
- tag_type_to_string(tag->type));
+ errx(1, "u64_cast: cannot cast %s to u64",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/u8.c b/libc3/u8.c
index 8501bbf..9a1bb2d 100644
--- a/libc3/u8.c
+++ b/libc3/u8.c
@@ -20,18 +20,9 @@
u8 * u8_cast (s_tag *tag, u8 *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (u8) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ u8 * u8_cast (s_tag *tag, u8 *dest)
case TAG_F64:
*dest = (u8) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_u8(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ u8 * u8_cast (s_tag *tag, u8 *dest)
case TAG_UW:
*dest = (u8) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "u8_cast: unknown tag type");
- errx(1, "u8_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("u8_cast: cannot cast %s to u8",
- tag_type_to_string(tag->type));
+ errx(1, "u8_cast: cannot cast %s to u8",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/uw.c b/libc3/uw.c
index 3304628..3a7faaf 100644
--- a/libc3/uw.c
+++ b/libc3/uw.c
@@ -20,18 +20,9 @@
uw * uw_cast (s_tag *tag, uw *dest)
{
switch (tag->type) {
- case TAG_VOID:
- *dest = 0;
- return dest;
- case TAG_ARRAY:
- goto ko;
case TAG_BOOL:
*dest = tag->data.bool ? 1 : 0;
return dest;
- case TAG_CALL:
- goto ko;
- case TAG_CFN:
- goto ko;
case TAG_CHARACTER:
*dest = (uw) tag->data.character;
return dest;
@@ -41,10 +32,6 @@ uw * uw_cast (s_tag *tag, uw *dest)
case TAG_F64:
*dest = (uw) tag->data.f64;
return dest;
- case TAG_FACT:
- case TAG_FN:
- case TAG_IDENT:
- goto ko;
case TAG_INTEGER:
*dest = integer_to_uw(&tag->data.integer);
return dest;
@@ -78,23 +65,11 @@ uw * uw_cast (s_tag *tag, uw *dest)
case TAG_UW:
*dest = (uw) tag->data.uw;
return dest;
- case TAG_LIST:
- case TAG_MAP:
- case TAG_PTAG:
- case TAG_PTR:
- case TAG_QUOTE:
- case TAG_STR:
- case TAG_SYM:
- case TAG_TUPLE:
- case TAG_VAR:
- goto ko;
+ default:
+ break;
}
- assert(! "uw_cast: unknown tag type");
- errx(1, "uw_cast: unknown tag type: %d", tag->type);
- return 0;
- ko:
- warnx("uw_cast: cannot cast %s to uw",
- tag_type_to_string(tag->type));
+ errx(1, "uw_cast: cannot cast %s to uw",
+ tag_type_to_string(tag->type));
return 0;
}
diff --git a/libc3/void.c b/libc3/void.c
new file mode 100644
index 0000000..41086ac
--- /dev/null
+++ b/libc3/void.c
@@ -0,0 +1,45 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include "assert.h"
+#include "void.h"
+#include "buf.h"
+#include "buf_inspect.h"
+#include "io.h"
+
+void * void_init_copy (void *dest, const void *src)
+{
+ (void) dest;
+ (void) src;
+ return dest;
+}
+
+s_str * void_inspect (void *b, s_str *dest)
+{
+ sw size;
+ s_buf tmp;
+ (void) b;
+ size = buf_inspect_void_size(NULL);
+ if (size < 0) {
+ assert(! "void_inspect: error");
+ return NULL;
+ }
+ buf_init_alloc(&tmp, size);
+ buf_inspect_void(&tmp, NULL);
+ assert(tmp.wpos == tmp.size);
+ if (tmp.wpos != tmp.size) {
+ buf_clean(&tmp);
+ err_write_1("void_inspect: buf_inspect_void");
+ return NULL;
+ }
+ return buf_to_str(&tmp, dest);
+}
diff --git a/libc3/void.h b/libc3/void.h
new file mode 100644
index 0000000..542ee8c
--- /dev/null
+++ b/libc3/void.h
@@ -0,0 +1,30 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/**
+ * @file void.h
+ * @brief Void operations. Be careful :)
+ *
+ * Structure to manipulate void. Nothing really.
+ */
+#ifndef LIBC3_VOID_H
+#define LIBC3_VOID_H
+
+#include "types.h"
+
+/* Stack-allocation compatible functions */
+void * void_init_copy (void *dest, const void *src);
+
+/* Observers */
+s_str * void_inspect (void *b, s_str *dest);
+
+#endif /* LIBC3_VOID_H */
diff --git a/libc3/window/cairo/quartz/sources.mk b/libc3/window/cairo/quartz/sources.mk
index 8ae455f..89d9c96 100644
--- a/libc3/window/cairo/quartz/sources.mk
+++ b/libc3/window/cairo/quartz/sources.mk
@@ -1,18 +1,18 @@
# sources.mk generated by update_sources
HEADERS = \
quartz_to_xkbcommon.h \
- window_cairo_quartz.h \
window_cairo_quartz_app_delegate.h \
- window_cairo_quartz_view.h \
+ window_cairo_quartz.h \
window_cairo_quartz_view_controller.h \
+ window_cairo_quartz_view.h \
xkbquartz.h \
SOURCES = \
quartz_to_xkbcommon.c \
OBJC_SOURCES = \
- window_cairo_quartz.m \
window_cairo_quartz_app_delegate.m \
- window_cairo_quartz_view.m \
+ window_cairo_quartz.m \
window_cairo_quartz_view_controller.m \
+ window_cairo_quartz_view.m \
diff --git a/libc3/window/cairo/quartz/sources.sh b/libc3/window/cairo/quartz/sources.sh
index 03cc583..baf8b5a 100644
--- a/libc3/window/cairo/quartz/sources.sh
+++ b/libc3/window/cairo/quartz/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-HEADERS='quartz_to_xkbcommon.h window_cairo_quartz.h window_cairo_quartz_app_delegate.h window_cairo_quartz_view.h window_cairo_quartz_view_controller.h xkbquartz.h '
+HEADERS='quartz_to_xkbcommon.h window_cairo_quartz_app_delegate.h window_cairo_quartz.h window_cairo_quartz_view_controller.h window_cairo_quartz_view.h xkbquartz.h '
SOURCES='quartz_to_xkbcommon.c '
-OBJC_SOURCES='window_cairo_quartz.m window_cairo_quartz_app_delegate.m window_cairo_quartz_view.m window_cairo_quartz_view_controller.m '
+OBJC_SOURCES='window_cairo_quartz_app_delegate.m window_cairo_quartz.m window_cairo_quartz_view_controller.m window_cairo_quartz_view.m '
diff --git a/libc3/window/sdl2/demo/earth.c b/libc3/window/sdl2/demo/earth.c
index 4452656..b7e02a0 100644
--- a/libc3/window/sdl2/demo/earth.c
+++ b/libc3/window/sdl2/demo/earth.c
@@ -32,7 +32,6 @@ bool earth_load (s_sequence *seq,
s_gl_camera *camera;
s_gl_sphere *sphere;
(void) window;
- // FIXME: leak
camera = gl_camera_new(window->w, window->h);
if (! camera)
return false;
@@ -42,12 +41,13 @@ bool earth_load (s_sequence *seq,
if (! tag_map(&seq->tag, 3))
return false;
map = &seq->tag.data.map;
- tag_init_sym_1(map->key + 0, "camera");
- tag_init_ptr(map->value + 0, true, sym_1("GL.Camera"), camera);
- tag_init_sym_1(map->key + 1, "camera_rot_x_speed");
- tag_init_f64(map->value + 1, 0.01);
- tag_init_sym_1(map->key + 2, "sphere");
- tag_init_ptr(map->value + 2, true, sym_1("GL.Sphere"), sphere);
+ tag_init_sym_1( map->key + 0, "camera");
+ tag_init_ptr_free( map->value + 0, camera);
+ tag_init_sym_1( map->key + 1, "camera_rot_x_speed");
+ tag_init_f64( map->value + 1, 0.01);
+ tag_init_sym_1( map->key + 2, "sphere");
+ tag_init_struct_with_data(map->value + 2, sym_1("GL.Sphere"),
+ true, sphere);
return true;
}
diff --git a/libc3/window/sdl2/demo/window_sdl2_demo.c b/libc3/window/sdl2/demo/window_sdl2_demo.c
index 1f05af1..8399818 100644
--- a/libc3/window/sdl2/demo/window_sdl2_demo.c
+++ b/libc3/window/sdl2/demo/window_sdl2_demo.c
@@ -37,6 +37,7 @@ static bool window_sdl2_demo_render (s_window_sdl2 *window,
void *context);
static bool window_sdl2_demo_resize (s_window_sdl2 *window,
uw w, uw h);
+static void window_sdl2_demo_unload (s_window_sdl2 *window);
int main (int argc, char **argv)
{
@@ -53,11 +54,15 @@ int main (int argc, char **argv)
window.load = window_sdl2_demo_load;
window.render = window_sdl2_demo_render;
window.resize = window_sdl2_demo_resize;
+ window.unload = window_sdl2_demo_unload;
if (! window_sdl2_run(&window)) {
err_puts("window_sdl2_run -> false");
+ window_sdl2_clean(&window);
c3_clean(NULL);
+ SDL_Quit();
return g_c3_exit_code;
}
+ window_sdl2_clean(&window);
c3_clean(NULL);
SDL_Quit();
return 0;
@@ -247,3 +252,16 @@ bool window_sdl2_demo_resize (s_window_sdl2 *window,
(void) h;
return true;
}
+
+void window_sdl2_demo_unload (s_window_sdl2 *window)
+{
+ assert(window);
+ (void) window;
+ sdl2_font_clean(&g_font_courier_new);
+ sdl2_sprite_clean(&g_sprite_toaster);
+ sdl2_sprite_clean(&g_sprite_toast);
+ sdl2_font_clean(&g_font_flies);
+ sdl2_sprite_clean(&g_sprite_fly);
+ sdl2_sprite_clean(&g_sprite_dead_fly);
+ sdl2_sprite_clean(&g_sprite_earth);
+}
diff --git a/libc3/window/sdl2/gl_sphere.c b/libc3/window/sdl2/gl_sphere.c
index 57c07e9..24b625b 100644
--- a/libc3/window/sdl2/gl_sphere.c
+++ b/libc3/window/sdl2/gl_sphere.c
@@ -37,14 +37,15 @@ s_gl_sphere * gl_sphere_init (s_gl_sphere *sphere, uw segments_u,
uw j;
s_gl_3d *p;
f64 r;
+ s_gl_sphere tmp = {0};
f64 z;
assert(sphere);
if (segments_u < 3)
segments_u = 3;
if (segments_v < 2)
segments_v = 2;
- sphere->segments_u = segments_u;
- sphere->segments_v = segments_v;
+ tmp.segments_u = segments_u;
+ tmp.segments_v = segments_v;
p = calloc(segments_u * segments_v + 2, sizeof(s_gl_3d));
if (! p) {
err_write_1("gl_sphere_init(");
@@ -54,7 +55,7 @@ s_gl_sphere * gl_sphere_init (s_gl_sphere *sphere, uw segments_u,
err_write_1("): failed to allocate memory");
return NULL;
}
- sphere->vertex = p;
+ tmp.vertex = p;
i = 0;
while (i < segments_v) {
angle_i = (i + 1) * M_PI / (segments_v + 1);
@@ -78,6 +79,7 @@ s_gl_sphere * gl_sphere_init (s_gl_sphere *sphere, uw segments_u,
p->x = 0.0;
p->y = 0.0;
p->z = -1.0;
+ *sphere = tmp;
return sphere;
}
diff --git a/libc3/window/sdl2/sources.mk b/libc3/window/sdl2/sources.mk
index 6b262d8..a35b520 100644
--- a/libc3/window/sdl2/sources.mk
+++ b/libc3/window/sdl2/sources.mk
@@ -1,8 +1,8 @@
# sources.mk generated by update_sources
HEADERS = \
- gl.h \
gl_camera.h \
gl_cylinder.h \
+ gl.h \
gl_sphere.h \
sdl2_font.h \
sdl2_sprite.h \
diff --git a/libc3/window/sdl2/sources.sh b/libc3/window/sdl2/sources.sh
index 8a15de9..9514a7c 100644
--- a/libc3/window/sdl2/sources.sh
+++ b/libc3/window/sdl2/sources.sh
@@ -1,3 +1,3 @@
# sources.sh generated by update_sources
-HEADERS='gl.h gl_camera.h gl_cylinder.h gl_sphere.h sdl2_font.h sdl2_sprite.h types.h window_sdl2.h '
+HEADERS='gl_camera.h gl_cylinder.h gl.h gl_sphere.h sdl2_font.h sdl2_sprite.h types.h window_sdl2.h '
SOURCES='gl.c gl_camera.c gl_cylinder.c gl_sphere.c sdl2_font.c sdl2_sprite.c window_sdl2.c '
diff --git a/libc3/window/sdl2/types.h b/libc3/window/sdl2/types.h
index 974fa4e..f97fadc 100644
--- a/libc3/window/sdl2/types.h
+++ b/libc3/window/sdl2/types.h
@@ -72,6 +72,8 @@ typedef bool (*f_window_sdl2_sequence_render) (s_sequence *seq,
s_window_sdl2 *window,
void *context);
+typedef void (*f_window_sdl2_unload) (s_window_sdl2 *window);
+
/* 1 */
struct gl_2d {
f64 x;
@@ -149,7 +151,9 @@ struct window_sdl2 {
s_sequence *sequence;
uw sequence_count;
uw sequence_pos;
+ s_tag tag; // TODO: move sequence to tag
const s8 *title;
+ f_window_sdl2_unload unload;
uw gl_w;
uw gl_h;
float dpi;
diff --git a/libc3/window/sdl2/window_sdl2.c b/libc3/window/sdl2/window_sdl2.c
index 60a0cee..ae3576e 100644
--- a/libc3/window/sdl2/window_sdl2.c
+++ b/libc3/window/sdl2/window_sdl2.c
@@ -15,98 +15,107 @@
#include <stdlib.h>
#include <xkbcommon/xkbcommon.h>
#include <libc3/tag.h>
+#include "../window.h"
#include "window_sdl2.h"
static bool g_window_sdl2_initialized = false;
-s_window_sdl2 * window_sdl2_init (s_window_sdl2 *window,
- sw x, sw y, uw w, uw h,
- const s8 *title,
- uw sequence_count)
+void window_sdl2_clean (s_window_sdl2 *window)
{
- assert(window);
- window->x = x;
- window->y = y;
- window->w = w;
- window->h = h;
- window->fullscreen = false;
- window->button = window_sdl2_button_default;
- window->key = window_sdl2_key_default;
- window->load = window_sdl2_load_default;
- window->motion = window_sdl2_motion_default;
- window->render = window_sdl2_render_default;
- window->resize = window_sdl2_resize_default;
- window->sdl_window = NULL;
- window->sequence = calloc(sequence_count, sizeof(s_sequence));
- window->sequence_count = sequence_count;
- window->sequence_pos = 0;
- window->title = title ? title : "C3.Window.Sdl2";
- return window;
+ window_clean((s_window *) window);
}
-bool window_sdl2_button_default (s_window_sdl2 *window, u8 button,
- sw x, sw y)
+bool window_sdl2_default_button_cb (s_window_sdl2 *window, u8 button,
+ sw x, sw y)
{
assert(window);
(void) window;
(void) button;
(void) x;
(void) y;
- printf("window_sdl2_button_default: %d (%ld, %ld)\n",
+ printf("window_sdl2_default_button_cb: %d (%ld, %ld)\n",
(int) button, x, y);
return true;
}
-bool window_sdl2_key_default (s_window_sdl2 *window, SDL_Keysym *keysym)
+bool window_sdl2_default_key_cb (s_window_sdl2 *window,
+ SDL_Keysym *keysym)
{
assert(window);
assert(keysym);
(void) window;
(void) keysym;
- printf("window_sdl2_key_default: %d\n", keysym->sym);
+ printf("window_sdl2_default_key_cb: %d\n", keysym->sym);
return true;
}
-bool window_sdl2_load_default (s_window_sdl2 *window)
+bool window_sdl2_default_load_cb (s_window_sdl2 *window)
{
assert(window);
(void) window;
- printf("window_sdl2_load_default\n");
+ printf("window_sdl2_default_load_cb\n");
return true;
}
-bool window_sdl2_motion_default (s_window_sdl2 *window, sw x, sw y)
+bool window_sdl2_default_motion_cb (s_window_sdl2 *window, sw x, sw y)
{
assert(window);
(void) window;
(void) x;
(void) y;
/*
- printf("window_sdl2_motion_default (%ld, %ld)\n", x, y);
+ printf("window_sdl2_default_motion_cb (%ld, %ld)\n", x, y);
*/
return true;
}
-bool window_sdl2_render_default (s_window_sdl2 *window,
- void *sdl_window)
+bool window_sdl2_default_render_cb (s_window_sdl2 *window,
+ void *sdl_window)
{
(void) window;
(void) sdl_window;
assert(window);
- printf("window_sdl2_render_default\n");
+ printf("window_sdl2_default_render_cb\n");
return true;
}
-bool window_sdl2_resize_default (s_window_sdl2 *window, uw w, uw h)
+bool window_sdl2_default_resize_cb (s_window_sdl2 *window, uw w, uw h)
{
assert(window);
(void) window;
(void) w;
(void) h;
- printf("window_sdl2_resize_default: %lu x %lu\n", w, h);
+ printf("window_sdl2_default_resize_cb: %lu x %lu\n", w, h);
return true;
}
+void window_sdl2_default_unload_cb (s_window_sdl2 *window)
+{
+ assert(window);
+ (void) window;
+ printf("window_sdl2_default_unload_cb\n");
+}
+
+s_window_sdl2 * window_sdl2_init (s_window_sdl2 *window,
+ sw x, sw y, uw w, uw h,
+ const s8 *title,
+ uw sequence_count)
+{
+ s_window_sdl2 tmp = {0};
+ assert(window);
+ title = title ? title : "C3.Window.Sdl2";
+ window_init((s_window *) &tmp, x, y, w, h, title, sequence_count);
+ tmp.button = window_sdl2_default_button_cb;
+ tmp.key = window_sdl2_default_key_cb;
+ tmp.load = window_sdl2_default_load_cb;
+ tmp.motion = window_sdl2_default_motion_cb;
+ tmp.render = window_sdl2_default_render_cb;
+ tmp.resize = window_sdl2_default_resize_cb;
+ tmp.unload = window_sdl2_default_unload_cb;
+ *window = tmp;
+ return window;
+}
+
bool window_sdl2_run (s_window_sdl2 *window)
{
SDL_GLContext context;
diff --git a/libc3/window/sdl2/window_sdl2.h b/libc3/window/sdl2/window_sdl2.h
index 596023f..b5f1503 100644
--- a/libc3/window/sdl2/window_sdl2.h
+++ b/libc3/window/sdl2/window_sdl2.h
@@ -15,25 +15,33 @@
#include "types.h"
+/* Stack-allocation compatible functions, call window_sdl2_clean
+ after use. */
+void window_sdl2_clean (s_window_sdl2 *window);
s_window_sdl2 * window_sdl2_init (s_window_sdl2 *window,
sw x, sw y, uw w, uw h,
const s8 *title,
uw sequence_count);
+
+/* Operators. */
bool window_sdl2_run (s_window_sdl2 *window);
+/* Sequences. */
s_sequence * window_sdl2_sequence_init
(s_sequence *sequence, f64 duration, const s8 *title,
f_window_sdl2_sequence_load load,
f_window_sdl2_sequence_render render);
-/* callbacks */
-bool window_sdl2_button_default (s_window_sdl2 *window, u8 button,
- sw x, sw y);
-bool window_sdl2_key_default (s_window_sdl2 *window, SDL_Keysym *keysym);
-bool window_sdl2_load_default (s_window_sdl2 *window);
-bool window_sdl2_motion_default (s_window_sdl2 *window, sw x, sw y);
-bool window_sdl2_render_default (s_window_sdl2 *window,
+/* Callbacks. */
+bool window_sdl2_default_button_cb (s_window_sdl2 *window, u8 button,
+ sw x, sw y);
+bool window_sdl2_default_key_cb (s_window_sdl2 *window,
+ SDL_Keysym *keysym);
+bool window_sdl2_default_load_cb (s_window_sdl2 *window);
+bool window_sdl2_default_motion_cb (s_window_sdl2 *window, sw x, sw y);
+bool window_sdl2_default_render_cb (s_window_sdl2 *window,
void *context);
-bool window_sdl2_resize_default (s_window_sdl2 *window, uw w, uw h);
+bool window_sdl2_default_resize_cb (s_window_sdl2 *window, uw w, uw h);
+void window_sdl2_default_unload_cb (s_window_sdl2 *window);
#endif /* LIBC3_WINDOW_SDL2_H */
diff --git a/sources.mk b/sources.mk
index e505fa6..b35395b 100644
--- a/sources.mk
+++ b/sources.mk
@@ -1,59 +1,59 @@
# sources.mk generated by update_sources
C3_CONFIGURES = \
c3c/configure \
- c3s/configure \
c3s/update_sources \
- ic3/configure \
+ c3s/configure \
ic3/update_sources \
- libc3/configure \
+ ic3/configure \
libc3/update_sources \
- libc3/window/configure \
+ libc3/configure \
libc3/window/update_sources \
- libc3/window/cairo/demo/configure \
- libc3/window/cairo/demo/update_sources \
- libc3/window/cairo/xcb/demo/configure \
+ libc3/window/configure \
+ libc3/window/sdl2/update_sources \
+ libc3/window/sdl2/demo/macos/configure \
+ libc3/window/sdl2/demo/update_sources \
+ libc3/window/sdl2/demo/configure \
+ libc3/window/sdl2/configure \
+ libc3/window/cairo/update_sources \
+ libc3/window/cairo/xcb/update_sources \
libc3/window/cairo/xcb/demo/update_sources \
+ libc3/window/cairo/xcb/demo/configure \
libc3/window/cairo/xcb/configure \
- libc3/window/cairo/xcb/update_sources \
- libc3/window/cairo/configure \
- libc3/window/cairo/update_sources \
- libc3/window/cairo/quartz/demo/configure \
- libc3/window/cairo/quartz/demo/update_sources \
- libc3/window/cairo/quartz/configure \
- libc3/window/cairo/quartz/update_sources \
- libc3/window/cairo/win32/demo/configure \
+ libc3/window/cairo/demo/update_sources \
+ libc3/window/cairo/demo/configure \
+ libc3/window/cairo/win32/update_sources \
libc3/window/cairo/win32/demo/update_sources \
+ libc3/window/cairo/win32/demo/configure \
libc3/window/cairo/win32/configure \
- libc3/window/cairo/win32/update_sources \
- libc3/window/sdl2/demo/macos/configure \
- libc3/window/sdl2/demo/configure \
- libc3/window/sdl2/demo/update_sources \
- libc3/window/sdl2/configure \
- libc3/window/sdl2/update_sources \
- libtommath/configure \
+ libc3/window/cairo/quartz/update_sources \
+ libc3/window/cairo/quartz/demo/update_sources \
+ libc3/window/cairo/quartz/demo/configure \
+ libc3/window/cairo/quartz/configure \
+ libc3/window/cairo/configure \
libtommath/update_sources \
- test/configure \
+ libtommath/configure \
test/update_sources \
+ test/configure \
ucd2c/configure \
C3_MAKEFILES = \
c3c/Makefile \
c3s/Makefile \
ic3/Makefile \
- libc3/Makefile \
libc3/gen.mk \
- libc3/window/Makefile \
- libc3/window/cairo/demo/Makefile \
+ libc3/window/sdl2/demo/macos/Makefile \
+ libc3/window/sdl2/demo/Makefile \
+ libc3/window/sdl2/Makefile \
libc3/window/cairo/xcb/demo/Makefile \
libc3/window/cairo/xcb/Makefile \
- libc3/window/cairo/Makefile \
- libc3/window/cairo/quartz/demo/Makefile \
- libc3/window/cairo/quartz/Makefile \
+ libc3/window/cairo/demo/Makefile \
libc3/window/cairo/win32/demo/Makefile \
libc3/window/cairo/win32/Makefile \
- libc3/window/sdl2/demo/macos/Makefile \
- libc3/window/sdl2/demo/Makefile \
- libc3/window/sdl2/Makefile \
+ libc3/window/cairo/quartz/demo/Makefile \
+ libc3/window/cairo/quartz/Makefile \
+ libc3/window/cairo/Makefile \
+ libc3/window/Makefile \
+ libc3/Makefile \
libtommath/Makefile \
test/Makefile \
ucd2c/Makefile \
@@ -64,433 +64,438 @@ C3_C_SOURCES = \
c3s/c3s.c \
c3s/buf_readline.h \
ic3/buf_linenoise.h \
- ic3/ic3.c \
ic3/linenoise.c \
ic3/buf_linenoise.c \
- libc3/buf_inspect_s_base.c.in \
- libc3/type.h \
- libc3/fact.c \
- libc3/time.h \
- libc3/fn.h \
- libc3/s16.h \
- libc3/buf_inspect_s8_octal.h \
- libc3/log.c \
- libc3/error.h \
- libc3/buf_inspect_u64_octal.h \
- libc3/set_item.h.in \
- libc3/compare.c \
- libc3/buf_inspect_s8_binary.h \
- libc3/buf_inspect_uw_hexadecimal.h \
- libc3/uw.c \
- libc3/eval.c \
- libc3/set__fact.c \
- libc3/sym.h \
- libc3/env.h \
- libc3/cfn.c \
- libc3/buf_inspect_u16_octal.h \
- libc3/u.h.in \
+ ic3/ic3.c \
libc3/buf_parse_s16.c \
- libc3/s8.h \
+ libc3/tuple.h \
+ libc3/u.c.in \
+ libc3/file.c \
+ libc3/struct.c \
+ libc3/buf_inspect_sw_decimal.h \
libc3/quote.h \
- libc3/buf_inspect_s32.h \
- libc3/buf_inspect.c \
- libc3/buf_parse_u.h.in \
- libc3/skiplist_node__fact.h \
- libc3/skiplist__fact.c \
- libc3/tag_add.c \
- libc3/buf_inspect_s32_hexadecimal.h \
- libc3/ceiling.h \
- libc3/struct_type.h \
- libc3/list.c \
- libc3/buf_inspect_u64.c \
- libc3/facts.h \
- libc3/tag_type.h \
- libc3/buf_inspect_u16_decimal.c \
- libc3/tag_sub.c \
- libc3/facts_with_cursor.c \
- libc3/buf_inspect_sw_decimal.c \
- libc3/facts_cursor.c \
- libc3/buf_inspect_u64_binary.h \
- libc3/buf_inspect_sw_hexadecimal.h \
- libc3/buf_inspect_s32_decimal.h \
- libc3/u16.h \
- libc3/buf_inspect_s64_octal.h \
- libc3/buf_inspect_u8_binary.h \
- libc3/buf_inspect_s8.h \
- libc3/buf_inspect_s16_octal.h \
- libc3/ucd.c \
- libc3/buf_inspect_s16_binary.h \
- libc3/tuple.c \
- libc3/buf_inspect_uw_octal.h \
+ libc3/tag_bxor.c \
+ libc3/call.h \
libc3/buf_parse_u8.c \
- libc3/tag.h \
- libc3/float.h \
- libc3/buf_inspect_u_base.c.in \
- libc3/buf_parse_u16.c \
- libc3/buf_inspect_u16_hexadecimal.h \
- libc3/buf_inspect_s8_decimal.c \
- libc3/buf_inspect_u32.h \
- libc3/array.c \
- libc3/buf_parse_sw.h \
- libc3/set.h.in \
- libc3/s.c.in \
- libc3/buf_parse_s.c.in \
- libc3/map.h \
- libc3/skiplist.h.in \
- libc3/set__tag.h \
- libc3/buf_inspect_s64.c \
- libc3/io.c \
- libc3/set_item__tag.c \
- libc3/sequence.c \
- libc3/types.h \
- libc3/buf_inspect_uw.c \
- libc3/buf_inspect_u32_binary.c \
- libc3/buf_inspect_s64_decimal.h \
- libc3/set_cursor.c.in \
- libc3/ident.c \
- libc3/buf_inspect_s64_hexadecimal.c \
+ libc3/list_init.h \
+ libc3/buf_inspect_u32_hexadecimal.c \
+ libc3/buf_inspect_u16_binary.h \
+ libc3/buf_inspect_u64_decimal.c \
+ libc3/buf_inspect_u32_octal.h \
+ libc3/tuple.c \
+ libc3/facts.c \
+ libc3/buf_save.c \
libc3/bool.h \
- libc3/s.h.in \
- libc3/set.c.in \
+ libc3/buf_parse_s16.h \
+ libc3/buf_parse_u16.c \
+ libc3/tag_sub.c \
libc3/skiplist.c.in \
- libc3/operator.h \
- libc3/fn_clause.h \
- libc3/buf_parse_s.h.in \
+ libc3/buf_inspect_sw_hexadecimal.c \
libc3/buf_inspect_s16.c \
- libc3/binding.c \
- libc3/ptag.h \
- libc3/buf_parse_s32.h \
- libc3/tag_bor.c \
- libc3/var.h \
- libc3/tag_shift_left.c \
- libc3/set_item__fact.h \
- libc3/ptr.c \
- libc3/u8.c \
- libc3/set_cursor.h.in \
- libc3/f32.c \
- libc3/buf_inspect_sw_octal.h \
- libc3/c3.h \
- libc3/arg.h \
- libc3/buf_inspect_u8_hexadecimal.c \
- libc3/buf_inspect_u32_hexadecimal.h \
- libc3/buf_parse_u64.c \
- libc3/module.c \
- libc3/frame.h \
- libc3/buf_inspect_s16_decimal.c \
- libc3/file.h \
- libc3/sw.h \
- libc3/s32.c \
- libc3/error_handler.c \
- libc3/str.c \
libc3/buf_parse.h \
- libc3/buf_inspect_uw_binary.c \
- libc3/buf_inspect_uw_decimal.h \
- libc3/facts_spec_cursor.c \
- libc3/tag_init.c \
- libc3/u64.h \
- libc3/buf_inspect_u_base.h.in \
- libc3/buf_inspect_s32_octal.h \
- libc3/f64.h \
- libc3/buf_inspect_u8_octal.h \
- libc3/buf_inspect_s64_binary.c \
- libc3/buf_inspect_u64_hexadecimal.c \
- libc3/buf_inspect_u16_binary.c \
- libc3/buf_save.h \
- libc3/buf_inspect_u16.c \
- libc3/buf_inspect_s8_hexadecimal.c \
- libc3/u.c.in \
- libc3/buf_inspect_sw.h \
- libc3/facts_with.c \
+ libc3/set_item.h.in \
+ libc3/buf_parse_u64.h \
libc3/buf_parse_u.c.in \
- libc3/buf_parse_u32.h \
- libc3/set_cursor__fact.c \
- libc3/buf.h \
- libc3/set_cursor__tag.h \
- libc3/buf_inspect_s16_hexadecimal.h \
- libc3/buf_inspect_u32_decimal.h \
- libc3/buf_parse_uw.c \
- libc3/buf_parse_s64.c \
- libc3/abs.h \
- libc3/list_init.c \
- libc3/buf_inspect_sw_binary.c \
- libc3/buf_parse_s8.h \
- libc3/call.h \
- libc3/sign.c \
- libc3/buf_inspect_u8_decimal.h \
- libc3/character.h \
- libc3/buf_inspect_u64_decimal.h \
- libc3/buf_inspect_s_base.h.in \
- libc3/buf_inspect_u32_octal.h \
+ libc3/sign.h \
+ libc3/buf_parse_s64.h \
+ libc3/s32.c \
+ libc3/eval.c \
+ libc3/array.c \
libc3/u32.c \
- libc3/hash.c \
- libc3/buf_file.h \
- libc3/struct.h \
- libc3/integer.c \
- libc3/buf_inspect_u8.c \
- libc3/facts_spec.c \
- libc3/buf_inspect_s32_binary.h \
- libc3/set_item.c.in \
- libc3/tag_bxor.c \
- libc3/s64.h \
- libc3/buf_inspect_u16_decimal.h \
- libc3/tag_type.c \
- libc3/facts.c \
- libc3/buf_inspect_u64.h \
- libc3/buf_inspect_sw_decimal.h \
- libc3/facts_with_cursor.h \
- libc3/skiplist_node__fact.c \
- libc3/buf_inspect.h \
+ libc3/tag_div.c \
+ libc3/buf_inspect_s64_decimal.c \
+ libc3/license.c \
+ libc3/types.h \
libc3/quote.c \
- libc3/buf_inspect_s32.c \
- libc3/skiplist_node.h.in \
- libc3/s8.c \
- libc3/buf_parse_s16.h \
- libc3/list.h \
+ libc3/buf_inspect_s_base.h.in \
libc3/struct_type.c \
- libc3/ceiling.c \
- libc3/buf_inspect_s.h.in \
- libc3/buf_inspect_s32_hexadecimal.c \
- libc3/skiplist__fact.h \
- libc3/uw.h \
- libc3/buf_inspect_uw_hexadecimal.c \
- libc3/buf_inspect_s8_binary.c \
- libc3/tag_mod.c \
- libc3/compare.h \
- libc3/buf_inspect_u64_octal.c \
- libc3/buf_inspect_u16_octal.c \
- libc3/tag_band.c \
- libc3/cfn.h \
- libc3/env.c \
- libc3/set__fact.h \
+ libc3/facts_cursor.c \
+ libc3/buf_inspect_s16_binary.h \
libc3/sym.c \
+ libc3/binding.h \
+ libc3/set_cursor.h.in \
+ libc3/s8.c \
+ libc3/buf.c \
+ libc3/void.c \
+ libc3/buf_inspect_u16_octal.c \
+ libc3/tag_mod.c \
+ libc3/fn.c \
+ libc3/buf_inspect_u32_decimal.c \
+ libc3/buf_parse_u32.c \
+ libc3/buf_inspect_u8.h \
+ libc3/skiplist_node__fact.c \
+ libc3/void.h \
+ libc3/var.c \
+ libc3/tag_add.c \
libc3/eval.h \
+ libc3/buf_inspect_s.h.in \
+ libc3/skiplist__fact.h \
+ libc3/buf_inspect.c \
+ libc3/buf_inspect_s16_octal.h \
+ libc3/character.c \
+ libc3/buf_inspect_u8_decimal.h \
+ libc3/f32.c \
+ libc3/buf_inspect_s16_decimal.h \
+ libc3/buf_inspect_s8_hexadecimal.c \
libc3/c3_main.h \
+ libc3/skiplist__fact.c \
+ libc3/tag_init.h \
+ libc3/buf_inspect_uw_hexadecimal.h \
+ libc3/buf_inspect_s64_hexadecimal.c \
+ libc3/f64.h \
+ libc3/tag_mul.c \
+ libc3/skiplist_node__fact.h \
+ libc3/buf_inspect_s32.c \
+ libc3/buf_inspect_s16_binary.c \
+ libc3/buf_inspect_u32_octal.c \
+ libc3/arg.c \
+ libc3/buf_inspect_u8_octal.c \
libc3/buf_inspect_s8_octal.c \
- libc3/s16.c \
- libc3/fn.c \
- libc3/time.c \
- libc3/fact.h \
- libc3/type.c \
- libc3/error.c \
- libc3/log.h \
- libc3/sequence.h \
- libc3/set_item__tag.h \
- libc3/io.h \
- libc3/buf_inspect_s64.h \
+ libc3/buf_inspect_u64.h \
+ libc3/facts_spec.c \
+ libc3/buf_inspect_s64_decimal.h \
+ libc3/bool.c \
+ libc3/f64.c \
+ libc3/buf_inspect_u64_binary.c \
+ libc3/u8.c \
+ libc3/buf_inspect_uw.h \
+ libc3/fn_clause.c \
+ libc3/tag_shift_right.c \
+ libc3/buf_inspect_sw_octal.h \
+ libc3/tag.h \
+ libc3/set_cursor__tag.h \
+ libc3/abs.h \
+ libc3/struct_type.h \
+ libc3/buf_inspect_sw_octal.c \
+ libc3/buf_inspect_u.h.in \
+ libc3/list_init.c \
+ libc3/buf_inspect_u64_hexadecimal.c \
+ libc3/tag.c \
+ libc3/buf_inspect_s32_binary.h \
+ libc3/buf_inspect_s64_octal.c \
libc3/buf_inspect_s64_hexadecimal.h \
+ libc3/buf_inspect_s16.h \
+ libc3/module.h \
+ libc3/cfn.h \
+ libc3/tag_shift_left.c \
+ libc3/file.h \
+ libc3/u16.c \
+ libc3/ptr.c \
+ libc3/buf_inspect_sw_binary.c \
+ libc3/uw.c \
+ libc3/set__tag.c \
+ libc3/skiplist_node.c.in \
+ libc3/io.h \
+ libc3/facts_with.c \
+ libc3/buf_parse_s.h.in \
+ libc3/buf_file.c \
+ libc3/buf_parse.c \
+ libc3/ucd.c \
+ libc3/set__fact.c \
+ libc3/skiplist_node.h.in \
+ libc3/buf_inspect_u8.c \
+ libc3/buf_inspect_uw_binary.h \
+ libc3/s16.h \
+ libc3/ptag.c \
+ libc3/buf_inspect_sw_hexadecimal.h \
+ libc3/hash.c \
+ libc3/facts_with_cursor.c \
+ libc3/buf_inspect_u16_octal.h \
+ libc3/set__tag.h \
+ libc3/assert.h \
+ libc3/buf_parse_uw.h \
+ libc3/s64.h \
+ libc3/buf_inspect_u64_octal.c \
+ libc3/env.c \
+ libc3/buf_inspect_u16_binary.c \
+ libc3/set_item.c.in \
+ libc3/c3.c \
+ libc3/buf_inspect_sw_binary.h \
+ libc3/fact.h \
+ libc3/buf_inspect_s64_octal.h \
+ libc3/buf_parse_u64.c \
+ libc3/buf_inspect_s32_decimal.h \
+ libc3/buf_parse_s64.c \
+ libc3/list.h \
+ libc3/fn.h \
+ libc3/facts_with_cursor.h \
+ libc3/buf_inspect_s32_decimal.c \
+ libc3/s16.c \
+ libc3/buf_inspect_u32_decimal.h \
+ libc3/buf_inspect_u32_hexadecimal.h \
+ libc3/list.c \
+ libc3/sym.h \
+ libc3/var.h \
+ libc3/call.c \
+ libc3/log.c \
+ libc3/buf_inspect_s64_binary.h \
+ libc3/io.c \
+ libc3/fact.c \
+ libc3/sign.c \
+ libc3/buf_inspect_uw_octal.h \
+ libc3/u.h.in \
+ libc3/f32.h \
+ libc3/set_cursor__fact.c \
+ libc3/skiplist.h.in \
+ libc3/ptr_free.c \
libc3/window/types.h \
libc3/window/window.h \
- libc3/window/cairo/demo/toasters.h \
- libc3/window/cairo/demo/window_cairo_demo.c \
- libc3/window/cairo/demo/lightspeed.h \
- libc3/window/cairo/demo/flies.h \
- libc3/window/cairo/demo/bg_rect.h \
- libc3/window/cairo/demo/window_cairo_demo.h \
- libc3/window/cairo/demo/toasters.c \
- libc3/window/cairo/demo/lightspeed.c \
- libc3/window/cairo/demo/flies.c \
- libc3/window/cairo/demo/bg_rect.c \
+ libc3/window/sdl2/gl_sphere.h \
+ libc3/window/sdl2/gl_camera.c \
+ libc3/window/sdl2/types.h \
+ libc3/window/sdl2/sdl2_sprite.h \
+ libc3/window/sdl2/sdl2_sprite.c \
+ libc3/window/sdl2/gl_cylinder.c \
+ libc3/window/sdl2/window_sdl2.c \
+ libc3/window/sdl2/gl_camera.h \
+ libc3/window/sdl2/sdl2_font.c \
+ libc3/window/sdl2/demo/window_sdl2_demo.h \
+ libc3/window/sdl2/demo/window_sdl2_demo.c \
+ libc3/window/sdl2/demo/lightspeed.c \
+ libc3/window/sdl2/demo/toasters.c \
+ libc3/window/sdl2/demo/bg_rect.h \
+ libc3/window/sdl2/demo/lightspeed.h \
+ libc3/window/sdl2/demo/flies.h \
+ libc3/window/sdl2/demo/earth.c \
+ libc3/window/sdl2/demo/bg_rect.c \
+ libc3/window/sdl2/demo/flies.c \
+ libc3/window/sdl2/demo/earth.h \
+ libc3/window/sdl2/demo/toasters.h \
+ libc3/window/sdl2/sdl2_font.h \
+ libc3/window/sdl2/gl_sphere.c \
+ libc3/window/sdl2/gl_cylinder.h \
+ libc3/window/sdl2/gl.h \
+ libc3/window/sdl2/window_sdl2.h \
+ libc3/window/sdl2/gl.c \
+ libc3/window/cairo/types.h \
+ libc3/window/cairo/window_cairo.h \
+ libc3/window/cairo/cairo_sprite.h \
+ libc3/window/cairo/xcb/window_cairo_xcb.c \
libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c \
libc3/window/cairo/xcb/window_cairo_xcb.h \
libc3/window/cairo/xcb/config.h \
- libc3/window/cairo/xcb/window_cairo_xcb.c \
- libc3/window/cairo/types.h \
- libc3/window/cairo/window_cairo.c \
libc3/window/cairo/cairo_font.h \
- libc3/window/cairo/cairo_sprite.h \
+ libc3/window/cairo/cairo_font.c \
+ libc3/window/cairo/demo/lightspeed.c \
+ libc3/window/cairo/demo/toasters.c \
+ libc3/window/cairo/demo/bg_rect.h \
+ libc3/window/cairo/demo/lightspeed.h \
+ libc3/window/cairo/demo/flies.h \
+ libc3/window/cairo/demo/bg_rect.c \
+ libc3/window/cairo/demo/flies.c \
+ libc3/window/cairo/demo/window_cairo_demo.c \
+ libc3/window/cairo/demo/window_cairo_demo.h \
+ libc3/window/cairo/demo/toasters.h \
+ libc3/window/cairo/win32/vk_to_xkbcommon.h \
+ libc3/window/cairo/win32/window_cairo_win32.c \
+ libc3/window/cairo/win32/demo/window_cairo_win32_demo.c \
+ libc3/window/cairo/win32/window_cairo_win32.h \
+ libc3/window/cairo/win32/vk_to_xkbcommon.c \
+ libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h \
+ libc3/window/cairo/quartz/window_cairo_quartz_view.h \
+ libc3/window/cairo/quartz/quartz_to_xkbcommon.h \
libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c \
+ libc3/window/cairo/quartz/xkbquartz.h \
libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h \
libc3/window/cairo/quartz/quartz_to_xkbcommon.c \
libc3/window/cairo/quartz/window_cairo_quartz.h \
- libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h \
- libc3/window/cairo/quartz/quartz_to_xkbcommon.h \
- libc3/window/cairo/quartz/xkbquartz.h \
- libc3/window/cairo/quartz/window_cairo_quartz_view.h \
- libc3/window/cairo/window_cairo.h \
- libc3/window/cairo/cairo_font.c \
- libc3/window/cairo/win32/demo/window_cairo_win32_demo.c \
- libc3/window/cairo/win32/vk_to_xkbcommon.c \
- libc3/window/cairo/win32/window_cairo_win32.h \
- libc3/window/cairo/win32/vk_to_xkbcommon.h \
- libc3/window/cairo/win32/window_cairo_win32.c \
libc3/window/cairo/cairo_sprite.c \
- libc3/window/sdl2/demo/toasters.h \
- libc3/window/sdl2/demo/earth.h \
- libc3/window/sdl2/demo/lightspeed.h \
- libc3/window/sdl2/demo/flies.h \
- libc3/window/sdl2/demo/window_sdl2_demo.c \
- libc3/window/sdl2/demo/bg_rect.h \
- libc3/window/sdl2/demo/toasters.c \
- libc3/window/sdl2/demo/earth.c \
- libc3/window/sdl2/demo/lightspeed.c \
- libc3/window/sdl2/demo/flies.c \
- libc3/window/sdl2/demo/bg_rect.c \
- libc3/window/sdl2/demo/window_sdl2_demo.h \
- libc3/window/sdl2/gl_sphere.h \
- libc3/window/sdl2/gl_camera.h \
- libc3/window/sdl2/sdl2_font.c \
- libc3/window/sdl2/gl.c \
- libc3/window/sdl2/window_sdl2.c \
- libc3/window/sdl2/gl_cylinder.h \
- libc3/window/sdl2/types.h \
- libc3/window/sdl2/sdl2_sprite.h \
- libc3/window/sdl2/gl_camera.c \
- libc3/window/sdl2/gl_sphere.c \
- libc3/window/sdl2/gl_cylinder.c \
- libc3/window/sdl2/window_sdl2.h \
- libc3/window/sdl2/gl.h \
- libc3/window/sdl2/sdl2_font.h \
- libc3/window/sdl2/sdl2_sprite.c \
+ libc3/window/cairo/window_cairo.c \
libc3/window/window.c \
+ libc3/set_item__tag.c \
+ libc3/abs.c \
libc3/ident.h \
- libc3/buf_inspect_s64_decimal.c \
- libc3/buf_inspect_u32_binary.h \
- libc3/buf_inspect_uw.h \
- libc3/buf_inspect_u.c.in \
+ libc3/s32.h \
libc3/buf_parse_sw.c \
- libc3/array.h \
+ libc3/facts_spec_cursor.c \
+ libc3/ident.c \
+ libc3/buf_inspect_u8_decimal.c \
+ libc3/facts_spec_cursor.h \
+ libc3/struct.h \
+ libc3/time.h \
+ libc3/buf_inspect_u8_hexadecimal.h \
+ libc3/buf_inspect_u64_binary.h \
+ libc3/u64.h \
+ libc3/buf_inspect_u16_hexadecimal.c \
+ libc3/arg.h \
+ libc3/buf_inspect_u32_binary.h \
+ libc3/hash.h \
+ libc3/fn_clause.h \
+ libc3/buf_inspect_uw_octal.c \
+ libc3/facts.h \
+ libc3/str.h \
+ libc3/buf_parse_s32.h \
+ libc3/sha1.h \
+ libc3/u16.h \
+ libc3/buf_inspect_s32.h \
+ libc3/ptr_free.h \
+ libc3/sw.h \
+ libc3/type.h \
+ libc3/buf_parse_s32.c \
+ libc3/set_item__tag.h \
+ libc3/ceiling.h \
+ libc3/buf_inspect_s8_hexadecimal.h \
+ libc3/u32.h \
+ libc3/log.h \
+ libc3/buf_inspect_u64_octal.h \
+ libc3/buf_inspect_u8_octal.h \
+ libc3/buf_inspect_s8_octal.h \
+ libc3/error.h \
libc3/buf_inspect_u32.c \
+ libc3/set_cursor.c.in \
+ libc3/sequence.c \
libc3/buf_inspect_s8_decimal.h \
- libc3/buf_inspect_u16_hexadecimal.c \
- libc3/buf_parse_u16.h \
- libc3/set__tag.c \
- libc3/map.c \
- libc3/tag_shift_right.c \
- libc3/tag.c \
- libc3/buf_parse_u8.h \
- libc3/buf_inspect_uw_octal.c \
- libc3/buf_inspect_u8_binary.c \
- libc3/tag_div.c \
- libc3/buf_inspect_s64_octal.c \
- libc3/u16.c \
- libc3/buf_inspect_sw_hexadecimal.c \
- libc3/buf_inspect_s32_decimal.c \
- libc3/buf_inspect_u64_binary.c \
- libc3/facts_cursor.h \
- libc3/tuple.h \
- libc3/buf_inspect_s16_binary.c \
- libc3/ucd.h \
+ libc3/buf_inspect_u16.h \
+ libc3/buf_inspect_s32_octal.c \
+ libc3/buf_parse_u.h.in \
libc3/buf_inspect_s16_octal.c \
- libc3/buf_inspect_s8.c \
- libc3/sha1.h \
- libc3/buf_inspect_uw_binary.h \
- libc3/buf_parse.c \
- libc3/str.h \
+ libc3/time.c \
+ libc3/buf_inspect_u64.c \
+ libc3/buf_parse_u8.h \
+ libc3/buf_inspect_u32.h \
+ libc3/buf_inspect_u_base.c.in \
+ libc3/ceiling.c \
+ libc3/buf_inspect_u64_decimal.h \
+ libc3/buf_inspect_s32_hexadecimal.c \
libc3/error_handler.h \
- libc3/u64.c \
- libc3/buf_inspect_s32_octal.c \
- libc3/tag_init.h \
- libc3/tag_mul.c \
- libc3/facts_spec_cursor.h \
- libc3/buf_inspect_uw_decimal.c \
- libc3/sw.c \
- libc3/file.c \
- libc3/buf_inspect_s16_decimal.h \
- libc3/frame.c \
- libc3/s32.h \
- libc3/c3.c \
- libc3/f32.h \
- libc3/buf_inspect_sw_octal.c \
- libc3/u8.h \
- libc3/ptr.h \
+ libc3/str.c \
+ libc3/facts_cursor.h \
+ libc3/buf_inspect_uw.c \
+ libc3/buf_inspect_u16_hexadecimal.h \
+ libc3/buf_inspect_s16_hexadecimal.c \
+ libc3/facts_spec.h \
+ libc3/buf_parse_s.c.in \
+ libc3/buf_inspect_u.c.in \
+ libc3/buf_inspect_s32_octal.h \
+ libc3/tag_bor.c \
+ libc3/frame.h \
+ libc3/compare.h \
+ libc3/set.h.in \
+ libc3/set_item__fact.h \
+ libc3/s.h.in \
+ libc3/compare.c \
+ libc3/buf_inspect_s64.c \
+ libc3/buf_inspect_sw.c \
+ libc3/buf_inspect_u32_binary.c \
+ libc3/buf_inspect_s16_hexadecimal.h \
+ libc3/error_handler.c \
+ libc3/tag_band.c \
+ libc3/buf_inspect_s8.h \
+ libc3/binding.c \
+ libc3/set_cursor__tag.c \
libc3/set_item__fact.c \
- libc3/var.c \
- libc3/module.h \
- libc3/license.c \
- libc3/buf_inspect_u32_hexadecimal.c \
- libc3/buf_parse_u64.h \
- libc3/buf_inspect_u8_hexadecimal.h \
- libc3/arg.c \
- libc3/fn_clause.c \
libc3/operator.c \
- libc3/bool.c \
- libc3/buf_parse_s32.c \
- libc3/ptag.c \
- libc3/binding.h \
- libc3/buf_inspect_u.h.in \
- libc3/buf_inspect_s16.h \
+ libc3/buf_inspect_s8_decimal.c \
+ libc3/set__fact.h \
+ libc3/ptr.h \
+ libc3/buf_inspect_s64_binary.c \
+ libc3/buf_inspect_uw_binary.c \
+ libc3/operator.h \
+ libc3/error.c \
+ libc3/array.h \
+ libc3/type.c \
+ libc3/s8.h \
+ libc3/ucd.h \
libc3/integer.h \
- libc3/buf_file.c \
- libc3/struct.c \
+ libc3/u8.h \
+ libc3/frame.c \
+ libc3/buf_inspect_s.c.in \
+ libc3/buf_file.h \
+ libc3/buf_inspect_u16.c \
+ libc3/tag_type.c \
+ libc3/buf_inspect_u8_hexadecimal.c \
+ libc3/buf_inspect_uw_decimal.h \
+ libc3/buf_inspect_u8_binary.h \
+ libc3/buf_inspect_u8_binary.c \
+ libc3/float.h \
+ libc3/buf_inspect_s16_decimal.c \
+ libc3/buf.h \
libc3/s64.c \
+ libc3/buf_inspect_sw_decimal.c \
libc3/buf_inspect_s32_binary.c \
- libc3/buf_inspect_u8.h \
- libc3/facts_spec.h \
- libc3/buf_inspect_u8_decimal.c \
- libc3/sign.h \
- libc3/call.c \
+ libc3/env.h \
+ libc3/buf_parse_s8.h \
+ libc3/u64.c \
+ libc3/set.c.in \
+ libc3/buf_inspect_u64_hexadecimal.h \
+ libc3/buf_inspect_s8_binary.c \
+ libc3/buf_parse_u16.h \
+ libc3/tag_init.c \
+ libc3/buf_inspect_s8_binary.h \
+ libc3/buf_parse_u32.h \
+ libc3/buf_inspect.h \
+ libc3/c3.h \
+ libc3/integer.c \
+ libc3/buf_inspect_uw_hexadecimal.c \
+ libc3/ptag.h \
+ libc3/module.c \
+ libc3/map.h \
+ libc3/buf_inspect_s_base.c.in \
+ libc3/sw.c \
+ libc3/sequence.h \
+ libc3/uw.h \
+ libc3/map.c \
+ libc3/buf_inspect_u_base.h.in \
+ libc3/buf_inspect_u16_decimal.c \
+ libc3/buf_inspect_s8.c \
+ libc3/buf_parse_uw.c \
libc3/buf_parse_s8.c \
- libc3/buf_inspect_sw_binary.h \
- libc3/hash.h \
- libc3/u32.h \
- libc3/buf_inspect_u32_octal.c \
- libc3/character.c \
- libc3/buf_inspect_u64_decimal.c \
- libc3/buf_parse_uw.h \
- libc3/buf_inspect_u32_decimal.c \
- libc3/buf_inspect_s16_hexadecimal.c \
- libc3/set_cursor__tag.c \
+ libc3/buf_parse_sw.h \
+ libc3/buf_inspect_u16_decimal.h \
+ libc3/buf_inspect_sw.h \
+ libc3/cfn.c \
+ libc3/s.c.in \
+ libc3/buf_save.h \
libc3/set_cursor__fact.h \
- libc3/buf.c \
- libc3/list_init.h \
- libc3/abs.c \
- libc3/buf_parse_s64.h \
- libc3/buf_inspect_s.c.in \
- libc3/buf_inspect_s64_binary.h \
- libc3/buf_inspect_u8_octal.c \
- libc3/f64.c \
- libc3/skiplist_node.c.in \
- libc3/buf_parse_u32.c \
+ libc3/character.h \
libc3/facts_with.h \
- libc3/buf_inspect_sw.c \
- libc3/buf_inspect_u16.h \
- libc3/buf_inspect_s8_hexadecimal.h \
- libc3/buf_inspect_u16_binary.h \
- libc3/buf_inspect_u64_hexadecimal.h \
- libc3/buf_save.c \
- test/ident_test.c \
- test/buf_parse_test_s16.c \
- test/buf_inspect_test.c \
- test/libc3_test.c \
+ libc3/tag_type.h \
+ libc3/buf_inspect_s64.h \
+ libc3/buf_inspect_s32_hexadecimal.h \
+ libc3/buf_inspect_uw_decimal.c \
+ test/bool_test.c \
+ test/sym_test.c \
test/fn_test.c \
- test/buf_parse_test_u16.c \
- test/str_test.c \
+ test/buf_parse_test.h \
+ test/libc3_test.c \
test/cfn_test.c \
- test/character_test.c \
- test/buf_parse_test_s8.c \
- test/skiplist__fact_test.c \
- test/sym_test.c \
- test/tag_test.h \
test/buf_file_test.c \
- test/bool_test.c \
- test/fact_test.h \
- test/buf_parse_test_u64.c \
- test/compare_test.c \
+ test/ident_test.c \
test/facts_with_test.c \
- test/array_test.c \
- test/buf_parse_test.h \
- test/test.h \
+ test/compare_test.h \
+ test/skiplist__fact_test.c \
test/buf_parse_test_su.h \
- test/env_test.c \
test/buf_parse_test_s64.c \
+ test/facts_test.c \
+ test/buf_test.c \
test/types_test.c \
- test/hash_test.c \
- test/call_test.c \
+ test/buf_parse_test_s16.c \
+ test/buf_parse_test_u16.c \
+ test/buf_parse_test_u64.c \
test/set__tag_test.c \
- test/facts_test.c \
- test/facts_cursor_test.c \
- test/compare_test.h \
- test/buf_parse_test_s32.c \
+ test/test.h \
+ test/compare_test.c \
test/test.c \
- test/buf_parse_test.c \
- test/fact_test.c \
- test/tag_test.c \
- test/set__fact_test.c \
test/buf_parse_test_u32.c \
- test/buf_test.c \
- test/list_test.c \
+ test/call_test.c \
+ test/str_test.c \
test/buf_parse_test_u8.c \
+ test/tag_test.c \
+ test/set__fact_test.c \
+ test/buf_inspect_test.c \
+ test/character_test.c \
+ test/env_test.c \
+ test/buf_parse_test.c \
+ test/array_test.c \
+ test/buf_parse_test_s32.c \
test/tuple_test.c \
+ test/list_test.c \
+ test/facts_cursor_test.c \
+ test/hash_test.c \
+ test/fact_test.h \
+ test/tag_test.h \
+ test/buf_parse_test_s8.c \
+ test/fact_test.c \
ucd2c/ucd.h \
ucd2c/ucd2c.c \
diff --git a/sources.sh b/sources.sh
index 82584e0..332f161 100644
--- a/sources.sh
+++ b/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-C3_CONFIGURES='c3c/configure c3s/configure c3s/update_sources ic3/configure ic3/update_sources libc3/configure libc3/update_sources libc3/window/configure libc3/window/update_sources libc3/window/cairo/demo/configure libc3/window/cairo/demo/update_sources libc3/window/cairo/xcb/demo/configure libc3/window/cairo/xcb/demo/update_sources libc3/window/cairo/xcb/configure libc3/window/cairo/xcb/update_sources libc3/window/cairo/configure libc3/window/cairo/update_sources libc3/window/cairo/quartz/demo/configure libc3/window/cairo/quartz/demo/update_sources libc3/window/cairo/quartz/configure libc3/window/cairo/quartz/update_sources libc3/window/cairo/win32/demo/configure libc3/window/cairo/win32/demo/update_sources libc3/window/cairo/win32/configure libc3/window/cairo/win32/update_sources libc3/window/sdl2/demo/macos/configure libc3/window/sdl2/demo/configure libc3/window/sdl2/demo/update_sources libc3/window/sdl2/configure libc3/window/sdl2/update_sources libtommath/configure libtommath/update_sources test/configure test/update_sources ucd2c/configure '
-C3_MAKEFILES='c3c/Makefile c3s/Makefile ic3/Makefile libc3/Makefile libc3/gen.mk libc3/window/Makefile libc3/window/cairo/demo/Makefile libc3/window/cairo/xcb/demo/Makefile libc3/window/cairo/xcb/Makefile libc3/window/cairo/Makefile libc3/window/cairo/quartz/demo/Makefile libc3/window/cairo/quartz/Makefile libc3/window/cairo/win32/demo/Makefile libc3/window/cairo/win32/Makefile libc3/window/sdl2/demo/macos/Makefile libc3/window/sdl2/demo/Makefile libc3/window/sdl2/Makefile libtommath/Makefile test/Makefile ucd2c/Makefile '
-C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/buf_linenoise.h ic3/ic3.c ic3/linenoise.c ic3/buf_linenoise.c libc3/buf_inspect_s_base.c.in libc3/type.h libc3/fact.c libc3/time.h libc3/fn.h libc3/s16.h libc3/buf_inspect_s8_octal.h libc3/log.c libc3/error.h libc3/buf_inspect_u64_octal.h libc3/set_item.h.in libc3/compare.c libc3/buf_inspect_s8_binary.h libc3/buf_inspect_uw_hexadecimal.h libc3/uw.c libc3/eval.c libc3/set__fact.c libc3/sym.h libc3/env.h libc3/cfn.c libc3/buf_inspect_u16_octal.h libc3/u.h.in libc3/buf_parse_s16.c libc3/s8.h libc3/quote.h libc3/buf_inspect_s32.h libc3/buf_inspect.c libc3/buf_parse_u.h.in libc3/skiplist_node__fact.h libc3/skiplist__fact.c libc3/tag_add.c libc3/buf_inspect_s32_hexadecimal.h libc3/ceiling.h libc3/struct_type.h libc3/list.c libc3/buf_inspect_u64.c libc3/facts.h libc3/tag_type.h libc3/buf_inspect_u16_decimal.c libc3/tag_sub.c libc3/facts_with_cursor.c libc3/buf_inspect_sw_decimal.c libc3/facts_cursor.c libc3/buf_inspect_u64_binary.h libc3/buf_inspect_sw_hexadecimal.h libc3/buf_inspect_s32_decimal.h libc3/u16.h libc3/buf_inspect_s64_octal.h libc3/buf_inspect_u8_binary.h libc3/buf_inspect_s8.h libc3/buf_inspect_s16_octal.h libc3/ucd.c libc3/buf_inspect_s16_binary.h libc3/tuple.c libc3/buf_inspect_uw_octal.h libc3/buf_parse_u8.c libc3/tag.h libc3/float.h libc3/buf_inspect_u_base.c.in libc3/buf_parse_u16.c libc3/buf_inspect_u16_hexadecimal.h libc3/buf_inspect_s8_decimal.c libc3/buf_inspect_u32.h libc3/array.c libc3/buf_parse_sw.h libc3/set.h.in libc3/s.c.in libc3/buf_parse_s.c.in libc3/map.h libc3/skiplist.h.in libc3/set__tag.h libc3/buf_inspect_s64.c libc3/io.c libc3/set_item__tag.c libc3/sequence.c libc3/types.h libc3/buf_inspect_uw.c libc3/buf_inspect_u32_binary.c libc3/buf_inspect_s64_decimal.h libc3/set_cursor.c.in libc3/ident.c libc3/buf_inspect_s64_hexadecimal.c libc3/bool.h libc3/s.h.in libc3/set.c.in libc3/skiplist.c.in libc3/operator.h libc3/fn_clause.h libc3/buf_parse_s.h.in libc3/buf_inspect_s16.c libc3/binding.c libc3/ptag.h libc3/buf_parse_s32.h libc3/tag_bor.c libc3/var.h libc3/tag_shift_left.c libc3/set_item__fact.h libc3/ptr.c libc3/u8.c libc3/set_cursor.h.in libc3/f32.c libc3/buf_inspect_sw_octal.h libc3/c3.h libc3/arg.h libc3/buf_inspect_u8_hexadecimal.c libc3/buf_inspect_u32_hexadecimal.h libc3/buf_parse_u64.c libc3/module.c libc3/frame.h libc3/buf_inspect_s16_decimal.c libc3/file.h libc3/sw.h libc3/s32.c libc3/error_handler.c libc3/str.c libc3/buf_parse.h libc3/buf_inspect_uw_binary.c libc3/buf_inspect_uw_decimal.h libc3/facts_spec_cursor.c libc3/tag_init.c libc3/u64.h libc3/buf_inspect_u_base.h.in libc3/buf_inspect_s32_octal.h libc3/f64.h libc3/buf_inspect_u8_octal.h libc3/buf_inspect_s64_binary.c libc3/buf_inspect_u64_hexadecimal.c libc3/buf_inspect_u16_binary.c libc3/buf_save.h libc3/buf_inspect_u16.c libc3/buf_inspect_s8_hexadecimal.c libc3/u.c.in libc3/buf_inspect_sw.h libc3/facts_with.c libc3/buf_parse_u.c.in libc3/buf_parse_u32.h libc3/set_cursor__fact.c libc3/buf.h libc3/set_cursor__tag.h libc3/buf_inspect_s16_hexadecimal.h libc3/buf_inspect_u32_decimal.h libc3/buf_parse_uw.c libc3/buf_parse_s64.c libc3/abs.h libc3/list_init.c libc3/buf_inspect_sw_binary.c libc3/buf_parse_s8.h libc3/call.h libc3/sign.c libc3/buf_inspect_u8_decimal.h libc3/character.h libc3/buf_inspect_u64_decimal.h libc3/buf_inspect_s_base.h.in libc3/buf_inspect_u32_octal.h libc3/u32.c libc3/hash.c libc3/buf_file.h libc3/struct.h libc3/integer.c libc3/buf_inspect_u8.c libc3/facts_spec.c libc3/buf_inspect_s32_binary.h libc3/set_item.c.in libc3/tag_bxor.c libc3/s64.h libc3/buf_inspect_u16_decimal.h libc3/tag_type.c libc3/facts.c libc3/buf_inspect_u64.h libc3/buf_inspect_sw_decimal.h libc3/facts_with_cursor.h libc3/skiplist_node__fact.c libc3/buf_inspect.h libc3/quote.c libc3/buf_inspect_s32.c libc3/skiplist_node.h.in libc3/s8.c libc3/buf_parse_s16.h libc3/list.h libc3/struct_type.c libc3/ceiling.c libc3/buf_inspect_s.h.in libc3/buf_inspect_s32_hexadecimal.c libc3/skiplist__fact.h libc3/uw.h libc3/buf_inspect_uw_hexadecimal.c libc3/buf_inspect_s8_binary.c libc3/tag_mod.c libc3/compare.h libc3/buf_inspect_u64_octal.c libc3/buf_inspect_u16_octal.c libc3/tag_band.c libc3/cfn.h libc3/env.c libc3/set__fact.h libc3/sym.c libc3/eval.h libc3/c3_main.h libc3/buf_inspect_s8_octal.c libc3/s16.c libc3/fn.c libc3/time.c libc3/fact.h libc3/type.c libc3/error.c libc3/log.h libc3/sequence.h libc3/set_item__tag.h libc3/io.h libc3/buf_inspect_s64.h libc3/buf_inspect_s64_hexadecimal.h libc3/window/types.h libc3/window/window.h libc3/window/cairo/demo/toasters.h libc3/window/cairo/demo/window_cairo_demo.c libc3/window/cairo/demo/lightspeed.h libc3/window/cairo/demo/flies.h libc3/window/cairo/demo/bg_rect.h libc3/window/cairo/demo/window_cairo_demo.h libc3/window/cairo/demo/toasters.c libc3/window/cairo/demo/lightspeed.c libc3/window/cairo/demo/flies.c libc3/window/cairo/demo/bg_rect.c libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c libc3/window/cairo/xcb/window_cairo_xcb.h libc3/window/cairo/xcb/config.h libc3/window/cairo/xcb/window_cairo_xcb.c libc3/window/cairo/types.h libc3/window/cairo/window_cairo.c libc3/window/cairo/cairo_font.h libc3/window/cairo/cairo_sprite.h libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h libc3/window/cairo/quartz/quartz_to_xkbcommon.c libc3/window/cairo/quartz/window_cairo_quartz.h libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h libc3/window/cairo/quartz/quartz_to_xkbcommon.h libc3/window/cairo/quartz/xkbquartz.h libc3/window/cairo/quartz/window_cairo_quartz_view.h libc3/window/cairo/window_cairo.h libc3/window/cairo/cairo_font.c libc3/window/cairo/win32/demo/window_cairo_win32_demo.c libc3/window/cairo/win32/vk_to_xkbcommon.c libc3/window/cairo/win32/window_cairo_win32.h libc3/window/cairo/win32/vk_to_xkbcommon.h libc3/window/cairo/win32/window_cairo_win32.c libc3/window/cairo/cairo_sprite.c libc3/window/sdl2/demo/toasters.h libc3/window/sdl2/demo/earth.h libc3/window/sdl2/demo/lightspeed.h libc3/window/sdl2/demo/flies.h libc3/window/sdl2/demo/window_sdl2_demo.c libc3/window/sdl2/demo/bg_rect.h libc3/window/sdl2/demo/toasters.c libc3/window/sdl2/demo/earth.c libc3/window/sdl2/demo/lightspeed.c libc3/window/sdl2/demo/flies.c libc3/window/sdl2/demo/bg_rect.c libc3/window/sdl2/demo/window_sdl2_demo.h libc3/window/sdl2/gl_sphere.h libc3/window/sdl2/gl_camera.h libc3/window/sdl2/sdl2_font.c libc3/window/sdl2/gl.c libc3/window/sdl2/window_sdl2.c libc3/window/sdl2/gl_cylinder.h libc3/window/sdl2/types.h libc3/window/sdl2/sdl2_sprite.h libc3/window/sdl2/gl_camera.c libc3/window/sdl2/gl_sphere.c libc3/window/sdl2/gl_cylinder.c libc3/window/sdl2/window_sdl2.h libc3/window/sdl2/gl.h libc3/window/sdl2/sdl2_font.h libc3/window/sdl2/sdl2_sprite.c libc3/window/window.c libc3/ident.h libc3/buf_inspect_s64_decimal.c libc3/buf_inspect_u32_binary.h libc3/buf_inspect_uw.h libc3/buf_inspect_u.c.in libc3/buf_parse_sw.c libc3/array.h libc3/buf_inspect_u32.c libc3/buf_inspect_s8_decimal.h libc3/buf_inspect_u16_hexadecimal.c libc3/buf_parse_u16.h libc3/set__tag.c libc3/map.c libc3/tag_shift_right.c libc3/tag.c libc3/buf_parse_u8.h libc3/buf_inspect_uw_octal.c libc3/buf_inspect_u8_binary.c libc3/tag_div.c libc3/buf_inspect_s64_octal.c libc3/u16.c libc3/buf_inspect_sw_hexadecimal.c libc3/buf_inspect_s32_decimal.c libc3/buf_inspect_u64_binary.c libc3/facts_cursor.h libc3/tuple.h libc3/buf_inspect_s16_binary.c libc3/ucd.h libc3/buf_inspect_s16_octal.c libc3/buf_inspect_s8.c libc3/sha1.h libc3/buf_inspect_uw_binary.h libc3/buf_parse.c libc3/str.h libc3/error_handler.h libc3/u64.c libc3/buf_inspect_s32_octal.c libc3/tag_init.h libc3/tag_mul.c libc3/facts_spec_cursor.h libc3/buf_inspect_uw_decimal.c libc3/sw.c libc3/file.c libc3/buf_inspect_s16_decimal.h libc3/frame.c libc3/s32.h libc3/c3.c libc3/f32.h libc3/buf_inspect_sw_octal.c libc3/u8.h libc3/ptr.h libc3/set_item__fact.c libc3/var.c libc3/module.h libc3/license.c libc3/buf_inspect_u32_hexadecimal.c libc3/buf_parse_u64.h libc3/buf_inspect_u8_hexadecimal.h libc3/arg.c libc3/fn_clause.c libc3/operator.c libc3/bool.c libc3/buf_parse_s32.c libc3/ptag.c libc3/binding.h libc3/buf_inspect_u.h.in libc3/buf_inspect_s16.h libc3/integer.h libc3/buf_file.c libc3/struct.c libc3/s64.c libc3/buf_inspect_s32_binary.c libc3/buf_inspect_u8.h libc3/facts_spec.h libc3/buf_inspect_u8_decimal.c libc3/sign.h libc3/call.c libc3/buf_parse_s8.c libc3/buf_inspect_sw_binary.h libc3/hash.h libc3/u32.h libc3/buf_inspect_u32_octal.c libc3/character.c libc3/buf_inspect_u64_decimal.c libc3/buf_parse_uw.h libc3/buf_inspect_u32_decimal.c libc3/buf_inspect_s16_hexadecimal.c libc3/set_cursor__tag.c libc3/set_cursor__fact.h libc3/buf.c libc3/list_init.h libc3/abs.c libc3/buf_parse_s64.h libc3/buf_inspect_s.c.in libc3/buf_inspect_s64_binary.h libc3/buf_inspect_u8_octal.c libc3/f64.c libc3/skiplist_node.c.in libc3/buf_parse_u32.c libc3/facts_with.h libc3/buf_inspect_sw.c libc3/buf_inspect_u16.h libc3/buf_inspect_s8_hexadecimal.h libc3/buf_inspect_u16_binary.h libc3/buf_inspect_u64_hexadecimal.h libc3/buf_save.c test/ident_test.c test/buf_parse_test_s16.c test/buf_inspect_test.c test/libc3_test.c test/fn_test.c test/buf_parse_test_u16.c test/str_test.c test/cfn_test.c test/character_test.c test/buf_parse_test_s8.c test/skiplist__fact_test.c test/sym_test.c test/tag_test.h test/buf_file_test.c test/bool_test.c test/fact_test.h test/buf_parse_test_u64.c test/compare_test.c test/facts_with_test.c test/array_test.c test/buf_parse_test.h test/test.h test/buf_parse_test_su.h test/env_test.c test/buf_parse_test_s64.c test/types_test.c test/hash_test.c test/call_test.c test/set__tag_test.c test/facts_test.c test/facts_cursor_test.c test/compare_test.h test/buf_parse_test_s32.c test/test.c test/buf_parse_test.c test/fact_test.c test/tag_test.c test/set__fact_test.c test/buf_parse_test_u32.c test/buf_test.c test/list_test.c test/buf_parse_test_u8.c test/tuple_test.c ucd2c/ucd.h ucd2c/ucd2c.c '
+C3_CONFIGURES='c3c/configure c3s/update_sources c3s/configure ic3/update_sources ic3/configure libc3/update_sources libc3/configure libc3/window/update_sources libc3/window/configure libc3/window/sdl2/update_sources libc3/window/sdl2/demo/macos/configure libc3/window/sdl2/demo/update_sources libc3/window/sdl2/demo/configure libc3/window/sdl2/configure libc3/window/cairo/update_sources libc3/window/cairo/xcb/update_sources libc3/window/cairo/xcb/demo/update_sources libc3/window/cairo/xcb/demo/configure libc3/window/cairo/xcb/configure libc3/window/cairo/demo/update_sources libc3/window/cairo/demo/configure libc3/window/cairo/win32/update_sources libc3/window/cairo/win32/demo/update_sources libc3/window/cairo/win32/demo/configure libc3/window/cairo/win32/configure libc3/window/cairo/quartz/update_sources libc3/window/cairo/quartz/demo/update_sources libc3/window/cairo/quartz/demo/configure libc3/window/cairo/quartz/configure libc3/window/cairo/configure libtommath/update_sources libtommath/configure test/update_sources test/configure ucd2c/configure '
+C3_MAKEFILES='c3c/Makefile c3s/Makefile ic3/Makefile libc3/gen.mk libc3/window/sdl2/demo/macos/Makefile libc3/window/sdl2/demo/Makefile libc3/window/sdl2/Makefile libc3/window/cairo/xcb/demo/Makefile libc3/window/cairo/xcb/Makefile libc3/window/cairo/demo/Makefile libc3/window/cairo/win32/demo/Makefile libc3/window/cairo/win32/Makefile libc3/window/cairo/quartz/demo/Makefile libc3/window/cairo/quartz/Makefile libc3/window/cairo/Makefile libc3/window/Makefile libc3/Makefile libtommath/Makefile test/Makefile ucd2c/Makefile '
+C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/buf_linenoise.h ic3/linenoise.c ic3/buf_linenoise.c ic3/ic3.c libc3/buf_parse_s16.c libc3/tuple.h libc3/u.c.in libc3/file.c libc3/struct.c libc3/buf_inspect_sw_decimal.h libc3/quote.h libc3/tag_bxor.c libc3/call.h libc3/buf_parse_u8.c libc3/list_init.h libc3/buf_inspect_u32_hexadecimal.c libc3/buf_inspect_u16_binary.h libc3/buf_inspect_u64_decimal.c libc3/buf_inspect_u32_octal.h libc3/tuple.c libc3/facts.c libc3/buf_save.c libc3/bool.h libc3/buf_parse_s16.h libc3/buf_parse_u16.c libc3/tag_sub.c libc3/skiplist.c.in libc3/buf_inspect_sw_hexadecimal.c libc3/buf_inspect_s16.c libc3/buf_parse.h libc3/set_item.h.in libc3/buf_parse_u64.h libc3/buf_parse_u.c.in libc3/sign.h libc3/buf_parse_s64.h libc3/s32.c libc3/eval.c libc3/array.c libc3/u32.c libc3/tag_div.c libc3/buf_inspect_s64_decimal.c libc3/license.c libc3/types.h libc3/quote.c libc3/buf_inspect_s_base.h.in libc3/struct_type.c libc3/facts_cursor.c libc3/buf_inspect_s16_binary.h libc3/sym.c libc3/binding.h libc3/set_cursor.h.in libc3/s8.c libc3/buf.c libc3/void.c libc3/buf_inspect_u16_octal.c libc3/tag_mod.c libc3/fn.c libc3/buf_inspect_u32_decimal.c libc3/buf_parse_u32.c libc3/buf_inspect_u8.h libc3/skiplist_node__fact.c libc3/void.h libc3/var.c libc3/tag_add.c libc3/eval.h libc3/buf_inspect_s.h.in libc3/skiplist__fact.h libc3/buf_inspect.c libc3/buf_inspect_s16_octal.h libc3/character.c libc3/buf_inspect_u8_decimal.h libc3/f32.c libc3/buf_inspect_s16_decimal.h libc3/buf_inspect_s8_hexadecimal.c libc3/c3_main.h libc3/skiplist__fact.c libc3/tag_init.h libc3/buf_inspect_uw_hexadecimal.h libc3/buf_inspect_s64_hexadecimal.c libc3/f64.h libc3/tag_mul.c libc3/skiplist_node__fact.h libc3/buf_inspect_s32.c libc3/buf_inspect_s16_binary.c libc3/buf_inspect_u32_octal.c libc3/arg.c libc3/buf_inspect_u8_octal.c libc3/buf_inspect_s8_octal.c libc3/buf_inspect_u64.h libc3/facts_spec.c libc3/buf_inspect_s64_decimal.h libc3/bool.c libc3/f64.c libc3/buf_inspect_u64_binary.c libc3/u8.c libc3/buf_inspect_uw.h libc3/fn_clause.c libc3/tag_shift_right.c libc3/buf_inspect_sw_octal.h libc3/tag.h libc3/set_cursor__tag.h libc3/abs.h libc3/struct_type.h libc3/buf_inspect_sw_octal.c libc3/buf_inspect_u.h.in libc3/list_init.c libc3/buf_inspect_u64_hexadecimal.c libc3/tag.c libc3/buf_inspect_s32_binary.h libc3/buf_inspect_s64_octal.c libc3/buf_inspect_s64_hexadecimal.h libc3/buf_inspect_s16.h libc3/module.h libc3/cfn.h libc3/tag_shift_left.c libc3/file.h libc3/u16.c libc3/ptr.c libc3/buf_inspect_sw_binary.c libc3/uw.c libc3/set__tag.c libc3/skiplist_node.c.in libc3/io.h libc3/facts_with.c libc3/buf_parse_s.h.in libc3/buf_file.c libc3/buf_parse.c libc3/ucd.c libc3/set__fact.c libc3/skiplist_node.h.in libc3/buf_inspect_u8.c libc3/buf_inspect_uw_binary.h libc3/s16.h libc3/ptag.c libc3/buf_inspect_sw_hexadecimal.h libc3/hash.c libc3/facts_with_cursor.c libc3/buf_inspect_u16_octal.h libc3/set__tag.h libc3/assert.h libc3/buf_parse_uw.h libc3/s64.h libc3/buf_inspect_u64_octal.c libc3/env.c libc3/buf_inspect_u16_binary.c libc3/set_item.c.in libc3/c3.c libc3/buf_inspect_sw_binary.h libc3/fact.h libc3/buf_inspect_s64_octal.h libc3/buf_parse_u64.c libc3/buf_inspect_s32_decimal.h libc3/buf_parse_s64.c libc3/list.h libc3/fn.h libc3/facts_with_cursor.h libc3/buf_inspect_s32_decimal.c libc3/s16.c libc3/buf_inspect_u32_decimal.h libc3/buf_inspect_u32_hexadecimal.h libc3/list.c libc3/sym.h libc3/var.h libc3/call.c libc3/log.c libc3/buf_inspect_s64_binary.h libc3/io.c libc3/fact.c libc3/sign.c libc3/buf_inspect_uw_octal.h libc3/u.h.in libc3/f32.h libc3/set_cursor__fact.c libc3/skiplist.h.in libc3/ptr_free.c libc3/window/types.h libc3/window/window.h libc3/window/sdl2/gl_sphere.h libc3/window/sdl2/gl_camera.c libc3/window/sdl2/types.h libc3/window/sdl2/sdl2_sprite.h libc3/window/sdl2/sdl2_sprite.c libc3/window/sdl2/gl_cylinder.c libc3/window/sdl2/window_sdl2.c libc3/window/sdl2/gl_camera.h libc3/window/sdl2/sdl2_font.c libc3/window/sdl2/demo/window_sdl2_demo.h libc3/window/sdl2/demo/window_sdl2_demo.c libc3/window/sdl2/demo/lightspeed.c libc3/window/sdl2/demo/toasters.c libc3/window/sdl2/demo/bg_rect.h libc3/window/sdl2/demo/lightspeed.h libc3/window/sdl2/demo/flies.h libc3/window/sdl2/demo/earth.c libc3/window/sdl2/demo/bg_rect.c libc3/window/sdl2/demo/flies.c libc3/window/sdl2/demo/earth.h libc3/window/sdl2/demo/toasters.h libc3/window/sdl2/sdl2_font.h libc3/window/sdl2/gl_sphere.c libc3/window/sdl2/gl_cylinder.h libc3/window/sdl2/gl.h libc3/window/sdl2/window_sdl2.h libc3/window/sdl2/gl.c libc3/window/cairo/types.h libc3/window/cairo/window_cairo.h libc3/window/cairo/cairo_sprite.h libc3/window/cairo/xcb/window_cairo_xcb.c libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c libc3/window/cairo/xcb/window_cairo_xcb.h libc3/window/cairo/xcb/config.h libc3/window/cairo/cairo_font.h libc3/window/cairo/cairo_font.c libc3/window/cairo/demo/lightspeed.c libc3/window/cairo/demo/toasters.c libc3/window/cairo/demo/bg_rect.h libc3/window/cairo/demo/lightspeed.h libc3/window/cairo/demo/flies.h libc3/window/cairo/demo/bg_rect.c libc3/window/cairo/demo/flies.c libc3/window/cairo/demo/window_cairo_demo.c libc3/window/cairo/demo/window_cairo_demo.h libc3/window/cairo/demo/toasters.h libc3/window/cairo/win32/vk_to_xkbcommon.h libc3/window/cairo/win32/window_cairo_win32.c libc3/window/cairo/win32/demo/window_cairo_win32_demo.c libc3/window/cairo/win32/window_cairo_win32.h libc3/window/cairo/win32/vk_to_xkbcommon.c libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h libc3/window/cairo/quartz/window_cairo_quartz_view.h libc3/window/cairo/quartz/quartz_to_xkbcommon.h libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c libc3/window/cairo/quartz/xkbquartz.h libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h libc3/window/cairo/quartz/quartz_to_xkbcommon.c libc3/window/cairo/quartz/window_cairo_quartz.h libc3/window/cairo/cairo_sprite.c libc3/window/cairo/window_cairo.c libc3/window/window.c libc3/set_item__tag.c libc3/abs.c libc3/ident.h libc3/s32.h libc3/buf_parse_sw.c libc3/facts_spec_cursor.c libc3/ident.c libc3/buf_inspect_u8_decimal.c libc3/facts_spec_cursor.h libc3/struct.h libc3/time.h libc3/buf_inspect_u8_hexadecimal.h libc3/buf_inspect_u64_binary.h libc3/u64.h libc3/buf_inspect_u16_hexadecimal.c libc3/arg.h libc3/buf_inspect_u32_binary.h libc3/hash.h libc3/fn_clause.h libc3/buf_inspect_uw_octal.c libc3/facts.h libc3/str.h libc3/buf_parse_s32.h libc3/sha1.h libc3/u16.h libc3/buf_inspect_s32.h libc3/ptr_free.h libc3/sw.h libc3/type.h libc3/buf_parse_s32.c libc3/set_item__tag.h libc3/ceiling.h libc3/buf_inspect_s8_hexadecimal.h libc3/u32.h libc3/log.h libc3/buf_inspect_u64_octal.h libc3/buf_inspect_u8_octal.h libc3/buf_inspect_s8_octal.h libc3/error.h libc3/buf_inspect_u32.c libc3/set_cursor.c.in libc3/sequence.c libc3/buf_inspect_s8_decimal.h libc3/buf_inspect_u16.h libc3/buf_inspect_s32_octal.c libc3/buf_parse_u.h.in libc3/buf_inspect_s16_octal.c libc3/time.c libc3/buf_inspect_u64.c libc3/buf_parse_u8.h libc3/buf_inspect_u32.h libc3/buf_inspect_u_base.c.in libc3/ceiling.c libc3/buf_inspect_u64_decimal.h libc3/buf_inspect_s32_hexadecimal.c libc3/error_handler.h libc3/str.c libc3/facts_cursor.h libc3/buf_inspect_uw.c libc3/buf_inspect_u16_hexadecimal.h libc3/buf_inspect_s16_hexadecimal.c libc3/facts_spec.h libc3/buf_parse_s.c.in libc3/buf_inspect_u.c.in libc3/buf_inspect_s32_octal.h libc3/tag_bor.c libc3/frame.h libc3/compare.h libc3/set.h.in libc3/set_item__fact.h libc3/s.h.in libc3/compare.c libc3/buf_inspect_s64.c libc3/buf_inspect_sw.c libc3/buf_inspect_u32_binary.c libc3/buf_inspect_s16_hexadecimal.h libc3/error_handler.c libc3/tag_band.c libc3/buf_inspect_s8.h libc3/binding.c libc3/set_cursor__tag.c libc3/set_item__fact.c libc3/operator.c libc3/buf_inspect_s8_decimal.c libc3/set__fact.h libc3/ptr.h libc3/buf_inspect_s64_binary.c libc3/buf_inspect_uw_binary.c libc3/operator.h libc3/error.c libc3/array.h libc3/type.c libc3/s8.h libc3/ucd.h libc3/integer.h libc3/u8.h libc3/frame.c libc3/buf_inspect_s.c.in libc3/buf_file.h libc3/buf_inspect_u16.c libc3/tag_type.c libc3/buf_inspect_u8_hexadecimal.c libc3/buf_inspect_uw_decimal.h libc3/buf_inspect_u8_binary.h libc3/buf_inspect_u8_binary.c libc3/float.h libc3/buf_inspect_s16_decimal.c libc3/buf.h libc3/s64.c libc3/buf_inspect_sw_decimal.c libc3/buf_inspect_s32_binary.c libc3/env.h libc3/buf_parse_s8.h libc3/u64.c libc3/set.c.in libc3/buf_inspect_u64_hexadecimal.h libc3/buf_inspect_s8_binary.c libc3/buf_parse_u16.h libc3/tag_init.c libc3/buf_inspect_s8_binary.h libc3/buf_parse_u32.h libc3/buf_inspect.h libc3/c3.h libc3/integer.c libc3/buf_inspect_uw_hexadecimal.c libc3/ptag.h libc3/module.c libc3/map.h libc3/buf_inspect_s_base.c.in libc3/sw.c libc3/sequence.h libc3/uw.h libc3/map.c libc3/buf_inspect_u_base.h.in libc3/buf_inspect_u16_decimal.c libc3/buf_inspect_s8.c libc3/buf_parse_uw.c libc3/buf_parse_s8.c libc3/buf_parse_sw.h libc3/buf_inspect_u16_decimal.h libc3/buf_inspect_sw.h libc3/cfn.c libc3/s.c.in libc3/buf_save.h libc3/set_cursor__fact.h libc3/character.h libc3/facts_with.h libc3/tag_type.h libc3/buf_inspect_s64.h libc3/buf_inspect_s32_hexadecimal.h libc3/buf_inspect_uw_decimal.c test/bool_test.c test/sym_test.c test/fn_test.c test/buf_parse_test.h test/libc3_test.c test/cfn_test.c test/buf_file_test.c test/ident_test.c test/facts_with_test.c test/compare_test.h test/skiplist__fact_test.c test/buf_parse_test_su.h test/buf_parse_test_s64.c test/facts_test.c test/buf_test.c test/types_test.c test/buf_parse_test_s16.c test/buf_parse_test_u16.c test/buf_parse_test_u64.c test/set__tag_test.c test/test.h test/compare_test.c test/test.c test/buf_parse_test_u32.c test/call_test.c test/str_test.c test/buf_parse_test_u8.c test/tag_test.c test/set__fact_test.c test/buf_inspect_test.c test/character_test.c test/env_test.c test/buf_parse_test.c test/array_test.c test/buf_parse_test_s32.c test/tuple_test.c test/list_test.c test/facts_cursor_test.c test/hash_test.c test/fact_test.h test/tag_test.h test/buf_parse_test_s8.c test/fact_test.c ucd2c/ucd.h ucd2c/ucd2c.c '
diff --git a/test/buf_parse_test.c b/test/buf_parse_test.c
index 8f3cd5e..01e1a08 100644
--- a/test/buf_parse_test.c
+++ b/test/buf_parse_test.c
@@ -767,9 +767,9 @@ TEST_CASE(buf_parse_cfn)
BUF_PARSE_TEST_NOT_CFN("a");
BUF_PARSE_TEST_NOT_CFN("z");
BUF_PARSE_TEST_NOT_CFN("cfn 0 1 (2)");
- BUF_PARSE_TEST_CFN("cfn :tag \"tag_add\" (:tag)");
- BUF_PARSE_TEST_CFN("cfn :tag \"tag_add\" (:tag, :tag)");
- BUF_PARSE_TEST_CFN("cfn :tag \"tag_add\" (:tag, :tag, :tag)");
+ BUF_PARSE_TEST_CFN("cfn Tag \"tag_add\" (Tag)");
+ BUF_PARSE_TEST_CFN("cfn Tag \"tag_add\" (Tag, Tag)");
+ BUF_PARSE_TEST_CFN("cfn Tag \"tag_add\" (Tag, Tag, Tag)");
}
TEST_CASE_END(buf_parse_cfn)
@@ -1262,6 +1262,7 @@ TEST_CASE(buf_parse_sym)
BUF_PARSE_TEST_SYM("Z", "Z");
BUF_PARSE_TEST_SYM("Az09az", "Az09az");
BUF_PARSE_TEST_SYM(":az09AZ", "az09AZ");
+ BUF_PARSE_TEST_SYM("A.B.C", "A.B.C");
}
TEST_CASE_END(buf_parse_sym)
diff --git a/test/ic3/list.in b/test/ic3/list.in
index 492f08e..7433dc6 100644
--- a/test/ic3/list.in
+++ b/test/ic3/list.in
@@ -41,6 +41,8 @@
] ## comment 9
## comment 9b
+quote List.map([1, 2, 3, 4], fn (x) { x * 2 })
List.map([1, 2, 3, 4], fn (x) { x * 2 })
+quote List.reverse([1, 2, 3, 4])
List.reverse([1, 2, 3, 4])
diff --git a/test/ic3/list.out.expected b/test/ic3/list.out.expected
index 26dc4f7..7837778 100644
--- a/test/ic3/list.out.expected
+++ b/test/ic3/list.out.expected
@@ -20,5 +20,7 @@
[:a, :b, :c, :d]
[:a, :b, :c | :d]
[:a, :b, :c | :d]
+List.map([1, 2, 3, 4], fn (x) { x * 2 })
[2, 4, 6, 8]
+List.reverse([1, 2, 3, 4])
[4, 3, 2, 1]
diff --git a/test/ic3/sym.in b/test/ic3/sym.in
index 4cd7962..87ebf39 100644
--- a/test/ic3/sym.in
+++ b/test/ic3/sym.in
@@ -26,3 +26,5 @@ Z
:😄
:🟣
:🤩
+quote GL.Sphere
+GL.Sphere
diff --git a/test/ic3/sym.out.expected b/test/ic3/sym.out.expected
index b175d40..7bae48b 100644
--- a/test/ic3/sym.out.expected
+++ b/test/ic3/sym.out.expected
@@ -25,3 +25,5 @@ Z
:😄
:🟣
:🤩
+GL.Sphere
+GL.Sphere
diff --git a/test/sources.mk b/test/sources.mk
index a908ad3..715546e 100644
--- a/test/sources.mk
+++ b/test/sources.mk
@@ -19,10 +19,10 @@ SOURCES = \
character_test.c \
compare_test.c \
env_test.c \
- fact_test.c \
facts_cursor_test.c \
facts_test.c \
facts_with_test.c \
+ fact_test.c \
fn_test.c \
hash_test.c \
ident_test.c \
diff --git a/test/sources.sh b/test/sources.sh
index 4d8d5cf..0f187b7 100644
--- a/test/sources.sh
+++ b/test/sources.sh
@@ -1,2 +1,2 @@
# sources.sh generated by update_sources
-SOURCES='array_test.c bool_test.c buf_file_test.c buf_inspect_test.c buf_parse_test.c buf_parse_test_s16.c buf_parse_test_s32.c buf_parse_test_s64.c buf_parse_test_s8.c buf_parse_test_u16.c buf_parse_test_u32.c buf_parse_test_u64.c buf_parse_test_u8.c buf_test.c call_test.c cfn_test.c character_test.c compare_test.c env_test.c fact_test.c facts_cursor_test.c facts_test.c facts_with_test.c fn_test.c hash_test.c ident_test.c libc3_test.c list_test.c set__fact_test.c set__tag_test.c skiplist__fact_test.c str_test.c sym_test.c tag_test.c test.c tuple_test.c types_test.c '
+SOURCES='array_test.c bool_test.c buf_file_test.c buf_inspect_test.c buf_parse_test.c buf_parse_test_s16.c buf_parse_test_s32.c buf_parse_test_s64.c buf_parse_test_s8.c buf_parse_test_u16.c buf_parse_test_u32.c buf_parse_test_u64.c buf_parse_test_u8.c buf_test.c call_test.c cfn_test.c character_test.c compare_test.c env_test.c facts_cursor_test.c facts_test.c facts_with_test.c fact_test.c fn_test.c hash_test.c ident_test.c libc3_test.c list_test.c set__fact_test.c set__tag_test.c skiplist__fact_test.c str_test.c sym_test.c tag_test.c test.c tuple_test.c types_test.c '
diff --git a/test/sym_test.c b/test/sym_test.c
index 36d2747..16a8884 100644
--- a/test/sym_test.c
+++ b/test/sym_test.c
@@ -136,7 +136,7 @@ TEST_CASE(sym_inspect)
SYM_TEST_INSPECT("test 123", ":\"test 123\"");
SYM_TEST_INSPECT("Test 123", ":\"Test 123\"");
SYM_TEST_INSPECT("test123.test456", ":\"test123.test456\"");
- SYM_TEST_INSPECT("Test123.Test456", ":\"Test123.Test456\"");
+ SYM_TEST_INSPECT("Test123.Test456", "Test123.Test456");
SYM_TEST_INSPECT("test123(test456)", ":\"test123(test456)\"");
SYM_TEST_INSPECT("Test123(Test456)", ":\"Test123(Test456)\"");
SYM_TEST_INSPECT("test123{test456}", ":\"test123{test456}\"");