-
Notifications
You must be signed in to change notification settings - Fork 1
MDL Extension | Objects
This MDL extension provides a simple, and extensible, method for creating complex types modeled around object oriented programming.
The base object extension describes the base object construct, that is the concept of objects having a specific type which provides information about object instances. It also describes basic object instances.
TypeClass(parents, members) a node representing a class using the objects extension. This object provides hookable methods for providing additional object extensions on top of this one.
Objects are pointers to object instance structs. An object instance struct contains 3 pointers. The first is a pointer to the class of the object, the classes of objects are themselves objects, and hence is a pointer to an object instance struct. The second pointer in an object instance struct is the private data, this pointer is the unique description of the object, casted objects should still have the same private data pointer. The final pointer is to the public data of the object.
Casted objects simply change the public data pointer. Reflection can be done by searching up the class pointer list until a null (0) pointer is found in the class pointer. That class is the base class type, and will provide reflection capabilities. A class is simply an object which has public variables which are function pointers representing the member functions of that class of object, and which can be called on any class instance.
Public variables are strongly typed. Given an object type it is possible to compute where public variables and member function calls are located at generation time. Additionally classes, and their public data, are guaranteed to not change location, so a function operating on a specific class can compute the pointer to the function at compile time, but more likely run time.