Download Self Handbook Documentation
Transcript
Self Handbook Documentation, Release 2 for Self 4.4 Conversion float double long_double bv bv_len Second part ptr_type ptr_type Self type float float float byte vector byte vector C/C++ type float double long double ptr_type ptr_type, int bv_null bv_len_null ptr_type ptr_type byte vector/0 byte vector/0 ptr_type ptr_type, int cbv cbv_len ptr_type ptr_type byte vector byte vector ptr_type ptr_type, int cbv_null cbv_len_null ptr_type ptr_type byte vector/0 byte vector/0 ptr_type ptr_type, int string byte vector char * string_len byte vector char *, int string_null byte vector/0 char * string_len_null byte vector/0 char *, int proxy (ptr_type, type_seal) proxy ptr_type, NULL proxy_null (ptr_type, type_seal) proxy ptr_type any_oop oop oop subtype any C/C++ type != any object oop corresponding oop (subtype) object int/float/proxy/byteint/float/ptr/ptr vector, int Errors badTypeError badTypeError badTypeError badTypeError badSizeError badTypeError badTypeError badSizeError badTypeError badTypeError badSizeError badTypeError badTypeError badSizeError badTypeError badTypeError nullCharError badTypeError nullCharError badTypeError nullCharError badTypeError nullCharError badTypeError badTypeSealError, deadProxyError,nullPointerError badTypeError badTypeSealError deadProxyError badTypeError badIndexError badTypeError deadProxyError Notes 3 3 3 4 4, 5 4, 6 4, 5, 6 7 7 7 7 8 5, 8 6, 8 5, 6, 8 9 9 10 11 12 1. The C type char has a system dependent range. Either 0..255 or -128..127. 2. The type smi is used internally in the virtual machine (a 30 bit integer). 3. Precision may be lost in the conversion. 4. The second part of the conversion is a C pointer type. The address of the first byte in the byte vector, cast to this pointer type, is passed to the foreign routine. It is the responsibility of the foreign routine not to go past the end of the byte vector. The foreign routine should not retain pointers into the byte vector after the call has terminated. Note: canonical strings can not be passed through a bv conversion (badTypeError will result). This is to ensure that they are not accidentally modified by a foreign function. 5. This conversion passes two values to the foreign routine: a pointer to the first byte in the byte vector, and an integer which is the length of the byte vector divided by sizeof(*ptr_type). If the size of the byte vector is not a multiple of sizeof(*ptr_type), badSizeError results. 6. In addition to accepting a byte vector, this conversion accepts the integer 0, in which case a NULL pointer is passed to the foreign routine. 126 Chapter 8. Virtual Machine Reference