Skip to main content

tolua

Description:

  The tolua record provides utilities for interfacing between C++ and Lua.

type

Type: Function.

Description:

  Returns the C++ object type of a Lua object.

Signature:

type: function(item: any): string

Parameters:

ParameterTypeDescription
itemanyThe Lua object to get the type of.

Returns:

Return TypeDescription
stringThe C++ object type.

cast

Type: Field.

Description:

  Attempts to cast a Lua object to a C++ type object.

Signature:

cast: function<T>(item: any, name: string): T | nil

Parameters:

ParameterTypeDescription
itemanyThe Lua object to cast.
namestringThe name of the C++ type to cast to.

Returns:

Return TypeDescription
T|nilThe cast object, or nil if the cast fails.

class

Type: Function.

Description:

  Gets the class object for a given class name.

Signature:

class: function(className: string): table | nil

Parameters:

ParameterTypeDescription
classNamestringThe name of the class to get the table for.

Returns:

Return TypeDescription
table|nilThe class table, or nil if the class does not exist.

setpeer

Type: Function.

Description:

  Sets the peer table for an object. A pear table is a table referenced by a Lua userdata providing custom fields for this userdata object.

Signature:

setpeer: function(obj: Object, data: table)

Parameters:

ParameterTypeDescription
objObjectThe object to set the peer table for.
datatableThe table to use as the peer table.

getpeer

Type: Function.

Description:

  Gets the peer table for an object. A pear table is a table referenced by a Lua userdata providing custom fields for this userdata object.

Signature:

getpeer: function(obj: Object): table

Parameters:

ParameterTypeDescription
objObjectThe object to get the peer table for.

Returns:

Return TypeDescription
tableThe peer table, or nil if the object has no peer table.