API Documentation
Classes | Typedefs | Enumerations
nkScripts Namespace Reference

Encompasses all API of component NilkinsScripts. More...

Classes

struct  ArrayAccessorDescriptor
 Holds information about the way to access a user type as an array. More...
 
struct  CompilationResult
 Holds information about script loading attempt. More...
 
class  ContentLoader
 Allows to export and import content through their declaration files. More...
 
class  ContentLoadResult
 Holds information about a content load attempt. More...
 
class  Environment
 Defines an environment in which scripts can execute. More...
 
class  EnvironmentManager
 Manages the environments available. More...
 
struct  ExecutionResult
 Holds information about the execution result of a script in an environment. More...
 
class  Function
 Holds information, and controls, over a function in a scripting environment. More...
 
struct  FunctionParameter
 A function parameter, used within the stack of arguments. More...
 
class  LogManager
 Responsible for logging all messages from the component. More...
 
class  Namespace
 Holds information and allow control over a namespace in a scripting environment. More...
 
class  ProjectLoader
 Offers project loading / saving capabilities. More...
 
struct  ProjectLoadQuery
 Holds information about a project load query. More...
 
struct  ProjectLoadResult
 Holds information about a project load attempt. More...
 
struct  ProjectSaveQuery
 Holds information for a project saving query. More...
 
class  ResourceDeclAugmentCallback
 Represents a callback enabling to "augment" a loading or saving of a project. More...
 
class  Script
 Holds all information for a script. More...
 
class  ScriptManager
 Manages the scripts available in the component. More...
 
class  ScriptObjectInterpreterReference
 Base interface for interpreter specific reference over script object. More...
 
class  ScriptObjectInterpreterView
 Base interface for an interpreter specific script object view. More...
 
class  ScriptObjectReference
 A reference over an object in the scripting environment. More...
 
struct  ScriptObjectReferenceStruct
 Holds information about a reference. More...
 
class  ScriptObjectView
 A view over an object in the scripting environment. More...
 
class  StringUtils
 Utility for string manipulations. More...
 
class  UserType
 Represents a user type and all the information and control related. More...
 
struct  UserTypeFieldDescriptor
 Holds all the information required to define a field. More...
 
struct  UserTypeHolder
 Holds information about a user type parameter. More...
 

Typedefs

using DataStack = nkMemory::BufferView< FunctionParameter >
 A data stack, mainly used for parameters.
 
using OutputValue = FunctionParameter
 The ouput value for a function.
 
using FunctionCallback = std::function< OutputValue(const DataStack &)>
 A callback in C++, the script environment will call when tied.
 
using ArrayReadFunction = FunctionCallback
 Callback function signature for array reading.
 
using ArrayWriteFunction = std::function< void(const DataStack &)>
 Callback function signature for array writing.
 
using ConstructorCallback = std::function< void *(const DataStack &)>
 Callback function signature for a constructor.
 
using DestructorCallback = std::function< void(void *)>
 Callback function signature for a destructor.
 
using FieldGetter = std::function< OutputValue(void *)>
 Callback function signature for a field getter.
 
using FieldSetter = std::function< void(const DataStack &)>
 Callback function signature for a field setter.
 
using ContentLoadResultScript = ContentLoadResult< Script >
 A shorthand for a script content load result.
 

Enumerations

enum  EXECUTION_FAILURE_TYPE {
  EXECUTION_FAILURE_TYPE::NO_ERROR = 0, EXECUTION_FAILURE_TYPE::UNKNOWN, EXECUTION_FAILURE_TYPE::INTERPRETER_UNKNOWN, EXECUTION_FAILURE_TYPE::INTERPRETER_TYPE_MISMATCH,
  EXECUTION_FAILURE_TYPE::BYTECODE_NOT_READY, EXECUTION_FAILURE_TYPE::RUNTIME, EXECUTION_FAILURE_TYPE::MEMORY_ALLOCATION
}
 Describes a type of script execution failure. More...
 
enum  FUNCTION_PARAMETER_TYPE : int {
  FUNCTION_PARAMETER_TYPE::VOID = 0, FUNCTION_PARAMETER_TYPE::BOOL, FUNCTION_PARAMETER_TYPE::INT, FUNCTION_PARAMETER_TYPE::FLOAT,
  FUNCTION_PARAMETER_TYPE::DOUBLE, FUNCTION_PARAMETER_TYPE::STRING, FUNCTION_PARAMETER_TYPE::USER_DATA, FUNCTION_PARAMETER_TYPE::USER_DATA_PTR,
  FUNCTION_PARAMETER_TYPE::SCRIPT_FUNCTION, FUNCTION_PARAMETER_TYPE::SCRIPT_OBJECT
}
 Describes a variable type. More...
 
