summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-28 15:40:57 +0200
committerGitHub <noreply@github.com>2021-03-28 15:40:57 +0200
commit748b121703fa28b10933f4432c09391e66179118 (patch)
tree58a39b6a75c3e9127507bf3c185a99e546147276 /src/Bindings/ManualBindings.h
parentFix Windows XP to 7 compatibility (#5167) (diff)
downloadcuberite-748b121703fa28b10933f4432c09391e66179118.tar
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.gz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.bz2
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.lz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.xz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.zst
cuberite-748b121703fa28b10933f4432c09391e66179118.zip
Diffstat (limited to 'src/Bindings/ManualBindings.h')
-rw-r--r--src/Bindings/ManualBindings.h222
1 files changed, 0 insertions, 222 deletions
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index a23c5d2e4..780c6ce41 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -211,228 +211,6 @@ public:
- /** Template for the bindings for the DoWithXYZAt(X, Y, Z) functions that don't need to check their coords. */
- template <
- class SELF,
- class ITEM,
- bool (SELF::*DoWithFn)(int, int, int, cFunctionRef<bool(ITEM &)>)
- >
- static int DoWithXYZ(lua_State * tolua_S)
- {
- // Check params:
- cLuaState L(tolua_S);
- if (
- !L.CheckParamNumber(2, 4) ||
- !L.CheckParamFunction(5) ||
- !L.CheckParamEnd(6)
- )
- {
- return 0;
- }
-
- // Get parameters:
- SELF * Self = nullptr;
- int BlockX = 0;
- int BlockY = 0;
- int BlockZ = 0;
- cLuaState::cRef FnRef;
- L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, FnRef);
- if (Self == nullptr)
- {
- return lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
- }
- if (!FnRef.IsValid())
- {
- return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a valid callback function for parameter #5");
- }
-
- // Call the DoWith function:
- bool res = (Self->*DoWithFn)(BlockX, BlockY, BlockZ, [&](ITEM & a_Item)
- {
- bool ret = false;
- L.Call(FnRef, &a_Item, cLuaState::Return, ret);
- return ret;
- }
- );
-
- // Push the result as the return value:
- L.Push(res);
- return 1;
- }
-
-
-
-
-
- /** Template for the bindings for the DoWithXYZAt(X, Y, Z) functions that need to check their coords. */
- template <
- class SELF,
- class ITEM,
- bool (SELF::*DoWithFn)(int, int, int, cFunctionRef<bool(ITEM &)>),
- bool (SELF::*CoordCheckFn)(int, int, int) const
- >
- static int DoWithXYZ(lua_State * tolua_S)
- {
- // Check params:
- cLuaState L(tolua_S);
- if (
- !L.CheckParamNumber(2, 4) ||
- !L.CheckParamFunction(5) ||
- !L.CheckParamEnd(6)
- )
- {
- return 0;
- }
-
- // Get parameters:
- SELF * Self = nullptr;
- int BlockX = 0;
- int BlockY = 0;
- int BlockZ = 0;
- cLuaState::cRef FnRef;
- L.GetStackValues(1, Self, BlockX, BlockY, BlockZ, FnRef);
- if (Self == nullptr)
- {
- return L.ApiParamError("Invalid 'self'");
- }
- if (!FnRef.IsValid())
- {
- return L.ApiParamError("Expected a valid callback function for parameter #5");
- }
- if (!(Self->*CoordCheckFn)(BlockX, BlockY, BlockZ))
- {
- return L.FApiParamError("The provided coordinates ({0}) are not valid",
- Vector3i{BlockX, BlockY, BlockZ}
- );
- }
-
- // Call the DoWith function:
- bool res = (Self->*DoWithFn)(BlockX, BlockY, BlockZ, [&](ITEM & a_Item)
- {
- bool ret = false;
- L.Call(FnRef, &a_Item, cLuaState::Return, ret);
- return ret;
- }
- );
-
- // Push the result as the return value:
- L.Push(res);
- return 1;
- }
-
-
-
-
-
- template <
- class Ty1,
- class Ty2,
- bool (Ty1::*ForEachFn)(int, int, cFunctionRef<bool(Ty2 &)>)
- >
- static int ForEachInChunk(lua_State * tolua_S)
- {
- // Check params:
- cLuaState L(tolua_S);
- if (
- !L.CheckParamNumber(2, 3) ||
- !L.CheckParamFunction(4) ||
- !L.CheckParamEnd(5)
- )
- {
- return 0;
- }
-
- // Get parameters:
- Ty1 * Self = nullptr;
- int ChunkX = 0;
- int ChunkZ = 0;
- cLuaState::cRef FnRef;
- L.GetStackValues(1, Self, ChunkX, ChunkZ, FnRef);
- if (Self == nullptr)
- {
- return lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
- }
- if (!FnRef.IsValid())
- {
- return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a valid callback function for parameter #4");
- }
-
- // Call the DoWith function:
- bool res = (Self->*ForEachFn)(ChunkX, ChunkZ, [&](Ty2 & a_Item)
- {
- bool ret = false;
- L.Call(FnRef, &a_Item, cLuaState::Return, ret);
- return ret;
- }
- );
-
- // Push the result as the return value:
- L.Push(res);
- return 1;
- }
-
-
-
-
-
- template <
- class Ty1,
- class Ty2,
- bool (Ty1::*ForEachFn)(const cBoundingBox &, cFunctionRef<bool(Ty2 &)>)
- >
- static int ForEachInBox(lua_State * tolua_S)
- {
- // Check params:
- cLuaState L(tolua_S);
- if (
- !L.CheckParamUserType(1, "cWorld") ||
- !L.CheckParamUserType(2, "cBoundingBox") ||
- !L.CheckParamFunction(3) ||
- !L.CheckParamEnd(4)
- )
- {
- return 0;
- }
-
- // Get the params:
- Ty1 * Self = nullptr;
- cBoundingBox * Box = nullptr;
- cLuaState::cRef FnRef;
- L.GetStackValues(1, Self, Box, FnRef);
- if ((Self == nullptr) || (Box == nullptr))
- {
- LOGWARNING("Invalid world (%p) or boundingbox (%p)", static_cast<void *>(Self), static_cast<void *>(Box));
- L.LogStackTrace();
- return 0;
- }
- if (!FnRef.IsValid())
- {
- return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a valid callback function for parameter #2");
- }
-
- bool res = (Self->*ForEachFn)(*Box, [&](Ty2 & a_Item)
- {
- bool ret = false;
- if (!L.Call(FnRef, &a_Item, cLuaState::Return, ret))
- {
- LOGWARNING("Failed to call Lua callback");
- L.LogStackTrace();
- return true; // Abort enumeration
- }
-
- return ret;
- }
- );
-
- // Push the result as the return value:
- L.Push(res);
- return 1;
- }
-
-
-
-
-
template <
class Ty1,
class Ty2,