Help with FFI structure pointer
Andreas Raab
andreas.raab at gmx.de
Wed Aug 2 12:25:46 UTC 2006
Ron Teitelbaum wrote:
> <apicall: MyStruct 'MyAPICall' (long) module: 'my.dll'> and sending in nil.
> And
> <apicall: MyStruct 'MyAPICall' (MyStruct) module: 'my.dll'> <- this is so
> cool! I assume that Andreas wrote this code, it is beautiful!
I did write the code but credits where credits are due: The design has
been *heavily* influenced by John Sarkela at the time who happened to
work with the customer and had done a similar design before (I think it
was for V but I don't quite remember).
Anyway, your two calls above should probably just one with:
myApiCall: myStruct
<apicall: MyStruct* 'MyAPICall' (MyStruct*) module: 'my.dll'>
since you can pass nil in places where pointers are expected (nil is
coerced to NULL in such situations), like here:
"call myApiCall with nil and record the result"
myStruct := self myApiCall: nil.
"call myApiCall with myStruct (ignoring the result)"
self myApiCall: myStruct.
> Ok now here it the problem:
>
> I have to call
>
> <apicall: void 'FreeContext' (MyStruct *) module: 'my.dll'> or something.
>
> The pointer needs to be sent to the apicall. Did I do this correctly (using
> MyStruct *) and it just doesn't work or is there another way to get the
> handle of the structure. The structure itself has a handle ivar but it's a
> byteArray.
This is likely because the missing pointer declaration in the first call
(e.g., using "MyStruct" instead of "MyStruct*").
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|