From 22612efbdbdf88bfdf78270d1d97a27f8c111658 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Fri, 22 Aug 2014 16:54:36 +0400 Subject: new package luabind luabind is compatible with Lua 5.1, but MXE Lua is 5.2, so sevaral patches are applied --- index.html | 4 + src/luabind-1-cmakelists.patch | 44 +++++++++ src/luabind-2-elif.patch | 121 +++++++++++++++++++++++ src/luabind-3-globalsindex.patch | 205 +++++++++++++++++++++++++++++++++++++++ src/luabind-4-fenv.patch | 29 ++++++ src/luabind-5-lua-resume.patch | 32 ++++++ src/luabind.mk | 30 ++++++ 7 files changed, 465 insertions(+) create mode 100644 src/luabind-1-cmakelists.patch create mode 100644 src/luabind-2-elif.patch create mode 100644 src/luabind-3-globalsindex.patch create mode 100644 src/luabind-4-fenv.patch create mode 100644 src/luabind-5-lua-resume.patch create mode 100644 src/luabind.mk diff --git a/index.html b/index.html index a3bdd54..f0805d3 100644 --- a/index.html +++ b/index.html @@ -1818,6 +1818,10 @@ local-pkg-list: $(LOCAL_PKG_LIST) Lua + luabind + Luabind + + lzo lzo diff --git a/src/luabind-1-cmakelists.patch b/src/luabind-1-cmakelists.patch new file mode 100644 index 0000000..b6927eb --- /dev/null +++ b/src/luabind-1-cmakelists.patch @@ -0,0 +1,44 @@ +This file is part of MXE. +See index.html for further information. + +commit 9b4639e25442a3b6d0337d8e602a8332ec0e26e0 +Author: Boris Nagaev +Date: Fri Aug 22 15:17:21 2014 +0400 + + CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +new file mode 100644 +index 0000000..acc47ae +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,29 @@ ++cmake_minimum_required(VERSION 2.6) ++project(luabind) ++ ++include(FindBoost) ++FIND_PACKAGE(Boost 1.34 REQUIRED) ++include_directories(${Boost_INCLUDE_DIRS}) ++ ++include(FindLua51) ++find_package(Lua51 REQUIRED) ++include_directories(${LUA_INCLUDE_DIR}) ++ ++include_directories(${PROJECT_SOURCE_DIR}) ++ ++file(GLOB sources "src/*.cpp") ++ ++add_library(luabind STATIC ${sources}) ++ ++set(luabind_cxx_flags "-ftemplate-depth-128 -finline-functions") ++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${luabind_cxx_flags}") ++ ++add_definitions(-DLUA_COMPAT_ALL) ++ ++target_link_libraries(luabind ${LUA_LIBRARIES} luabind) ++ ++install(TARGETS luabind DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/lib) ++install(DIRECTORY luabind DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/include) ++ diff --git a/src/luabind-2-elif.patch b/src/luabind-2-elif.patch new file mode 100644 index 0000000..7d0e893 --- /dev/null +++ b/src/luabind-2-elif.patch @@ -0,0 +1,121 @@ +This file is part of MXE. +See index.html for further information. + +commit eb5ec7b7b1deb7301eba0333e6736a975b4396df +Author: Boris Nagaev +Date: Fri Aug 22 15:20:46 2014 +0400 + + elif + +diff --git a/luabind/config.hpp b/luabind/config.hpp +index e8eea87..609fb95 100644 +--- a/luabind/config.hpp ++++ b/luabind/config.hpp +@@ -58,20 +58,24 @@ namespace std + // registered. Must at least be 2 + #ifndef LUABIND_MAX_ARITY + #define LUABIND_MAX_ARITY 10 +-#elif LUABIND_MAX_ARITY <= 1 ++#else ++#if LUABIND_MAX_ARITY <= 1 + #undef LUABIND_MAX_ARITY + #define LUABIND_MAX_ARITY 2 + #endif ++#endif + + // the maximum number of classes one class + // can derive from + // max bases must at least be 1 + #ifndef LUABIND_MAX_BASES + #define LUABIND_MAX_BASES 4 +-#elif LUABIND_MAX_BASES <= 0 ++#else ++#if LUABIND_MAX_BASES <= 0 + #undef LUABIND_MAX_BASES + #define LUABIND_MAX_BASES 1 + #endif ++#endif + + // LUABIND_NO_ERROR_CHECKING + // define this to remove all error checks +diff --git a/luabind/detail/call_function.hpp b/luabind/detail/call_function.hpp +index 1b45ec1..8f5afff 100644 +--- a/luabind/detail/call_function.hpp ++++ b/luabind/detail/call_function.hpp +@@ -323,7 +323,8 @@ namespace luabind + + #endif // LUABIND_CALL_FUNCTION_HPP_INCLUDED + +-#elif BOOST_PP_ITERATION_FLAGS() == 1 ++#else ++#if BOOST_PP_ITERATION_FLAGS() == 1 + + #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * + #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n +@@ -440,4 +441,5 @@ namespace luabind + + + #endif ++#endif + +diff --git a/luabind/detail/call_member.hpp b/luabind/detail/call_member.hpp +index de8d563..e63555b 100644 +--- a/luabind/detail/call_member.hpp ++++ b/luabind/detail/call_member.hpp +@@ -316,7 +316,8 @@ namespace luabind + + #endif // LUABIND_CALL_MEMBER_HPP_INCLUDED + +-#elif BOOST_PP_ITERATION_FLAGS() == 1 ++#else ++#if BOOST_PP_ITERATION_FLAGS() == 1 + + #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * + #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n +@@ -360,4 +361,5 @@ namespace luabind + #undef LUABIND_TUPLE_PARAMS + + #endif ++#endif + +diff --git a/luabind/detail/policy.hpp b/luabind/detail/policy.hpp +index 689c733..4a02a90 100644 +--- a/luabind/detail/policy.hpp ++++ b/luabind/detail/policy.hpp +@@ -1004,7 +1004,8 @@ namespace luabind { namespace + return boost::arg<0>(); + } + # define LUABIND_PLACEHOLDER_ARG(N) boost::arg(*)() +-#elif defined(BOOST_MSVC) || defined(__MWERKS__) \ ++#else ++#if defined(BOOST_MSVC) || defined(__MWERKS__) \ + || (BOOST_VERSION >= 103900 && defined(__GNUC__) \ + && (__GNUC__ * 100 + __GNUC_MINOR__ == 400)) + static boost::arg<0> return_value; +@@ -1015,6 +1016,7 @@ namespace luabind { namespace + boost::arg<0> result; + # define LUABIND_PLACEHOLDER_ARG(N) boost::arg + #endif ++#endif + }} + + #endif // LUABIND_POLICY_HPP_INCLUDED +diff --git a/luabind/wrapper_base.hpp b/luabind/wrapper_base.hpp +index d54c668..0f88cc5 100755 +--- a/luabind/wrapper_base.hpp ++++ b/luabind/wrapper_base.hpp +@@ -89,7 +89,8 @@ namespace luabind + + #endif // LUABIND_WRAPPER_BASE_HPP_INCLUDED + +-#elif BOOST_PP_ITERATION_FLAGS() == 1 ++#else ++#if BOOST_PP_ITERATION_FLAGS() == 1 + + #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * + #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n +@@ -188,3 +189,4 @@ namespace luabind + #undef N + + #endif ++#endif diff --git a/src/luabind-3-globalsindex.patch b/src/luabind-3-globalsindex.patch new file mode 100644 index 0000000..e34c00b --- /dev/null +++ b/src/luabind-3-globalsindex.patch @@ -0,0 +1,205 @@ +This file is part of MXE. +See index.html for further information. + +commit 7325c469a8eb443cd2d46c9860f278cd2672dace +Author: Boris Nagaev +Date: Fri Aug 22 15:27:11 2014 +0400 + + LUA_GLOBALSINDEX + +diff --git a/luabind/detail/call_function.hpp b/luabind/detail/call_function.hpp +index 8f5afff..cb56dc0 100644 +--- a/luabind/detail/call_function.hpp ++++ b/luabind/detail/call_function.hpp +@@ -347,8 +347,7 @@ namespace luabind + , luabind::detail::proxy_function_void_caller > + , luabind::detail::proxy_function_caller > >::type proxy_type; + +- lua_pushstring(L, name); +- lua_gettable(L, LUA_GLOBALSINDEX); ++ lua_getglobal(L, name); + + return proxy_type(L, 1, &detail::pcall, args); + } +@@ -390,8 +389,7 @@ namespace luabind + , luabind::detail::proxy_function_void_caller > + , luabind::detail::proxy_function_caller > >::type proxy_type; + +- lua_pushstring(L, name); +- lua_gettable(L, LUA_GLOBALSINDEX); ++ lua_getglobal(L, name); + + return proxy_type(L, 1, &detail::resume_impl, args); + } +diff --git a/luabind/detail/object_funs.hpp b/luabind/detail/object_funs.hpp +index 2600238..f826d7a 100644 +--- a/luabind/detail/object_funs.hpp ++++ b/luabind/detail/object_funs.hpp +@@ -184,7 +184,11 @@ namespace luabind + + inline object get_globals(lua_State* L) + { ++#ifdef LUA_GLOBALSINDEX + lua_pushvalue(L, LUA_GLOBALSINDEX); ++#else ++ lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); ++#endif + detail::lua_reference ref; + ref.set(L); + return object(L, ref, true/*object::reference()*/); +diff --git a/luabind/object.hpp b/luabind/object.hpp +index f7b7ca5..b288171 100644 +--- a/luabind/object.hpp ++++ b/luabind/object.hpp +@@ -1207,7 +1207,12 @@ inline object newtable(lua_State* interpreter) + // this could be optimized by returning a proxy + inline object globals(lua_State* interpreter) + { ++#ifdef LUA_GLOBALSINDEX + lua_pushvalue(interpreter, LUA_GLOBALSINDEX); ++#else ++ lua_rawgeti(interpreter, LUA_REGISTRYINDEX, ++ LUA_RIDX_GLOBALS); ++#endif + detail::stack_pop pop(interpreter, 1); + return object(from_stack(interpreter, -1)); + } +diff --git a/src/class_rep.cpp b/src/class_rep.cpp +index 70bb623..912df95 100755 +--- a/src/class_rep.cpp ++++ b/src/class_rep.cpp +@@ -146,11 +146,10 @@ int luabind::detail::class_rep::constructor_dispatcher(lua_State* L) + && cls->get_class_type() == class_rep::lua_class + && !cls->bases().empty()) + { +- lua_pushstring(L, "super"); + lua_pushvalue(L, 1); + lua_pushvalue(L, -3); + lua_pushcclosure(L, super_callback, 2); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + lua_pushvalue(L, -1); +@@ -169,9 +168,8 @@ int luabind::detail::class_rep::constructor_dispatcher(lua_State* L) + + if (super_deprecation_disabled) + { +- lua_pushstring(L, "super"); + lua_pushnil(L); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + return 1; +@@ -214,17 +212,15 @@ int luabind::detail::class_rep::super_callback(lua_State* L) + + if (base->bases().empty()) + { +- lua_pushstring(L, "super"); + lua_pushnil(L); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + else + { +- lua_pushstring(L, "super"); + lua_pushlightuserdata(L, base); + lua_pushvalue(L, lua_upvalueindex(2)); + lua_pushcclosure(L, super_callback, 2); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + base->get_table(L); +@@ -241,9 +237,8 @@ int luabind::detail::class_rep::super_callback(lua_State* L) + // TODO: instead of clearing the global variable "super" + // store it temporarily in the registry. maybe we should + // have some kind of warning if the super global is used? +- lua_pushstring(L, "super"); + lua_pushnil(L); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + + return 0; + } +diff --git a/src/create_class.cpp b/src/create_class.cpp +index c0eb719..47251ef 100755 +--- a/src/create_class.cpp ++++ b/src/create_class.cpp +@@ -126,9 +126,8 @@ namespace luabind { namespace detail + new(c) class_rep(L, name); + + // make the class globally available +- lua_pushstring(L, name); +- lua_pushvalue(L, -2); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_pushvalue(L, -1); ++ lua_setglobal(L, name); + + // also add it to the closure as return value + lua_pushcclosure(L, &stage2, 1); +diff --git a/src/open.cpp b/src/open.cpp +index f20dcfc..ec8e4ff 100755 +--- a/src/open.cpp ++++ b/src/open.cpp +@@ -178,21 +178,18 @@ namespace + lua_settable(L, LUA_REGISTRYINDEX); + + // add functions (class, cast etc...) +- lua_pushstring(L, "class"); + lua_pushcclosure(L, detail::create_class::stage1, 0); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "class"); + +- lua_pushstring(L, "property"); + lua_pushcclosure(L, &make_property, 0); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "property"); + + lua_pushlightuserdata(L, &main_thread_tag); + lua_pushlightuserdata(L, L); + lua_rawset(L, LUA_REGISTRYINDEX); + +- lua_pushstring(L, "super"); + lua_pushcclosure(L, &deprecated_super, 0); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + } // namespace luabind +diff --git a/src/scope.cpp b/src/scope.cpp +index 6495687..d4d1f24 100755 +--- a/src/scope.cpp ++++ b/src/scope.cpp +@@ -136,22 +136,25 @@ namespace luabind { + { + if (m_name) + { +- lua_pushstring(m_state, m_name); +- lua_gettable(m_state, LUA_GLOBALSINDEX); ++ lua_getglobal(m_state, m_name); + + if (!lua_istable(m_state, -1)) + { + lua_pop(m_state, 1); + + lua_newtable(m_state); +- lua_pushstring(m_state, m_name); +- lua_pushvalue(m_state, -2); +- lua_settable(m_state, LUA_GLOBALSINDEX); ++ lua_pushvalue(m_state, -1); ++ lua_setglobal(m_state, m_name); + } + } + else + { ++#ifdef LUA_GLOBALSINDEX + lua_pushvalue(m_state, LUA_GLOBALSINDEX); ++#else ++ lua_rawgeti(m_state, LUA_REGISTRYINDEX, ++ LUA_RIDX_GLOBALS); ++#endif + } + + lua_pop_stack guard(m_state); diff --git a/src/luabind-4-fenv.patch b/src/luabind-4-fenv.patch new file mode 100644 index 0000000..ca01fe5 --- /dev/null +++ b/src/luabind-4-fenv.patch @@ -0,0 +1,29 @@ +This file is part of MXE. +See index.html for further information. + +commit eb4c3507be8a468da07d6ad9f8019c90fbd31b76 +Author: Boris Nagaev +Date: Fri Aug 22 16:24:28 2014 +0400 + + lua_getfenv/lua_setfenv + +diff --git a/src/object_rep.cpp b/src/object_rep.cpp +index 6977bee..bd322e1 100755 +--- a/src/object_rep.cpp ++++ b/src/object_rep.cpp +@@ -25,6 +25,15 @@ + #include + #include + ++// http://lua-users.org/lists/lua-l/2010-01/msg00516.html ++ ++#ifndef LUA_ENVIRONINDEX ++ ++#define lua_getfenv lua_getuservalue ++#define lua_setfenv lua_setuservalue ++ ++#endif ++ + namespace luabind { namespace detail + { + diff --git a/src/luabind-5-lua-resume.patch b/src/luabind-5-lua-resume.patch new file mode 100644 index 0000000..7ead13f --- /dev/null +++ b/src/luabind-5-lua-resume.patch @@ -0,0 +1,32 @@ +This file is part of MXE. +See index.html for further information. + +commit 61587d1b0ffa1d08874154fcdaf0644f8b5b2461 +Author: Boris Nagaev +Date: Fri Aug 22 16:46:35 2014 +0400 + + lua_resume + +diff --git a/src/pcall.cpp b/src/pcall.cpp +index 66dbeaa..7a5d0c2 100755 +--- a/src/pcall.cpp ++++ b/src/pcall.cpp +@@ -47,6 +47,10 @@ namespace luabind { namespace detail + + int resume_impl(lua_State *L, int nargs, int) + { ++#if LUA_VERSION_NUM >= 502 ++ int res = lua_resume(L, NULL, nargs); ++ return (res == LUA_YIELD) ? 0 : res; ++#else + #if LUA_VERSION_NUM >= 501 + // Lua 5.1 added LUA_YIELD as a possible return value, + // this was causing crashes, because the caller expects 0 on success. +@@ -55,6 +59,7 @@ namespace luabind { namespace detail + #else + return lua_resume(L, nargs); + #endif ++#endif + } + + }} diff --git a/src/luabind.mk b/src/luabind.mk new file mode 100644 index 0000000..2a1608a --- /dev/null +++ b/src/luabind.mk @@ -0,0 +1,30 @@ +# This file is part of MXE. +# See index.html for further information. + +PKG := luabind +$(PKG)_IGNORE := +$(PKG)_VERSION := 0.9.1 +$(PKG)_CHECKSUM := 2e92a18b8156d2e2948951d429cd3482e7347550 +$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION) +$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz +$(PKG)_URL := http://$(SOURCEFORGE_MIRROR)/luabind/$($(PKG)_FILE) +$(PKG)_DEPS := gcc boost lua + +define $(PKG)_UPDATE + $(WGET) -q -O- 'http://sourceforge.net/projects/luabind/files/luabind/' | \ + $(SED) -n 's,.*