User primitive tables
Some VA Smalltalk platforms require user primitives to be statically linked with the virtual machine. Others require that all user primitives be placed in an external shared library. See
Platform requirements for details about your platform. In either case, user primitives are defined in the same way.
Platforms that require user primitives to be in an external shared library do not have user primitive tables. All user primitive functions must be public (exported) from the shared library. The name of the user primitive function must exactly match the name used in the Smalltalk primitive declaration or PlatformFunction function field.
For platforms that require static linking, all user primitives are accessed by the virtual machine through the user primitive table, EsUserPrimitiveTable.
The file userprim.c contains an empty user primitive table. To add user primitives, modify the file to include new primitives. For example:
EsDefinePrimitiveTable(EsUserPrimitiveTable)
EsPrimitiveTableEntry("nameFromSmalltalk", function)
...
EsEndPrimitiveTable
nameFromSmalltalk is the exact (case sensitive) name that the Smalltalk user primitive used in the <primitive: > statement.
See the sections at the end of this chapter for platform-specific examples of building a new user primitive table.
To allow multifile user primitives, tables can be nested, as follows:
/* userprim.c */
extern EsPrimitiveTable file1Table; /* prims from file1.c */
extern EsPrimitiveTable file2Table;
EsDefineUserPrimitive(function)
{
...
}
EsDefinePrimitiveTable(EsUserPrimitiveTable)
EsPrimitiveTableEntry("nameFromSmalltalk", function)
EsSubTable(file1Table)
EsSubTable(file2Table)
...
EsEndPrimitiveTable
/* file1.c */
EsDefinePrimitiveTable(file1Table)
EsPrimitiveTableEntry("nameFromSmalltalk", function)
...
EsEndPrimitiveTable
Primitive tables have type EsPrimitiveTable.
Last modified date: 01/29/2015