enum  TYPE_BUILT_IN_FUNCTIONS {
  TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_TO_STRING = 0, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_UNARY_MINUS, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_ADD, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_SUB,
  TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_MUL, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_DIV, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_MOD, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_POW,
  TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_CONCAT, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_EQ, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_LT, TYPE_BUILT_IN_FUNCTIONS::BUILT_IN_LE
}
 Available overridable built in functions. More...
 
enum  CONTENT_LOAD_RESULT_STATE { CONTENT_LOAD_RESULT_STATE::SUCCESS = 0, CONTENT_LOAD_RESULT_STATE::PARTIAL, CONTENT_LOAD_RESULT_STATE::FAILURE }
 Describes a loading result state. More...
 
enum  INTERPRETER { INTERPRETER::UNKNOWN = 0, INTERPRETER::LUA }
 Supported scripting environments. More...
 
enum  COMPILATION_FAILURE_TYPE {
  COMPILATION_FAILURE_TYPE::NO_ERROR = 0, COMPILATION_FAILURE_TYPE::UNKNOWN, COMPILATION_FAILURE_TYPE::INTERPRETER_UNKNOWN, COMPILATION_FAILURE_TYPE::SYNTAX,
  COMPILATION_FAILURE_TYPE::MEMORY_ALLOCATION
}
 Describes compilation failure types. More...
 

Detailed Description

Encompasses all API of component NilkinsScripts.

This components enables scripting capabilities. Currently, supported scripting language is lua, through LuaJIT.

Heart of the component are nkScripts::Environment, where all information relative to execution can be set. Prepare an environment by specifying the functions, namespaces, user types that should be addressable inside.

Then, take advantage of the environment setup by dynamically executing nkScripts::Script.

For more information, be sure to check the dedicated tutorials as they will hold a lot of valuable clues to get started.

Enumeration Type Documentation

◆ EXECUTION_FAILURE_TYPE

Describes a type of script execution failure.

Enumerator
NO_ERROR 

Execution went fine.

UNKNOWN 

Unknown place holder.

INTERPRETER_UNKNOWN 

The environment interpreter is unknown.

INTERPRETER_TYPE_MISMATCH 

The environment interpreter and the script interpreter mismatched.

BYTECODE_NOT_READY 

The script bytecode was not ready. Often due to unloaded scripts.

RUNTIME 

Runtime error.

MEMORY_ALLOCATION 

A memory allocation failed.

◆ FUNCTION_PARAMETER_TYPE

Describes a variable type.

Enumerator
VOID 

Void place holder.

BOOL 

Boolean variable.

INT 

Int variable.

FLOAT 

Float variable.

DOUBLE 

Double variable.

STRING 

String variable.

USER_DATA 

User data variable, with reference holding.

USER_DATA_PTR 

User data variable, with no reference holding.

SCRIPT_FUNCTION 

A script function reference variable.

SCRIPT_OBJECT 

A script object reference variable.

◆ TYPE_BUILT_IN_FUNCTIONS

Available overridable built in functions.

Enumerator
BUILT_IN_TO_STRING 

To string conversion.

BUILT_IN_UNARY_MINUS 

-a.

BUILT_IN_ADD 

a + b.

BUILT_IN_SUB 

a - b.

BUILT_IN_MUL 

a * b.

BUILT_IN_DIV 

a / b.

BUILT_IN_MOD 

a % b.

BUILT_IN_POW 

a^b

BUILT_IN_CONCAT 

String concatenation.

BUILT_IN_EQ 

a == b.

BUILT_IN_LT 

a < b.

BUILT_IN_LE 

a <= b.

◆ CONTENT_LOAD_RESULT_STATE

Describes a loading result state.

Enumerator
SUCCESS 

Loading went without problem.

PARTIAL 

Loading could load part of the data, but some other had errors.

FAILURE 

Loading could not load anything.

◆ INTERPRETER

Supported scripting environments.

Enumerator
UNKNOWN 

Unknown place holder.

LUA 

Lua environment.

◆ COMPILATION_FAILURE_TYPE

Describes compilation failure types.

Enumerator
NO_ERROR 

No error, compilation went fine.

UNKNOWN 

An unknown error.

INTERPRETER_UNKNOWN 

The interpreter for the script is unknown.

SYNTAX 

Syntax parsing error in sources.

MEMORY_ALLOCATION 

Could not allocate memory when needed.