#include <ScriptContext.h>
Public Member Functions | |
AZ_TYPE_INFO (ScriptDataContext, "{7ec9e09e-6559-49bd-8826-5eef8880d970}") | |
Assumes that the inspected value is on the top of the stack. It will be poped when the context is destroyed or Reset. | |
ScriptContext * | GetScriptContext () const |
lua_State * | GetNativeContext () const |
bool | IsFunction (int index) const |
returns true for script or C function (bound in script). | |
bool | IsCFunction (int index) const |
returns true for C functions only. | |
bool | IsNumber (int index, bool aceptNumberStrings=false) const |
bool | IsString (int index, bool acceptNumbers=false) const |
bool | IsBoolean (int index) const |
bool | IsNil (int index) const |
bool | IsTable (int index) const |
bool | IsRegisteredClass (int index) const |
Check if this is a registered class with the system (context.Class<T>(...)). This is a test if the userdata has metable assigned. | |
template<class T > | |
bool | IsClass (int index) const |
int | CacheValue (int index) |
Cached a value, using a weak reference, by index (instead of a hash search) | |
void | ReleaseCached (int cachedIndex) |
Release a cached value (so it can be garbage collected) | |
bool | AcquireOwnership (int index, bool isNullPointer) const |
Script will release ownership and the C++ runtime we will responsible to release the object. | |
bool | ReleaseOwnership (int index) const |
Script will take ownership of the object, C++ runtime will NOT release it. | |
Caller Mode | |
template<class T > | |
void | PushArg (const T &value) |
Push argument for the script call. | |
template<class Arg , class... Args> | |
void | PushArgs (Arg &value, Args &&... args) |
void | PushArgs () |
void | PushArgFromRegistryIndex (int cachedIndex) |
Push value from the lua registery for the script call. | |
void | PushArgCached (int cachedIndex) |
Push cached value for the script call. | |
void | PushArgScriptProperty (AZ::ScriptProperty *scriptProperty) |
int | GetNumResults () const |
Get number of results from a script call (ExecuteScriptCall must be called) | |
template<class T > | |
bool | ReadResult (int index, T &valueRef) const |
Read result from a script call [0,GetNumResults()). Returns true if successful otherwise false. | |
Callee Mode | |
int | GetNumArguments () const |
Get number of arguments passed for you. | |
template<class T > | |
bool | ReadArg (int index, T &valueRef) const |
Read argument from a script [0,GetNumArguments). Returns true if successful otherwise false. | |
template<class T > | |
void | PushResult (const T &value) |
Push result for the script. | |
void | PushResultCached (int cachedIndex) |
Push result from a cache value. | |
Inspect Mode | |
template<class T > | |
bool | ReadValue (int index, T &valueRef) const |
template<class T > | |
bool | ReadTableElement (int tableIndex, const char *name, T &value) |
template<class T > | |
void | AddReplaceTableElement (int tableIndex, const char *name, const T &value) |
bool | CheckTableElement (int tableIndex, const char *name) |
Check if table element with 'name' exists. | |
bool | CheckTableElement (const char *name) |
Check if table element with 'name' exists, assming the context points to a table. | |
bool | PushTableElement (int tableIndex, const char *name, int *valueIndex=nullptr) |
Load table element on the stack if 'name' exists. | |
bool | PushTableElement (const char *name, int *valueIndex=nullptr) |
Load table element on the stack if 'name' exists, assming the context points to a table. | |
ScriptProperty * | ConstructTableScriptProperty (const char *name, bool restrictToPropertyArrays=false) |
Construct a table element as a ScriptProperty, assuming the context points to a table. | |
bool | InspectTable (int tableIndex, ScriptDataContext &dc) |
Load a table element. | |
bool | InspectMetaTable (int index, ScriptDataContext &dc) |
Inspects a metatable to the value on the stack. If the value has no metatable we return false, otherwise true. | |
bool | InspectNextElement (int &valueIndex, const char *&name, int &index, bool isProtectedElements=false) |
int | GetStartIndex () const |
Return context start index. For example if this context is get from "InspectTable" the start index is the address of the the table. | |
bool | Call (int functionIndex, ScriptDataContext &dc) |
bool | Call (int tableIndex, const char *functionName, ScriptDataContext &dc) |
bool | CallExecute () |
AZ::ScriptProperty * | ConstructScriptProperty (int index, const char *name=nullptr, bool restrictToPropertyArrays=false) |
Static Public Member Functions | |
static const char * | GetInterpreterVersion () |
Friends | |
class | LuaGenericCaller |
class | LuaEBusHandler |
A generic interface to access the script data. Internally it has 3 modes: During a script call to a C function, it's called 'callee mode' and you are allowed to use the functions in Callee Mode. When you are about to call a function from C to script caller mode. And finally when you inspect a script (traverse,cache,change or call) from C you can use Inspect Mode functionality. All of these modes are set internally depending on what you are doing with the context and they will error to prevent you from calling the wrong functions in the wrong mode. You are not allowed to create or destroy the ScriptDataContext, this is why the constructor and destructor are private.
AZ::ScriptProperty * AZ::ScriptDataContext::ConstructScriptProperty | ( | int | index, |
const char * | name = nullptr , |
||
bool | restrictToPropertyArrays = false |
||
) |
Converts the value at a given index into a ScriptProperty object. If restrictToPropertyArrays is true. Will only parse out to property arrays(i.e. an array of all numbers) If restrictToPropertyArarys is false. May return a table that can be of mixed values, instead of an array.
|
static |
Retrieve a string representing the current version of the interpreter. Example of use: To signal incompatibility with previously emitted bytecode, to invalidate
bool AZ::ScriptDataContext::InspectNextElement | ( | int & | valueIndex, |
const char *& | name, | ||
int & | index, | ||
bool | isProtectedElements = false |
||
) |
Inspect next table element. There are 2 types of table elements: 1. Elements with name (hashed named elements) and 2. Index elements. When the function return true either "name" will be != NULL or index will be != -1.
name | - name of the element, valid of we have a named element otherwise NULL. |
index | - index of the element, valid for indexed elements otherwise -1. |
isProtectedElements | - true if you want to inspect protected elements (in LUA for example they start with "__") |
bool AZ::ScriptDataContext::InspectTable | ( | int | tableIndex, |
ScriptDataContext & | dc | ||
) |
Load a table element.
Inspect a table and return true if the table is a table and data context is set, otherwise false.