Jump to: navigation, search


The DOM or Data Object Model (not to be confused with the GOM) is a collection of dynamic definition objects. The DOM is where node classes are created and defined, fields in those classes are further specified, certain field values are enumerated, and prototypes are created. GOM data is then placed in those fields.

Structure of a node


Prototypes are a combination of DOM structure and GOM data. For more information, see the section on Prototypes.

DOM Reflection via HeroScript Language

Definitions stored in the DOM are exposed to HSL via a series of external functions, using those functions it is possible to query the DOM for information on classes, including their inheritance hierarchy and listing their member fields.

Get Parent Classes of a Class

The external function GetParentClasses() retrieves the immediate parents of a child class.

ParentsOfClass as List of String = GetParentClasses( className )

List Member Fields of a Class

A class is comprised of its own member fields and any fields it inherits from its parent classes. The external function GetClassFields() retrieves the member fields of a class, but not any fields it inherits.

fields as list of string = GetClassFields( className )

Retrieving all of the fields that class has or inherits requires you get the parent classes, get their fields, and recurse until you reach the penultimate parent class(es) removing any duplicates along the way.

public function getAllFieldsInClass( className as String ) as List of String
  classes as List of String
  // call a function to get the parent classes and all of their parent classes recursively
  getAllParentsForClass( className, classes )
  fields as List of String = getClassFields( className )
  foreach c in classes
    classFields as List of String = GetClassFields( c )
    alreadyInList as Boolean
    // eliminate duplicate adds
    foreach cf in classFields
      foreach f in fields
        if f = cf
          alreadyInList = true
      if not alreadyInList
        add back cf to fields
  return fields
public function getAllParentsForClass(Class as String, ClassList references List of String)
  ParentsOfClass as List of String = GetParentClasses(Class)
  // For all of the parents, check for whether or not they are already in the class list
  //    if not, add them to the list and then recurse to walk their parent classes
  foreach p in ParentsOfClass
    AlreadyInClassList as Boolean
    foreach c in ClassList
      if (c == p)
        AlreadyInClassList = true
    if not AlreadyInClassList
      add back p to classList
      // recurse
      getAllParentsForClass(p, ClassList)

See also

Personal tools