summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/AllToLua.pkg1
-rw-r--r--src/Bindings/BindingsProcessor.lua37
-rw-r--r--src/Bindings/CMakeLists.txt1
-rw-r--r--src/BlockID.h38
-rw-r--r--src/EffectID.h4
-rw-r--r--src/World.h2
6 files changed, 61 insertions, 22 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 418e37d23..b59af7374 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -46,6 +46,7 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
+$cfile "../EffectID.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua
index 4bea64435..d6c39dec6 100644
--- a/src/Bindings/BindingsProcessor.lua
+++ b/src/Bindings/BindingsProcessor.lua
@@ -951,8 +951,9 @@ end
--- Installs a hook that is called by ToLua++ for each instantiation of classEnumerate
-- The hook is used to fix DoxyComments in enums
local function installEnumHook()
+ --Hook for normal enums
local oldEnumerate = Enumerate
- Enumerate = function (a_Name, a_Body, a_VarName)
+ Enumerate = function (a_Name, a_Body, a_VarName, a_Type)
-- We need to remove the DoxyComment items from the enum
-- otherwise ToLua++ parser would make an enum value out of them
a_Body = string.gsub(a_Body, ",[%s\n]*}", "\n}") -- eliminate last ','
@@ -977,7 +978,39 @@ local function installEnumHook()
enumValues[numEnumValues] = txt
end
end
- local res = oldEnumerate(a_Name, "{" .. table.concat(enumValues, ",") .. "}", a_VarName)
+ local res = oldEnumerate(a_Name, "{" .. table.concat(enumValues, ",") .. "}", a_VarName, a_Type)
+ res.DoxyComments = doxyComments
+ return res
+ end
+
+ --Hook for scoped enums
+ local oldScopedEnum = ScopedEnum
+ ScopedEnum = function (a_Name, a_Body, a_VarName, a_Type)
+ -- We need to remove the DoxyComment items from the enum class
+ -- otherwise ToLua++ parser would make an enum value out of them
+ a_Body = string.gsub(a_Body, ",[%s\n]*}", "\n}") -- eliminate last ','
+ local t = split(strsub(a_Body, 2, -2), ',') -- eliminate braces
+ local doxyComments = {}
+ local enumValues = {}
+ local numEnumValues = 0
+ for _, txt in ipairs(t) do
+ txt = txt:gsub("(%b\17\18)",
+ function (a_CommentID)
+ doxyComments[numEnumValues + 1] = g_ForwardDoxyComments[tonumber(a_CommentID:sub(2, -2))]
+ return ""
+ end
+ ):gsub("(%b\19\20)",
+ function (a_CommentID)
+ doxyComments[numEnumValues] = g_BackwardDoxyComments[tonumber(a_CommentID:sub(2, -2))]
+ return ""
+ end
+ )
+ if (txt ~= "") then
+ numEnumValues = numEnumValues + 1
+ enumValues[numEnumValues] = txt
+ end
+ end
+ local res = oldScopedEnum(a_Name, "{" .. table.concat(enumValues, ",") .. "}", a_VarName, a_Type)
res.DoxyComments = doxyComments
return res
end
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 747f22157..64db464f2 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -92,6 +92,7 @@ set(BINDING_DEPENDENCIES
../CraftingRecipes.h
../Cuboid.h
../Defines.h
+ ../EffectID.h
../Enchantments.h
../Entities/Boat.h
../Entities/ArrowEntity.h
diff --git a/src/BlockID.h b/src/BlockID.h
index bd24f9312..0f66026b6 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -1,15 +1,11 @@
#pragma once
-// The following hackery is to allow typed C++ enum for C++ code, yet have ToLua process the values.
-// ToLua doesn't understand typed enums, so we use preprocessor to hide it from ToLua.
-
-static const BLOCKTYPE
-#if 0
// tolua_begin
-enum BLOCKTYPE
+
+
+enum ENUM_BLOCK_ID : BLOCKTYPE
{
-#endif
E_BLOCK_AIR = 0,
E_BLOCK_STONE = 1,
E_BLOCK_GRASS = 2,
@@ -265,20 +261,14 @@ enum BLOCKTYPE
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
E_BLOCK_WOODEN_DOOR = E_BLOCK_OAK_DOOR,
E_BLOCK_FENCE_GATE = E_BLOCK_OAK_FENCE_GATE,
- E_BLOCK_WOODEN_STAIRS = E_BLOCK_OAK_WOOD_STAIRS
-
-#if 0
-}
-#endif
- ;
-// tolua_end
+ E_BLOCK_WOODEN_STAIRS = E_BLOCK_OAK_WOOD_STAIRS,
+};
-// tolua_begin
-enum ENUM_ITEM_ID
+enum ENUM_ITEM_ID : short
{
E_ITEM_EMPTY = -1,
@@ -514,10 +504,10 @@ enum ENUM_ITEM_ID
-enum
+enum ENUM_BLOCK_META : NIBBLETYPE
{
- // Please keep this list alpha-sorted by the blocktype / itemtype part
- // then number-sorted for the same block / item
+ // Please keep this list alpha-sorted by the blocktype part
+ // then number-sorted for the same block
////////////////////////////////////////////////////////////////////////////////
// Block metas:
@@ -912,6 +902,16 @@ enum
E_META_WOOL_GREEN = 13,
E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15,
+};
+
+
+
+
+
+enum ENUM_ITEM_META : short
+{
+ // Please keep this list alpha-sorted by the itemtype part
+ // then number-sorted for the same item
////////////////////////////////////////////////////////////////////////////////
// Item metas:
diff --git a/src/EffectID.h b/src/EffectID.h
index 471266ac1..355412a21 100644
--- a/src/EffectID.h
+++ b/src/EffectID.h
@@ -1,5 +1,7 @@
#pragma once
+// tolua_begin
+
enum class EffectID : Int32
{
SFX_RANDOM_DISPENSER_DISPENSE = 1000,
@@ -64,3 +66,5 @@ enum class SmokeDirection : Int32
NORTH = 7,
NORTH_WEST = 8,
};
+
+// tolua_end
diff --git a/src/World.h b/src/World.h
index 495fdf174..3af766166 100644
--- a/src/World.h
+++ b/src/World.h
@@ -4,7 +4,7 @@
#ifndef _WIN32
#include "BlockID.h"
#else
- enum ENUM_ITEM_ID;
+ enum ENUM_ITEM_ID : short;
#endif
#define MAX_PLAYERS 65535