[squeak-dev] FFI related questions
vagy
vagy at freemail.gr
Tue Jan 5 13:43:02 UTC 2010
Hello and a happy new year!,
first of i would like to express a big thumbs up for the tremendous effort
you
all have been doing the last months wrt the trunk image. Its really
amazing :-)
I have some FFI on Windows related questions.
(fyi, i am using the trunk image on which i loaded the latest FFI code
from SqueakSource, FFI-Kernel-ar.12.mcz and FFI-Pools-ar.1.mcz)
Is it possible, in general, to pass down to C "basic" Smalltalk objects,
like Integers,
Floats etc. and have their value changed by the C routine? I am trying to
do something
like:
anInteger := 5.
that i want to send to C and simply change it by, say :
apiChangeInteger: anInteger
<cdecl: void 'change_integer' (long*) module:'MyDLL'>
(which finally in C reads like: void set_integer(int* anInteger) {
*anInteger = *anInteger + 5; } )
I have found the above scheme to not work as i would expect.
Interestingly, if i push down to C an array of basic values like:
integers := {10. 20. 30} asIntegerArray
the C routine can change the values. For completeness, passing down arrays
of values
works for FloatArrays like:
singlePrecisionFloats := {10.5. 20.5. 30.5} asFloatArray
(and then passed to a C routine having a float* argument)
but not for :
doublePrecisionFloats := {10.5. 20.5. 30.5}
(with the C routine having a double* argument)
Probably i am not using FFI as intended although i would expect to be able
to do all this.
Can someone (Andreas?) please shed some light to all this?
Another thing that isn't clear to me is if its possible to have FFI create
Smalltalk objects
in behalf of a requesting client. In Java's JNI for instance one can say:
jni->NewFloatArray(length of the array);
If it can be done (i mean no VM restrictions) and you also think that it
would be generally useful (i do),
i am willing to implement such "helper" routines.
Cheers
- Vagelis
More information about the Squeak-dev
mailing list
|