UStruct

A UStruct is simply a special data structure which can hold multiple UFields and is self a UField. These children describe the instance and its contents like datatypes, array lengths and so on.

Children

These children are simply a row of references until the reference of one UField is equal to nullptr. The first child in that row is referred by the childs attribute.

Iterating over children

As already said, the children of a UStruct are additional information of a UStruct about its f.e. functions, attributes and components. Each of those are represented through an instance of an UField . Important to note is that each UField points with the next attribute to next one of the class. Iterating is simply following this next-pointer until it reaches nullptr.

UStruct* struc;
UField* field = struc->childs;
while (field) {
    // Do something with the field
    field = field->next;
}

If you want to also iterate overextended fields, you will need to switch to the superclass when the field pointer reaches nullptr.

UStruct* struc;
UField* field = struc->childs;
while(field || clazz) {
    if (!field) {
        struc = (UStruct*) struc->super;
        field = struc->childs;
        continue;
    }
    // do stuff
    field = field->next;
}

and because this is so much to write the SML::Objects::UStruct implements a C iterator. With that said you can use a c for-each loop to iterate over the fields of a UStruct recursively with following code:

UStruct* struc;
for (UField* field : *struc) {
    // do stuff
}

Inheritance

To get the superclass of an UClass just simply follow the super attribute. It contains the pointer to inherited UStruct. Multiple inheritances are not possible.