Author's_notes - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

I'll be brief, and someone can format this all nice-like later.

While extending ENIGMA by adding a new API is simple and requires minimal rewriting, extending it by porting to a new language (other than C++) involves a total rewrite of all systems, including functions defined by Universal_System/, which is responsible for sensitive and important key systems, such as instance management. This page is a collection of notes from developers who have implemented these systems; may they help you in porting to new languages.

Instance Management

Storage

To implement GM's random-access routines on objects by index, by id, and by heritage, it is wise to store a data structure of some kind for each of those. In C++, a list is kept for each object index, and a map is kept for id-based access. Children of an object are added to both the parent's list and the child's list.

Destruction

In compiled languages, instance_destroy() is a dangerous mechanism. Since it is the current instance that is being destroyed, it would be folly to free concerned memory immediately upon the call to the function. Instead, iterators are removed during the call, but are kept valid, and maintained upon later destroys. Instances are "Garbage Collected" at the end of the event, and the iterators finally removed.

Instantiation

In the C version, upon instantiation, each object adds its own iterators and keeps a reference to them for when it is destroyed. The actual destructor is designed to remove them.