From 428e7a38254a337e8bb6eeaeccdde8aea59909fd Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 19:20:18 +0300 Subject: [PATCH] Replace builtinspec_t with struct --- c/builtins.c | 2 +- c/cvalues.h | 29 +++++++++++++++-------------- c/flisp.c | 4 ++-- c/flisp.h | 6 +++--- c/iostream.c | 2 +- c/string.c | 2 +- c/table.c | 17 +++++++++-------- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/c/builtins.c b/c/builtins.c index c21b93b..f85fea4 100644 --- a/c/builtins.c +++ b/c/builtins.c @@ -477,7 +477,7 @@ extern void stringfuncs_init(void); extern void table_init(void); extern void iostream_init(void); -static builtinspec_t builtin_info[] = { +static struct builtinspec builtin_info[] = { { "environment", fl_global_env }, { "constant?", fl_constantp }, { "top-level-value", fl_top_level_value }, diff --git a/c/cvalues.h b/c/cvalues.h index e9a8b87..d549c4a 100644 --- a/c/cvalues.h +++ b/c/cvalues.h @@ -895,21 +895,22 @@ static value_t fl_logxor(value_t *args, u_int32_t nargs); static value_t fl_lognot(value_t *args, u_int32_t nargs); static value_t fl_ash(value_t *args, u_int32_t nargs); -static builtinspec_t cvalues_builtin_info[] = { { "c-value", cvalue_new }, - { "typeof", cvalue_typeof }, - { "sizeof", cvalue_sizeof }, - { "builtin", fl_builtin }, - { "copy", fl_copy }, - { "plain-old-data?", - fl_podp }, +static struct builtinspec cvalues_builtin_info[] = { + { "c-value", cvalue_new }, + { "typeof", cvalue_typeof }, + { "sizeof", cvalue_sizeof }, + { "builtin", fl_builtin }, + { "copy", fl_copy }, + { "plain-old-data?", fl_podp }, - { "logand", fl_logand }, - { "logior", fl_logior }, - { "logxor", fl_logxor }, - { "lognot", fl_lognot }, - { "ash", fl_ash }, - // todo: autorelease - { NULL, NULL } }; + { "logand", fl_logand }, + { "logior", fl_logior }, + { "logxor", fl_logxor }, + { "lognot", fl_lognot }, + { "ash", fl_ash }, + // todo: autorelease + { NULL, NULL } +}; #define cv_intern(tok) tok##sym = symbol(#tok) #define ctor_cv_intern(tok) \ diff --git a/c/flisp.c b/c/flisp.c index 2efc7ca..029e4bf 100644 --- a/c/flisp.c +++ b/c/flisp.c @@ -2217,7 +2217,7 @@ static value_t _stacktrace(uint32_t top) // builtins // ------------------------------------------------------------------- -void assign_global_builtins(builtinspec_t *b) +void assign_global_builtins(struct builtinspec *b) { while (b->name != NULL) { setc(symbol(b->name), cbuiltin(b->name, b->fptr)); @@ -2437,7 +2437,7 @@ value_t fl_map1(value_t *args, u_int32_t nargs) return first; } -static builtinspec_t core_builtin_info[] = { +static struct builtinspec core_builtin_info[] = { { "function", fl_function }, { "function:code", fl_function_code }, { "function:vals", fl_function_vals }, diff --git a/c/flisp.h b/c/flisp.h index 71b0487..eb46a09 100644 --- a/c/flisp.h +++ b/c/flisp.h @@ -401,12 +401,12 @@ uint32_t conv_to_uint32(void *data, numerictype_t tag); #define conv_to_ulong conv_to_uint32 #endif -typedef struct { +struct builtinspec { char *name; builtin_t fptr; -} builtinspec_t; +}; -void assign_global_builtins(builtinspec_t *b); +void assign_global_builtins(struct builtinspec *b); /* builtins */ value_t fl_hash(value_t *args, u_int32_t nargs); diff --git a/c/iostream.c b/c/iostream.c index 3616061..d7bb3f7 100644 --- a/c/iostream.c +++ b/c/iostream.c @@ -435,7 +435,7 @@ value_t fl_iotostring(value_t *args, u_int32_t nargs) return stream_to_string(&args[0]); } -static builtinspec_t iostreamfunc_info[] = { +static struct builtinspec iostreamfunc_info[] = { { "iostream?", fl_iostreamp }, { "eof-object", fl_eof_object }, { "eof-object?", fl_eof_objectp }, diff --git a/c/string.c b/c/string.c index 1f9c6af..51b84f1 100644 --- a/c/string.c +++ b/c/string.c @@ -419,7 +419,7 @@ value_t fl_string_isutf8(value_t *args, u_int32_t nargs) return u8_isvalid(s, len) ? FL_T : FL_F; } -static builtinspec_t stringfunc_info[] = { +static struct builtinspec stringfunc_info[] = { { "string", fl_string }, { "string?", fl_stringp }, { "string.count", fl_string_count }, diff --git a/c/table.c b/c/table.c index 62e436f..76e0fdc 100644 --- a/c/table.c +++ b/c/table.c @@ -205,14 +205,15 @@ value_t fl_table_foldl(value_t *args, uint32_t nargs) return zero; } -static builtinspec_t tablefunc_info[] = { { "table", fl_table }, - { "table?", fl_tablep }, - { "put!", fl_table_put }, - { "get", fl_table_get }, - { "has?", fl_table_has }, - { "del!", fl_table_del }, - { "table.foldl", fl_table_foldl }, - { NULL, NULL } }; +static struct builtinspec tablefunc_info[] = { { "table", fl_table }, + { "table?", fl_tablep }, + { "put!", fl_table_put }, + { "get", fl_table_get }, + { "has?", fl_table_has }, + { "del!", fl_table_del }, + { "table.foldl", + fl_table_foldl }, + { NULL, NULL } }; void table_init(void) {