Skip to content

Commit

Permalink
Convert the stack pointer from alien to ExternalAddress early
Browse files Browse the repository at this point in the history
This way >>#handle:at: will work with the ExternalAddress instead of an alien and FFIExternalStructure handle (or handle of handles) will work with an address. In case of structs (and not pointers to struct) this means they reference the stack and are invalid once the FFI call returns. While this looks scary it seems to be desired over a copy.
  • Loading branch information
zecke committed Apr 4, 2019
1 parent d1fa886 commit 08302d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/UnifiedFFI/FFICallbackArgumentReader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ FFICallbackArgumentReader >> extractPointerOfType: aType [

| pair baseAddressToRead offsetOfBaseAddress |
pair := self nextBaseAddressFor: aType.
baseAddressToRead := pair first.
baseAddressToRead := ExternalAddress fromAddress: pair first address.
offsetOfBaseAddress := pair second.

extractedArguments add: (aType handle: baseAddressToRead at: offsetOfBaseAddress).
Expand All @@ -207,7 +207,7 @@ FFICallbackArgumentReader >> extractStructType: type [
| pair baseAddressToRead offsetOfBaseAddress |

pair := self nextBaseAddressForStructure: type.
baseAddressToRead := pair first.
baseAddressToRead := ExternalAddress fromAddress: pair first address.
offsetOfBaseAddress := pair second.

extractedArguments add: (type handle: baseAddressToRead at: offsetOfBaseAddress).
Expand Down

0 comments on commit 08302d7

Please sign in to comment.