![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In addition to the functions described so far, the VMProxy
that is
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'.
NULL
, but
not an arbitrary pointer) and sets up the interpreter to call the
function as soon as the next message send is executed.
Caution: This and the next two are the only functions in the
intepreterProxy
that are thread-safe.
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.
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.
wakeUp
is an
alternative way to wake up the main Smalltalk loop. This should rarely
be necessary, since the above functions already call it automatically.
Semaphore
object and signals
that object so that one of the processes waiting on that semaphore is
waken up. If the semaphore has no process waiting in the queue and
the second argument is true, an excess signal is added to the semaphore.
Since a Smalltalk call-in is not an atomic operation, the correct way to
signal a semaphore is not to send the signal
or notify
methods to the object but, rather, to use:
syncSignal(semaphoreOOP, true) |
The sync
in the name of this function distinguishes it from
asyncSignal
, in that it can only be called from a procedure
already scheduled with asyncCall
. It cannot be called from
a call-in, or from other threads than the interpreter thread.
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(20):
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.8 Manipulating instances of your own Smalltalk classes from C).
variableByteSubclass
. The first parameter must be a structure
declared as described in 5.8 Manipulating instances of your own Smalltalk classes from C).
variableSubclass
.
The first parameter must be a structure declared as described in
5.8 Manipulating instances of your own Smalltalk classes from C).
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |