diff --git a/README.md b/README.md index 35a1649..e83967c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # luabind +luabind is a library, inspired by and similar to Boost.Python, that helps you create bindings between C++ and Lua. It has the ability to expose functions and classes, written in C++, to Lua. + diff --git a/luabind-0.9.1-libboost-1.55.patch b/luabind-0.9.1-libboost-1.55.patch new file mode 100644 index 0000000..92e3282 --- /dev/null +++ b/luabind-0.9.1-libboost-1.55.patch @@ -0,0 +1,59 @@ +diff --git luabind-0.9.1/luabind/detail/call_function.hpp luabind-0.9.1-fixed/luabind/detail/call_function.hpp +index 1b45ec1..8f5afff 100644 +--- luabind-0.9.1/luabind/detail/call_function.hpp ++++ luabind-0.9.1-fixed/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 luabind-0.9.1/luabind/detail/call_member.hpp luabind-0.9.1-fixed/luabind/detail/call_member.hpp +index de8d563..e63555b 100644 +--- luabind-0.9.1/luabind/detail/call_member.hpp ++++ luabind-0.9.1-fixed/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 luabind-0.9.1/luabind/wrapper_base.hpp luabind-0.9.1-fixed/luabind/wrapper_base.hpp +index d54c668..0f88cc5 100755 +--- luabind-0.9.1/luabind/wrapper_base.hpp ++++ luabind-0.9.1-fixed/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/luabind-0.9.1-lua-5.2-Jamfile.patch b/luabind-0.9.1-lua-5.2-Jamfile.patch new file mode 100644 index 0000000..a86837a --- /dev/null +++ b/luabind-0.9.1-lua-5.2-Jamfile.patch @@ -0,0 +1,25 @@ +diff -Nru luabind-0.9.1.orig/Jamroot luabind-0.9.1/Jamroot +--- luabind-0.9.1.orig/Jamroot 2014-09-15 12:08:13.322118415 +0200 ++++ luabind-0.9.1/Jamroot 2014-09-15 13:14:51.009240593 +0200 +@@ -64,7 +64,7 @@ + $(LUA_PATH) $(HOME)/Library/Frameworks /Library/Frameworks /usr /usr/local /opt/local /opt ; + + local possible-suffixes = +- include/lua5.1 include/lua51 include/lua include ; ++ include/lua5.2 include/lua52 include/lua include ; + + local includes = [ GLOB $(possible-prefixes)/$(possible-suffixes) : lua.h ] ; + +@@ -83,10 +83,10 @@ + + local lib = $(prefix)/lib64 ; + +- local names = liblua5.1 liblua51 liblua ; ++ local names = liblua5.2 liblua52 liblua ; + local extensions = .a .so ; + +- library = [ GLOB $(lib)/lua51 $(lib)/lua5.1 $(lib)/lua $(lib) : ++ library = [ GLOB $(lib)/lua52 $(lib)/lua5.2 $(lib)/lua $(lib) : + $(names)$(extensions) ] ; + lib-name = [ MATCH "lib(.*)" : $(library[1]:B) ] ; + diff --git a/luabind-0.9.1-lua-5.2.patch b/luabind-0.9.1-lua-5.2.patch new file mode 100644 index 0000000..c0c973a --- /dev/null +++ b/luabind-0.9.1-lua-5.2.patch @@ -0,0 +1,593 @@ +diff -ru luabind-0.9.1/doc/docs.rst luabind/doc/docs.rst +--- luabind-0.9.1/doc/docs.rst 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/doc/docs.rst 2014-09-15 11:25:43.353599276 +0200 +@@ -1116,7 +1116,7 @@ + If you want to manipulate the object with Lua functions directly you can push + it onto the Lua stack by calling ``push()``. + +-The operator== will call lua_equal() on the operands and return its result. ++The operator== will call lua_compare() on the operands and return its result. + + The ``is_valid()`` function tells you whether the object has been initialized + or not. When created with its default constructor, objects are invalid. To make +@@ -1734,7 +1734,7 @@ + { + try + { +- lua_state L = lua_open(); ++ lua_state L = luaL_newstate(); + /* ... */ + } + catch(luabind::error& e) +diff -ru luabind-0.9.1/examples/any_converter/any_converter.cpp luabind/examples/any_converter/any_converter.cpp +--- luabind-0.9.1/examples/any_converter/any_converter.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/any_converter/any_converter.cpp 2014-09-15 11:25:43.355599277 +0200 +@@ -69,7 +69,7 @@ + register_any_converter(); + register_any_converter(); + +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + #if LUA_VERSION_NUM >= 501 + luaL_openlibs(L); + #else +diff -ru luabind-0.9.1/examples/cln/cln_test.cpp luabind/examples/cln/cln_test.cpp +--- luabind-0.9.1/examples/cln/cln_test.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/cln/cln_test.cpp 2014-09-15 11:25:43.355599277 +0200 +@@ -107,7 +107,7 @@ + + int main() + { +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + lua_baselibopen(L); + lua_mathlibopen(L); + luabind::open(L); +diff -ru luabind-0.9.1/examples/filesystem/filesystem.cpp luabind/examples/filesystem/filesystem.cpp +--- luabind-0.9.1/examples/filesystem/filesystem.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/filesystem/filesystem.cpp 2014-09-15 11:25:43.355599277 +0200 +@@ -78,7 +78,7 @@ + + int main(int argc, const char* argv[]) + { +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + luaopen_base(L); + luaopen_string(L); + luaopen_table(L); +diff -ru luabind-0.9.1/examples/glut/glut_bind.cpp luabind/examples/glut/glut_bind.cpp +--- luabind-0.9.1/examples/glut/glut_bind.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/glut/glut_bind.cpp 2014-09-15 11:25:43.356599277 +0200 +@@ -167,7 +167,7 @@ + + int main(int argc, char* argv[]) + { +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + lua_baselibopen(L); + lua_mathlibopen(L); + bind_glut(L); +diff -ru luabind-0.9.1/examples/intrusive_ptr/intrusive_ptr.cpp luabind/examples/intrusive_ptr/intrusive_ptr.cpp +--- luabind-0.9.1/examples/intrusive_ptr/intrusive_ptr.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/intrusive_ptr/intrusive_ptr.cpp 2014-09-15 11:25:43.356599277 +0200 +@@ -140,7 +140,7 @@ + + int main() + { +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + lua_baselibopen(L); + + luabind::open(L); +diff -ru luabind-0.9.1/examples/regexp/regex_wrap.cpp luabind/examples/regexp/regex_wrap.cpp +--- luabind-0.9.1/examples/regexp/regex_wrap.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/examples/regexp/regex_wrap.cpp 2014-09-15 11:25:43.357599278 +0200 +@@ -44,7 +44,7 @@ + + int main() + { +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + lua_baselibopen(L); + lua_strlibopen(L); + luabind::open(L); +diff -ru luabind-0.9.1/luabind/detail/call_function.hpp luabind/luabind/detail/call_function.hpp +--- luabind-0.9.1/luabind/detail/call_function.hpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/luabind/detail/call_function.hpp 2014-09-15 11:25:43.358599278 +0200 +@@ -346,8 +346,7 @@ + , 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); + } +@@ -389,8 +388,7 @@ + , 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 -ru luabind-0.9.1/luabind/detail/policy.hpp luabind/luabind/detail/policy.hpp +--- luabind-0.9.1/luabind/detail/policy.hpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/luabind/detail/policy.hpp 2014-09-15 11:25:43.362599280 +0200 +@@ -66,6 +66,10 @@ + #include + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_rawlen lua_objlen ++#endif ++ + namespace luabind + { + namespace detail +@@ -745,7 +749,7 @@ + + std::string from(lua_State* L, int index) + { +- return std::string(lua_tostring(L, index), lua_strlen(L, index)); ++ return std::string(lua_tostring(L, index), lua_rawlen(L, index)); + } + + void to(lua_State* L, std::string const& value) +@@ -1017,5 +1021,9 @@ + #endif + }} + ++#if LUA_VERSION_NUM < 502 ++# undef lua_rawlen ++#endif ++ + #endif // LUABIND_POLICY_HPP_INCLUDED + +diff -ru luabind-0.9.1/luabind/object.hpp luabind/luabind/object.hpp +--- luabind-0.9.1/luabind/object.hpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/luabind/object.hpp 2014-09-15 11:25:43.365599281 +0200 +@@ -45,6 +45,14 @@ + #include + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_compare(L, index1, index2, fn) fn(L, index1, index2) ++# define LUA_OPEQ lua_equal ++# define LUA_OPLT lua_lessthan ++# define lua_rawlen lua_objlen ++# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) ++#endif ++ + namespace luabind { + + namespace detail +@@ -208,11 +216,11 @@ + detail::stack_pop pop2(L, 1); \ + detail::push(L, rhs); \ + \ +- return fn(L, -1, -2) != 0; \ ++ return lua_compare(L, -1, -2, fn) != 0; \ + } + +-LUABIND_BINARY_OP_DEF(==, lua_equal) +-LUABIND_BINARY_OP_DEF(<, lua_lessthan) ++LUABIND_BINARY_OP_DEF(==, LUA_OPEQ) ++LUABIND_BINARY_OP_DEF(<, LUA_OPLT) + + template + std::ostream& operator<<(std::ostream& os +@@ -225,7 +233,7 @@ + value_wrapper_traits::unwrap(interpreter + , static_cast(v)); + char const* p = lua_tostring(interpreter, -1); +- std::size_t len = lua_strlen(interpreter, -1); ++ std::size_t len = lua_rawlen(interpreter, -1); + std::copy(p, p + len, std::ostream_iterator(os)); + return os; + } +@@ -523,7 +531,7 @@ + detail::stack_pop pop(m_interpreter, 2); + m_key.push(m_interpreter); + other.m_key.push(m_interpreter); +- return lua_equal(m_interpreter, -2, -1) != 0; ++ return lua_compare(m_interpreter, -2, -1, LUA_OPEQ) != 0; + } + + adl::iterator_proxy dereference() const +@@ -1207,7 +1215,7 @@ + // this could be optimized by returning a proxy + inline object globals(lua_State* interpreter) + { +- lua_pushvalue(interpreter, LUA_GLOBALSINDEX); ++ lua_pushglobaltable(interpreter); + detail::stack_pop pop(interpreter, 1); + return object(from_stack(interpreter, -1)); + } +@@ -1406,5 +1414,13 @@ + + } // namespace luabind + ++#if LUA_VERSION_NUM < 502 ++# undef lua_compare ++# undef LUA_OPEQ ++# undef LUA_OPLT ++# undef lua_rawlen ++# undef lua_pushglobaltable ++#endif ++ + #endif // LUABIND_OBJECT_050419_HPP + +diff -ru luabind-0.9.1/src/class_rep.cpp luabind/src/class_rep.cpp +--- luabind-0.9.1/src/class_rep.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/class_rep.cpp 2014-09-15 11:25:43.368599282 +0200 +@@ -31,6 +31,10 @@ + #include + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_rawlen lua_objlen ++#endif ++ + using namespace luabind::detail; + + namespace luabind { namespace detail +@@ -146,11 +150,10 @@ + && cls->get_class_type() == class_rep::lua_class + && !cls->bases().empty()) + { +- lua_pushstring(L, "super"); + lua_pushvalue(L, 1); +- lua_pushvalue(L, -3); ++ lua_pushvalue(L, -2); + lua_pushcclosure(L, super_callback, 2); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + lua_pushvalue(L, -1); +@@ -169,9 +172,8 @@ + + if (super_deprecation_disabled) + { +- lua_pushstring(L, "super"); + lua_pushnil(L); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "super"); + } + + return 1; +@@ -214,17 +216,15 @@ + + 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 +241,8 @@ + // 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; + } +@@ -292,7 +291,7 @@ + + const char* key = lua_tostring(L, 2); + +- if (std::strlen(key) != lua_strlen(L, 2)) ++ if (std::strlen(key) != lua_rawlen(L, 2)) + { + lua_pushnil(L); + return 1; +diff -ru luabind-0.9.1/src/create_class.cpp luabind/src/create_class.cpp +--- luabind-0.9.1/src/create_class.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/create_class.cpp 2014-09-15 11:25:43.368599282 +0200 +@@ -26,6 +26,12 @@ + + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_compare(L, index1, index2, fn) fn(L, index1, index2) ++# define LUA_OPEQ lua_equal ++# define lua_rawlen lua_objlen ++#endif ++ + namespace luabind { namespace detail + { + namespace +@@ -40,7 +46,7 @@ + while (lua_next(L, -2)) + { + lua_pushstring(L, "__init"); +- if (lua_equal(L, -1, -3)) ++ if (lua_compare(L, -1, -3, LUA_OPEQ)) + { + lua_pop(L, 2); + continue; +@@ -48,7 +54,7 @@ + else lua_pop(L, 1); // __init string + + lua_pushstring(L, "__finalize"); +- if (lua_equal(L, -1, -3)) ++ if (lua_compare(L, -1, -3, LUA_OPEQ)) + { + lua_pop(L, 2); + continue; +@@ -112,7 +118,7 @@ + lua_error(L); + } + +- if (std::strlen(lua_tostring(L, 1)) != lua_strlen(L, 1)) ++ if (std::strlen(lua_tostring(L, 1)) != lua_rawlen(L, 1)) + { + lua_pushstring(L, "luabind does not support class names with extra nulls"); + lua_error(L); +@@ -126,9 +132,8 @@ + 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 -ru luabind-0.9.1/src/inheritance.cpp luabind/src/inheritance.cpp +--- luabind-0.9.1/src/inheritance.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/inheritance.cpp 2014-09-15 11:25:43.368599282 +0200 +@@ -64,7 +64,7 @@ + void put( + class_id src, class_id target, class_id dynamic_id + , std::ptrdiff_t object_offset +- , std::size_t distance, std::ptrdiff_t offset); ++ , std::ptrdiff_t offset, int distance); + + void invalidate(); + +@@ -90,7 +90,7 @@ + + void cache::put( + class_id src, class_id target, class_id dynamic_id +- , std::ptrdiff_t object_offset, std::size_t distance, std::ptrdiff_t offset) ++ , std::ptrdiff_t object_offset, std::ptrdiff_t offset, int distance) + { + m_cache.insert(std::make_pair( + key_type(src, target, dynamic_id, object_offset) +@@ -175,7 +175,7 @@ + { + m_cache.put( + src, target, dynamic_id, object_offset +- , qe.distance, (char*)qe.p - (char*)p ++ , (char*)qe.p - (char*)p, qe.distance + ); + + return std::make_pair(qe.p, qe.distance); +diff -ru luabind-0.9.1/src/object_rep.cpp luabind/src/object_rep.cpp +--- luabind-0.9.1/src/object_rep.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/object_rep.cpp 2014-09-15 11:25:43.368599282 +0200 +@@ -25,6 +25,11 @@ + #include + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_getuservalue lua_getfenv ++# define lua_setuservalue lua_setfenv ++#endif ++ + namespace luabind { namespace detail + { + +@@ -94,7 +99,7 @@ + + int set_instance_value(lua_State* L) + { +- lua_getfenv(L, 1); ++ lua_getuservalue(L, 1); + lua_pushvalue(L, 2); + lua_rawget(L, -2); + +@@ -129,7 +134,7 @@ + { + lua_newtable(L); + lua_pushvalue(L, -1); +- lua_setfenv(L, 1); ++ lua_setuservalue(L, 1); + lua_pushvalue(L, 4); + lua_setmetatable(L, -2); + } +@@ -147,7 +152,7 @@ + + int get_instance_value(lua_State* L) + { +- lua_getfenv(L, 1); ++ lua_getuservalue(L, 1); + lua_pushvalue(L, 2); + lua_rawget(L, -2); + +@@ -262,7 +267,7 @@ + void* storage = lua_newuserdata(L, sizeof(object_rep)); + object_rep* result = new (storage) object_rep(0, cls); + cls->get_table(L); +- lua_setfenv(L, -2); ++ lua_setuservalue(L, -2); + lua_rawgeti(L, LUA_REGISTRYINDEX, cls->metatable_ref()); + lua_setmetatable(L, -2); + return result; +diff -ru luabind-0.9.1/src/open.cpp luabind/src/open.cpp +--- luabind-0.9.1/src/open.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/open.cpp 2014-09-15 11:25:43.368599282 +0200 +@@ -178,21 +178,18 @@ + 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 -ru luabind-0.9.1/src/pcall.cpp luabind/src/pcall.cpp +--- luabind-0.9.1/src/pcall.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/pcall.cpp 2014-09-15 11:25:43.369599282 +0200 +@@ -47,14 +47,14 @@ + + int resume_impl(lua_State *L, int nargs, int) + { +-#if LUA_VERSION_NUM >= 501 ++#if LUA_VERSION_NUM >= 502 ++ int res = lua_resume(L, NULL, nargs); ++#else ++ int res = lua_resume(L, nargs); ++#endif + // Lua 5.1 added LUA_YIELD as a possible return value, + // this was causing crashes, because the caller expects 0 on success. +- int res = lua_resume(L, nargs); + return (res == LUA_YIELD) ? 0 : res; +-#else +- return lua_resume(L, nargs); +-#endif + } + + }} +diff -ru luabind-0.9.1/src/scope.cpp luabind/src/scope.cpp +--- luabind-0.9.1/src/scope.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/src/scope.cpp 2014-09-15 11:25:43.369599282 +0200 +@@ -29,6 +29,10 @@ + #include + #include + ++#if LUA_VERSION_NUM < 502 ++# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) ++#endif ++ + namespace luabind { namespace detail { + + registration::registration() +@@ -136,22 +140,20 @@ + { + 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 + { +- lua_pushvalue(m_state, LUA_GLOBALSINDEX); ++ lua_pushglobaltable(m_state); + } + + lua_pop_stack guard(m_state); +diff -ru luabind-0.9.1/test/benchmark.cpp luabind/test/benchmark.cpp +--- luabind-0.9.1/test/benchmark.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/test/benchmark.cpp 2014-09-15 11:25:43.369599282 +0200 +@@ -41,7 +41,7 @@ + + using namespace luabind; + +- lua_State* L = lua_open(); ++ lua_State* L = luaL_newstate(); + open(L); + + class_(L, "A") +@@ -49,9 +49,8 @@ + + function(L, "test1", &f1); + +- lua_pushstring(L, "test2"); + lua_pushcclosure(L, &f2, 0); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "test2"); + + std::clock_t total1 = 0; + std::clock_t total2 = 0; +diff -ru luabind-0.9.1/test/main.cpp luabind/test/main.cpp +--- luabind-0.9.1/test/main.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/test/main.cpp 2014-09-15 11:25:43.369599282 +0200 +@@ -50,7 +50,7 @@ + }; + + lua_state::lua_state() +- : m_state(lua_open()) ++ : m_state(luaL_newstate()) + { + luaopen_base(m_state); + #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 +diff -ru luabind-0.9.1/test/test_free_functions.cpp luabind/test/test_free_functions.cpp +--- luabind-0.9.1/test/test_free_functions.cpp 2010-08-31 15:24:52.000000000 +0200 ++++ luabind/test/test_free_functions.cpp 2014-09-15 11:25:43.373599284 +0200 +@@ -77,9 +77,8 @@ + { + using namespace luabind; + +- lua_pushstring(L, "f"); + lua_pushcclosure(L, &function_should_never_be_called, 0); +- lua_settable(L, LUA_GLOBALSINDEX); ++ lua_setglobal(L, "f"); + + DOSTRING(L, "assert(f() == 10)"); + +@@ -145,7 +144,12 @@ + catch(luabind::error const& e) + { + if (std::string("[string \"function failing_fun() error('expected " +- "erro...\"]:1: expected error message") != lua_tostring(L, -1)) ++#if LUA_VERSION_NUM >= 502 ++ "error ..." ++#else ++ "erro..." ++#endif ++ "\"]:1: expected error message") != lua_tostring(L, -1)) + { + TEST_ERROR("function failed with unexpected error message"); + } diff --git a/luabind-0.9.1-x86_64-libdir.patch b/luabind-0.9.1-x86_64-libdir.patch new file mode 100644 index 0000000..bfc4d1f --- /dev/null +++ b/luabind-0.9.1-x86_64-libdir.patch @@ -0,0 +1,11 @@ +--- luabind-0.9.1/Jamroot.orig 2014-09-15 11:34:08.535786284 +0200 ++++ luabind-0.9.1/Jamroot 2014-09-15 11:33:08.276763977 +0200 +@@ -81,7 +81,7 @@ + prefix = $(prefix:D) ; + } + +- local lib = $(prefix)/lib ; ++ local lib = $(prefix)/lib64 ; + + local names = liblua5.1 liblua51 liblua ; + local extensions = .a .so ; diff --git a/luabind.spec b/luabind.spec new file mode 100644 index 0000000..a68800b --- /dev/null +++ b/luabind.spec @@ -0,0 +1,107 @@ +Name: luabind +Version: 0.9.1 +Release: 2mamba +Summary: A library that helps you create bindings between C++ and Lua +Group: Development/Libraries +Vendor: openmamba +Distribution: openmamba +Packager: Silvan Calarco +URL: http://sourceforge.net/projects/luabind/ +Source: http://downloads.sourceforge.net/project/luabind/luabind/%{version}/luabind-%{version}.tar.gz +Source1: http://prdownloads.sourceforge.net/boost/boost-build-2.0-m12.tar.bz2 +Patch0: luabind-0.9.1-lua-5.2.patch +Patch1: luabind-0.9.1-x86_64-libdir.patch +Patch2: luabind-0.9.1-libboost-1.55.patch +Patch3: luabind-0.9.1-lua-5.2-Jamfile.patch +License: MIT +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: libgcc +BuildRequires: liblua-devel +BuildRequires: libstdc++6-devel +## AUTOBUILDREQ-END +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +luabind is a library, inspired by and similar to Boost.Python, that helps you create bindings between C++ and Lua. It has the ability to expose functions and classes, written in C++, to Lua. + +%package -n lib%{name} +Group: System/Libraries +Summary: Shared libraries for %{name} + +%description -n lib%{name} +This package contains shared libraries for %{name}. + +%package -n lib%{name}-devel +Group: Development/Libraries +Summary: Development files for %{name} +Requires: lib%{name} = %{?epoch:%epoch:}%{version}-%{release} + +%description -n lib%{name}-devel +This package contains libraries and header files for developing applications that use %{name}. + +%debug_package + +%prep +%setup -q -a1 +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%ifnarch x86_64 +sed -i "s|/lib64|/lib|" Jamroot +%endif + +%build +export BOOST_BUILD_PATH=`pwd`/boost-build +bjam release + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +export BOOST_BUILD_PATH=`pwd`/boost-build +bjam install release --prefix=%{buildroot}%{_prefix} --libdir=%{buildroot}%{_libdir} + +install -d -m0755 %{buildroot}%{_libdir}/pkgconfig +cat > %{buildroot}%{_libdir}/pkgconfig/luabind.pc << _EOF +prefix=%{_prefix} +exec_prefix=\${prefix} +libdir=%{_libdir} +includedir=\${prefix}/include + +Name: Luabind +Description: c++ binding for lua +URL: http://www.rasterbar.com/products/luabind.html +Version: 0.9.1 +Libs: -L\${libdir} -lluabind +Libs.private: -llua5.2 +Cflags: -I\${includedir} -I%{_includedir}/lua5.2 +_EOF + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%post -n lib%{name} -p /sbin/ldconfig +%postun -n lib%{name} -p /sbin/ldconfig + +%files -n lib%{name} +%defattr(-,root,root) +%{_libdir}/libluabind.so.* +%doc LICENSE + +%files -n lib%{name}-devel +%defattr(-,root,root) +%dir %{_includedir}/luabind/ +%{_includedir}/luabind/*.hpp +%dir %{_includedir}/luabind/detail/ +%{_includedir}/luabind/detail/*.hpp +%{_libdir}/libluabind.so +%{_libdir}/pkgconfig/luabind.pc + +%changelog +* Wed Sep 17 2014 Silvan Calarco 0.9.1-2mamba +- added pkg-config file +- build release not debug library + +* Mon Sep 15 2014 Silvan Calarco 0.9.1-1mamba +- package created using the webbuild interface