diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-26 06:39:24 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-26 06:39:24 -0700 |
commit | 86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d (patch) | |
tree | 8221e9e8446b7ec862bfabbed849cf6b440a804b /lib.c | |
parent | abd32610d0c1b75226e0edb6a34c54723de83eb6 (diff) | |
download | txr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.tar.gz txr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.tar.bz2 txr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.zip |
New cptr functions cptr-cast and int-cptr.
* eval.c (eval_init): Register new intrinsics cptr-cast and
int-cptr.
* lib.c (cptr_cast, int_cptr): New functions.
* lib.h (cptr_cast, int_cptr): Declared.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -7558,6 +7558,17 @@ val cptr_free(val cptr) return cptr; } +val cptr_cast(val to_type, val cptr) +{ + mem_t *ptr = cptr_handle(cptr, nil, lit("cptr-cast")); + return cptr_typed(ptr, to_type, 0); +} + +val int_cptr(val cptr) +{ + return num(coerce(cnum, cptr_handle(cptr, nil, lit("int-cptr")))); +} + mem_t *cptr_handle(val cptr, val type_sym, val self) { if (type(cptr) != CPTR) |