How to return via buffers using FFI?

Andreas Raab Andreas.Raab at gmx.de
Sun Sep 8 00:03:01 UTC 2002


Ned,

> I got past that hurdle.
> 
> Now it's complaining about a bad argument.
> I've tried a few things here, none of which worked:
> * declare the length parameters as 'ulong*' and pass numbers

Of course not! Where would you expect the result to be stored?!
Somewhere in Squeak's object memory?! ;-)

> * declare the 'reserved' parameter as 'void*' and pass 
> ExternalData new beNull

If it's a pointer to something you can always pass nil (which will be
interpreted as NULL). That's not the problem here.

> * declare the length parameters as 'Win32DWORD*" and pass 
> same (not sure if I made this right)

This one is. There's a subtle, yet important, difference between
	MyClass class>>defineFields
		^#('foo'	ulong)
and
	MyClass class>>defineFields
		^#(
			('foo' ulong)
		).
The first version basically declares an explicit alias (#define) of the
structure you're defining to the type of foo whereas the second defines
a structure (typdef struct) containing the type of foo. In the beginning
I thought it would be a useful feature to be able of having something
that allows one to use the equivalent of "#define MyInt int" but I think
this feature has turned out to be more like a bug...

Cheers,
  - Andreas




More information about the Squeak-dev mailing list