[Q] primtives versus apicall
Jamie Gjerde
jgjerde at contrarymotion.com
Fri Mar 12 14:56:05 UTC 2004
i have recently built a small squeak plugin written in c to communicate
and execute some c code for both windows (dll) and macosx(.bundle). i
am using named primitives <primitive: module:> and everything works
just fine. now i am really curious as to how different the named
primitive method is to <apicall: module:> . i was able to find a little
info on google about apicall but nothing that directly stated any
differences between apicall and the named primitive method.
at first glance it would seem to me that the apicall method does not
require creating a c wrapper to communicate with the interpreterProxy
like the named primitve method does. i can easily infer this by looking
at the ffi smalltalk classes and looking at all of the win32 api calls
that i am familiar with.
since i am doing everything in c to begin with, compiling my plugins,
and just writing a simple smalltalk interface that inherits from
InterpreterPlugin, it seems that i would be better off using the
apicall method. i notice that the osx apicalls go to frameworks on
panther at least, but this is not a problem.
so i have a couple questions that i would be grateful for someone to
either answer for me or point at some documentation that might explain
it.
1) am i correct in assuming that i can directly call any c function
that resides in a dll or framework from squeak by simply doing
<apicall: module:> without having to recompile any part of the vm?
2)how are datatypes mapped to each other from smalltalk to c in the
apicall method? pointers, structures, a two dimensional array ( int**
myIntPointers)? and then how are they returned where squeak knows what
they are? i know the primtive method uses the interpreterProxy.
3)other than not having to write the primitive wrappers, are there any
other advantages to using apicall over named primitives? is it faster?
thanks in advance, i hope that am not asking for too much information
but i have not been able to find what i want to know from anywhere
else.
ps: i do not want to touch or recompile anything that has to do with
the vm. what i have done so far with named primitives has prevented me
from having to recompile anything else but the code for plugin, which
is what i want.
jamie
More information about the Squeak-dev
mailing list
|