Appendix B. Calling external functions using Smalltalk
As you learned in
Accessing external functions, VA Smalltalk supports calling external functions by using objects called
platform functions. A platform function (an instance of class
PlatformFunction) represents a function outside the VA Smalltalk environment. This chapter covers how to call external functions using VA Smalltalk code instead of visual parts.
Generally, the process of calling an external function from VA Smalltalk code involves the following steps:
• Create a new record wrapper class (as a subclass of AbtForeignOSObject) to represent each parameter that will be passed to the external function.
• Parse the C header file or COBOL copybook to identify the function prototypes and data types described in the file. The parser stores the resulting information in an object called an object table.
• Use an entry in the object table to generate getter and setter methods in the record wrapper class. You can use these methods to set the parameter value contained by the record wrapper. If the parameter is of a compound data type, generate getter and setter methods for each field.
• Create an instance of the PlatformFunction class to represent the external function you want to call.
• Create an instance of your record wrapper class and use the setter methods to provide the input values for the function call.
• Use the PlatformFunction instance to call the external function, passing it the record wrapper containing the input values.
• Use the getter methods of the record wrappers to retrieve the external function's output values.
The basic, non-part-based portion of VA Smalltalk provides classes that enable you to perform each of these tasks.
Last modified date: 09/30/2019