diff --git a/lib/c3/0.1/u32.facts b/lib/c3/0.1/u32.facts
index 3ef55f0..29e6146 100644
--- a/lib/c3/0.1/u32.facts
+++ b/lib/c3/0.1/u32.facts
@@ -1,5 +1,5 @@
%{module: C3.Facts.Dump,
version: 1}
-add {U32, :is_a, :module}
-add {U32, :symbol, U32.cast}
-replace {U32.cast, :cfn, cfn :u32 "u32_cast" (:tag)}
+replace {U32, :is_a, :module}
+replace {U32, :symbol, U32.cast}
+replace {U32.cast, :cfn, cfn U32 "u32_cast" (Tag, Result)}
diff --git a/lib/c3/0.1/u64.facts b/lib/c3/0.1/u64.facts
index 1b7fd15..7cea2fe 100644
--- a/lib/c3/0.1/u64.facts
+++ b/lib/c3/0.1/u64.facts
@@ -1,5 +1,5 @@
%{module: C3.Facts.Dump,
version: 1}
-add {U64, :is_a, :module}
-add {U64, :symbol, U64.cast}
-replace {U64.cast, :cfn, cfn :u64 "u64_cast" (:tag)}
+replace {U64, :is_a, :module}
+replace {U64, :symbol, U64.cast}
+replace {U64.cast, :cfn, cfn U64 "u64_cast" (Tag, Result)}
diff --git a/lib/c3/0.1/uw.facts b/lib/c3/0.1/uw.facts
index 888555a..c4a25a5 100644
--- a/lib/c3/0.1/uw.facts
+++ b/lib/c3/0.1/uw.facts
@@ -1,5 +1,5 @@
%{module: C3.Facts.Dump,
version: 1}
-add {Uw, :is_a, :module}
-add {Uw, :symbol, Uw.cast}
-replace {Uw.cast, :cfn, cfn :uw "uw_cast" (:tag)}
+replace {Uw, :is_a, :module}
+replace {Uw, :symbol, Uw.cast}
+replace {Uw.cast, :cfn, cfn Uw "uw_cast" (Tag, Result)}
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 850bdc2..8a3d178 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -29,6 +29,7 @@ s_tag * cfn_apply (s_cfn *cfn, s_list *args, s_tag *dest)
s_list *a;
void **arg_pointers = NULL;
void **arg_values = NULL;
+ void **result_pointer = NULL;
u8 arity;
s_list *cfn_arg_types;
sw i = 0;
@@ -45,13 +46,18 @@ s_tag * cfn_apply (s_cfn *cfn, s_list *args, s_tag *dest)
arity, num_args);
return NULL;
}
- if (cfn->arg_result) {
+ if (cfn->cif.rtype == &ffi_type_pointer) {
cfn_tag_init(&tmp2, cfn->result_type);
- cfn->result_type = type_pointer(cfn->result_type);
+ cfn_tag_init(&tmp, cfn->result_type);
+ /* make result point to result_pointer */
+ result_pointer = tag_to_ffi_pointer(&tmp, cfn->result_type);
+ result = &result_pointer;
+ }
+ else {
+ cfn_tag_init(&tmp, cfn->result_type);
+ /* make result point to tmp value */
+ result = tag_to_ffi_pointer(&tmp, cfn->result_type);
}
- cfn_tag_init(&tmp, cfn->result_type);
- /* make result point to tmp value */
- result = tag_to_ffi_pointer(&tmp, cfn->result_type);
if (cfn->arity) {
if (! (arg_pointers = calloc(sizeof(void *), cfn->arity + 1)))
err(1, "cfn_apply");
diff --git a/libc3/s.c.in b/libc3/s.c.in
index 44a9c81..b2d0ed4 100644
--- a/libc3/s.c.in
+++ b/libc3/s.c.in
@@ -17,53 +17,70 @@
#include "tag.h"
#include "s_bits$.h"
-s_bits$ s_bits$_cast (s_tag *tag)
+s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (s_bits$) tag->data.character;
+ *dest = (s_bits$) tag->data.character;
+ return dest;
case TAG_F32:
- return (s_bits$) tag->data.f32;
+ *dest = (s_bits$) tag->data.f32;
+ return dest;
case TAG_F64:
- return (s_bits$) tag->data.f64;
+ *dest = (s_bits$) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_s_bits$(&tag->data.integer);
+ *dest = integer_to_s_bits$(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (s_bits$) tag->data.sw;
+ *dest = (s_bits$) tag->data.sw;
+ return dest;
case TAG_S64:
- return (s_bits$) tag->data.s64;
+ *dest = (s_bits$) tag->data.s64;
+ return dest;
case TAG_S32:
- return (s_bits$) tag->data.s32;
+ *dest = (s_bits$) tag->data.s32;
+ return dest;
case TAG_S16:
- return (s_bits$) tag->data.s16;
+ *dest = (s_bits$) tag->data.s16;
+ return dest;
case TAG_S8:
- return (s_bits$) tag->data.s8;
+ *dest = (s_bits$) tag->data.s8;
+ return dest;
case TAG_U8:
- return (s_bits$) tag->data.u8;
+ *dest = (s_bits$) tag->data.u8;
+ return dest;
case TAG_U16:
- return (s_bits$) tag->data.u16;
+ *dest = (s_bits$) tag->data.u16;
+ return dest;
case TAG_U32:
- return (s_bits$) tag->data.u32;
+ *dest = (s_bits$) tag->data.u32;
+ return dest;
case TAG_U64:
- return (s_bits$) tag->data.u64;
+ *dest = (s_bits$) tag->data.u64;
+ return dest;
case TAG_UW:
- return (s_bits$) tag->data.uw;
+ *dest = (s_bits$) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/s.h.in b/libc3/s.h.in
index 074eca2..d85a655 100644
--- a/libc3/s.h.in
+++ b/libc3/s.h.in
@@ -16,7 +16,7 @@
#include "types.h"
-s_bits$ s_bits$_cast (s_tag *tag);
+s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest);
s_bits$ * s_bits$_copy (const s_bits$ *src, s_bits$ *dest);
#endif /* S8_H */
diff --git a/libc3/s16.c b/libc3/s16.c
index e0d1301..ca14bd7 100644
--- a/libc3/s16.c
+++ b/libc3/s16.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "s16.h"
-s16 s16_cast (s_tag *tag)
+s16 * s16_cast (s_tag *tag, s16 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (s16) tag->data.character;
+ *dest = (s16) tag->data.character;
+ return dest;
case TAG_F32:
- return (s16) tag->data.f32;
+ *dest = (s16) tag->data.f32;
+ return dest;
case TAG_F64:
- return (s16) tag->data.f64;
+ *dest = (s16) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_s16(&tag->data.integer);
+ *dest = integer_to_s16(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (s16) tag->data.sw;
+ *dest = (s16) tag->data.sw;
+ return dest;
case TAG_S64:
- return (s16) tag->data.s64;
+ *dest = (s16) tag->data.s64;
+ return dest;
case TAG_S32:
- return (s16) tag->data.s32;
+ *dest = (s16) tag->data.s32;
+ return dest;
case TAG_S16:
- return (s16) tag->data.s16;
+ *dest = (s16) tag->data.s16;
+ return dest;
case TAG_S8:
- return (s16) tag->data.s8;
+ *dest = (s16) tag->data.s8;
+ return dest;
case TAG_U8:
- return (s16) tag->data.u8;
+ *dest = (s16) tag->data.u8;
+ return dest;
case TAG_U16:
- return (s16) tag->data.u16;
+ *dest = (s16) tag->data.u16;
+ return dest;
case TAG_U32:
- return (s16) tag->data.u32;
+ *dest = (s16) tag->data.u32;
+ return dest;
case TAG_U64:
- return (s16) tag->data.u64;
+ *dest = (s16) tag->data.u64;
+ return dest;
case TAG_UW:
- return (s16) tag->data.uw;
+ *dest = (s16) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/s16.h b/libc3/s16.h
index 7385b59..8010e59 100644
--- a/libc3/s16.h
+++ b/libc3/s16.h
@@ -16,7 +16,7 @@
#include "types.h"
-s16 s16_cast (s_tag *tag);
+s16 * s16_cast (s_tag *tag, s16 *dest);
s16 * s16_copy (const s16 *src, s16 *dest);
#endif /* S8_H */
diff --git a/libc3/s32.c b/libc3/s32.c
index 38022e3..bf16690 100644
--- a/libc3/s32.c
+++ b/libc3/s32.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "s32.h"
-s32 s32_cast (s_tag *tag)
+s32 * s32_cast (s_tag *tag, s32 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (s32) tag->data.character;
+ *dest = (s32) tag->data.character;
+ return dest;
case TAG_F32:
- return (s32) tag->data.f32;
+ *dest = (s32) tag->data.f32;
+ return dest;
case TAG_F64:
- return (s32) tag->data.f64;
+ *dest = (s32) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_s32(&tag->data.integer);
+ *dest = integer_to_s32(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (s32) tag->data.sw;
+ *dest = (s32) tag->data.sw;
+ return dest;
case TAG_S64:
- return (s32) tag->data.s64;
+ *dest = (s32) tag->data.s64;
+ return dest;
case TAG_S32:
- return (s32) tag->data.s32;
+ *dest = (s32) tag->data.s32;
+ return dest;
case TAG_S16:
- return (s32) tag->data.s16;
+ *dest = (s32) tag->data.s16;
+ return dest;
case TAG_S8:
- return (s32) tag->data.s8;
+ *dest = (s32) tag->data.s8;
+ return dest;
case TAG_U8:
- return (s32) tag->data.u8;
+ *dest = (s32) tag->data.u8;
+ return dest;
case TAG_U16:
- return (s32) tag->data.u16;
+ *dest = (s32) tag->data.u16;
+ return dest;
case TAG_U32:
- return (s32) tag->data.u32;
+ *dest = (s32) tag->data.u32;
+ return dest;
case TAG_U64:
- return (s32) tag->data.u64;
+ *dest = (s32) tag->data.u64;
+ return dest;
case TAG_UW:
- return (s32) tag->data.uw;
+ *dest = (s32) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/s32.h b/libc3/s32.h
index bf99894..2e8d9f6 100644
--- a/libc3/s32.h
+++ b/libc3/s32.h
@@ -16,7 +16,7 @@
#include "types.h"
-s32 s32_cast (s_tag *tag);
+s32 * s32_cast (s_tag *tag, s32 *dest);
s32 * s32_copy (const s32 *src, s32 *dest);
#endif /* S8_H */
diff --git a/libc3/s64.c b/libc3/s64.c
index 222e464..cdeb692 100644
--- a/libc3/s64.c
+++ b/libc3/s64.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "s64.h"
-s64 s64_cast (s_tag *tag)
+s64 * s64_cast (s_tag *tag, s64 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (s64) tag->data.character;
+ *dest = (s64) tag->data.character;
+ return dest;
case TAG_F32:
- return (s64) tag->data.f32;
+ *dest = (s64) tag->data.f32;
+ return dest;
case TAG_F64:
- return (s64) tag->data.f64;
+ *dest = (s64) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_s64(&tag->data.integer);
+ *dest = integer_to_s64(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (s64) tag->data.sw;
+ *dest = (s64) tag->data.sw;
+ return dest;
case TAG_S64:
- return (s64) tag->data.s64;
+ *dest = (s64) tag->data.s64;
+ return dest;
case TAG_S32:
- return (s64) tag->data.s32;
+ *dest = (s64) tag->data.s32;
+ return dest;
case TAG_S16:
- return (s64) tag->data.s16;
+ *dest = (s64) tag->data.s16;
+ return dest;
case TAG_S8:
- return (s64) tag->data.s8;
+ *dest = (s64) tag->data.s8;
+ return dest;
case TAG_U8:
- return (s64) tag->data.u8;
+ *dest = (s64) tag->data.u8;
+ return dest;
case TAG_U16:
- return (s64) tag->data.u16;
+ *dest = (s64) tag->data.u16;
+ return dest;
case TAG_U32:
- return (s64) tag->data.u32;
+ *dest = (s64) tag->data.u32;
+ return dest;
case TAG_U64:
- return (s64) tag->data.u64;
+ *dest = (s64) tag->data.u64;
+ return dest;
case TAG_UW:
- return (s64) tag->data.uw;
+ *dest = (s64) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/s64.h b/libc3/s64.h
index 2b48859..6100515 100644
--- a/libc3/s64.h
+++ b/libc3/s64.h
@@ -16,7 +16,7 @@
#include "types.h"
-s64 s64_cast (s_tag *tag);
+s64 * s64_cast (s_tag *tag, s64 *dest);
s64 * s64_copy (const s64 *src, s64 *dest);
#endif /* S8_H */
diff --git a/libc3/s8.c b/libc3/s8.c
index 4f5057b..e99c186 100644
--- a/libc3/s8.c
+++ b/libc3/s8.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "s8.h"
-s8 s8_cast (s_tag *tag)
+s8 * s8_cast (s_tag *tag, s8 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (s8) tag->data.character;
+ *dest = (s8) tag->data.character;
+ return dest;
case TAG_F32:
- return (s8) tag->data.f32;
+ *dest = (s8) tag->data.f32;
+ return dest;
case TAG_F64:
- return (s8) tag->data.f64;
+ *dest = (s8) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_s8(&tag->data.integer);
+ *dest = integer_to_s8(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (s8) tag->data.sw;
+ *dest = (s8) tag->data.sw;
+ return dest;
case TAG_S64:
- return (s8) tag->data.s64;
+ *dest = (s8) tag->data.s64;
+ return dest;
case TAG_S32:
- return (s8) tag->data.s32;
+ *dest = (s8) tag->data.s32;
+ return dest;
case TAG_S16:
- return (s8) tag->data.s16;
+ *dest = (s8) tag->data.s16;
+ return dest;
case TAG_S8:
- return (s8) tag->data.s8;
+ *dest = (s8) tag->data.s8;
+ return dest;
case TAG_U8:
- return (s8) tag->data.u8;
+ *dest = (s8) tag->data.u8;
+ return dest;
case TAG_U16:
- return (s8) tag->data.u16;
+ *dest = (s8) tag->data.u16;
+ return dest;
case TAG_U32:
- return (s8) tag->data.u32;
+ *dest = (s8) tag->data.u32;
+ return dest;
case TAG_U64:
- return (s8) tag->data.u64;
+ *dest = (s8) tag->data.u64;
+ return dest;
case TAG_UW:
- return (s8) tag->data.uw;
+ *dest = (s8) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/s8.h b/libc3/s8.h
index 7d6f3da..c7b7ba0 100644
--- a/libc3/s8.h
+++ b/libc3/s8.h
@@ -16,7 +16,7 @@
#include "types.h"
-s8 s8_cast (s_tag *tag);
+s8 * s8_cast (s_tag *tag, s8 *dest);
s8 * s8_copy (const s8 *src, s8 *dest);
#endif /* S8_H */
diff --git a/libc3/sw.c b/libc3/sw.c
index 99132fa..706ca01 100644
--- a/libc3/sw.c
+++ b/libc3/sw.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "sw.h"
-sw sw_cast (s_tag *tag)
+sw * sw_cast (s_tag *tag, sw *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (sw) tag->data.character;
+ *dest = (sw) tag->data.character;
+ return dest;
case TAG_F32:
- return (sw) tag->data.f32;
+ *dest = (sw) tag->data.f32;
+ return dest;
case TAG_F64:
- return (sw) tag->data.f64;
+ *dest = (sw) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_sw(&tag->data.integer);
+ *dest = integer_to_sw(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (sw) tag->data.sw;
+ *dest = (sw) tag->data.sw;
+ return dest;
case TAG_S64:
- return (sw) tag->data.s64;
+ *dest = (sw) tag->data.s64;
+ return dest;
case TAG_S32:
- return (sw) tag->data.s32;
+ *dest = (sw) tag->data.s32;
+ return dest;
case TAG_S16:
- return (sw) tag->data.s16;
+ *dest = (sw) tag->data.s16;
+ return dest;
case TAG_S8:
- return (sw) tag->data.s8;
+ *dest = (sw) tag->data.s8;
+ return dest;
case TAG_U8:
- return (sw) tag->data.u8;
+ *dest = (sw) tag->data.u8;
+ return dest;
case TAG_U16:
- return (sw) tag->data.u16;
+ *dest = (sw) tag->data.u16;
+ return dest;
case TAG_U32:
- return (sw) tag->data.u32;
+ *dest = (sw) tag->data.u32;
+ return dest;
case TAG_U64:
- return (sw) tag->data.u64;
+ *dest = (sw) tag->data.u64;
+ return dest;
case TAG_UW:
- return (sw) tag->data.uw;
+ *dest = (sw) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/sw.h b/libc3/sw.h
index 9c869bf..200a0bb 100644
--- a/libc3/sw.h
+++ b/libc3/sw.h
@@ -16,7 +16,7 @@
#include "types.h"
-sw sw_cast (s_tag *tag);
+sw * sw_cast (s_tag *tag, sw *dest);
sw * sw_copy (const sw *src, sw *dest);
#endif /* S8_H */
diff --git a/libc3/sym.c b/libc3/sym.c
index a04a3cb..f179abe 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -160,7 +160,7 @@ ffi_type * sym_to_ffi_type (const s_sym *sym, ffi_type *result_type)
warnx("invalid result type: &result");
return result_type;
}
- if (sym->str.ptr.ps8[sym->str.size - 1] == '*')
+ if (sym->str.ptr.ps8[sym->str.size - 2] == '*')
return &ffi_type_pointer;
if (sym == sym_1("Integer") ||
sym == sym_1("integer"))
diff --git a/libc3/u.c.in b/libc3/u.c.in
index 2e8c9d8..8b2fec3 100644
--- a/libc3/u.c.in
+++ b/libc3/u.c.in
@@ -17,53 +17,70 @@
#include "tag.h"
#include "u_bits$.h"
-u_bits$ u_bits$_cast (s_tag *tag)
+u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (u_bits$) tag->data.character;
+ *dest = (u_bits$) tag->data.character;
+ return dest;
case TAG_F32:
- return (u_bits$) tag->data.f32;
+ *dest = (u_bits$) tag->data.f32;
+ return dest;
case TAG_F64:
- return (u_bits$) tag->data.f64;
+ *dest = (u_bits$) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_u_bits$(&tag->data.integer);
+ *dest = integer_to_u_bits$(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (u_bits$) tag->data.sw;
+ *dest = (u_bits$) tag->data.sw;
+ return dest;
case TAG_S64:
- return (u_bits$) tag->data.s64;
+ *dest = (u_bits$) tag->data.s64;
+ return dest;
case TAG_S32:
- return (u_bits$) tag->data.s32;
+ *dest = (u_bits$) tag->data.s32;
+ return dest;
case TAG_S16:
- return (u_bits$) tag->data.s16;
+ *dest = (u_bits$) tag->data.s16;
+ return dest;
case TAG_S8:
- return (u_bits$) tag->data.s8;
+ *dest = (u_bits$) tag->data.s8;
+ return dest;
case TAG_U8:
- return (u_bits$) tag->data.u8;
+ *dest = (u_bits$) tag->data.u8;
+ return dest;
case TAG_U16:
- return (u_bits$) tag->data.u16;
+ *dest = (u_bits$) tag->data.u16;
+ return dest;
case TAG_U32:
- return (u_bits$) tag->data.u32;
+ *dest = (u_bits$) tag->data.u32;
+ return dest;
case TAG_U64:
- return (u_bits$) tag->data.u64;
+ *dest = (u_bits$) tag->data.u64;
+ return dest;
case TAG_UW:
- return (u_bits$) tag->data.uw;
+ *dest = (u_bits$) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/u.h.in b/libc3/u.h.in
index 76861d2..a905fc6 100644
--- a/libc3/u.h.in
+++ b/libc3/u.h.in
@@ -16,7 +16,7 @@
#include "types.h"
-u_bits$ u_bits$_cast (s_tag *tag);
+u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest);
u_bits$ * u_bits$_copy (const u_bits$ *src, u_bits$ *dest);
#endif /* U8_H */
diff --git a/libc3/u16.c b/libc3/u16.c
index 8772877..6cb15e2 100644
--- a/libc3/u16.c
+++ b/libc3/u16.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "u16.h"
-u16 u16_cast (s_tag *tag)
+u16 * u16_cast (s_tag *tag, u16 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (u16) tag->data.character;
+ *dest = (u16) tag->data.character;
+ return dest;
case TAG_F32:
- return (u16) tag->data.f32;
+ *dest = (u16) tag->data.f32;
+ return dest;
case TAG_F64:
- return (u16) tag->data.f64;
+ *dest = (u16) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_u16(&tag->data.integer);
+ *dest = integer_to_u16(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (u16) tag->data.sw;
+ *dest = (u16) tag->data.sw;
+ return dest;
case TAG_S64:
- return (u16) tag->data.s64;
+ *dest = (u16) tag->data.s64;
+ return dest;
case TAG_S32:
- return (u16) tag->data.s32;
+ *dest = (u16) tag->data.s32;
+ return dest;
case TAG_S16:
- return (u16) tag->data.s16;
+ *dest = (u16) tag->data.s16;
+ return dest;
case TAG_S8:
- return (u16) tag->data.s8;
+ *dest = (u16) tag->data.s8;
+ return dest;
case TAG_U8:
- return (u16) tag->data.u8;
+ *dest = (u16) tag->data.u8;
+ return dest;
case TAG_U16:
- return (u16) tag->data.u16;
+ *dest = (u16) tag->data.u16;
+ return dest;
case TAG_U32:
- return (u16) tag->data.u32;
+ *dest = (u16) tag->data.u32;
+ return dest;
case TAG_U64:
- return (u16) tag->data.u64;
+ *dest = (u16) tag->data.u64;
+ return dest;
case TAG_UW:
- return (u16) tag->data.uw;
+ *dest = (u16) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/u16.h b/libc3/u16.h
index 05b5ab4..da730f6 100644
--- a/libc3/u16.h
+++ b/libc3/u16.h
@@ -16,7 +16,7 @@
#include "types.h"
-u16 u16_cast (s_tag *tag);
+u16 * u16_cast (s_tag *tag, u16 *dest);
u16 * u16_copy (const u16 *src, u16 *dest);
#endif /* U8_H */
diff --git a/libc3/u32.c b/libc3/u32.c
index c6fc325..4e84a8f 100644
--- a/libc3/u32.c
+++ b/libc3/u32.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "u32.h"
-u32 u32_cast (s_tag *tag)
+u32 * u32_cast (s_tag *tag, u32 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (u32) tag->data.character;
+ *dest = (u32) tag->data.character;
+ return dest;
case TAG_F32:
- return (u32) tag->data.f32;
+ *dest = (u32) tag->data.f32;
+ return dest;
case TAG_F64:
- return (u32) tag->data.f64;
+ *dest = (u32) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_u32(&tag->data.integer);
+ *dest = integer_to_u32(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (u32) tag->data.sw;
+ *dest = (u32) tag->data.sw;
+ return dest;
case TAG_S64:
- return (u32) tag->data.s64;
+ *dest = (u32) tag->data.s64;
+ return dest;
case TAG_S32:
- return (u32) tag->data.s32;
+ *dest = (u32) tag->data.s32;
+ return dest;
case TAG_S16:
- return (u32) tag->data.s16;
+ *dest = (u32) tag->data.s16;
+ return dest;
case TAG_S8:
- return (u32) tag->data.s8;
+ *dest = (u32) tag->data.s8;
+ return dest;
case TAG_U8:
- return (u32) tag->data.u8;
+ *dest = (u32) tag->data.u8;
+ return dest;
case TAG_U16:
- return (u32) tag->data.u16;
+ *dest = (u32) tag->data.u16;
+ return dest;
case TAG_U32:
- return (u32) tag->data.u32;
+ *dest = (u32) tag->data.u32;
+ return dest;
case TAG_U64:
- return (u32) tag->data.u64;
+ *dest = (u32) tag->data.u64;
+ return dest;
case TAG_UW:
- return (u32) tag->data.uw;
+ *dest = (u32) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/u32.h b/libc3/u32.h
index c54a3a6..3de9145 100644
--- a/libc3/u32.h
+++ b/libc3/u32.h
@@ -16,7 +16,7 @@
#include "types.h"
-u32 u32_cast (s_tag *tag);
+u32 * u32_cast (s_tag *tag, u32 *dest);
u32 * u32_copy (const u32 *src, u32 *dest);
#endif /* U8_H */
diff --git a/libc3/u64.c b/libc3/u64.c
index 0c65ba8..1a92170 100644
--- a/libc3/u64.c
+++ b/libc3/u64.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "u64.h"
-u64 u64_cast (s_tag *tag)
+u64 * u64_cast (s_tag *tag, u64 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (u64) tag->data.character;
+ *dest = (u64) tag->data.character;
+ return dest;
case TAG_F32:
- return (u64) tag->data.f32;
+ *dest = (u64) tag->data.f32;
+ return dest;
case TAG_F64:
- return (u64) tag->data.f64;
+ *dest = (u64) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_u64(&tag->data.integer);
+ *dest = integer_to_u64(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (u64) tag->data.sw;
+ *dest = (u64) tag->data.sw;
+ return dest;
case TAG_S64:
- return (u64) tag->data.s64;
+ *dest = (u64) tag->data.s64;
+ return dest;
case TAG_S32:
- return (u64) tag->data.s32;
+ *dest = (u64) tag->data.s32;
+ return dest;
case TAG_S16:
- return (u64) tag->data.s16;
+ *dest = (u64) tag->data.s16;
+ return dest;
case TAG_S8:
- return (u64) tag->data.s8;
+ *dest = (u64) tag->data.s8;
+ return dest;
case TAG_U8:
- return (u64) tag->data.u8;
+ *dest = (u64) tag->data.u8;
+ return dest;
case TAG_U16:
- return (u64) tag->data.u16;
+ *dest = (u64) tag->data.u16;
+ return dest;
case TAG_U32:
- return (u64) tag->data.u32;
+ *dest = (u64) tag->data.u32;
+ return dest;
case TAG_U64:
- return (u64) tag->data.u64;
+ *dest = (u64) tag->data.u64;
+ return dest;
case TAG_UW:
- return (u64) tag->data.uw;
+ *dest = (u64) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/u64.h b/libc3/u64.h
index e4f188d..43f89a3 100644
--- a/libc3/u64.h
+++ b/libc3/u64.h
@@ -16,7 +16,7 @@
#include "types.h"
-u64 u64_cast (s_tag *tag);
+u64 * u64_cast (s_tag *tag, u64 *dest);
u64 * u64_copy (const u64 *src, u64 *dest);
#endif /* U8_H */
diff --git a/libc3/u8.c b/libc3/u8.c
index 6f00b8d..32424e2 100644
--- a/libc3/u8.c
+++ b/libc3/u8.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "u8.h"
-u8 u8_cast (s_tag *tag)
+u8 * u8_cast (s_tag *tag, u8 *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (u8) tag->data.character;
+ *dest = (u8) tag->data.character;
+ return dest;
case TAG_F32:
- return (u8) tag->data.f32;
+ *dest = (u8) tag->data.f32;
+ return dest;
case TAG_F64:
- return (u8) tag->data.f64;
+ *dest = (u8) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_u8(&tag->data.integer);
+ *dest = integer_to_u8(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (u8) tag->data.sw;
+ *dest = (u8) tag->data.sw;
+ return dest;
case TAG_S64:
- return (u8) tag->data.s64;
+ *dest = (u8) tag->data.s64;
+ return dest;
case TAG_S32:
- return (u8) tag->data.s32;
+ *dest = (u8) tag->data.s32;
+ return dest;
case TAG_S16:
- return (u8) tag->data.s16;
+ *dest = (u8) tag->data.s16;
+ return dest;
case TAG_S8:
- return (u8) tag->data.s8;
+ *dest = (u8) tag->data.s8;
+ return dest;
case TAG_U8:
- return (u8) tag->data.u8;
+ *dest = (u8) tag->data.u8;
+ return dest;
case TAG_U16:
- return (u8) tag->data.u16;
+ *dest = (u8) tag->data.u16;
+ return dest;
case TAG_U32:
- return (u8) tag->data.u32;
+ *dest = (u8) tag->data.u32;
+ return dest;
case TAG_U64:
- return (u8) tag->data.u64;
+ *dest = (u8) tag->data.u64;
+ return dest;
case TAG_UW:
- return (u8) tag->data.uw;
+ *dest = (u8) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/u8.h b/libc3/u8.h
index 2767023..e790b0d 100644
--- a/libc3/u8.h
+++ b/libc3/u8.h
@@ -16,7 +16,7 @@
#include "types.h"
-u8 u8_cast (s_tag *tag);
+u8 * u8_cast (s_tag *tag, u8 *dest);
u8 * u8_copy (const u8 *src, u8 *dest);
#endif /* U8_H */
diff --git a/libc3/uw.c b/libc3/uw.c
index a43e148..ae2da6f 100644
--- a/libc3/uw.c
+++ b/libc3/uw.c
@@ -17,53 +17,70 @@
#include "tag.h"
#include "uw.h"
-uw uw_cast (s_tag *tag)
+uw * uw_cast (s_tag *tag, uw *dest)
{
switch (tag->type) {
case TAG_VOID:
- return 0;
+ *dest = 0;
+ return dest;
case TAG_ARRAY:
goto ko;
case TAG_BOOL:
- return tag->data.bool ? 1 : 0;
+ *dest = tag->data.bool ? 1 : 0;
+ return dest;
case TAG_CALL:
goto ko;
case TAG_CFN:
goto ko;
case TAG_CHARACTER:
- return (uw) tag->data.character;
+ *dest = (uw) tag->data.character;
+ return dest;
case TAG_F32:
- return (uw) tag->data.f32;
+ *dest = (uw) tag->data.f32;
+ return dest;
case TAG_F64:
- return (uw) tag->data.f64;
+ *dest = (uw) tag->data.f64;
+ return dest;
case TAG_FACT:
case TAG_FN:
case TAG_IDENT:
goto ko;
case TAG_INTEGER:
- return integer_to_uw(&tag->data.integer);
+ *dest = integer_to_uw(&tag->data.integer);
+ return dest;
case TAG_SW:
- return (uw) tag->data.sw;
+ *dest = (uw) tag->data.sw;
+ return dest;
case TAG_S64:
- return (uw) tag->data.s64;
+ *dest = (uw) tag->data.s64;
+ return dest;
case TAG_S32:
- return (uw) tag->data.s32;
+ *dest = (uw) tag->data.s32;
+ return dest;
case TAG_S16:
- return (uw) tag->data.s16;
+ *dest = (uw) tag->data.s16;
+ return dest;
case TAG_S8:
- return (uw) tag->data.s8;
+ *dest = (uw) tag->data.s8;
+ return dest;
case TAG_U8:
- return (uw) tag->data.u8;
+ *dest = (uw) tag->data.u8;
+ return dest;
case TAG_U16:
- return (uw) tag->data.u16;
+ *dest = (uw) tag->data.u16;
+ return dest;
case TAG_U32:
- return (uw) tag->data.u32;
+ *dest = (uw) tag->data.u32;
+ return dest;
case TAG_U64:
- return (uw) tag->data.u64;
+ *dest = (uw) tag->data.u64;
+ return dest;
case TAG_UW:
- return (uw) tag->data.uw;
+ *dest = (uw) tag->data.uw;
+ return dest;
case TAG_LIST:
case TAG_PTAG:
+ case TAG_PTR:
case TAG_QUOTE:
case TAG_STR:
case TAG_SYM:
diff --git a/libc3/uw.h b/libc3/uw.h
index d8f656c..99fb617 100644
--- a/libc3/uw.h
+++ b/libc3/uw.h
@@ -16,7 +16,7 @@
#include "types.h"
-uw uw_cast (s_tag *tag);
+uw * uw_cast (s_tag *tag, uw *dest);
uw * uw_copy (const uw *src, uw *dest);
#endif /* U8_H */