Programmer Reference : VAST Virtual Machine API : Entry points : Parameter types and return types
Parameter types and return types
The supported parameter types and return types are:
none, void
This is not a valid parameter type. If it is used as the return type, the return value of the Smalltalk message is ignored and no value is returned to the caller of the EsEntryPoint.
char, char8
If it is used as a parameter type, the low eight bits of the parameter are converted to a Character whose numeric value is between 0 and 255. If it is used as a return type, the return value from the Smalltalk message must be a Character whose numeric value is between 0 and 255.
char16
If it is used as a parameter type, the low 16 bits of the parameter are converted to a Character. If it is used as a return type, the return value from the Smalltalk message must be a Character.
bool, boolean
If it is used as a parameter type, the low eight bits of the parameter are tested for 0. If they are 0, false is passed to the Smalltalk message. If they are not 0, true is passed. If it is used as a return type, only true or false can be converted. The return value is TRUE for true, and FALSE for false.
The return value for true is platform-dependent. In C it is the value of !0.
handle
@see pointer
int8, int16, int32, int64, uint8, uint16, uint32, uint64
If it is used as a parameter type, the low 8, 16, 32 or 64 bits of the parameter are converted to an Integer that is in the specified range. If it is used as a return type, the return value must be an Integer (see Returned parameters). The integer ranges are as follows:
int8
-128...127
int16
-32768...32767
int32
-2147483648...2147483647
int64
-2305843009213693952...2305843009213693951
uint8
0...255
uint16
0...65535
uint32
0...4294967295
uint64
0...18446744073709551616
struct
If it is used as a parameter type, the parameter is converted using uint32 conversion. If it is used as a return type, the return value must be a byte, word, or long object or a non-immediate OSObject. nil is returned as 0.
pointer
If used as a parameter type, the parameter is converted using uint32 conversion on a 32-bit virtual machine or a uint64 conversion on a 64-bit virtual machine. If it is used as a return type, this is an amalgamation of struct, char, bool, and int type conversions. For a given parameter type, the conversion performed is as follows:
byte object, word object, long object, nil
struct
true, false
bool
Character
char16
Integer
uint32
OSObject
struct
All other objects cause the conversion to fail.
safePointer
If it is used as a parameter type, this is the same as pointer conversion. If it is used as a return type, the parameter can be a fixed byte, word, or long object. Instances of OSObject can also be supplied as the parameter provided they are non-immediate.
If an OSObject whose reference is a byte, word, or long object is returned, the reference must be in fixed space. This is also true for byte, word, or long objects that are returned directly.
Returned parameters
The specified return type of a platform function should accurately reflect the type specified in the declaration of the function in C.
For example, if the return type of a C function is a int * (i.e. pointer), then the return type of the associated platform function is best expressed as pointer. Defining the return type instead as an int16 is not only semantically incorrect, but it will also be functionally incorrect in many cases since the return value will be truncated to 16 bits.
The example given above was not true in versions of VA Smalltalk prior to 9.0. In these older versions of the product, all values returned to external language functions were extended to a 32-bit quantity before being returned (except for int64 and uint64 which are returned as 64-bit quantities). This meant that one could return pointer sized values through int8 types. The change in version 9.0 has to do with implementation details of newer virtual machines introduced in that version.
Last modified date: 11/04/2019