From 54c7a0d127ce761f6a3d8c2c40fed28ef712a407 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 5 May 2003 21:01:46 +0000 Subject: [PATCH] added makefiles for the library. --- luabind/class.hpp | 5 ----- luabind/detail/get_overload_signature.hpp | 5 ++++- luabind/detail/get_signature.hpp | 31 +++++++++++++------------------ makefile | 8 ++++++++ src/class_rep.cpp | 19 ++++++++++++++++++- src/find_best_match.cpp | 1 - src/function.cpp | 1 - src/implicit_cast.cpp | 5 ++--- src/makefile | 31 +++++++++++++++++++++++++++++++ src/open.cpp | 1 - test/makefile | 4 ++-- test/test.h | 2 +- test/test_lua_classes.cpp | 1 + 13 files changed, 80 insertions(+), 34 deletions(-) create mode 100755 makefile create mode 100755 src/makefile diff --git a/luabind/class.hpp b/luabind/class.hpp index 63b48c5..188ae8a 100644 --- a/luabind/class.hpp +++ b/luabind/class.hpp @@ -649,12 +649,8 @@ namespace luabind lua_newuserdata(L, sizeof(detail::class_rep)); crep = reinterpret_cast(lua_touserdata(L, -1)); - const char* n = lua_typename(L, lua_type(L, -1)); - new(crep) detail::class_rep(m_type, m_name, L, m_destructor, m_held_type, m_extractor); - const char* b = lua_typename(L, lua_type(L, -1)); - // register this new type in the class registry r->add_class(m_type, crep); @@ -899,7 +895,6 @@ namespace luabind { lua_pushstring(m_L, name()); commit(m_L); - const char* n = lua_typename(m_L, lua_type(m_L, -1)); lua_settable(m_L, LUA_GLOBALSINDEX); } } diff --git a/luabind/detail/get_overload_signature.hpp b/luabind/detail/get_overload_signature.hpp index 2dcab27..4bb8b84 100644 --- a/luabind/detail/get_overload_signature.hpp +++ b/luabind/detail/get_overload_signature.hpp @@ -43,6 +43,7 @@ namespace luabind { namespace detail #ifndef LUABIND_NO_ERROR_CHECKING +#ifndef LUABIND_NO_HEADERS_ONLY static std::string get_overload_signatures_candidates(lua_State* L, std::vector::iterator start, std::vector::iterator end, std::string name) { @@ -55,7 +56,9 @@ namespace luabind { namespace detail } return s; } - +#else + std::string get_overload_signatures_candidates(lua_State* L, std::vector::iterator start, std::vector::iterator end, std::string name); +#endif #endif }} diff --git a/luabind/detail/get_signature.hpp b/luabind/detail/get_signature.hpp index 234606f..02cfc7e 100644 --- a/luabind/detail/get_signature.hpp +++ b/luabind/detail/get_signature.hpp @@ -42,30 +42,25 @@ namespace luabind { namespace detail { - template - struct get_class_name + static std::string get_class_name(lua_State* L, LUABIND_TYPE_INFO i) { - static std::string name(lua_State* L) + std::string ret; + class_registry* r = class_registry::get_registry(L); + class_rep* crep = r->find_class(i); + + if (crep == 0) + { + ret = "custom"; + } + else { - std::string ret; - class_registry* r = class_registry::get_registry(L); - - class_rep* crep = r->find_class(LUABIND_TYPEID(T)); - - if (crep == 0) - { - ret = "custom"; - } - else - { - ret += crep->name(); - } - return ret; + ret += crep->name(); } + return ret; }; template - std::string name_of_type(by_value, lua_State* L) { return get_class_name::name(L); }; + std::string name_of_type(by_value, lua_State* L) { return get_class_name(L, LUABIND_TYPEID(T)); }; template std::string name_of_type(by_reference, lua_State* L) { return name_of_type(LUABIND_DECORATE_TYPE(T), L) + "&"; }; template diff --git a/makefile b/makefile new file mode 100755 index 0000000..f96b731 --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ + +all clean: lib + cd src; $(MAKE) $@ + cd test; $(MAKE) $@ + +lib: + mkdir -p $@ + diff --git a/src/class_rep.cpp b/src/class_rep.cpp index 471799d..bdc927e 100755 --- a/src/class_rep.cpp +++ b/src/class_rep.cpp @@ -27,7 +27,6 @@ extern "C" #include "lualib.h" } -#define LUABIND_NO_ERROR_CHECKING #define LUABIND_NO_HEADERS_ONLY #include @@ -35,6 +34,24 @@ extern "C" using namespace luabind::detail; + +#ifndef LUABIND_NO_ERROR_CHECKING + + std::string luabind::detail::get_overload_signatures_candidates(lua_State* L, std::vector::iterator start, std::vector::iterator end, std::string name) + { + std::string s; + for (; start != end; ++start) + { + s += name; + (*start)->get_signature(L, s); + s += "\n"; + } + return s; + } + +#endif + + luabind::detail::class_rep::class_rep(LUABIND_TYPE_INFO t, const char* name, lua_State* L, diff --git a/src/find_best_match.cpp b/src/find_best_match.cpp index ad1ee9e..01dcb98 100755 --- a/src/find_best_match.cpp +++ b/src/find_best_match.cpp @@ -27,7 +27,6 @@ extern "C" #include "lualib.h" } -#define LUABIND_NO_ERROR_CHECKING #define LUABIND_NO_HEADERS_ONLY #include diff --git a/src/function.cpp b/src/function.cpp index 17e4dcd..127c491 100755 --- a/src/function.cpp +++ b/src/function.cpp @@ -27,7 +27,6 @@ extern "C" #include "lualib.h" } -#define LUABIND_NO_ERROR_CHECKING #define LUABIND_NO_HEADERS_ONLY #include diff --git a/src/implicit_cast.cpp b/src/implicit_cast.cpp index 5c0859d..b3b0863 100755 --- a/src/implicit_cast.cpp +++ b/src/implicit_cast.cpp @@ -27,7 +27,6 @@ extern "C" #include "lualib.h" } -#define LUABIND_NO_ERROR_CHECKING #define LUABIND_NO_HEADERS_ONLY #include @@ -51,8 +50,8 @@ using namespace luabind::detail; namespace luabind { namespace detail { int implicit_cast(const class_rep* crep, - LUABIND_TYPE_INFO const& type_id, - int& pointer_offset) + LUABIND_TYPE_INFO const& type_id, + int& pointer_offset) { int offset = 0; if (LUABIND_TYPE_INFO_EQUAL(crep->type(), type_id)) return 0; diff --git a/src/makefile b/src/makefile new file mode 100755 index 0000000..ea52d81 --- /dev/null +++ b/src/makefile @@ -0,0 +1,31 @@ +# the library's configuration is +# controlled through the CONFIG variable + +#$(CONFIG) = \ +# -DLUABIND_DONT_COPY_STRINGS \ +# -DLUABIND_NO_EXCEPTIONS \ +# -DLUABIND_NO_ERROR_CHECKING + +SRCS = \ + class_rep.cpp \ + function.cpp \ + find_best_match.cpp \ + implicit_cast.cpp \ + open.cpp + +OBJS = $(SRCS:.cpp=.o) + +TARGET = ../lib/libluabind.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(AR) rcu $@ $(OBJS) + ranlib $@ + +%.o:%.cpp + g++ -c $? -o $@ -I- -I.. $(CONFIG) + +clean: + rm -f $(OBJS) $(TARGET) + diff --git a/src/open.cpp b/src/open.cpp index 0212195..bbd9d1c 100755 --- a/src/open.cpp +++ b/src/open.cpp @@ -28,7 +28,6 @@ extern "C" } #define LUABIND_NO_HEADERS_ONLY -#define LUABIND_NO_ERROR_CHECKING #include diff --git a/test/makefile b/test/makefile index 25c4c32..b05180e 100644 --- a/test/makefile +++ b/test/makefile @@ -20,8 +20,8 @@ sources =\ target = test_luabind -#libs = -llua -llualib -L/scratch/lua-5.0/lib -L. -libs = -llua -llualib -lluabind -L/usr/local/lib -L../src +#libs = -lluabind -llua -llualib -L/scratch/lua-5.0/lib -L../lib +libs = -lluabind -llua -llualib -L/usr/local/lib -L../lib #inc = -I./ -I/scratch/lua-5.0/include -I- -I.. -I/scratch/boost_1_30_0 inc = -I./ -I/usr/local/include -I- -I.. diff --git a/test/test.h b/test/test.h index 3be64bb..1f23bf9 100644 --- a/test/test.h +++ b/test/test.h @@ -7,7 +7,7 @@ extern "C" #include "lualib.h" } -#define LUABIND_NO_ERROR_CHECKING +//#define LUABIND_NO_ERROR_CHECKING //#define LUABIND_DONT_COPY_STRINGS //#define LUABIND_NO_EXCEPTIONS #define LUABIND_NO_HEADERS_ONLY diff --git a/test/test_lua_classes.cpp b/test/test_lua_classes.cpp index d8c32e6..f51f4cb 100644 --- a/test/test_lua_classes.cpp +++ b/test/test_lua_classes.cpp @@ -47,6 +47,7 @@ namespace struct no_copy { + no_copy() {} virtual void f() = 0; private: no_copy(const no_copy&) {} -- 2.11.4.GIT