A Class object represents a class definition; it contains static methods and properties.
The documentation below uses
Cls as a placeholder for any class object. Note that "class" should not be used as a variable name as it is used to refer to the Class class itself. Ordinarily, one refers to a class object by the name given in its class definition.
Each class object is based on whatever class it extends, or Object if not specified. The global class object
Object is based on
Class.Prototype, which is based on
Object.Prototype, so classes can inherit methods and properties from any of these base objects.
"Static" methods and properties are any methods and properties which are owned by the class object itself (and therefore do not apply to a specific instance), while methods and properties for instances of the class are owned by the class's Prototype.
Classes typically have the following:
Constructs a new instance of the class.
Obj := Cls.New(Params*)
New can be overridden within a class definition by defining a static method, such as
static New(). This allows classes to modify or prevent the construction of new instances.
Class.New() can be used to construct a new Class object based on
Class.Prototype. However, this new object initially has no New method as it is not a subclass of Object. It can become a subclass of Object by assigning to Base, or the New method can be copied with GetMethod and DefineMethod. A Prototype must also be created and assigned to the class before it can be instantiated with the standard New method.
Retrieves or sets the object on which all instances of the class are based.
Proto := Cls.Prototype
Cls.Prototype := Proto
By default, the class's Prototype contains all instance methods and dynamic properties defined within the class definition, and can be used to retrieve references to methods or property getters/setters or define new ones. The script can also define new value properties, which act as default property values for all instances.
Prototype is automatically defined as an own property of any class object created by a class definition.