[FFI] moving large memory

John M McIntosh johnmci at smalltalkconsulting.com
Wed May 17 16:55:37 UTC 2006


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