![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In addition to the functions above, the VMProxy
that is made
available to modules contains entry-points for many functions that aid
in developing GNU Smalltalk extensions in C. This node documents these
functions and the macros that are defined by `libgst/gstpub.h'.
Semaphore
object and signals
that object so that one of the processes waiting on that semaphore is
waken up. Since a Smalltalk call-in is not an atomic operation, the
correct way to signal a semaphore is not to send the signal
method to the object but, rather, to use:
asyncSignal(semaphoreOOP) |
The signal request will be processed as soon as the next message send is executed.
Caution: This and the next one are the only functions in the
intepreterProxy
that can be called from within a signal handler.
Semaphore
object and signals
that object so that one of the processes waiting on that semaphore is
waken up; the signal request will be processed as soon as the next
message send is executed. The object is then removed from the registry.
Semaphore
object and puts the
current process to sleep, unless the semaphore has excess signals on it.
Since a Smalltalk call-in is not an atomic operation, the correct way to
signal a semaphore is not to send the wait
method to the object
but, rather, to use:
syncWait(semaphoreOOP) |
The sync
in the name of this function distinguishes it from
asyncSignal
, in that it cannot be called from within a signal
handler.
objectAlloc
function allocates an OOP for a newly created
instance of the class whose OOP is passed as the first parameter; if
that parameter is not a class the results are undefined (for now, read
as "the program will most likely core dump", but that could change in
a future version).
The second parameter is used only if the class is an indexable one,
otherwise it is discarded: it contains the number of indexed instance
variables in the object that is going to be created. Simple uses of
objectAlloc
include:
OOP myClassOOP; OOP myNewObject; myNewObjectData obj; ... myNewObject = objectAlloc(myClassOOP, 0); obj = (myNewObjectData) OOP_TO_OBJ (myNewObject); obj->arguments = objectAlloc(classNameToOOP("Array"), 10); ... |
The function returns the old value of the indexed instance variable.
Finally, several slots of the interpreter proxy provide access to the system objects and to the most important classes. These are:
nilOOP
, trueOOP
, falseOOP
, processorOOP
objectClass
, arrayClass
, stringClass
,
characterClass
, smallIntegerClass
, floatDClass
,
floatEClass
, byteArrayClass
, objectMemoryClass
,
classClass
, behaviorClass
, blockClosureClass
,
contextPartClass
, blockContextClass
,
methodContextClass
, compiledMethodClass
,
compiledBlockClass
, fileDescriptorClass
,
fileStreamClass
, processClass
, semaphoreClass
,
cObjectClass
More may be added in the future
The macros are(22):
OOP_TO_OBJ
is not
valid anymore if a garbage-collection happens; for this reason, you
should assume that a pointer to object data is not valid after doing a
call-in, calling objectAlloc
, and caling any of the "C to
Smalltalk" functions (see section 5.4 Manipulating Smalltalk data from C).
OOP_CLASS(proxy->stringToOOP("Wonderful GNU Smalltalk"))
is the
String
class, as returned by classNameToOOP("String")
.
gst_object
structure. It is not safe to use
OOP_TO_OBJ
and OOP_CLASS
if isInt
returns false.
OOP_TO_OBJ
and
OOP_CLASS
only if IS_OOP
returns true.
gst_object
is defined, which prevents indexedOOP
from
working.
gst_object
is defined, which prevents indexedByte
from
working.
variableWordSubclass
. The first parameter must be a structure
declared as described in 5.7 Manipulating instances of your own Smalltalk classes from C).
variableByteSubclass
. The first parameter must be a structure
declared as described in 5.7 Manipulating instances of your own Smalltalk classes from C).
variableSubclass
.
The first parameter must be a structure declared as described in
5.7 Manipulating instances of your own Smalltalk classes from C).
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |