[squeak-dev] Re: FFI: Pass a Smalltalk String as part of a Structure
Andreas Raab
andreas.raab at gmx.de
Fri Oct 23 03:41:54 UTC 2009
Hi -
You need to create an instance of ExternalData and pass this in. For
example:
setPath: aString
"Set the path in this structure from a Squeak string"
| xHandle xData |
xHandle:= ExternalAddress allocate: aString size+1.
1 to: aString size do:[:i| xHandle byteAt: i-1 put: (aString byteAt: i)].
xHandle byteAt: aString size put: 0.
xData := ExternalData fromHandle: xHandle type: ExternalType char
asPointerType.
^self path: xData
Hope this helps,
- Andreas
Udo Schneider wrote:
> Hi,
>
> I defined an FFI Structure using
>
> MyStruc class>>fields
> ^#( #path 'char*) )
>
> After calling define Fields I see that the wrappers are generated.
> However I not quite sure how to pass a Smalltalk String in.
>
> Something like
>
> MyStruc new path: '/home/udos/'
>
> does not work.
>
> Any pointers?
>
> CU,
>
> Udo
>
>
>
More information about the Squeak-dev
mailing list
|