Programmer Reference : VAST Virtual Machine API : Using user primitive functions outside user primitives
Using user primitive functions outside user primitives
Many of the functions described in this chapter can be used only from within a user primitive, where EsPrimVMContext is defined. In order to use these functions from other places, you must set up a dummy user primitive environment in your function.
You first need to store a globalInfo. (See Asynchronous messages (interrupts) for details.) Then, you can handle the following code anywhere in the local variable declaration section of your function:
ESGlobalInfo * gInfo;
...Variable declarations...
...Now you can use any user primitive function...
You cannot use EsPrimReceiver, EsPrimArgumentCount, or EsPrimArgument(n) from within the dummy environment. EsPrimVMContext is defined.
This mechanism can be used only from a clean point in the virtual machine. The virtual machine is at a clean point when it calls a user primitive or PlatformFunction. This mechanism should not be used during an interrupt handler, because the virtual machine is not then at a clean point.
This mechanism is most useful for callbacks from the operating system. For example, if you were to call out (using a PlatformFunction) to the operating system and bring a window to the front, the operating system might immediately call back asking the window to expose or paint. These messages can immediately be sent to Smalltalk using EsSendMessage, because the virtual machine was at a clean point when it called out to the operating system.
Last modified date: 01/29/2015