summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-03-12 12:27:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-03-12 12:27:57 -0700
commit6b7c80ff724f4f8baec2fc0984c6178f75fd9bcd (patch)
tree7d27494d2058e68d5a727387e810fbdd78a9237d /struct.c
parent7809492815eb35df33e52aae72e03ce10349def5 (diff)
downloadtxr-6b7c80ff724f4f8baec2fc0984c6178f75fd9bcd.tar.gz
txr-6b7c80ff724f4f8baec2fc0984c6178f75fd9bcd.tar.bz2
txr-6b7c80ff724f4f8baec2fc0984c6178f75fd9bcd.zip
New: struct-from-plist and struct-from-args.
* struct.c (struct_init): Register new functions. (struct_from_plist, struct_from_args): New functions. * struct.h (struct_from_plist, struct_from_args): Declared. * txr.1: Documented.
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/struct.c b/struct.c
index 5a0e4734..91e6807c 100644
--- a/struct.c
+++ b/struct.c
@@ -131,6 +131,8 @@ void struct_init(void)
reg_fun(intern(lit("struct-type-p"), user_package), func_n1(struct_type_p));
reg_fun(intern(lit("super"), user_package), func_n1(super));
reg_fun(intern(lit("make-struct"), user_package), func_n2v(make_struct));
+ reg_fun(intern(lit("struct-from-plist"), user_package), func_n1v(struct_from_plist));
+ reg_fun(intern(lit("struct-from-args"), user_package), func_n1v(struct_from_args));
reg_fun(intern(lit("make-lazy-struct"), user_package),
func_n2(make_lazy_struct));
reg_fun(make_struct_lit_s, func_n2(make_struct_lit));
@@ -503,6 +505,18 @@ val make_struct(val type, val plist, struct args *args)
return sinst;
}
+val struct_from_plist(val type, struct args *plist)
+{
+ val list = args_get_list(plist);
+ args_decl(boa, 0);
+ return make_struct(type, list, boa);
+}
+
+val struct_from_args(val type, struct args *boa)
+{
+ return make_struct(type, nil, boa);
+}
+
static void lazy_struct_init(val sinst, struct struct_inst *si)
{
val self = lit("make-lazy-struct");