diff options
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/AllToLua.pkg | 1 | ||||
-rw-r--r-- | src/Bindings/BindingsProcessor.lua | 37 | ||||
-rw-r--r-- | src/Bindings/CMakeLists.txt | 1 |
3 files changed, 37 insertions, 2 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 |