Class new_class
An instantiatable class to inherit for defining new instantiatable classes classes
the "base" class.
To make a new class call new_class:inherit(your_new_class)
.
Also note that these classes will not have the type table
but instead class
when type(object)
is called.
This is apart of the LEEF-class module
-
leef.class.is_class (value)
-
checks if something is a class
Parameters:
Returns:
bool
-
new_class.instance
-
instance
- instance
defines wether the object is an instance, use this in construction to determine what changes to make
-
new_class.base_class
-
base_class
- base_class
only present for instances: the class from which this instance originates
-
new_class.parent_class
-
parent_class
- parent_class
the class from which this class was inherited from
-
new_class:inherit (self, def)
-
creates a new base class. Calls all constructors in the chain with def.instance=true
Parameters:
- self
the table which is being inherited (meaning variables that do not exist in the child, will read as the parent's). Be careful to remember that subtable values are NOT inherited, use the constructor to create subtables.
- def
the table containing the base definition of the class. This should contain a construct
Returns:
def a new base class
-
new_class:construct (self)
-
Called when a child, grandchild, (and so on), instance or class is created. Check
self.instance
and self.base_class
to determine what type of object it is.
every constructor from every parent is called in heirarchy (first to last).
use this to instantiate things like subtables or child class instances.
Parameters:
- self
the table (which would be def from new()).
-
new_class:new (def)
-
creates an instance of the base class. Calls all constructors in the chain with def.instance=true
Parameters:
- def
field for the new instance of the class. If fields are not present they will refer to the base class's fields (if present in the base class).
Returns:
self a new instance of the class.
-
new_class:dump (self, dump_classes)
-
(for printing) dumps the variables of this class
Parameters:
- self
- dump_classes
bool
whether to also print/dump classes.
Returns:
string