Previous: , Up: syslib structs   [Index]


12.14.2 Low level structure operations

The arguments stru to these operations must be references to data structures, the arguments std must be references to structure type descriptors, the arguments fx must be fixnums of appropriate value. The following bindings are exported by the library (vicare system $structs).

Unsafe Operation: base-rtd

Return a reference to the type descriptor used as type for all the type descriptors.

Unsafe Operation: $struct? obj

Evaluate to true if obj is the reference to a structure.

Unsafe Operation: $struct/rtd? stru std

Evaluate to true if stru is a structure of type std.

Unsafe Operation: $make-struct std fx

Allocate a new data structure of type std capable of holding fx words and return a reference to it.

NOTE This operation initialises only the std field, leaving all the other fields set to a machine word with all the bits set to 1. We must be careful not to trigger a garbage collection before those fields are initialised with valid values, else the behaviour is undefined.

Unsafe Operation: $make-clean-struct std

Allocate a new data structure of type std and reset all the fields to the fixnum zero.

Unsafe Operation: $struct-std stru

Return a reference to the type descriptor of stru.

Unsafe Operation: $struct-ref stru fx

Return the value in the field at index fx of stru.

Unsafe Operation: $struct-set! stru fx value

Store value in the field at index fx of stru.

Unsafe Operation: $struct std value ...

Allocate a new data structure of type std capable of holding as many words as given value arguments and initialise the fields with such values. Return a reference to the structure.

Operations on struct type descriptors

Unsafe Operation: $std-std std
Unsafe Operation: $set-std-std! std new-std

Given a struct type descriptor return its struct type descriptor or set a new type descriptor.

Unsafe Operation: $std-name std
Unsafe Operation: $set-std-name! std new-name

Given a struct type descriptor return its name as a string or set a new name.

Unsafe Operation: $std-length std
Unsafe Operation: $set-std-length! std new-len

Given a struct type descriptor return a non–negative fixnum representing the number of fields or set a new number of fields.

Unsafe Operation: $std-fields std
Unsafe Operation: $set-std-fields! std fields

Given a struct type descriptor return a list of symbols representing the field names or set a new list of field names.

Unsafe Operation: $std-printer std
Unsafe Operation: $set-std-printer! std new-printer

Given a struct type descriptor return its printer function or set a new printer function.

Unsafe Operation: $std-symbol std
Unsafe Operation: $set-std-symbol! std new-uid

Given a struct type descriptor return its UID symbol or set a new UID symbol. When setting a new struct UID we must store the struct type descriptor in the value slot of the UID.

Unsafe Operation: $std-destructor std
Unsafe Operation: $set-std-destructor! std new-destr

Given a struct type descriptor return #f or its destructor function or set a new destructor function.


Previous: , Up: syslib structs   [Index]