Calling an EsEntryPoint
Once an EsEntryPoint is created, send it the message address to bind it. The address can be passed to an external language function that requires a function pointer. For example, to get the address of the WindowProc callback described above:
address := windowProc address.
External functions calling Smalltalk using EsEntryPoint must run in the same thread as Smalltalk.
Error cases
The call to address can fail and cause a walkback for the following reasons:
No more entry points
All available EsEntryPoint addresses are in use.
Invalid calling convention
The EsEntryPoint is using an unsupported calling convention.
Not enough memory
There is insufficient memory to allocate a LargeInteger for the return value of the function or to allocate internal support structures.
EsEntryPoint failure
When the address of an EsEntryPoint is called by the external language, there is always the possibility of failure. It may not be possible to allocate the necessary objects required for the conversion to Smalltalk objects. The return value from Smalltalk may be invalid and unconvertable.
EsEntryPoint instances contain a fail address that defaults to 0. When the callback fails for any reason, this address is checked. If it is 0, 0 is returned from the callback. If it is not 0, it must be the address of a function that has exactly the same prototype as the EsEntryPoint. Upon failure, this function is called.
For example, in Windows, the following code can be used to catch a WindowProc failure:
windowProc failAddress: (PlatformFunctions at: 'DefWindowProc') address
This code causes DefWindowProc to be called when the Smalltalk WindowProc fails. When an EsEntryPoint unbinds, the fail address is reset to 0.
Last modified date: 01/29/2015