Perform work in macro calling environment #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Call
ffi--prep-cif
and thedefiner-function
offfi--struct-union-helper
in the calling environment of the macros not during the macro expansion. This is so that compiling programs that usedefine-ffi-function
,define-ffi-struct
, etc. work. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Wrong-Time.html#Wrong-Time.Also instead of defining the library as a function in
define-ffi-library
I thought it would be better to mark it as a constant since a library is only every opened once. Note thatdefine-ffi-library
also had the problem of performing work when expanding the macro as described above.Finally, I changed the expansion of
define-ffi-function
based on the expansion oflexical-let
. In the previous implementation, a variable which holds theffi
function object returned byffi--dlsym
was using the globalobarray
symbol table (this holds all the variable and function symbols visible to emacs. This means thatdescribe-variable
and the like would show the variable holding theffi
function object when really this is only ever used inside the function returned bydefine-ffi-function
. In this re-implementation, the variables which hold thecif
and theffi
function objects are not added to the globalobarray
and are only visible to the function returned bydefine-ffi-function
.