class Struct extends Any
Struct is the base class for all structs.
Unlike Object, a struct's properties are limited to those defined by its base object (the Prototype of the struct's class). These are typically typed properties declared in a struct definition, but can include dynamic properties, methods and read-only value properties.
A struct instance cannot own properties. DefineProp, ObjGetCapacity, ObjSetCapacity, ObjHasOwnProp, ObjOwnPropCount and ObjOwnProps raise a TypeError when given a struct instance. Define members on the struct's prototype instead.
"Obj" is used below as a placeholder for any instance of the Struct class.
Instances of Struct are indirectly based on Struct.Prototype, which is based on Any.Prototype. In addition to the methods and properties inherited from Any, Structs have the following predefined methods and properties.
Creates a new Struct.
Obj := StructClass(FieldValues*) Obj := StructClass.Call(FieldValues*)
StructClass must be a subclass of Struct. Subclasses can be created by a struct definition or at runtime.
Arguments are passed to __New.
Creates a boxed pointer, which behaves as an instance of StructClass.
Obj := StructClass.At(Address)
Type: Integer
The address of a struct of the type defined by StructClass.
For a nonempty struct, addresses from 0 through 65535 are rejected. An empty struct accepts any address.
Type: Object
StructClass can be Struct itself or a subclass.
See Boxed Pointer for further details.
To create an object with a data pointer and enable its __Delete method, use ObjCreateWithDataPtr.
Gets the Prototype on which all instances of the struct class are based.
Proto := ClassObj.Prototype
See ClassObj.Prototype for details.
Gets a class representing a pointer to a StructClass.
PtrClass := StructClass.Ptr
Type: Class
This is used with DllCall and typed properties.
See Pointers to Structs for further details.
Gets a class representing a fixed-size array of StructClass elements.
ArrayClass := StructClass[Length]
ArrayClass := StructClass.__Item[Length]
Type: Integer
The length of the array type.
Type: Class
The return value is a subclass of Struct.Array.
This is typically used with DllCall and typed properties.
Initializes typed fields from positional values.
Obj.__New(FieldValues*)
Values for every typed field in declaration order, including inherited fields first. If omitted, fields remain unchanged; otherwise, the count must match exactly. Each value is converted to its field's type.
Called automatically after field initializers; a subclass can override it. Assignments run in reverse declaration order, so earlier overlapping fields are assigned last. A conversion error stops initialization and leaves already assigned fields changed.
Int32(42) initializes a stored number; POINT.Ptr(Address) initializes an address. Array elements do not count as typed fields.
Retrieves a nested struct or virtual reference to a property.
Obj.__Ref(Name)
Type: String
The property's name.
Type: Object
If the property is a nested struct, a reference to the struct is returned. The property corresponding to a nested struct can only be assigned a value if the struct defines a settable __Value property. The struct itself can also be used as a virtual reference in that case. An abstract data type typically implements both a getter and a setter, in which case the nested struct itself can only be retrieved via this method.
If the property is a pointer type or not a nested struct, a PropRef is created and returned.
This method is normally called indirectly via the reference operator. For example, &Obj.Prop is equivalent to Obj.__Ref('Prop').
A virtual reference can be passed to a ByRef parameter in place of a variable reference.
Gets the address of the struct.
Address := Obj.Ptr
Type: Integer
The address of a struct is the same as the address of its first field (typed property).