Understanding record structures
A record structure is an object that acts as a container for a parameter passed to an external function. Record structures contain information about each of the data types and fields identified in the parsed source file. The basic, non-part-based portion of VA Smalltalk uses this information to map Smalltalk objects to data passed to the external function.
A record structure contains a field for the parameter's value; if the parameter is of a compound type, the record structure contains multiple fields, one for each field of the data type. Methods of the record structure enable you to set and retrieve the values of the fields.
When your application passes the record structure to the external function, the basic, non-part-based portion of VA Smalltalk converts each record structure's value into a byte array that the external function can manipulate. If the external function changes the value of any parameters passed by reference, those changes are reflected in the record structure object. When the external function finishes, other parts of your application can retrieve the new values.
The two different kinds of record structures are as follows:
• Record wrapper classes. A record wrapper is a subclass of the AbtForeignOSObject class which is predefined to contain the correct data type for a particular parameter. An instance of a record wrapper class is therefore already configured for a particular external function parameter, so you do not have to tailor the individual instances of the record wrapper. A record wrapper class provides standard Smalltalk getter and setter methods that you can use to access the parameter values. Each field of a compound data type has a getter selector and a setter selector.
• AbtRecord, a "generic" record structure class. Each instance of the AbtRecord class is set up to contain the correct byte array for a particular external function parameter. The AbtRecord object provides an at:put: method you can use to place data into the byte array, specifying different field names if the AbtRecord object represents a compound data type. The AbtRecord object also provides an at: method, which retrieves the field values.
In Smalltalk programs, record wrappers are typically easier to use than AbtRecord. Each instance of AbtRecord must be separately set up to contain the correct fields, while record wrapper instances are predefined. However, because the VA Smalltalk parts that support external functions use AbtRecord to build record structures, you might want to use the AbtRecord technique in a Smalltalk program if you need your code to interact with an application built with VA Smalltalk.
Last modified date: 09/30/2019