Replace builtinspec_t with struct

This commit is contained in:
Lassi Kortela 2019-08-09 19:20:18 +03:00
parent e54797e4eb
commit 428e7a3825
7 changed files with 32 additions and 30 deletions

View File

@ -477,7 +477,7 @@ extern void stringfuncs_init(void);
extern void table_init(void); extern void table_init(void);
extern void iostream_init(void); extern void iostream_init(void);
static builtinspec_t builtin_info[] = { static struct builtinspec builtin_info[] = {
{ "environment", fl_global_env }, { "environment", fl_global_env },
{ "constant?", fl_constantp }, { "constant?", fl_constantp },
{ "top-level-value", fl_top_level_value }, { "top-level-value", fl_top_level_value },

View File

@ -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_lognot(value_t *args, u_int32_t nargs);
static value_t fl_ash(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 }, static struct builtinspec cvalues_builtin_info[] = {
{ "typeof", cvalue_typeof }, { "c-value", cvalue_new },
{ "sizeof", cvalue_sizeof }, { "typeof", cvalue_typeof },
{ "builtin", fl_builtin }, { "sizeof", cvalue_sizeof },
{ "copy", fl_copy }, { "builtin", fl_builtin },
{ "plain-old-data?", { "copy", fl_copy },
fl_podp }, { "plain-old-data?", fl_podp },
{ "logand", fl_logand }, { "logand", fl_logand },
{ "logior", fl_logior }, { "logior", fl_logior },
{ "logxor", fl_logxor }, { "logxor", fl_logxor },
{ "lognot", fl_lognot }, { "lognot", fl_lognot },
{ "ash", fl_ash }, { "ash", fl_ash },
// todo: autorelease // todo: autorelease
{ NULL, NULL } }; { NULL, NULL }
};
#define cv_intern(tok) tok##sym = symbol(#tok) #define cv_intern(tok) tok##sym = symbol(#tok)
#define ctor_cv_intern(tok) \ #define ctor_cv_intern(tok) \

View File

@ -2217,7 +2217,7 @@ static value_t _stacktrace(uint32_t top)
// builtins // builtins
// ------------------------------------------------------------------- // -------------------------------------------------------------------
void assign_global_builtins(builtinspec_t *b) void assign_global_builtins(struct builtinspec *b)
{ {
while (b->name != NULL) { while (b->name != NULL) {
setc(symbol(b->name), cbuiltin(b->name, b->fptr)); 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; return first;
} }
static builtinspec_t core_builtin_info[] = { static struct builtinspec core_builtin_info[] = {
{ "function", fl_function }, { "function", fl_function },
{ "function:code", fl_function_code }, { "function:code", fl_function_code },
{ "function:vals", fl_function_vals }, { "function:vals", fl_function_vals },

View File

@ -401,12 +401,12 @@ uint32_t conv_to_uint32(void *data, numerictype_t tag);
#define conv_to_ulong conv_to_uint32 #define conv_to_ulong conv_to_uint32
#endif #endif
typedef struct { struct builtinspec {
char *name; char *name;
builtin_t fptr; builtin_t fptr;
} builtinspec_t; };
void assign_global_builtins(builtinspec_t *b); void assign_global_builtins(struct builtinspec *b);
/* builtins */ /* builtins */
value_t fl_hash(value_t *args, u_int32_t nargs); value_t fl_hash(value_t *args, u_int32_t nargs);

View File

@ -435,7 +435,7 @@ value_t fl_iotostring(value_t *args, u_int32_t nargs)
return stream_to_string(&args[0]); return stream_to_string(&args[0]);
} }
static builtinspec_t iostreamfunc_info[] = { static struct builtinspec iostreamfunc_info[] = {
{ "iostream?", fl_iostreamp }, { "iostream?", fl_iostreamp },
{ "eof-object", fl_eof_object }, { "eof-object", fl_eof_object },
{ "eof-object?", fl_eof_objectp }, { "eof-object?", fl_eof_objectp },

View File

@ -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; return u8_isvalid(s, len) ? FL_T : FL_F;
} }
static builtinspec_t stringfunc_info[] = { static struct builtinspec stringfunc_info[] = {
{ "string", fl_string }, { "string", fl_string },
{ "string?", fl_stringp }, { "string?", fl_stringp },
{ "string.count", fl_string_count }, { "string.count", fl_string_count },

View File

@ -205,14 +205,15 @@ value_t fl_table_foldl(value_t *args, uint32_t nargs)
return zero; return zero;
} }
static builtinspec_t tablefunc_info[] = { { "table", fl_table }, static struct builtinspec tablefunc_info[] = { { "table", fl_table },
{ "table?", fl_tablep }, { "table?", fl_tablep },
{ "put!", fl_table_put }, { "put!", fl_table_put },
{ "get", fl_table_get }, { "get", fl_table_get },
{ "has?", fl_table_has }, { "has?", fl_table_has },
{ "del!", fl_table_del }, { "del!", fl_table_del },
{ "table.foldl", fl_table_foldl }, { "table.foldl",
{ NULL, NULL } }; fl_table_foldl },
{ NULL, NULL } };
void table_init(void) void table_init(void)
{ {