summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-30 20:59:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-30 20:59:31 -0700
commit81d654e02fc4f6f9896ad6b1755ea8138900e2a3 (patch)
tree011e575958758ffe373d16c0ce8ecce55740be5b /ffi.c
parentd5de2c354ccd3c2a1836963f0366522bc36c04d2 (diff)
downloadtxr-81d654e02fc4f6f9896ad6b1755ea8138900e2a3.tar.gz
txr-81d654e02fc4f6f9896ad6b1755ea8138900e2a3.tar.bz2
txr-81d654e02fc4f6f9896ad6b1755ea8138900e2a3.zip
ffi: new ffi-type-operator-p and ffi-type-p.
* ffi.c (ffi_type_operator_p, ffi_type_p): New functions. (ffi_init): Register ffi-type-operator-p and ffi-type-p intrinsics. * ffi.h (ffi_type_operator_p, ffi_type_p): Declared. * txr.1: Documented.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ffi.c b/ffi.c
index 3c8a1c8c..8170cb8b 100644
--- a/ffi.c
+++ b/ffi.c
@@ -3591,6 +3591,22 @@ excess:
self, syntax, nao);
}
+val ffi_type_operator_p(val sym)
+{
+ return tnil(sym == struct_s || sym == union_s || sym == array_s ||
+ sym == zarray_s || sym == ptr_in_s || sym == ptr_in_d_s ||
+ sym == ptr_out_s || sym == ptr_out_d_s || sym == ptr_s ||
+ sym == ptr_out_s_s || sym == buf_s || sym == buf_d_s ||
+ sym == cptr_s || sym == carray_s || sym == sbit_s ||
+ sym == ubit_s || sym == bit_s || sym == enum_s ||
+ sym == enumed_s || sym == align_s || sym == bool_s);
+}
+
+val ffi_type_p(val sym)
+{
+ return tnil(gethash(ffi_typedef_hash, sym));
+}
+
static void ffi_init_types(void)
{
#if UCHAR_MAX == CHAR_MAX
@@ -5416,6 +5432,8 @@ void ffi_init(void)
ffi_call_desc_s = intern(lit("ffi-call-desc"), user_package);
ffi_closure_s = intern(lit("ffi-closure"), user_package);
reg_fun(intern(lit("ffi-type-compile"), user_package), func_n1(ffi_type_compile));
+ reg_fun(intern(lit("ffi-type-operator-p"), user_package), func_n1(ffi_type_operator_p));
+ reg_fun(intern(lit("ffi-type-p"), user_package), func_n1(ffi_type_p));
#if HAVE_LIBFFI
reg_fun(intern(lit("ffi-make-call-desc"), user_package), func_n4(ffi_make_call_desc));
reg_fun(intern(lit("ffi-call"), user_package), func_n2v(ffi_call_wrap));