API Documentation
Static Public Member Functions | List of all members
nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S > Class Template Referencefinal

Basic template class for wrapping a std::array into a scripting environment. More...

Static Public Member Functions

static nkScripts::FUNCTION_PARAMETER_TYPE getNkType ()
 
static void updateEnvironmentPod (nkScripts::Environment *env, const nkMemory::StringView &typeName)
 
static void updateEnvironmentClass (nkScripts::Environment *env, const nkMemory::StringView &typeName, const nkMemory::StringView &containedType)
 
static void * constructor (const nkScripts::DataStack &stack)
 
static void destructor (void *data)
 
static nkScripts::OutputValue size (const nkScripts::DataStack &stack)
 
static nkScripts::OutputValue readIndexPod (const nkScripts::DataStack &stack)
 
static nkScripts::OutputValue readIndexClass (const nkScripts::DataStack &stack, const nkMemory::StringView &typeName)
 
static void writeIndexPod (const nkScripts::DataStack &stack)
 
static void writeIndexClass (const nkScripts::DataStack &stack)
 

Detailed Description

template<typename T, int S>
class nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >

Basic template class for wrapping a std::array into a scripting environment.

Usage depends on whether the type is a class (which needs to be wrapped too) or a plain type :

Template Parameters
TThe array type, first argument in std::array's template parameter list.
SThe array size, second argument in std::array's template parameter list.

Member Function Documentation

◆ getNkType()

template<typename T , int S>
static nkScripts::FUNCTION_PARAMETER_TYPE nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::getNkType ( )
static

Utility function translating a template type T into the attached function parameter type to wrap in nkScripts.

Returns
The equivalent type of T as a function parameter type.

◆ updateEnvironmentPod()

template<typename T , int S>
static void nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::updateEnvironmentPod ( nkScripts::Environment env,
const nkMemory::StringView typeName 
)
static

Updates an environment to add a type mirroring an std::array<T, S>, for a plain type.

Parameters
envThe environment to set up.
typeNameThe type name of the array to set up, which will be its name in the environment.
Remarks
The type name will be prefixed by std, both in C++ and Lua. As a result, it will be accessible in C++ by using std::typeName, and usable in Lua via std.typeName.

◆ updateEnvironmentClass()

template<typename T , int S>
static void nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::updateEnvironmentClass ( nkScripts::Environment env,
const nkMemory::StringView typeName,
const nkMemory::StringView containedType 
)
static

Updates an environment to add a type mirroring an std::array<T, S>, for a class type.

Parameters
envThe environment to set up.
typeNameThe type name of the array to set up, which will be its name in the environment.
containedTypeThe type name of the array's contained type.
Remarks
The type name will be prefixed by std, both in C++ and Lua. As a result, it will be accessible in C++ by using std::typeName, and usable in Lua via std.typeName.

◆ constructor()

template<typename T , int S>
static void* nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::constructor ( const nkScripts::DataStack stack)
static

Wrapper function for the constructor of the user type.

local m = nkMaths.typeName.new() ;
Parameters
stackThe parameter stack.
Returns
An output value with the user type and data allocated.

◆ destructor()

template<typename T , int S>
static void nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::destructor ( void *  data)
static

Wrapper function for the destructor of the user type.

Parameters
dataThe data that has to be freed.

◆ size()

template<typename T , int S>
static nkScripts::OutputValue nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::size ( const nkScripts::DataStack stack)
static

Wrapper function for std::array<T, S>::size.

local s = t:size() ;
Parameters
stackThe parameter stack.
Returns
The return value, as an int.

◆ readIndexPod()

template<typename T , int S>
static nkScripts::OutputValue nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::readIndexPod ( const nkScripts::DataStack stack)
static

Exposes the read by index operation on the type.

local v = t[i] ;
Parameters
stackThe parameter stack.
Returns
The return value, as a T.
Remarks
The indexing starts at 1 in Lua, retaining its indexing logic.

◆ readIndexClass()

template<typename T , int S>
static nkScripts::OutputValue nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::readIndexClass ( const nkScripts::DataStack stack,
const nkMemory::StringView typeName 
)
static

Exposes the read by index operation on the type.

local v = t[i] ;
Parameters
stackThe parameter stack.
typeNameThe contained type name.
Returns
The return value, as a T.
Remarks
The indexing starts at 1 in Lua, retaining its indexing logic.

◆ writeIndexPod()

template<typename T , int S>
static void nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::writeIndexPod ( const nkScripts::DataStack stack)
static

Exposes the write by index operation on the type.

t[i] = v ;
Parameters
stackThe parameter stack.
Remarks
The indexing starts at 1 in Lua, retaining its indexing logic.

◆ writeIndexClass()

template<typename T , int S>
static void nkAstraeus::stdWrap::ArrayWrapperTemplate< T, S >::writeIndexClass ( const nkScripts::DataStack stack)
static

Exposes the write by index operation on the type.

t[i] = v ;
Parameters
stackThe parameter stack.
Remarks
The indexing starts at 1 in Lua, retaining its indexing logic.

The documentation for this class was generated from the following file:
nkAstraeus::stdWrap::ArrayWrapperTemplate::updateEnvironmentClass
static void updateEnvironmentClass(nkScripts::Environment *env, const nkMemory::StringView &typeName, const nkMemory::StringView &containedType)
nkAstraeus::stdWrap::ArrayWrapperTemplate::updateEnvironmentPod
static void updateEnvironmentPod(nkScripts::Environment *env, const nkMemory::StringView &typeName)