[FFI] moving large memory

nicolas cellier ncellier at ifrance.com
Wed May 17 18:16:28 UTC 2006


Thanks John,

I hadn't understood that the ByteArray can be simply passed as char* and 
WordArray as long* in FFI, so your tip helped me a lot.

Le Mercredi 17 Mai 2006 13:47, nicolas cellier a écrit :
> Andreas, thanks
> but then how do i gain pointer access to data through smalltalk oop?
> Is there another way but writing a plugin?
>
> Nicolas

Yes, i understand at last FFI do that for us.
Apologies to Andreas for my being a little slow-brained, his solution was 
good.

Nicolas


Le Mercredi 17 Mai 2006 18:55, John M McIntosh a écrit :
> On 17-May-06, at 4:47 AM, nicolas cellier wrote:
> > Alan, thanks,
> > it seems convenient to move memory from Smalltalk to Smalltalk,
> > but i did not see any example using an ExternalAddress.
> > Since ExternalAddress are ByteArray with four bytes containing the
> > address,
> > i'am afraid it won't be interpreted as a pointer, but an array of
> > 32bits...
> > Or maybe i am wrong?
>
> In Sophie before using a Quicktime call to write bits into an
> external display surface we moved data from a a quicktime GWorld into
> a instance of Form
> using  the original mac os blockmovedata call which btw resolves to
> bcopy.
>
> fields
>  "MacPixMapHandle defineFields"
>  ^#((nil 'long'))
>
>
> updateOffscreenForm
>
>  | src dataSize |
>
>  src := self pixMapHandle getPixBaseAddr. "This returns a a memory
> address"
>
>  dataSize := (self offscreenForm width * 4) * self offscreenForm height.
>  SophieQuickTimeInterface apiBlockMoveData: src dest: (self
> offscreenForm bits) size: dataSize
>
> "self offscreenForm bits  points to the ByteArray of the Form"
>
>
> apiBlockMoveData: srcPtr dest:destPtr size:size
>  <cdecl: void 'BlockMoveData' (long long* long )
> module:'Carbon.framework'>
>  ^ self externalCallFailed
>
>
>
> "void BlockMoveData (
>     const void * srcPtr,
>     void * destPtr,
>     Size byteCount
> ); "
>
>
>
> --
> ========================================================================
> ===
> John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ========================================================================
> ===




More information about the Squeak-dev mailing list