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-cifand thedefiner-functionofffi--struct-union-helperin 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-libraryI thought it would be better to mark it as a constant since a library is only every opened once. Note thatdefine-ffi-libraryalso had the problem of performing work when expanding the macro as described above.Finally, I changed the expansion of
define-ffi-functionbased on the expansion oflexical-let. In the previous implementation, a variable which holds theffifunction object returned byffi--dlsymwas using the globalobarraysymbol table (this holds all the variable and function symbols visible to emacs. This means thatdescribe-variableand the like would show the variable holding theffifunction object when really this is only ever used inside the function returned bydefine-ffi-function. In this re-implementation, the variables which hold thecifand theffifunction objects are not added to the globalobarrayand are only visible to the function returned bydefine-ffi-function.