diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-06-21 15:10:32 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-06-29 18:58:48 +0200 |
commit | 33527067ede2e9f37cc9c2f94548669d7ee92372 (patch) | |
tree | 28bcc6b44ddf64774e3bdc08c269967f7ab49b2c /src/Bindings | |
parent | Updated cItemGrid API docs to reflect required GetInventory() calls. (diff) | |
download | cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar.gz cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar.bz2 cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar.lz cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar.xz cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.tar.zst cuberite-33527067ede2e9f37cc9c2f94548669d7ee92372.zip |
Diffstat (limited to 'src/Bindings')
-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 |