diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-19 23:21:41 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-19 23:21:41 -0700 |
commit | 1ebafaf91f4f2bb09a1f4d23d7bfcfa97506a0e8 (patch) | |
tree | 686dd3007265a9e16a122521e3b18e6351006944 /lib.c | |
parent | 9dbcde8882a8a917b6d0329e06ea2232e62b1c8c (diff) | |
download | txr-1ebafaf91f4f2bb09a1f4d23d7bfcfa97506a0e8.tar.gz txr-1ebafaf91f4f2bb09a1f4d23d7bfcfa97506a0e8.tar.bz2 txr-1ebafaf91f4f2bb09a1f4d23d7bfcfa97506a0e8.zip |
cptr-int and cptr-obj can make typed cptr objects.
* eval.c (eval_init): Update registration of cptr-int and
cptr-obj with one optional argument.
* lib.c (cptr_int): New type symbol argument, defaulting
to nil. Also, don't bother defaulting the integer argument;
the function isn't registered for that being optional.
(cptr_obj): New type symbol argument, defaulting to nil.
* lib.h (cptr_int, cptr_obj): Declarations updated.
* txr.1: Documented cptr-int and cptr-obj function changes.
Added discussion of type tag to introductory paragraph.
Also added neglected documentation of the FFI cptr type,
both unparametrized and parametrized.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -7531,14 +7531,16 @@ val cptr_type(val cptr) return cptr->co.cls; } -val cptr_int(val n) +val cptr_int(val n, val type_sym_in) { - return if3(missingp(n), cptr(0), cptr(coerce(mem_t *, c_num(n)))); + val type_sym = default_null_arg(type_sym_in); + return cptr_typed(coerce(mem_t *, c_num(n)), type_sym, 0); } -val cptr_obj(val obj) +val cptr_obj(val obj, val type_sym_in) { - return cptr(coerce(mem_t *, obj)); + val type_sym = default_null_arg(type_sym_in); + return cptr_typed(coerce(mem_t *, obj), type_sym, 0); } val cptr_zap(val cptr) |