Represents a user type and all the information and control related. More...
Public Member Functions | |
UserType (nkMemory::StringView name) noexcept | |
virtual | ~UserType () |
nkMemory::StringView | getName () const |
nkMemory::StringView | getFullName () const |
virtual Function * | getMethod (nkMemory::StringView name)=0 |
virtual Function * | getStaticMethod (nkMemory::StringView name)=0 |
virtual void | setConstructor (ConstructorCallback constructor)=0 |
virtual void | setDestructor (DestructorCallback destructor)=0 |
virtual Function * | addMethod (nkMemory::StringView name, bool strongReferenceOverThis=false)=0 |
virtual Function * | addStaticMethod (nkMemory::StringView name)=0 |
virtual Function * | overrideBuiltInFunction (TYPE_BUILT_IN_FUNCTIONS builtInFunc)=0 |
virtual void | addField (const UserTypeFieldDescriptor &fieldDescriptor)=0 |
virtual void | enableArrayIndexing (const ArrayAccessorDescriptor &descriptor)=0 |
virtual void | reset ()=0 |
Represents a user type and all the information and control related.
Current information is true for the lua environment, especially.
User types are types defined from the C++ API, and addressable within the script environment. A User type is given by a pointer to an object, and an identifier string, that identifies it within the scripting environment.
When an object is given in an Environment through external API calls, the C++ environment is considered as the owner of the memory. This means that garbage collection won't happen when the object is collected. However, if the object is allocated within the scripting environment (through a call to new()), then the environment is considered owner, and the memory will be freed when garbage collection happens. To override the creation and garbage collection of an object, see setConstructor() and setDestructor(). External code should provide the way to create and garbage collect user types when needed. They usually go in pair.
|
noexcept |
Constructor.
name | The user type name. |
|
virtual |
Destructor.
nkMemory::StringView nkScripts::UserType::getName | ( | ) | const |
nkMemory::StringView nkScripts::UserType::getFullName | ( | ) | const |
|
pure virtual |
name | The name of the method to get. |
|
pure virtual |
name | The name of the static method to get. |
|
pure virtual |
Sets the user type constructor. Called when an object is created within a script.
constructor | The constructor callback to use. |
|
pure virtual |
Sets the user type destructor. Called when an object the environment is responsible for gets garbage collected.
destructor | The destructor callback to use. |
|
pure virtual |
Adds a callable method to the user type.
name | The method's name. |
strongReferenceOverThis | Whether the first argument, user value over the caller, should have a strong reference (true) or not (false). |
|
pure virtual |
Adds a callable static method to the user type.
name | The static method's name. |
|
pure virtual |
Overrides a built in operator for the user type.
builtInFunc | The function to override. |
|
pure virtual |
Adds a field within the user type.
fieldDescriptor | The description of the field to create. |
|
pure virtual |
Enables indexing the user type as an array.
descriptor | The description of the accessing method. |
|
pure virtual |
Resets the user type. Frees all methods, static methods, fields, and access descriptions.