summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-08-21 11:03:10 +0200
committerGitHub <noreply@github.com>2016-08-21 11:03:10 +0200
commitd4aff474c29d3d9b1a524cfcd5fca925dab79c5b (patch)
tree6fb19fb62a7f268e827e9aef92a5c4e424572ede /src/Bindings/LuaState.h
parentFix minecart destruction crash (#3336) (diff)
downloadcuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar.gz
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar.bz2
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar.lz
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar.xz
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.tar.zst
cuberite-d4aff474c29d3d9b1a524cfcd5fca925dab79c5b.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 4def2c663..60ae840b0 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -12,11 +12,12 @@ If owning a state, trying to attach a state will automatically close the previou
Calling a Lua function is done internally by pushing the function using PushFunction(), then pushing the
arguments and finally executing CallFunction(). cLuaState automatically keeps track of the number of
arguments and the name of the function (for logging purposes). After the call the return values are read from
-the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call(),
-which is generated automatically by gen_LuaState_Call.lua script file into the LuaState_Call.inc file.
+the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call().
Reference management is provided by the cLuaState::cRef class. This is used when you need to hold a reference to
-any Lua object across several function calls. The class is RAII-like, with automatic resource management.
+any Lua object across several function calls. The class is RAII-like, with automatic resource management. Note
+that the cRef object is not inherently thread-safe and is not notified when its cLuaState is closed. For those
+purposes, cTrackedRef can be used.
Callbacks management is provided by the cLuaState::cCallback class. Use a GetStackValue() with cCallbackPtr
parameter to store the callback, and then at any time you can use the cCallback's Call() templated function
@@ -462,6 +463,14 @@ public:
/** Returns true if a_FunctionName is a valid Lua function that can be called */
bool HasFunction(const char * a_FunctionName);
+ /** Pushes multiple arguments onto the Lua stack. */
+ template <typename Arg1, typename Arg2, typename... Args>
+ void Push(Arg1 && a_Arg1, Arg2 && a_Arg2, Args &&... a_Args)
+ {
+ Push(std::forward<Arg1>(a_Arg1));
+ Push(std::forward<Arg2>(a_Arg2), std::forward<Args>(a_Args)...);
+ }
+
void PushNil(void);
// Push a const value onto the stack (keep alpha-sorted):