summaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2015-08-25 07:00:56 +0200
committerest31 <MTest31@outlook.com>2015-08-27 01:56:06 +0200
commit8658c8d9b5f30dc952eed29a19d619de9210474c (patch)
treea9f6e6d48d0ac1b3a0d9a566e99a3d74dac63e22 /src/script/common
parent34b7a147dcf9831f3b4d81599c473ba01ff5da00 (diff)
downloadminetest-8658c8d9b5f30dc952eed29a19d619de9210474c.tar.gz
minetest-8658c8d9b5f30dc952eed29a19d619de9210474c.tar.bz2
minetest-8658c8d9b5f30dc952eed29a19d619de9210474c.zip
Use numeric indices and raw table access with LUA_REGISTRYINDEX
Diffstat (limited to 'src/script/common')
-rw-r--r--src/script/common/c_internal.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/script/common/c_internal.h b/src/script/common/c_internal.h
index ecb514c8f..80576b5e9 100644
--- a/src/script/common/c_internal.h
+++ b/src/script/common/c_internal.h
@@ -34,6 +34,27 @@ extern "C" {
#include "common/c_types.h"
+
+/*
+ Define our custom indices into the Lua registry table.
+
+ Lua 5.2 and above define the LUA_RIDX_LAST macro. Only numbers above that
+ may be used for custom indices, anything else is reserved.
+
+ Lua 5.1 / LuaJIT do not use any numeric indices (only string indices),
+ so we can use numeric indices freely.
+*/
+#ifdef LUA_RIDX_LAST
+#define CUSTOM_RIDX_BASE ((LUA_RIDX_LAST)+1)
+#else
+#define CUSTOM_RIDX_BASE 1
+#endif
+
+#define CUSTOM_RIDX_SCRIPTAPI (CUSTOM_RIDX_BASE)
+#define CUSTOM_RIDX_GLOBALS_BACKUP (CUSTOM_RIDX_BASE + 1)
+#define CUSTOM_RIDX_CURRENT_MOD_NAME (CUSTOM_RIDX_BASE + 2)
+
+
#define PCALL_RESL(L, RES) do { \
int result_ = (RES); \
if (result_ != 0) { \