(in ./Carbon/OOP.lua)

Provides object orientation features for Carbon.

TODO: migrate advanced attributes to Allocator attribute.


class public OOP:StaticClass()

Returns StaticClass

Creates a static class, enabling it to inherit from other objects without having instantiation capability.

class public OOP:Class([Class based_on])

Returns Class

  • optional based_on: A class to make a direct copy of for the basis of this class.

Creates a new, empty class.

class public OOP:RegisterAttribute(string type, any identifier, function method)

Returns void

  • required type: The type of attribute (Class, PreInitialize, PostInitialize, or Copy).
  • required identifier: The identifier of the attribute.
  • required method: The class applicator. For function signatures, see below.

Registers a new custom class attribute.

  • Class: void function(class)
    Called immediately when the attribute is added to the class.
  • PreInitialize: void function(class, instance)
    Called after instance allocation but before the object's initializer is called.
  • PostInitialize: void function(class, instance)
    Called after the object is fully initialized.
  • Copy: void function(original, copy)
    Called after the copied object has been allocated and filled.

class public OOP:SetAttributeInherited(any identifier, bool inherited)

Returns void

  • required identifier: The identifier of the attribute to define a value for.
  • required inherited: Whether inheriting a class will also inherit this attribute.

Marks an attribute as inherited or not inherited explicitly.