mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Exploring how define-c could inline functions
This commit is contained in:
parent
7c287a97a2
commit
074dee7886
2 changed files with 20 additions and 3 deletions
|
@ -275,6 +275,21 @@ object Cyc_io_read_line(void *data, object cont, object port);
|
||||||
*/
|
*/
|
||||||
/**@{*/
|
/**@{*/
|
||||||
|
|
||||||
|
#define unboxed_inexact_double_op(data, ptr, OP, z) \
|
||||||
|
double unboxed; \
|
||||||
|
Cyc_check_num(data, z); \
|
||||||
|
if (obj_is_int(z)) { \
|
||||||
|
unboxed = OP(obj_obj2int(z)); \
|
||||||
|
} else if (type_of(z) == integer_tag) { \
|
||||||
|
unboxed = OP(((integer_type *)z)->value); \
|
||||||
|
} else if (type_of(z) == bignum_tag) { \
|
||||||
|
unboxed = OP(mp_get_double(&bignum_value(z))); \
|
||||||
|
} else { \
|
||||||
|
unboxed = OP(((double_type *)z)->value); \
|
||||||
|
} \
|
||||||
|
assign_double(ptr, unboxed); \
|
||||||
|
return ptr;
|
||||||
|
|
||||||
#define return_inexact_double_op(data, cont, OP, z) \
|
#define return_inexact_double_op(data, cont, OP, z) \
|
||||||
make_double(d, 0.0); \
|
make_double(d, 0.0); \
|
||||||
Cyc_check_num(data, z); \
|
Cyc_check_num(data, z); \
|
||||||
|
|
|
@ -72,9 +72,11 @@
|
||||||
; TODO: experimenting with how an inline definition might look.
|
; TODO: experimenting with how an inline definition might look.
|
||||||
; need something that can both work within the same module and
|
; need something that can both work within the same module and
|
||||||
; also when imported into another module.
|
; also when imported into another module.
|
||||||
; inline:
|
;; Inline arguments:
|
||||||
; "(void *data, object ptr, object z)"
|
"(void *data, object ptr, object z)"
|
||||||
; " return_inexact_double_op(data, k, log, z);"
|
;; must always return an object
|
||||||
|
;; Inline body:
|
||||||
|
" unboxed_inexact_double_op(data, ptr, log, z);"
|
||||||
)
|
)
|
||||||
(define-c sin
|
(define-c sin
|
||||||
"(void *data, int argc, closure _, object k, object z)"
|
"(void *data, int argc, closure _, object k, object z)"
|
||||||
|
|
Loading…
Add table
Reference in a new issue