Squeak Class Documentation category index | class index  
 
ExternalType
  category: FFI-Kernel
  superclass: Object
  subclasses:

An external type represents the type of external objects.

Instance variables:
compiledSpec <WordArray> Compiled specification of the external type
referentClass <Behavior | nil> Class type of argument required
referencedType <ExternalType> Associated (non)pointer type with the receiver

Compiled Spec:
The compiled spec defines the type in terms which are understood by the VM. Each word is defined as:
bits 0...15 - byte size of the entity
bit 16 - structure flag (FFIFlagStructure)
This flag is set if the following words define a structure
bit 17 - pointer flag (FFIFlagPointer)
This flag is set if the entity represents a pointer to another object
bit 18 - atomic flag (FFIFlagAtomic)
This flag is set if the entity represents an atomic type.
If the flag is set the atomic type bits are valid.
bits 19...23 - unused
bits 24...27 - atomic type (FFITypeVoid ... FFITypeDoubleFloat)
bits 28...31 - unused

Note that all combinations of the flags FFIFlagPointer, FFIFlagAtomic, and FFIFlagStructure are invalid, EXCEPT from the following:

FFIFlagPointer + FFIFlagAtomic:
This defines a pointer to an atomic type (e.g., 'char*', 'int*').
The actual atomic type is represented in the atomic type bits.

FFIFlagPointer + FFIFlagStructure:
This defines a structure which is a typedef of a pointer type as in
typedef void* VoidPointer;
typedef Pixmap* PixmapPtr;
It requires a byte size of four (e.g. a 32bit pointer) to work correctly.

[Note: Other combinations may be allowed in the future]

instance methods
  accessing
  atomicType
byteSize
compiledSpec
referentClass

  converting
  asNonPointerType
asPointerType

  printing
  printOn:

  private
  compiledSpec:
embeddedSpecWithSize:
externalTypeName
headerWord
newReferentClass:
readFieldAt:
setReferencedType:
writeFieldAt:with:

  testing
  isAtomic
isIntegerType
isPointerType
isSigned
isStructureType
isUnsigned
isVoid

class methods
  class initialization
  initialize
initializeAtomicTypes
initializeDefaultTypes
initializeFFIConstants
initializeStructureTypes
obsolete

  housekeeping
  cleanupUnusedTypes
noticeModificationOf:
noticeRemovalOf:
noticeRenamingOf:from:to:

  instance creation
  new

  private
  atomicTypeNamed:
forceTypeNamed:
newTypeNamed:force:
pointerSpec
structTypeNamed:
structureSpec

  type constants
  bool
byte
char
double
float
long
sbyte
schar
short
signedByte
signedChar
signedLong
signedLongLong
signedShort
string
ulong
unsignedByte
unsignedChar
unsignedLong
unsignedLongLong
unsignedShort
ushort
void

instance methods
  accessing top  
 

atomicType


 

byteSize

Return the size in bytes of this type


 

compiledSpec

Return the compiled spec of the receiver


 

referentClass

Return the class specifying the receiver


  converting top  
 

asNonPointerType

convert the receiver into a non pointer type


 

asPointerType

convert the receiver into a pointer type


  printing top  
 

printOn:

Append to the argument, aStream, a sequence of characters that
identifies the receiver.


  private top  
 

compiledSpec:


 

embeddedSpecWithSize:

Return a compiled spec for embedding in a new compiled spec.


 

externalTypeName


 

headerWord

Return the compiled header word


 

newReferentClass:

The class I'm referencing has changed. Update my spec.


 

readFieldAt:

Return a string defining the accessor to an entity of the receiver type starting at the given byte offset.
Private. Used for field definition only.


 

setReferencedType:


 

writeFieldAt:with:

Return a string defining the accessor to an entity
of the receiver type starting at the given byte offset.
Private. Used for field definition only.


  testing top  
 

isAtomic

Return true if the receiver describes a built-in type


 

isIntegerType

Return true if the receiver is a built-in integer type


 

isPointerType

Return true if the receiver represents a pointer type


 

isSigned

Return true if the receiver is a signed type.
Note: Only useful for integer types.


 

isStructureType

Return true if the receiver represents a structure type


 

isUnsigned

Return true if the receiver is an unsigned type.
Note: Only useful for integer types.


 

isVoid

Return true if the receiver describes a plain 'void' type


class methods
  class initialization top  
 

initialize

ExternalType initialize


 

initializeAtomicTypes

ExternalType initialize


 

initializeDefaultTypes

ExternalType initialize


 

initializeFFIConstants

ExternalType initialize


 

initializeStructureTypes

ExternalType initialize


 

obsolete

Change the receiver and all of its subclasses to an obsolete class.


  housekeeping top  
 

cleanupUnusedTypes

ExternalType cleanupUnusedTypes


 

noticeModificationOf:

A subclass of ExternalStructure has been redefined.
Clean out any obsolete references to its type.


 

noticeRemovalOf:

A subclass of ExternalStructure is being removed.
Clean out any obsolete references to its type.


 

noticeRenamingOf:from:to:

An ExternalStructure has been renamed from oldName to newName.
Keep our type names in sync.


  instance creation top  
 

new

Use either the type constants or #externalType for creating external types


  private top  
 

atomicTypeNamed:


 

forceTypeNamed:


 

newTypeNamed:force:


 

pointerSpec


 

structTypeNamed:


 

structureSpec


  type constants top  
 

bool


 

byte

byte defaults to unsigned byte


 

char

char defaults to unsigned char


 

double


 

float


 

long


 

sbyte


 

schar


 

short


 

signedByte


 

signedChar


 

signedLong


 

signedLongLong


 

signedShort


 

string


 

ulong


 

unsignedByte


 

unsignedChar


 

unsignedLong


 

unsignedLongLong


 

unsignedShort


 

ushort


 

void