Programmer's Reference
The supported parameter types for the C language are:
- none, void
- This is not a valid parameter type. If used as the return type, the value
nil is returned.
- object
- No conversion is performed. The parameter value is passed directly to the
called function. Returned values are passed directly back to Smalltalk. The
PlatformFunction author must ensure that only valid VA Smalltalk Base
objects are returned.
- struct
- Can be used only as a parameter type; for parameters, this is valid only
for byte, word, or long objects and nil. For byte, word, and long
objects, the passed parameter is a pointer to the first instance variable of
the object. For nil, 0 (NULL) is passed.
- char, char8
- If used as a parameter type, the parameter must be a Character
whose numeric value is between 0 and 255. The parameter is converted to a C
char. If used as a return value, the low 8 bits of the return value are
converted to a Character before returning to Smalltalk.
- char16
- All instances of Character are converted. This means that the
passed-in values will be between 0 and 65535 and the low 16 bits of the return
value are converted to a Character on return.
- float, double, extended
- If used as a parameter type, the parameter must be a Float. The
parameter is converted to the specified size of float. If used as a return
value, the result is converted to an instance of Float.
- bool, boolean
- For outgoing parameters, only true or false can be
converted. The passed parameter is TRUE for true, FALSE for
false. As a return type, 0 is converted to false, and all other
values are converted to true. The passed value for true is
platform-dependent. The value of !0 in C is passed.
- int8, int16, 1nt32, int64, uint8, uint16, uint32, uint64
- If used as a parameter type, the parameter must be an Integer that
can be represented in 32 bits, Character, Boolean, or nil
(see Passed
parameters). Instances of OSObject with reftype immediate
(namely true, false, nil, Characters, and
SmallIntegers) can also be used (see OSObjects).
If used as a return type, the low n (8, 16, 32) bits of the return value are
sign- or zero-extended (signed or unsigned, respectively) and then converted
to a Smalltalk Integer. The return value in Smalltalk is guaranteed to
be within these given ranges:
- int8
- -128...127
- int16
- -32768...32767
- int32
- -2147483648...2147483647
- int64
- -2305843009213693952...2305843009213693951
- uint8
- 0...255
- uint16
- 0...65535
- uint32
- 0...4294967295
- uint64
- 0...18446744073709551616
- pointer
- As a parameter type, this is an amalgamation of the struct,
char, bool, and int type conversions. If the parameter is
a byte, word, or long object or nil, the struct conversion is
performed. If the parameter is true or false, the bool
conversion is performed. If the parameter is a Character, the
char16 conversion is performed. If the parameter is an Integer,
the uint32 conversion is performed.
Instances of OSObject can also be supplied as the parameter. If the
OSObject reftype is handle, the handle is dereferenced and the offset
is added. All other objects cause the conversion to fail. If used as a return
type, the uint32 conversion is performed.
- safePointer
- As a parameter type, the parameter may be a byte, word or long object.
Instances of OSObject can also be supplied as the parameter provided
they do not have reftype immediate. If used as a return type, the
uint32 conversion is performed.
All values passed to C functions are extended to a 32-bit quantity before
being passed. Signed integers are sign extended; unsigned integers are zero
extended. Because the C compiler does the same thing, it will be transparent to
you.
All of the int types perform the same conversion for when converting
from VA Smalltalk Base objects to external language values. For example, it is
legal to pass -1 as a uint32 or a uint8. Both result in 0xFFFFFFFF
being passed.
[ Top of
Page | Previous Page
| Next Page
| Table of
Contents | Index
]