diff options
author | Andy Wingo <wingo@pobox.com> | 2010-01-25 18:15:35 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-01-26 22:56:41 +0100 |
commit | d8b04f04e90882f3903092ea85038a9e3cd10d39 (patch) | |
tree | 96bc2b6908de147279883c2f41628b9d85a525bf /libguile/foreign.h | |
parent | 827dc8dcb61dcbdd62ad1ae41b98d65ecd8d5b66 (diff) | |
download | guile-d8b04f04e90882f3903092ea85038a9e3cd10d39.tar.gz |
first pass at implementing low-level foreign functions
* libguile/Makefile.am (AM_CPPFLAGS): Move LIBFFI_CFLAGS here (from
AM_CFLAGS), allowing snarfing to work.
* libguile/foreign.h (scm_make_foreign_function): New public function.
* libguile/foreign.c: Flesh out an implementation of foreign functions.
(scm_take_foreign_pointer): Bugfix for the case in which we have a
finalizer.
* module/system/foreign.scm: Export `make-foreign-function'.
Diffstat (limited to 'libguile/foreign.h')
-rw-r--r-- | libguile/foreign.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libguile/foreign.h b/libguile/foreign.h index 4a73afcdd..8424cde4b 100644 --- a/libguile/foreign.h +++ b/libguile/foreign.h @@ -98,6 +98,29 @@ SCM_API SCM scm_bytevector_to_foreign (SCM bv, SCM offset, SCM len); SCM_INTERNAL void scm_i_foreign_print (SCM foreign, SCM port, scm_print_state *pstate); + + + +/* Foreign functions */ + +/* The goal is to make it so that calling a foreign function doesn't cause any + heap allocation. That means we need native Scheme formats for all kinds of + arguments. + + For "value" types like s64 or f32, we just use native Scheme value types. + (Note that in both these cases, allocation is possible / likely, as the + value might need to be boxed, but perhaps we won't worry about that. Hmm.) + + For everything else, we use foreign pointers. This includes arrays, pointer + arguments and return vals, struct args and return vals, and out and in/out + arguments. + */ + +SCM_API SCM scm_make_foreign_function (SCM return_type, SCM func_ptr, + SCM arg_types); + + + SCM_INTERNAL void scm_register_foreign (void); |