[squeak-dev] FFI: FFI-Tests-mt.60.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Aug 12 14:33:41 UTC 2021
Marcel Taeumel uploaded a new version of FFI-Tests to project FFI:
http://source.squeak.org/FFI/FFI-Tests-mt.60.mcz
==================== Summary ====================
Name: FFI-Tests-mt.60
Author: mt
Time: 12 August 2021, 4:33:41.048047 pm
UUID: d606180c-bdf8-ba4d-bc00-78ec76a5a699
Ancestors: FFI-Tests-mt.59
Complements FFI-Kernel-mt.200
=============== Diff against FFI-Tests-mt.59 ===============
Item was changed:
----- Method: FFIPluginLibraryTests>>invoke:withArguments: (in category 'support') -----
invoke: functionName withArguments: someObjects
"Use an instance of the library. Compile class-side methods to instance-side methods as needed."
| selector library |
selector := self lookupSelector: functionName numArgs: someObjects size.
library := FFITestLibrary new.
+ (library respondsTo: selector) ifFalse: [ | signature source prototype method |
- (library respondsTo: selector) ifFalse: [ | signature source prototype priorAuthorInitials |
"1) Build method signature."
signature := String streamContents: [:s | | index |
index := 0. selector do: [:char | s nextPut: char.
char = $: ifTrue: [ index := index + 1.
s space; nextPutAll: 'arg'; nextPutAll: index asString; space]]].
"2) Construct method source."
prototype := library class class compiledMethodAt: selector.
source := '{1}\ {2}\ <generated>\ {3}\ ^ self externalCallFailed' withCRs
format: {
signature.
'"This method was automatically generated. See {1}>>{2}"'
format: {prototype methodClass. prototype selector}.
prototype externalLibraryFunction copy
setModule: nil; printString }.
"3) Compile instance-side FFI call in library."
+ library class compileSilently: source classified: '*autogenerated - primitives'.
+ method := library class compiledMethodAt: selector.
+ method becomeForward: (method copyWithSourceCode: source)].
- priorAuthorInitials := Utilities authorInitialsPerSe.
- [Utilities authorInitials: 'FFI'.
- library class compile: source classified: '*autogenerated - primitives'
- ] ensure: [Utilities authorInitials: priorAuthorInitials]].
^ library perform: selector withArguments: someObjects!
More information about the Squeak-dev
mailing list
|