luabind-cvs Mailing List for luabind (Page 2)
Brought to you by:
arvidn,
daniel_wallin
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(7) |
Oct
(53) |
Nov
(13) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(15) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(5) |
Jun
(7) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
(5) |
Nov
|
Dec
|
From: Arvid N. <ar...@us...> - 2006-03-26 20:34:17
|
Update of /cvsroot/luabind/luabind/luabind/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17155/src Modified Files: class_info.cpp Log Message: added a primitive converter for objects of type LUA_TTHREAD to lua_State*. Fixed bug in class_info.cpp. added stack pops ti test.hpp where a test would fail, it still preserve the stack now. Removed obsolete tests of functor and added a test of call_function where the function that is called fails. Index: class_info.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/src/class_info.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- class_info.cpp 28 Nov 2005 20:55:34 -0000 1.5 +++ class_info.cpp 26 Mar 2006 20:34:13 -0000 1.6 @@ -52,7 +52,7 @@ std::size_t index = 1; for (map_type::const_iterator i = obj->crep()->properties().begin(); - i != obj->crep()->properties().end(); ++i) + i != obj->crep()->properties().end(); ++i, ++index) { result.attributes[index] = i->first; } |
From: Arvid N. <ar...@us...> - 2006-03-26 20:34:17
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17155/test Modified Files: test.hpp test_free_functions.cpp Log Message: added a primitive converter for objects of type LUA_TTHREAD to lua_State*. Fixed bug in class_info.cpp. added stack pops ti test.hpp where a test would fail, it still preserve the stack now. Removed obsolete tests of functor and added a test of call_function where the function that is called fails. Index: test_free_functions.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_free_functions.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_free_functions.cpp 28 Nov 2005 20:55:34 -0000 1.19 +++ test_free_functions.cpp 26 Mar 2006 20:34:13 -0000 1.20 @@ -22,16 +22,7 @@ #include "test.hpp" #include <luabind/luabind.hpp> -//#include <luabind/functor.hpp> #include <luabind/adopt_policy.hpp> -/* -luabind::functor<int> functor_test; - -void set_functor(luabind::functor<int> f) -{ - functor_test = f; -} -*/ struct base : counted_type<base> { @@ -166,17 +157,22 @@ "f(number)\n" "f(number, number)\n"); -// DOSTRING(L, -// "function functor_test(a) glob = a\n" -// " return 'foobar'\n" -// "end"); -// functor<std::string> functor_test = object_cast<functor<std::string> >(globals(L)["functor_test"]); - -// TEST_CHECK(functor_test(6)[detail::null_type()] == "foobar"); -// TEST_CHECK(object_cast<int>(globals(L)["glob"]) == 6); -// functor<std::string> functor_test2 = object_cast<functor<std::string> >(globals(L)["functor_test"]); + DOSTRING(L, "function failing_fun() error('expected error message') end"); + try + { + call_function<void>(L, "failing_fun"); + TEST_ERROR("function didn't fail when it was expected to"); + } + catch(luabind::error const& e) + { + if (std::string("[string \"function failing_fun() error('expected " + "erro...\"]:1: expected error message") != lua_tostring(L, -1)) + { + TEST_ERROR("function failed with unexpected error message"); + lua_pop(L, 1); + } + } -// TEST_CHECK(functor_test == functor_test2); } Index: test.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test.hpp 28 Nov 2005 20:55:34 -0000 1.9 +++ test.hpp 26 Mar 2006 20:34:13 -0000 1.10 @@ -108,12 +108,13 @@ , (char const*)expected)) \ { \ TEST_ERROR(lua_tostring(e.state(), -1)); \ + lua_pop(L, 1); \ } \ } \ catch (std::string const& s) \ { \ if (s != expected) \ - TEST_ERROR(s.c_str()); \ + TEST_ERROR(s.c_str()); \ } \ } @@ -126,6 +127,7 @@ catch (luabind::error const& e) \ { \ TEST_ERROR(lua_tostring(e.state(), -1)); \ + lua_pop(L, 1); \ } \ catch (std::string const& s) \ { \ |
From: Arvid N. <ar...@us...> - 2006-03-26 16:16:38
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20806/doc Modified Files: docs.rst Log Message: fixed typo Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- docs.rst 26 Mar 2006 15:47:30 -0000 1.27 +++ docs.rst 26 Mar 2006 16:16:30 -0000 1.28 @@ -801,7 +801,7 @@ .. parsed-literal:: class_<foo>("foo") - .def(constructor<>() + .def(constructor<>()) **.scope [ class_<inner>("nested"), |
From: Arvid N. <ar...@us...> - 2006-03-26 15:47:34
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247/luabind/test Modified Files: makefile test_held_type.cpp test_lua_classes.cpp test_object.cpp Log Message: merged back rc 0.7 changes into head Index: makefile =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/makefile,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- makefile 28 Nov 2005 20:55:34 -0000 1.21 +++ makefile 26 Mar 2006 15:47:30 -0000 1.22 @@ -26,15 +26,13 @@ test_iterator.cpp \ -CPPFLAGS = -Wno-long-double - all: $(SOURCES:.cpp=.exe) %.exe:%.o main.o $(CXX) $? -o $@ -g -L$(LUA_PATH)/lib -L../lib -lluabind -llualib -llua %.o:%.cpp - $(CXX) -Wall -ftemplate-depth-100 -g $(CPPFLAGS) $(CONFIG) -I$(LUA_PATH)/include -I. -I- -I../ -I$(BOOST_ROOT) -c $? -o $@ + $(CXX) -Wall -ftemplate-depth-100 -g $(CONFIG) -I$(LUA_PATH)/include -I. -I- -I../ -I$(BOOST_ROOT) -c $? -o $@ #just to force the tests to be run test: $(SOURCES:.cpp=.dummy) Index: test_held_type.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_held_type.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- test_held_type.cpp 28 Nov 2005 20:55:34 -0000 1.30 +++ test_held_type.cpp 26 Mar 2006 15:47:30 -0000 1.31 @@ -27,11 +27,13 @@ namespace luabind { +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP template<class T> - T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); } + T* get_pointer(boost::shared_ptr<T> const& p) { return p.get(); } +#endif template<class A> - boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A>*) + boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A> const*) { return 0; } Index: test_object.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_object.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- test_object.cpp 28 Nov 2005 20:55:34 -0000 1.28 +++ test_object.cpp 26 Mar 2006 15:47:30 -0000 1.29 @@ -26,6 +26,9 @@ #include <luabind/adopt_policy.hpp> #include <luabind/detail/debug.hpp> #include <luabind/error.hpp> +#include <luabind/operator.hpp> + +#include <boost/lexical_cast.hpp> #include <utility> @@ -87,6 +90,9 @@ { luabind::object obj; luabind::object obj2; + + bool operator==(test_param const& rhs) const + { return obj == rhs.obj && obj2 == rhs.obj2; } }; COUNTER_GUARD(test_param); @@ -127,11 +133,19 @@ .def(constructor<>()) .def_readwrite("obj", &test_param::obj) .def_readonly("obj2", &test_param::obj2) + .def(const_self == const_self) ]; object uninitialized; TEST_CHECK(!uninitialized); TEST_CHECK(!uninitialized.is_valid()); + + test_param temp_object; + globals(L)["temp"] = temp_object; + TEST_CHECK(object_cast<test_param>(globals(L)["temp"]) == temp_object); + globals(L)["temp"] = &temp_object; + TEST_CHECK(object_cast<test_param const*>(globals(L)["temp"]) == &temp_object); + TEST_CHECK(globals(L)["temp"] == temp_object); DOSTRING(L, "t = 2\n" @@ -153,6 +167,9 @@ int a = type(test_param_policies); TEST_CHECK(a == LUA_TFUNCTION); + luabind::object obj; + obj = luabind::object(); + // call the function and tell lua to adopt the pointer passed as first argument test_param_policies(5, new test_param())[adopt(_2)]; @@ -179,6 +196,11 @@ object temp_val = g["temp_val"]; TEST_CHECK(ret_val == temp_val); + g["temp"] = "test string"; + TEST_CHECK(boost::lexical_cast<std::string>(g["temp"]) == "test string"); + g["temp"] = 6; + TEST_CHECK(boost::lexical_cast<std::string>(g["temp"]) == "6"); + TEST_CHECK(object_cast<std::string>(g["glob"]) == "teststring"); TEST_CHECK(object_cast<std::string>(gettable(g, "glob")) == "teststring"); TEST_CHECK(object_cast<std::string>(rawget(g, "glob")) == "teststring"); Index: test_lua_classes.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_lua_classes.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- test_lua_classes.cpp 28 Nov 2005 20:55:34 -0000 1.27 +++ test_lua_classes.cpp 26 Mar 2006 15:47:30 -0000 1.28 @@ -29,8 +29,10 @@ namespace luabind { +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP template<class T> - T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); } + T* get_pointer(boost::shared_ptr<T> const& p) { return p.get(); } +#endif template<class A> boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A>*) |
From: Arvid N. <ar...@us...> - 2006-03-26 15:47:33
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247/luabind/luabind Modified Files: class.hpp function.hpp handle.hpp object.hpp Log Message: merged back rc 0.7 changes into head Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- object.hpp 16 Dec 2005 18:52:23 -0000 1.38 +++ object.hpp 26 Mar 2006 15:47:30 -0000 1.39 @@ -140,23 +140,46 @@ }; # endif - template<class T, class U, class V> - lua_State* binary_interpreter(T const& x, U const&, boost::mpl::true_, V) + template<class T, class U> + int binary_interpreter(lua_State*& L, T const& lhs, U const& rhs + , boost::mpl::true_, boost::mpl::true_) { - return value_wrapper_traits<T>::interpreter(x); + L = value_wrapper_traits<T>::interpreter(lhs); + lua_State* L2 = value_wrapper_traits<U>::interpreter(rhs); + + // you are comparing objects with different interpreters + // that's not allowed. + assert(L == L2 || L == 0 || L2 == 0); + + // if the two objects we compare have different interpreters + // then they + + if (L != L2) return -1; + if (L == 0) return 1; + return 0; + } + + template<class T, class U> + int binary_interpreter(lua_State*& L, T const& x, U const& + , boost::mpl::true_, boost::mpl::false_) + { + L = value_wrapper_traits<T>::interpreter(x); + return 0; } template<class T, class U> - lua_State* binary_interpreter(T const&, U const& x, boost::mpl::false_, boost::mpl::true_) + int binary_interpreter(lua_State*& L, T const&, U const& x, boost::mpl::false_, boost::mpl::true_) { - return value_wrapper_traits<U>::interpreter(x); + L = value_wrapper_traits<U>::interpreter(x); + return 0; } template<class T, class U> - lua_State* binary_interpreter(T const& x, U const& y) + int binary_interpreter(lua_State*& L, T const& x, U const& y) { return binary_interpreter( - x + L + , x , y , is_value_wrapper<T>() , is_value_wrapper<U>() @@ -168,7 +191,14 @@ typename enable_binary<bool,LHS,RHS>::type \ operator op(LHS const& lhs, RHS const& rhs) \ { \ - lua_State* L = binary_interpreter(lhs, rhs); \ + lua_State* L = 0; \ + switch (binary_interpreter(L, lhs, rhs)) \ + { \ + case 1: \ + return true; \ + case -1: \ + return false; \ + } \ \ assert(L); \ \ @@ -180,8 +210,24 @@ return fn(L, -1, -2) != 0; \ } - LUABIND_BINARY_OP_DEF(==, lua_equal) - LUABIND_BINARY_OP_DEF(<, lua_lessthan) +LUABIND_BINARY_OP_DEF(==, lua_equal) +LUABIND_BINARY_OP_DEF(<, lua_lessthan) + + template<class ValueWrapper> + std::ostream& operator<<(std::ostream& os + , object_interface<ValueWrapper> const& v) + { + using namespace luabind; + lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter( + static_cast<ValueWrapper const&>(v)); + detail::stack_pop pop(interpreter, 1); + value_wrapper_traits<ValueWrapper>::unwrap(interpreter + , static_cast<ValueWrapper const&>(v)); + char const* p = lua_tostring(interpreter, -1); + int len = lua_strlen(interpreter, -1); + std::copy(p, p + len, std::ostream_iterator<char>(os)); + return os; + } #undef LUABIND_BINARY_OP_DEF Index: handle.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/handle.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- handle.hpp 28 Nov 2005 20:55:34 -0000 1.2 +++ handle.hpp 26 Mar 2006 15:47:30 -0000 1.3 @@ -62,6 +62,7 @@ : m_interpreter(other.m_interpreter) , m_index(LUA_NOREF) { + if (m_interpreter == 0) return; detail::getref(m_interpreter, other.m_index); m_index = detail::ref(m_interpreter); } Index: class.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/class.hpp,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- class.hpp 28 Nov 2005 20:55:34 -0000 1.64 +++ class.hpp 26 Mar 2006 15:47:30 -0000 1.65 @@ -726,11 +726,11 @@ , const boost::function2<int, lua_State*, int>& g); #ifdef LUABIND_NO_ERROR_CHECKING - void class_base::add_setter( + void add_setter( const char* name , const boost::function2<int, lua_State*, int>& s); #else - void class_base::add_setter( + void add_setter( const char* name , const boost::function2<int, lua_State*, int>& s , int (*match)(lua_State*, int) Index: function.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/function.hpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- function.hpp 4 Dec 2005 13:56:15 -0000 1.25 +++ function.hpp 26 Mar 2006 15:47:30 -0000 1.26 @@ -87,7 +87,7 @@ char end; }; - struct function_rep + struct LUABIND_API function_rep { function_rep(const char* name): m_name(name) {} void add_overload(const free_functions::overload_rep& o); |
From: cyril R. <c.r...@la...> - 2006-02-04 01:07:49
|
Hi, I found a little bug in the test/makefile of the luabind-0.7 release (January 24, 2006). I downloaded the luabind-0.7 tarball on the sourceforge page. It compiled except the test directory. The error is: ------- /usr/lib/liblualib.so: undefined reference to `dlerror' /usr/lib/liblualib.so: undefined reference to `dlclose' /usr/lib/liblualib.so: undefined reference to `dlopen' /usr/lib/liblualib.so: undefined reference to `dlsym' ------- Indeed, it is because '-ldl' is missing in the makefile. I simply suggest to add it at the end of the concerned line: ------- $(CXX) $? -o $@ -g -L$(LUA_PATH)/lib -L../lib -lluabind -llualib -llua -ldl ------- Could you please update the tarball, so that source-based Linux distributions (like Gentoo) could download and compile it without problems ? Thanks in advance. Best regards, Cyril |
From: Arvid N. <ar...@us...> - 2006-01-24 18:21:29
|
Update of /cvsroot/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10536/luabind Modified Files: Tag: luabind_rc_0_7 config Log Message: restored config to use plain g++ Index: config =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/config,v retrieving revision 1.12.8.1 retrieving revision 1.12.8.2 diff -u -d -r1.12.8.1 -r1.12.8.2 --- config 24 Jan 2006 18:20:24 -0000 1.12.8.1 +++ config 24 Jan 2006 18:21:11 -0000 1.12.8.2 @@ -14,5 +14,5 @@ # and LUA_PATH to the path to your lua # installation (prebuilt) -CXX = g++-4.0 +CXX = g++ |
From: Arvid N. <ar...@us...> - 2006-01-24 18:20:54
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10070/luabind/test Modified Files: Tag: luabind_rc_0_7 test_held_type.cpp test_lua_classes.cpp Log Message: fixed adl issue Index: test_held_type.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_held_type.cpp,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -u -d -r1.30 -r1.30.2.1 --- test_held_type.cpp 28 Nov 2005 20:55:34 -0000 1.30 +++ test_held_type.cpp 24 Jan 2006 18:20:24 -0000 1.30.2.1 @@ -27,11 +27,13 @@ namespace luabind { +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP template<class T> - T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); } + T* get_pointer(boost::shared_ptr<T> const& p) { return p.get(); } +#endif template<class A> - boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A>*) + boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A> const*) { return 0; } Index: test_lua_classes.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_lua_classes.cpp,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -d -r1.27 -r1.27.2.1 --- test_lua_classes.cpp 28 Nov 2005 20:55:34 -0000 1.27 +++ test_lua_classes.cpp 24 Jan 2006 18:20:24 -0000 1.27.2.1 @@ -29,8 +29,10 @@ namespace luabind { +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP template<class T> - T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); } + T* get_pointer(boost::shared_ptr<T> const& p) { return p.get(); } +#endif template<class A> boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A>*) |
From: Arvid N. <ar...@us...> - 2006-01-24 18:20:36
|
Update of /cvsroot/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10070/luabind Modified Files: Tag: luabind_rc_0_7 config Log Message: fixed adl issue Index: config =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/config,v retrieving revision 1.12 retrieving revision 1.12.8.1 diff -u -d -r1.12 -r1.12.8.1 --- config 21 Mar 2004 01:43:24 -0000 1.12 +++ config 24 Jan 2006 18:20:24 -0000 1.12.8.1 @@ -14,5 +14,5 @@ # and LUA_PATH to the path to your lua # installation (prebuilt) -CXX = g++ +CXX = g++-4.0 |
From: Arvid N. <ar...@us...> - 2006-01-11 23:33:28
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7891 Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: minor documentation updates Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54.2.5 retrieving revision 1.54.2.6 diff -u -d -r1.54.2.5 -r1.54.2.6 --- docs.html 11 Jan 2006 00:53:25 -0000 1.54.2.5 +++ docs.html 11 Jan 2006 23:33:14 -0000 1.54.2.6 @@ -7,7 +7,7 @@ <title>luabind</title> <meta name="author" content="Daniel Wallin, Arvid Norberg" /> <meta name="copyright" content="Copyright Daniel Wallin, Arvid Norberg 2003." /> -<meta name="date" content="2006-01-10" /> +<meta name="date" content="2006-01-11" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> @@ -22,9 +22,9 @@ <tr><th class="docinfo-name">Copyright:</th> <td>Copyright Daniel Wallin, Arvid Norberg 2003.</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2006-01-10</td></tr> +<td>2006-01-11</td></tr> <tr><th class="docinfo-name">Revision:</th> -<td>1.26.2.4</td></tr> +<td>1.26.2.5</td></tr> <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -110,7 +110,7 @@ <li><a class="reference" href="#pcall-errorfunc" id="id87" name="id87">14.1 pcall errorfunc</a></li> <li><a class="reference" href="#file-and-line-numbers" id="id88" name="id88">14.2 file and line numbers</a></li> <li><a class="reference" href="#lua-panic" id="id89" name="id89">14.3 lua panic</a></li> -<li><a class="reference" href="#msvc-exceptions" id="id90" name="id90">14.4 msvc exceptions</a></li> +<li><a class="reference" href="#structured-exceptions-msvc" id="id90" name="id90">14.4 structured exceptions (MSVC)</a></li> <li><a class="reference" href="#error-messages" id="id91" name="id91">14.5 Error messages</a></li> </ul> </li> @@ -2706,16 +2706,18 @@ function is to make sure lua is compiled as C++ and throw an exception from the panic function. Throwing an exception instead of using <tt class="docutils literal"><span class="pre">setjmp</span></tt> and <tt class="docutils literal"><span class="pre">longjmp</span></tt> will make sure the stack is correctly unwound.</p> +<p>When the panic function is called, the lua state is invalid, and the only +allowed operation on it is to close it.</p> <p>For more information, see the <a class="reference" href="http://www.lua.org/manual/5.0/manual.html#3.19">lua manual section 3.19</a>.</p> </div> -<div class="section" id="msvc-exceptions"> -<h2><a name="msvc-exceptions">14.4 msvc exceptions</a></h2> +<div class="section" id="structured-exceptions-msvc"> +<h2><a name="structured-exceptions-msvc">14.4 structured exceptions (MSVC)</a></h2> <p>Since lua is generally built as a C library, any callbacks called from lua cannot under any circumstance throw an exception. Because of that, luabind has to catch all exceptions and translate them into proper lua errors (by calling <tt class="docutils literal"><span class="pre">lua_error()</span></tt>). This means we have a <tt class="docutils literal"><span class="pre">catch(...)</span> <span class="pre">{}</span></tt> in there.</p> -<p>In VisualStudio, <tt class="docutils literal"><span class="pre">catch</span> <span class="pre">(...)</span></tt> will not only catch C++ exceptions, it will -also catch hardware exceptions like Segmentation fault. This means that if +<p>In Visual Studio, <tt class="docutils literal"><span class="pre">catch</span> <span class="pre">(...)</span></tt> will not only catch C++ exceptions, it will +also catch structured exceptions, such as segmentation fault. This means that if your function, that gets called from luabind, makes an invalid memory adressing, you won't notice it. All that will happen is that lua will return an error message saying "unknown exception".</p> @@ -2728,7 +2730,7 @@ ::_set_se_translator(straight_to_debugger); #endif </pre> -<p>This will make hardware exceptions, like segmentation fault, to actually get +<p>This will make structured exceptions, like segmentation fault, to actually get caught by the debugger.</p> </div> <div class="section" id="error-messages"> @@ -2836,11 +2838,11 @@ </dd> <dt>LUA_API</dt> <dd>If you want to link dynamically against Lua, you can set this define to -the import-keyword on your compiler and platform. On windows in VisualStudio +the import-keyword on your compiler and platform. On Windows in Visual Studio this should be <tt class="docutils literal"><span class="pre">__declspec(dllimport)</span></tt> if you want to link against Lua as a dll.</dd> <dt>LUABIND_EXPORT, LUABIND_IMPORT</dt> -<dd>If you want to link against luabind as a dll (in VisualStudio), you can +<dd>If you want to link against luabind as a dll (in Visual Studio), you can define <tt class="docutils literal"><span class="pre">LUABIND_EXPORT</span></tt> to <tt class="docutils literal"><span class="pre">__declspec(dllexport)</span></tt> and <tt class="docutils literal"><span class="pre">LUABIND_IMPORT</span></tt> to <tt class="docutils literal"><span class="pre">__declspec(dllimport)</span></tt> or <tt class="docutils literal"><span class="pre">__attribute__</span> <span class="pre">((visibility("default")))</span></tt> on GCC 4. @@ -2995,7 +2997,7 @@ <dd>VC6.5 chokes on warnings, if you are getting alot of warnings from your code try suppressing them with a pragma directive, this should solve the problem.</dd> -<dt>Crashes when linking against luabind as a dll in windows</dt> +<dt>Crashes when linking against luabind as a dll in Windows</dt> <dd>When you build luabind, Lua and you project, make sure you link against the runtime dynamically (as a dll).</dd> <dt>I cannot register a function with a non-const parameter</dt> Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26.2.5 retrieving revision 1.26.2.6 diff -u -d -r1.26.2.5 -r1.26.2.6 --- docs.rst 11 Jan 2006 00:53:27 -0000 1.26.2.5 +++ docs.rst 11 Jan 2006 23:33:14 -0000 1.26.2.6 @@ -2204,20 +2204,23 @@ the panic function. Throwing an exception instead of using ``setjmp`` and ``longjmp`` will make sure the stack is correctly unwound. +When the panic function is called, the lua state is invalid, and the only +allowed operation on it is to close it. + For more information, see the `lua manual section 3.19`_. .. _`lua manual section 3.19`: http://www.lua.org/manual/5.0/manual.html#3.19 -msvc exceptions ---------------- +structured exceptions (MSVC) +---------------------------- Since lua is generally built as a C library, any callbacks called from lua cannot under any circumstance throw an exception. Because of that, luabind has to catch all exceptions and translate them into proper lua errors (by calling ``lua_error()``). This means we have a ``catch(...) {}`` in there. -In VisualStudio, ``catch (...)`` will not only catch C++ exceptions, it will -also catch hardware exceptions like Segmentation fault. This means that if +In Visual Studio, ``catch (...)`` will not only catch C++ exceptions, it will +also catch structured exceptions, such as segmentation fault. This means that if your function, that gets called from luabind, makes an invalid memory adressing, you won't notice it. All that will happen is that lua will return an error message saying "unknown exception". @@ -2231,7 +2234,7 @@ ::_set_se_translator(straight_to_debugger); #endif -This will make hardware exceptions, like segmentation fault, to actually get +This will make structured exceptions, like segmentation fault, to actually get caught by the debugger. @@ -2353,12 +2356,12 @@ LUA_API If you want to link dynamically against Lua, you can set this define to - the import-keyword on your compiler and platform. On windows in VisualStudio + the import-keyword on your compiler and platform. On Windows in Visual Studio this should be ``__declspec(dllimport)`` if you want to link against Lua as a dll. LUABIND_EXPORT, LUABIND_IMPORT - If you want to link against luabind as a dll (in VisualStudio), you can + If you want to link against luabind as a dll (in Visual Studio), you can define ``LUABIND_EXPORT`` to ``__declspec(dllexport)`` and ``LUABIND_IMPORT`` to ``__declspec(dllimport)`` or ``__attribute__ ((visibility("default")))`` on GCC 4. @@ -2527,7 +2530,7 @@ code try suppressing them with a pragma directive, this should solve the problem. -Crashes when linking against luabind as a dll in windows +Crashes when linking against luabind as a dll in Windows When you build luabind, Lua and you project, make sure you link against the runtime dynamically (as a dll). |
From: Arvid N. <ar...@us...> - 2006-01-11 22:33:07
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/luabind Modified Files: Tag: luabind_rc_0_7 class.hpp function.hpp Log Message: added missing LUABIND_API in function.hpp and removed illegal qualification in class.hpp add_setter Index: class.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/class.hpp,v retrieving revision 1.64 retrieving revision 1.64.2.1 diff -u -d -r1.64 -r1.64.2.1 --- class.hpp 28 Nov 2005 20:55:34 -0000 1.64 +++ class.hpp 11 Jan 2006 22:32:59 -0000 1.64.2.1 @@ -726,11 +726,11 @@ , const boost::function2<int, lua_State*, int>& g); #ifdef LUABIND_NO_ERROR_CHECKING - void class_base::add_setter( + void add_setter( const char* name , const boost::function2<int, lua_State*, int>& s); #else - void class_base::add_setter( + void add_setter( const char* name , const boost::function2<int, lua_State*, int>& s , int (*match)(lua_State*, int) Index: function.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/function.hpp,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -d -r1.25 -r1.25.2.1 --- function.hpp 4 Dec 2005 13:56:15 -0000 1.25 +++ function.hpp 11 Jan 2006 22:32:59 -0000 1.25.2.1 @@ -87,7 +87,7 @@ char end; }; - struct function_rep + struct LUABIND_API function_rep { function_rep(const char* name): m_name(name) {} void add_overload(const free_functions::overload_rep& o); |
From: Arvid N. <ar...@us...> - 2006-01-11 22:32:31
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20464 Modified Files: Tag: luabind_rc_0_7 makefile Log Message: removed the -Wno-long-double build flag from the makefile Index: makefile =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/makefile,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -d -r1.21 -r1.21.2.1 --- makefile 28 Nov 2005 20:55:34 -0000 1.21 +++ makefile 11 Jan 2006 22:32:18 -0000 1.21.2.1 @@ -26,15 +26,13 @@ test_iterator.cpp \ -CPPFLAGS = -Wno-long-double - all: $(SOURCES:.cpp=.exe) %.exe:%.o main.o $(CXX) $? -o $@ -g -L$(LUA_PATH)/lib -L../lib -lluabind -llualib -llua %.o:%.cpp - $(CXX) -Wall -ftemplate-depth-100 -g $(CPPFLAGS) $(CONFIG) -I$(LUA_PATH)/include -I. -I- -I../ -I$(BOOST_ROOT) -c $? -o $@ + $(CXX) -Wall -ftemplate-depth-100 -g $(CONFIG) -I$(LUA_PATH)/include -I. -I- -I../ -I$(BOOST_ROOT) -c $? -o $@ #just to force the tests to be run test: $(SOURCES:.cpp=.dummy) |
From: Arvid N. <ar...@us...> - 2006-01-11 00:53:40
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31961 Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: added sections about how to add file and line number to error messages, notes about how catch(...) can be worked around on msvc, created a new section called error handling and moved related topics together under it Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54.2.4 retrieving revision 1.54.2.5 diff -u -d -r1.54.2.4 -r1.54.2.5 --- docs.html 10 Jan 2006 00:36:47 -0000 1.54.2.4 +++ docs.html 11 Jan 2006 00:53:25 -0000 1.54.2.5 @@ -24,7 +24,7 @@ <tr><th class="docinfo-name">Date:</th> <td>2006-01-10</td></tr> <tr><th class="docinfo-name">Revision:</th> -<td>1.26.2.3</td></tr> +<td>1.26.2.4</td></tr> <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -106,15 +106,19 @@ </ul> </li> <li><a class="reference" href="#splitting-up-the-registration" id="id85" name="id85">13 Splitting up the registration</a></li> -<li><a class="reference" href="#configuration" id="id86" name="id86">14 Configuration</a><ul class="auto-toc"> -<li><a class="reference" href="#build-options" id="id87" name="id87">14.1 Build options</a></li> +<li><a class="reference" href="#error-handling" id="id86" name="id86">14 Error Handling</a><ul class="auto-toc"> +<li><a class="reference" href="#pcall-errorfunc" id="id87" name="id87">14.1 pcall errorfunc</a></li> +<li><a class="reference" href="#file-and-line-numbers" id="id88" name="id88">14.2 file and line numbers</a></li> +<li><a class="reference" href="#lua-panic" id="id89" name="id89">14.3 lua panic</a></li> +<li><a class="reference" href="#msvc-exceptions" id="id90" name="id90">14.4 msvc exceptions</a></li> +<li><a class="reference" href="#error-messages" id="id91" name="id91">14.5 Error messages</a></li> </ul> </li> -<li><a class="reference" href="#implementation-notes" id="id88" name="id88">15 Implementation notes</a></li> -<li><a class="reference" href="#error-messages" id="id89" name="id89">16 Error messages</a></li> -<li><a class="reference" href="#faq" id="id90" name="id90">17 FAQ</a></li> -<li><a class="reference" href="#known-issues" id="id91" name="id91">18 Known issues</a></li> -<li><a class="reference" href="#acknowledgments" id="id92" name="id92">19 Acknowledgments</a></li> +<li><a class="reference" href="#build-options" id="id92" name="id92">15 Build options</a></li> +<li><a class="reference" href="#implementation-notes" id="id93" name="id93">16 Implementation notes</a></li> +<li><a class="reference" href="#faq" id="id94" name="id94">17 FAQ</a></li> +<li><a class="reference" href="#known-issues" id="id95" name="id95">18 Known issues</a></li> +<li><a class="reference" href="#acknowledgments" id="id96" name="id96">19 Acknowledgments</a></li> </ul> </div> <div class="section" id="introduction"> @@ -216,7 +220,7 @@ <p>When building luabind you have several options that may streamline the library to better suit your needs. It is extremely important that your application has the same settings as the library was built with. The available options are -found in the <a class="reference" href="#configuration">Configuration</a> section.</p> +found in the <a class="reference" href="#build-options">Build options</a> section.</p> <p>If you want to change the settings to differ from the default, it's recommended that you define the settings on the command line of all your files (in the project settings in visual studio).</p> @@ -479,7 +483,7 @@ int ret = call_function(L, "fun", boost::ref(val)); </pre> <p>If you want to use a custom error handler for the function call, see -<tt class="docutils literal"><span class="pre">set_pcall_callback</span></tt> under <a class="reference" href="#configuration">Configuration</a>.</p> +<tt class="docutils literal"><span class="pre">set_pcall_callback</span></tt> under <a class="reference" href="#pcall-errorfunc">pcall errorfunc</a>.</p> </div> <div class="section" id="using-lua-threads"> <h2><a name="using-lua-threads">7.4 Using Lua threads</a></h2> @@ -1078,15 +1082,13 @@ conversion from C++ value to Lua. If your <tt class="docutils literal"><span class="pre">luabind::object</span></tt> is a table you can access its members through the operator[] or the <a class="reference" href="#iterators">Iterators</a>. The value returned from the operator[] is a proxy object that can be used both for -reading and writing values into the table (using operator=). Note that it is -impossible to know if a Lua value is indexable or not (lua_gettable doesn't -fail, it succeeds or crashes). This means that if you're trying to index -something that cannot be indexed, you're on your own. Lua will call its -<tt class="docutils literal"><span class="pre">panic()</span></tt> function. You can define your own panic function using -<tt class="docutils literal"><span class="pre">lua_atpanic</span></tt>. Unless you want to terminate the application, the best way -to continue from the panic function is to make sure lua is compiled as C++ -and throw an exception from the panic function. There are also free functions -that can be used for indexing the table, see <a class="reference" href="#related-functions">Related functions</a>.</p> +reading and writing values into the table (using operator=).</p> +<p>Note that it is impossible to know if a Lua value is indexable or not +(<tt class="docutils literal"><span class="pre">lua_gettable</span></tt> doesn't fail, it succeeds or crashes). This means that if +you're trying to index something that cannot be indexed, you're on your own. +Lua will call its <tt class="docutils literal"><span class="pre">panic()</span></tt> function. See <a class="reference" href="#lua-panic">lua panic</a>.</p> +<p>There are also free functions that can be used for indexing the table, see +<a class="reference" href="#related-functions">Related functions</a>.</p> <p>The constructor that takes a <tt class="docutils literal"><span class="pre">from_stack</span></tt> object is used when you want to initialize the object with a value from the lua stack. The <tt class="docutils literal"><span class="pre">from_stack</span></tt> type has the following constructor:</p> @@ -1248,7 +1250,7 @@ <p>The <tt class="docutils literal"><span class="pre">object_cast</span></tt> function casts the value of an object to a C++ value. You can supply a policy to handle the conversion from lua to C++. If the cast cannot be made a <tt class="docutils literal"><span class="pre">cast_failed</span></tt> exception will be thrown. If you have -defined LUABIND_NO_ERROR_CHECKING (see configuration) no checking will occur, +defined LUABIND_NO_ERROR_CHECKING (see <a class="reference" href="#build-options">Build options</a>) no checking will occur, and if the cast is invalid the application may very well crash. The nothrow versions will return an uninitialized <tt class="docutils literal"><span class="pre">boost::optional<T></span></tt> object, to indicate that the cast could not be performed.</p> @@ -1662,16 +1664,16 @@ <div class="contents topic" id="policies-currently-implemented"> <p class="topic-title first"><a name="policies-currently-implemented">Policies currently implemented</a></p> <ul class="auto-toc simple"> -<li><a class="reference" href="#adopt" id="id93" name="id93">12.1 adopt</a></li> -<li><a class="reference" href="#dependency" id="id94" name="id94">12.2 dependency</a></li> -<li><a class="reference" href="#out-value" id="id95" name="id95">12.3 out_value</a></li> -<li><a class="reference" href="#pure-out-value" id="id96" name="id96">12.4 pure_out_value</a></li> -<li><a class="reference" href="#return-reference-to" id="id97" name="id97">12.5 return_reference_to</a></li> -<li><a class="reference" href="#copy" id="id98" name="id98">12.6 copy</a></li> -<li><a class="reference" href="#discard-result" id="id99" name="id99">12.7 discard_result</a></li> -<li><a class="reference" href="#return-stl-iterator" id="id100" name="id100">12.8 return_stl_iterator</a></li> -<li><a class="reference" href="#raw" id="id101" name="id101">12.9 raw</a></li> -<li><a class="reference" href="#yield" id="id102" name="id102">12.10 yield</a></li> +<li><a class="reference" href="#adopt" id="id97" name="id97">12.1 adopt</a></li> +<li><a class="reference" href="#dependency" id="id98" name="id98">12.2 dependency</a></li> +<li><a class="reference" href="#out-value" id="id99" name="id99">12.3 out_value</a></li> +<li><a class="reference" href="#pure-out-value" id="id100" name="id100">12.4 pure_out_value</a></li> +<li><a class="reference" href="#return-reference-to" id="id101" name="id101">12.5 return_reference_to</a></li> +<li><a class="reference" href="#copy" id="id102" name="id102">12.6 copy</a></li> +<li><a class="reference" href="#discard-result" id="id103" name="id103">12.7 discard_result</a></li> +<li><a class="reference" href="#return-stl-iterator" id="id104" name="id104">12.8 return_stl_iterator</a></li> +<li><a class="reference" href="#raw" id="id105" name="id105">12.9 raw</a></li> +<li><a class="reference" href="#yield" id="id106" name="id106">12.10 yield</a></li> </ul> </div> <div class="section" id="adopt"> @@ -2630,8 +2632,10 @@ } </pre> </div> -<div class="section" id="configuration"> -<h1><a name="configuration">14 Configuration</a></h1> +<div class="section" id="error-handling"> +<h1><a name="error-handling">14 Error Handling</a></h1> +<div class="section" id="pcall-errorfunc"> +<h2><a name="pcall-errorfunc">14.1 pcall errorfunc</a></h2> <p>As mentioned in the <a class="reference" href="http://www.lua.org/manual/5.0/manual.html">Lua documentation</a>, it is possible to pass an error handler function to <tt class="docutils literal"><span class="pre">lua_pcall()</span></tt>. Luabind makes use of <tt class="docutils literal"><span class="pre">lua_pcall()</span></tt> internally when calling member functions and free functions. @@ -2657,8 +2661,133 @@ std::cout << error_msg << std::endl; } </pre> +</div> +<div class="section" id="file-and-line-numbers"> +<h2><a name="file-and-line-numbers">14.2 file and line numbers</a></h2> +<p>If you want to add file name and line number to the error messages generated +by luabind you can define your own <a class="reference" href="#pcall-errorfunc">pcall errorfunc</a>. You may want to modify +this callback to better suit your needs, but the basic functionality could be +implemented like this:</p> +<pre class="literal-block"> +int add_file_and_line(lua_State* L) +{ + lua_Debug d; + lua_getstack(L, 1, &d); + lua_getinfo(L, "Sln", &d); + std::string err = lua_tostring(L, -1); + lua_pop(L, 1); + std::stringstream msg; + msg << d.short_src << ":" << d.currentline; + + if (d.name != 0) + { + msg << "(" << d.namewhat << " " << d.name << ")"; + } + msg << " " << err; + lua_pushstring(L, msg.str().c_str()); + return 1; +} +</pre> +<p>For more information about what kind of information you can add to the error +message, see <a class="reference" href="http://www.lua.org/manual/5.0/manual.html#4">the debug section of the lua manual</a>.</p> +<p>Note that the callback set by <tt class="docutils literal"><span class="pre">set_pcall_callback()</span></tt> will only be used when +luabind executes lua code. Anytime when you call <tt class="docutils literal"><span class="pre">lua_pcall</span></tt> yourself, you +have to supply your function if you want error messages translated.</p> +</div> +<div class="section" id="lua-panic"> +<h2><a name="lua-panic">14.3 lua panic</a></h2> +<p>When lua encounters a fatal error caused by a bug from the C/C++ side, it will +call its internal panic function. This can happen, for example, when you call +<tt class="docutils literal"><span class="pre">lua_gettable</span></tt> on a value that isn't a table. If you do the same thing from +within lua, it will of course just fail with an error message.</p> +<p>The default panic function will <tt class="docutils literal"><span class="pre">exit()</span></tt> the application. If you want to +handle this case without terminating your application, you can define your own +panic function using <tt class="docutils literal"><span class="pre">lua_atpanic</span></tt>. The best way to continue from the panic +function is to make sure lua is compiled as C++ and throw an exception from +the panic function. Throwing an exception instead of using <tt class="docutils literal"><span class="pre">setjmp</span></tt> and +<tt class="docutils literal"><span class="pre">longjmp</span></tt> will make sure the stack is correctly unwound.</p> +<p>For more information, see the <a class="reference" href="http://www.lua.org/manual/5.0/manual.html#3.19">lua manual section 3.19</a>.</p> +</div> +<div class="section" id="msvc-exceptions"> +<h2><a name="msvc-exceptions">14.4 msvc exceptions</a></h2> +<p>Since lua is generally built as a C library, any callbacks called from lua +cannot under any circumstance throw an exception. Because of that, luabind has +to catch all exceptions and translate them into proper lua errors (by calling +<tt class="docutils literal"><span class="pre">lua_error()</span></tt>). This means we have a <tt class="docutils literal"><span class="pre">catch(...)</span> <span class="pre">{}</span></tt> in there.</p> +<p>In VisualStudio, <tt class="docutils literal"><span class="pre">catch</span> <span class="pre">(...)</span></tt> will not only catch C++ exceptions, it will +also catch hardware exceptions like Segmentation fault. This means that if +your function, that gets called from luabind, makes an invalid memory +adressing, you won't notice it. All that will happen is that lua will return +an error message saying "unknown exception".</p> +<p>To remedy this, you can create your own <em>exception translator</em>:</p> +<pre class="literal-block"> +void straight_to_debugger(unsigned int, _EXCEPTION_POINTERS*) +{ throw; } + +#ifdef _MSC_VER + ::_set_se_translator(straight_to_debugger); +#endif +</pre> +<p>This will make hardware exceptions, like segmentation fault, to actually get +caught by the debugger.</p> +</div> +<div class="section" id="error-messages"> +<h2><a name="error-messages">14.5 Error messages</a></h2> +<p>These are the error messages that can be generated by luabind, with a more +in-depth explanation.</p> +<ul> +<li><pre class="first literal-block"> +the attribute '<em>class-name.attribute-name</em>' is read only +</pre> +<p>There is no data member named <em>attribute-name</em> in the class <em>class-name</em>, +or there's no setter-function registered on that property name. See the +<a class="reference" href="#properties">Properties</a> section.</p> +</li> +<li><pre class="first literal-block"> +the attribute '<em>class-name.attribute-name</em>' is of type: (<em>class-name</em>) and does not match (<em>class_name</em>) +</pre> +<p>This error is generated if you try to assign an attribute with a value +of a type that cannot be converted to the attribute's type.</p> +</li> +<li><pre class="first literal-block"> +<em>class-name()</em> threw an exception, <em>class-name:function-name()</em> threw an exception +</pre> +<p>The class' constructor or member function threw an unknown exception. +Known exceptions are const char*, std::exception. See the +<a class="reference" href="#exceptions">exceptions</a> section.</p> +</li> +<li><pre class="first literal-block"> +no overload of '<em>class-name:function-name</em>' matched the arguments (<em>parameter-types</em>) +no match for function call '<em>function-name</em>' with the parameters (<em>parameter-types</em>) +no constructor of <em>class-name</em> matched the arguments (<em>parameter-types</em>) +no operator <em>operator-name</em> matched the arguments (<em>parameter-types</em>) +</pre> +<p>No function/operator with the given name takes the parameters you gave +it. You have either misspelled the function name, or given it incorrect +parameters. This error is followed by a list of possible candidate +functions to help you figure out what parameter has the wrong type. If +the candidate list is empty there's no function at all with that name. +See the signature matching section.</p> +</li> +<li><pre class="first literal-block"> +call of overloaded '<em>class-name:function-name*(*parameter-types</em>)' is ambiguous +ambiguous match for function call '<em>function-name</em>' with the parameters (<em>parameter-types</em>) +call of overloaded constructor '<em>class-name*(*parameter-types</em>)' is ambiguous +call of overloaded operator <em>operator-name</em> (<em>parameter-types</em>) is ambiguous +</pre> +<p>This means that the function/operator you are trying to call has at least +one other overload that matches the arguments just as good as the first +overload.</p> +</li> +<li><pre class="first literal-block"> +cannot derive from C++ class '<em>class-name</em>'. It does not have a wrapped type. +</pre> +</li> +</ul> +</div> +</div> <div class="section" id="build-options"> -<h2><a name="build-options">14.1 Build options</a></h2> +<h1><a name="build-options">15 Build options</a></h1> <p>There are a number of configuration options available when building luabind. It is very important that your project has the exact same configuration options as the ones given when the library was build! The exceptions are the @@ -2707,11 +2836,11 @@ </dd> <dt>LUA_API</dt> <dd>If you want to link dynamically against Lua, you can set this define to -the import-keyword on your compiler and platform. On windows in devstudio +the import-keyword on your compiler and platform. On windows in VisualStudio this should be <tt class="docutils literal"><span class="pre">__declspec(dllimport)</span></tt> if you want to link against Lua as a dll.</dd> <dt>LUABIND_EXPORT, LUABIND_IMPORT</dt> -<dd>If you want to link against luabind as a dll (in devstudio), you can +<dd>If you want to link against luabind as a dll (in VisualStudio), you can define <tt class="docutils literal"><span class="pre">LUABIND_EXPORT</span></tt> to <tt class="docutils literal"><span class="pre">__declspec(dllexport)</span></tt> and <tt class="docutils literal"><span class="pre">LUABIND_IMPORT</span></tt> to <tt class="docutils literal"><span class="pre">__declspec(dllimport)</span></tt> or <tt class="docutils literal"><span class="pre">__attribute__</span> <span class="pre">((visibility("default")))</span></tt> on GCC 4. @@ -2761,9 +2890,8 @@ build.</dd> </dl> </div> -</div> <div class="section" id="implementation-notes"> -<h1><a name="implementation-notes">15 Implementation notes</a></h1> +<h1><a name="implementation-notes">16 Implementation notes</a></h1> <p>The classes and objects are implemented as user data in Lua. To make sure that the user data really is the internal structure it is supposed to be, we tag their metatables. A user data who's metatable contains a boolean member named @@ -2791,58 +2919,6 @@ <p>Inside the luabind namespace, there's another namespace called detail. This namespace contains non-public classes and are not supposed to be used directly.</p> </div> -<div class="section" id="error-messages"> -<h1><a name="error-messages">16 Error messages</a></h1> -<ul> -<li><pre class="first literal-block"> -the attribute '<em>class-name.attribute-name</em>' is read only -</pre> -<p>There is no data member named <em>attribute-name</em> in the class <em>class-name</em>, -or there's no setter-function registered on that property name. See the -<a class="reference" href="#properties">Properties</a> section.</p> -</li> -<li><pre class="first literal-block"> -the attribute '<em>class-name.attribute-name</em>' is of type: (<em>class-name</em>) and does not match (<em>class_name</em>) -</pre> -<p>This error is generated if you try to assign an attribute with a value -of a type that cannot be converted to the attribute's type.</p> -</li> -<li><pre class="first literal-block"> -<em>class-name()</em> threw an exception, <em>class-name:function-name()</em> threw an exception -</pre> -<p>The class' constructor or member function threw an unknown exception. -Known exceptions are const char*, std::exception. See the -<a class="reference" href="#exceptions">exceptions</a> section.</p> -</li> -<li><pre class="first literal-block"> -no overload of '<em>class-name:function-name</em>' matched the arguments (<em>parameter-types</em>) -no match for function call '<em>function-name</em>' with the parameters (<em>parameter-types</em>) -no constructor of <em>class-name</em> matched the arguments (<em>parameter-types</em>) -no operator <em>operator-name</em> matched the arguments (<em>parameter-types</em>) -</pre> -<p>No function/operator with the given name takes the parameters you gave -it. You have either misspelled the function name, or given it incorrect -parameters. This error is followed by a list of possible candidate -functions to help you figure out what parameter has the wrong type. If -the candidate list is empty there's no function at all with that name. -See the signature matching section.</p> -</li> -<li><pre class="first literal-block"> -call of overloaded '<em>class-name:function-name*(*parameter-types</em>)' is ambiguous -ambiguous match for function call '<em>function-name</em>' with the parameters (<em>parameter-types</em>) -call of overloaded constructor '<em>class-name*(*parameter-types</em>)' is ambiguous -call of overloaded operator <em>operator-name</em> (<em>parameter-types</em>) is ambiguous -</pre> -<p>This means that the function/operator you are trying to call has at least -one other overload that matches the arguments just as good as the first -overload.</p> -</li> -<li><pre class="first literal-block"> -cannot derive from C++ class '<em>class-name</em>'. It does not have a wrapped type. -</pre> -</li> -</ul> -</div> <div class="section" id="faq"> <h1><a name="faq">17 FAQ</a></h1> <dl class="docutils"> @@ -2860,9 +2936,6 @@ internal structure overflow. You should try to split that compilation unit up in smaller ones. See <a class="reference" href="#splitting-up-the-registration">Splitting up the registration</a> and <a class="reference" href="#splitting-class-registrations">Splitting class registrations</a>.</dd> -</dl> -<!-- the three entries above were removed, why? --> -<dl class="docutils"> <dt>What's wrong with precompiled headers in VC?</dt> <dd>Visual Studio doesn't like anonymous namespace's in its precompiled headers. If you encounter this problem you can disable precompiled @@ -2944,8 +3017,6 @@ <li>luabind does not support class hierarchies with virtual inheritance. Casts are done with static pointer offsets.</li> </ul> -<!-- remove? - Visual studio have problems selecting the correct overload of std::swap() -for luabind::object. --> </div> <div class="section" id="acknowledgments"> <h1><a name="acknowledgments">19 Acknowledgments</a></h1> Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26.2.4 retrieving revision 1.26.2.5 diff -u -d -r1.26.2.4 -r1.26.2.5 --- docs.rst 10 Jan 2006 00:36:49 -0000 1.26.2.4 +++ docs.rst 11 Jan 2006 00:53:27 -0000 1.26.2.5 @@ -148,7 +148,7 @@ When building luabind you have several options that may streamline the library to better suit your needs. It is extremely important that your application has the same settings as the library was built with. The available options are -found in the `Configuration`_ section. +found in the `Build options`_ section. If you want to change the settings to differ from the default, it's recommended that you define the settings on the command line of all your files (in the @@ -441,7 +441,7 @@ If you want to use a custom error handler for the function call, see -``set_pcall_callback`` under Configuration_. +``set_pcall_callback`` under `pcall errorfunc`_. Using Lua threads ----------------- @@ -1060,15 +1060,15 @@ conversion from C++ value to Lua. If your ``luabind::object`` is a table you can access its members through the operator[] or the Iterators_. The value returned from the operator[] is a proxy object that can be used both for -reading and writing values into the table (using operator=). Note that it is -impossible to know if a Lua value is indexable or not (lua_gettable doesn't -fail, it succeeds or crashes). This means that if you're trying to index -something that cannot be indexed, you're on your own. Lua will call its -``panic()`` function. You can define your own panic function using -``lua_atpanic``. Unless you want to terminate the application, the best way -to continue from the panic function is to make sure lua is compiled as C++ -and throw an exception from the panic function. There are also free functions -that can be used for indexing the table, see `Related functions`_. +reading and writing values into the table (using operator=). + +Note that it is impossible to know if a Lua value is indexable or not +(``lua_gettable`` doesn't fail, it succeeds or crashes). This means that if +you're trying to index something that cannot be indexed, you're on your own. +Lua will call its ``panic()`` function. See `lua panic`_. + +There are also free functions that can be used for indexing the table, see +`Related functions`_. The constructor that takes a ``from_stack`` object is used when you want to initialize the object with a value from the lua stack. The ``from_stack`` @@ -1257,7 +1257,7 @@ The ``object_cast`` function casts the value of an object to a C++ value. You can supply a policy to handle the conversion from lua to C++. If the cast cannot be made a ``cast_failed`` exception will be thrown. If you have -defined LUABIND_NO_ERROR_CHECKING (see configuration) no checking will occur, +defined LUABIND_NO_ERROR_CHECKING (see `Build options`_) no checking will occur, and if the cast is invalid the application may very well crash. The nothrow versions will return an uninitialized ``boost::optional<T>`` object, to indicate that the cast could not be performed. @@ -2118,8 +2118,11 @@ } -Configuration -============= +Error Handling +============== + +pcall errorfunc +--------------- As mentioned in the `Lua documentation`_, it is possible to pass an error handler function to ``lua_pcall()``. Luabind makes use of @@ -2152,9 +2155,149 @@ .. _`pcall section of the lua manual`: http://www.lua.org/manual/5.0/manual.html#3.15 .. _`the debug section of the lua manual`: http://www.lua.org/manual/5.0/manual.html#4 +file and line numbers +--------------------- + +If you want to add file name and line number to the error messages generated +by luabind you can define your own `pcall errorfunc`_. You may want to modify +this callback to better suit your needs, but the basic functionality could be +implemented like this:: + + int add_file_and_line(lua_State* L) + { + lua_Debug d; + lua_getstack(L, 1, &d); + lua_getinfo(L, "Sln", &d); + std::string err = lua_tostring(L, -1); + lua_pop(L, 1); + std::stringstream msg; + msg << d.short_src << ":" << d.currentline; + + if (d.name != 0) + { + msg << "(" << d.namewhat << " " << d.name << ")"; + } + msg << " " << err; + lua_pushstring(L, msg.str().c_str()); + return 1; + } + +For more information about what kind of information you can add to the error +message, see `the debug section of the lua manual`_. + +Note that the callback set by ``set_pcall_callback()`` will only be used when +luabind executes lua code. Anytime when you call ``lua_pcall`` yourself, you +have to supply your function if you want error messages translated. + +lua panic +--------- + +When lua encounters a fatal error caused by a bug from the C/C++ side, it will +call its internal panic function. This can happen, for example, when you call +``lua_gettable`` on a value that isn't a table. If you do the same thing from +within lua, it will of course just fail with an error message. + +The default panic function will ``exit()`` the application. If you want to +handle this case without terminating your application, you can define your own +panic function using ``lua_atpanic``. The best way to continue from the panic +function is to make sure lua is compiled as C++ and throw an exception from +the panic function. Throwing an exception instead of using ``setjmp`` and +``longjmp`` will make sure the stack is correctly unwound. + +For more information, see the `lua manual section 3.19`_. + +.. _`lua manual section 3.19`: http://www.lua.org/manual/5.0/manual.html#3.19 + +msvc exceptions +--------------- + +Since lua is generally built as a C library, any callbacks called from lua +cannot under any circumstance throw an exception. Because of that, luabind has +to catch all exceptions and translate them into proper lua errors (by calling +``lua_error()``). This means we have a ``catch(...) {}`` in there. + +In VisualStudio, ``catch (...)`` will not only catch C++ exceptions, it will +also catch hardware exceptions like Segmentation fault. This means that if +your function, that gets called from luabind, makes an invalid memory +adressing, you won't notice it. All that will happen is that lua will return +an error message saying "unknown exception". + +To remedy this, you can create your own *exception translator*:: + + void straight_to_debugger(unsigned int, _EXCEPTION_POINTERS*) + { throw; } + + #ifdef _MSC_VER + ::_set_se_translator(straight_to_debugger); + #endif + +This will make hardware exceptions, like segmentation fault, to actually get +caught by the debugger. + + +Error messages +-------------- + +These are the error messages that can be generated by luabind, with a more +in-depth explanation. + +- .. parsed-literal:: + + the attribute '*class-name.attribute-name*' is read only + + There is no data member named *attribute-name* in the class *class-name*, + or there's no setter-function registered on that property name. See the + Properties_ section. + +- .. parsed-literal:: + + the attribute '*class-name.attribute-name*' is of type: (*class-name*) and does not match (*class_name*) + + This error is generated if you try to assign an attribute with a value + of a type that cannot be converted to the attribute's type. + + +- .. parsed-literal:: + + *class-name()* threw an exception, *class-name:function-name()* threw an exception + + The class' constructor or member function threw an unknown exception. + Known exceptions are const char*, std::exception. See the + `exceptions`_ section. + +- .. parsed-literal:: + + no overload of '*class-name:function-name*' matched the arguments (*parameter-types*) + no match for function call '*function-name*' with the parameters (*parameter-types*) + no constructor of *class-name* matched the arguments (*parameter-types*) + no operator *operator-name* matched the arguments (*parameter-types*) + + No function/operator with the given name takes the parameters you gave + it. You have either misspelled the function name, or given it incorrect + parameters. This error is followed by a list of possible candidate + functions to help you figure out what parameter has the wrong type. If + the candidate list is empty there's no function at all with that name. + See the signature matching section. + +- .. parsed-literal:: + + call of overloaded '*class-name:function-name*(*parameter-types*)' is ambiguous + ambiguous match for function call '*function-name*' with the parameters (*parameter-types*) + call of overloaded constructor '*class-name*(*parameter-types*)' is ambiguous + call of overloaded operator *operator-name* (*parameter-types*) is ambiguous + + This means that the function/operator you are trying to call has at least + one other overload that matches the arguments just as good as the first + overload. + +- .. parsed-literal:: + + cannot derive from C++ class '*class-name*'. It does not have a wrapped type. + + Build options -------------- +============= There are a number of configuration options available when building luabind. It is very important that your project has the exact same configuration @@ -2210,12 +2353,12 @@ LUA_API If you want to link dynamically against Lua, you can set this define to - the import-keyword on your compiler and platform. On windows in devstudio + the import-keyword on your compiler and platform. On windows in VisualStudio this should be ``__declspec(dllimport)`` if you want to link against Lua as a dll. LUABIND_EXPORT, LUABIND_IMPORT - If you want to link against luabind as a dll (in devstudio), you can + If you want to link against luabind as a dll (in VisualStudio), you can define ``LUABIND_EXPORT`` to ``__declspec(dllexport)`` and ``LUABIND_IMPORT`` to ``__declspec(dllimport)`` or ``__attribute__ ((visibility("default")))`` on GCC 4. @@ -2303,63 +2446,6 @@ namespace contains non-public classes and are not supposed to be used directly. -Error messages -============== - -- .. parsed-literal:: - - the attribute '*class-name.attribute-name*' is read only - - There is no data member named *attribute-name* in the class *class-name*, - or there's no setter-function registered on that property name. See the - Properties_ section. - -- .. parsed-literal:: - - the attribute '*class-name.attribute-name*' is of type: (*class-name*) and does not match (*class_name*) - - This error is generated if you try to assign an attribute with a value - of a type that cannot be converted to the attribute's type. - - -- .. parsed-literal:: - - *class-name()* threw an exception, *class-name:function-name()* threw an exception - - The class' constructor or member function threw an unknown exception. - Known exceptions are const char*, std::exception. See the - `exceptions`_ section. - -- .. parsed-literal:: - - no overload of '*class-name:function-name*' matched the arguments (*parameter-types*) - no match for function call '*function-name*' with the parameters (*parameter-types*) - no constructor of *class-name* matched the arguments (*parameter-types*) - no operator *operator-name* matched the arguments (*parameter-types*) - - No function/operator with the given name takes the parameters you gave - it. You have either misspelled the function name, or given it incorrect - parameters. This error is followed by a list of possible candidate - functions to help you figure out what parameter has the wrong type. If - the candidate list is empty there's no function at all with that name. - See the signature matching section. - -- .. parsed-literal:: - - call of overloaded '*class-name:function-name*(*parameter-types*)' is ambiguous - ambiguous match for function call '*function-name*' with the parameters (*parameter-types*) - call of overloaded constructor '*class-name*(*parameter-types*)' is ambiguous - call of overloaded operator *operator-name* (*parameter-types*) is ambiguous - - This means that the function/operator you are trying to call has at least - one other overload that matches the arguments just as good as the first - overload. - -- .. parsed-literal:: - - cannot derive from C++ class '*class-name*'. It does not have a wrapped type. - - FAQ === @@ -2380,8 +2466,6 @@ unit up in smaller ones. See `Splitting up the registration`_ and `Splitting class registrations`_. -.. the three entries above were removed, why? - What's wrong with precompiled headers in VC? Visual Studio doesn't like anonymous namespace's in its precompiled headers. If you encounter this problem you can disable precompiled @@ -2470,9 +2554,6 @@ - luabind does not support class hierarchies with virtual inheritance. Casts are done with static pointer offsets. -.. remove? - Visual studio have problems selecting the correct overload of std::swap() - for luabind::object. - Acknowledgments =============== |
From: Arvid N. <ar...@us...> - 2006-01-10 00:36:59
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30994/doc Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: fixed typo and added references for retrieving debug info from lua Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54.2.3 retrieving revision 1.54.2.4 diff -u -d -r1.54.2.3 -r1.54.2.4 --- docs.html 10 Jan 2006 00:31:39 -0000 1.54.2.3 +++ docs.html 10 Jan 2006 00:36:47 -0000 1.54.2.4 @@ -7,7 +7,7 @@ <title>luabind</title> <meta name="author" content="Daniel Wallin, Arvid Norberg" /> <meta name="copyright" content="Copyright Daniel Wallin, Arvid Norberg 2003." /> -<meta name="date" content="2006-01-09" /> +<meta name="date" content="2006-01-10" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> @@ -22,9 +22,9 @@ <tr><th class="docinfo-name">Copyright:</th> <td>Copyright Daniel Wallin, Arvid Norberg 2003.</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2006-01-09</td></tr> +<td>2006-01-10</td></tr> <tr><th class="docinfo-name">Revision:</th> -<td>1.26.2.2</td></tr> +<td>1.26.2.3</td></tr> <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -2645,13 +2645,17 @@ returned by a failed protected call. For more information on how to use the pcall_callback function, see <tt class="docutils literal"><span class="pre">errfunc</span></tt> under the <a class="reference" href="http://www.lua.org/manual/5.0/manual.html#3.15">pcall section of the lua manual</a>.</p> +<p>For more information on how to retrieve debugging information from lua, see +<a class="reference" href="http://www.lua.org/manual/5.0/manual.html#4">the debug section of the lua manual</a>.</p> <p>The message returned by the <tt class="docutils literal"><span class="pre">pcall_callback</span></tt> is accessable as the top lua value on the stack. For example, if you would like to access it as a luabind object, you could do like this:</p> <pre class="literal-block"> catch(error& e) -object error_msg(from_stack(e.state(), -1)); -std::cout << error_msg << std::endl; +{ + object error_msg(from_stack(e.state(), -1)); + std::cout << error_msg << std::endl; +} </pre> <div class="section" id="build-options"> <h2><a name="build-options">14.1 Build options</a></h2> Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26.2.3 retrieving revision 1.26.2.4 diff -u -d -r1.26.2.3 -r1.26.2.4 --- docs.rst 10 Jan 2006 00:31:40 -0000 1.26.2.3 +++ docs.rst 10 Jan 2006 00:36:49 -0000 1.26.2.4 @@ -2135,16 +2135,22 @@ pcall_callback function, see ``errfunc`` under the `pcall section of the lua manual`_. +For more information on how to retrieve debugging information from lua, see +`the debug section of the lua manual`_. + The message returned by the ``pcall_callback`` is accessable as the top lua value on the stack. For example, if you would like to access it as a luabind object, you could do like this:: catch(error& e) - object error_msg(from_stack(e.state(), -1)); - std::cout << error_msg << std::endl; + { + object error_msg(from_stack(e.state(), -1)); + std::cout << error_msg << std::endl; + } .. _Lua documentation: http://www.lua.org/manual/5.0/manual.html .. _`pcall section of the lua manual`: http://www.lua.org/manual/5.0/manual.html#3.15 +.. _`the debug section of the lua manual`: http://www.lua.org/manual/5.0/manual.html#4 Build options |
From: Arvid N. <ar...@us...> - 2006-01-10 00:31:50
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30150/doc Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: updated docs about pcall_callback Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54.2.2 retrieving revision 1.54.2.3 diff -u -d -r1.54.2.2 -r1.54.2.3 --- docs.html 9 Jan 2006 16:46:54 -0000 1.54.2.2 +++ docs.html 10 Jan 2006 00:31:39 -0000 1.54.2.3 @@ -7,7 +7,7 @@ <title>luabind</title> <meta name="author" content="Daniel Wallin, Arvid Norberg" /> <meta name="copyright" content="Copyright Daniel Wallin, Arvid Norberg 2003." /> -<meta name="date" content="2006-01-01" /> +<meta name="date" content="2006-01-09" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> @@ -22,9 +22,9 @@ <tr><th class="docinfo-name">Copyright:</th> <td>Copyright Daniel Wallin, Arvid Norberg 2003.</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2006-01-01</td></tr> +<td>2006-01-09</td></tr> <tr><th class="docinfo-name">Revision:</th> -<td>1.26.2.1</td></tr> +<td>1.26.2.2</td></tr> <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -2638,11 +2638,21 @@ It is possible to set the error handler function that Luabind will use globally:</p> <pre class="literal-block"> -typedef void(*pcall_callback_fun)(lua_State*); +typedef int(*pcall_callback_fun)(lua_State*); void set_pcall_callback(pcall_callback_fun fn); </pre> <p>This is primarily useful for adding more information to the error message -returned by a failed protected call.</p> +returned by a failed protected call. For more information on how to use the +pcall_callback function, see <tt class="docutils literal"><span class="pre">errfunc</span></tt> under the +<a class="reference" href="http://www.lua.org/manual/5.0/manual.html#3.15">pcall section of the lua manual</a>.</p> +<p>The message returned by the <tt class="docutils literal"><span class="pre">pcall_callback</span></tt> is accessable as the top lua +value on the stack. For example, if you would like to access it as a luabind +object, you could do like this:</p> +<pre class="literal-block"> +catch(error& e) +object error_msg(from_stack(e.state(), -1)); +std::cout << error_msg << std::endl; +</pre> <div class="section" id="build-options"> <h2><a name="build-options">14.1 Build options</a></h2> <p>There are a number of configuration options available when building luabind. Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26.2.2 retrieving revision 1.26.2.3 diff -u -d -r1.26.2.2 -r1.26.2.3 --- docs.rst 9 Jan 2006 16:46:54 -0000 1.26.2.2 +++ docs.rst 10 Jan 2006 00:31:40 -0000 1.26.2.3 @@ -2127,13 +2127,25 @@ It is possible to set the error handler function that Luabind will use globally:: - typedef void(*pcall_callback_fun)(lua_State*); + typedef int(*pcall_callback_fun)(lua_State*); void set_pcall_callback(pcall_callback_fun fn); This is primarily useful for adding more information to the error message -returned by a failed protected call. +returned by a failed protected call. For more information on how to use the +pcall_callback function, see ``errfunc`` under the +`pcall section of the lua manual`_. + +The message returned by the ``pcall_callback`` is accessable as the top lua +value on the stack. For example, if you would like to access it as a luabind +object, you could do like this:: + + catch(error& e) + object error_msg(from_stack(e.state(), -1)); + std::cout << error_msg << std::endl; .. _Lua documentation: http://www.lua.org/manual/5.0/manual.html +.. _`pcall section of the lua manual`: http://www.lua.org/manual/5.0/manual.html#3.15 + Build options ------------- |
From: Arvid N. <ar...@us...> - 2006-01-09 16:47:03
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6784/doc Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: changed lua_setpanicf to lua_atpanic Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54.2.1 retrieving revision 1.54.2.2 diff -u -d -r1.54.2.1 -r1.54.2.2 --- docs.html 1 Jan 2006 16:55:56 -0000 1.54.2.1 +++ docs.html 9 Jan 2006 16:46:54 -0000 1.54.2.2 @@ -3,11 +3,11 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta name="generator" content="Docutils 0.3.8: http://docutils.sourceforge.net/" /> +<meta name="generator" content="Docutils 0.3.9: http://docutils.sourceforge.net/" /> <title>luabind</title> <meta name="author" content="Daniel Wallin, Arvid Norberg" /> <meta name="copyright" content="Copyright Daniel Wallin, Arvid Norberg 2003." /> -<meta name="date" content="2005-11-28" /> +<meta name="date" content="2006-01-01" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> @@ -22,9 +22,9 @@ <tr><th class="docinfo-name">Copyright:</th> <td>Copyright Daniel Wallin, Arvid Norberg 2003.</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2005-11-28</td></tr> +<td>2006-01-01</td></tr> <tr><th class="docinfo-name">Revision:</th> -<td>1.26</td></tr> +<td>1.26.2.1</td></tr> <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -882,8 +882,8 @@ <col width="49%" /> </colgroup> <thead valign="bottom"> -<tr><th>Source</th> -<th>Target</th> +<tr><th class="head">Source</th> +<th class="head">Target</th> </tr> </thead> <tbody valign="top"> @@ -925,8 +925,8 @@ <col width="44%" /> </colgroup> <thead valign="bottom"> -<tr><th>Source</th> -<th>Target</th> +<tr><th class="head">Source</th> +<th class="head">Target</th> </tr> </thead> <tbody valign="top"> @@ -1082,9 +1082,11 @@ impossible to know if a Lua value is indexable or not (lua_gettable doesn't fail, it succeeds or crashes). This means that if you're trying to index something that cannot be indexed, you're on your own. Lua will call its -<tt class="docutils literal"><span class="pre">panic()</span></tt> function (you can define your own panic function using -<tt class="docutils literal"><span class="pre">lua_setpanicf</span></tt>). There are also free functions that can be used for -indexing the table, see <a class="reference" href="#related-functions">Related functions</a>.</p> +<tt class="docutils literal"><span class="pre">panic()</span></tt> function. You can define your own panic function using +<tt class="docutils literal"><span class="pre">lua_atpanic</span></tt>. Unless you want to terminate the application, the best way +to continue from the panic function is to make sure lua is compiled as C++ +and throw an exception from the panic function. There are also free functions +that can be used for indexing the table, see <a class="reference" href="#related-functions">Related functions</a>.</p> <p>The constructor that takes a <tt class="docutils literal"><span class="pre">from_stack</span></tt> object is used when you want to initialize the object with a value from the lua stack. The <tt class="docutils literal"><span class="pre">from_stack</span></tt> type has the following constructor:</p> @@ -1698,8 +1700,8 @@ <col width="83%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -1753,8 +1755,8 @@ <col width="77%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -1816,8 +1818,8 @@ <col width="80%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -1880,8 +1882,8 @@ <col width="80%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -1958,8 +1960,8 @@ <col width="87%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -2028,8 +2030,8 @@ <col width="83%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> @@ -2174,8 +2176,8 @@ <col width="83%" /> </colgroup> <thead valign="bottom"> -<tr><th>Parameter</th> -<th>Purpose</th> +<tr><th class="head">Parameter</th> +<th class="head">Purpose</th> </tr> </thead> <tbody valign="top"> Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26.2.1 retrieving revision 1.26.2.2 diff -u -d -r1.26.2.1 -r1.26.2.2 --- docs.rst 1 Jan 2006 16:55:56 -0000 1.26.2.1 +++ docs.rst 9 Jan 2006 16:46:54 -0000 1.26.2.2 @@ -1064,9 +1064,11 @@ impossible to know if a Lua value is indexable or not (lua_gettable doesn't fail, it succeeds or crashes). This means that if you're trying to index something that cannot be indexed, you're on your own. Lua will call its -``panic()`` function (you can define your own panic function using -``lua_setpanicf``). There are also free functions that can be used for -indexing the table, see `Related functions`_. +``panic()`` function. You can define your own panic function using +``lua_atpanic``. Unless you want to terminate the application, the best way +to continue from the panic function is to make sure lua is compiled as C++ +and throw an exception from the panic function. There are also free functions +that can be used for indexing the table, see `Related functions`_. The constructor that takes a ``from_stack`` object is used when you want to initialize the object with a value from the lua stack. The ``from_stack`` |
From: Arvid N. <ar...@us...> - 2006-01-01 23:58:29
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22841/luabind Modified Files: Tag: luabind_rc_0_7 object.hpp Log Message: optimized operator<< for object Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.36.2.3 retrieving revision 1.36.2.4 diff -u -d -r1.36.2.3 -r1.36.2.4 --- object.hpp 1 Jan 2006 19:41:53 -0000 1.36.2.3 +++ object.hpp 1 Jan 2006 23:58:20 -0000 1.36.2.4 @@ -225,8 +225,10 @@ detail::stack_pop pop(interpreter, 1); value_wrapper_traits<ValueWrapper>::unwrap(interpreter , static_cast<ValueWrapper const&>(v)); - return os << std::string(lua_tostring(interpreter, -1) - , lua_strlen(interpreter, -1)); + char const* p = lua_tostring(interpreter, -1); + int len = lua_strlen(interpreter, -1); + std::copy(p, p + len, std::ostream_iterator<char>(os)); + return os; } #undef LUABIND_BINARY_OP_DEF |
From: Arvid N. <ar...@us...> - 2006-01-01 19:42:02
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13602/luabind/luabind Modified Files: Tag: luabind_rc_0_7 object.hpp Log Message: merged in changes to object.hpp from head and fixed the stream operator on object to be more restrictive in which types it accepts Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.36.2.2 retrieving revision 1.36.2.3 diff -u -d -r1.36.2.2 -r1.36.2.3 --- object.hpp 1 Jan 2006 16:55:56 -0000 1.36.2.2 +++ object.hpp 1 Jan 2006 19:41:53 -0000 1.36.2.3 @@ -42,6 +42,7 @@ #include <boost/python/detail/is_xxx.hpp> #include <boost/preprocessor/iteration/iterate.hpp> +#include <boost/utility/enable_if.hpp> #include <iosfwd> @@ -93,6 +94,54 @@ namespace adl { + namespace mpl = boost::mpl; + + template <class T> + class object_interface; + + namespace is_object_interface_aux + { + typedef char (&yes)[1]; + typedef char (&no)[2]; + + template <class T> + yes check(object_interface<T>*); + no check(void*); + + template <class T> + struct impl + { + BOOST_STATIC_CONSTANT(bool, value = + sizeof(is_object_interface_aux::check((T*)0)) == sizeof(yes) + ); + + typedef mpl::bool_<value> type; + }; + + } // namespace detail + + template <class T> + struct is_object_interface + : is_object_interface_aux::impl<T>::type + {}; + + template <class R, class T, class U> + struct enable_binary +# ifndef BOOST_NO_SFINAE + : boost::enable_if< + mpl::or_< + is_object_interface<T> + , is_object_interface<U> + > + , R + > + {}; +# else + { + typedef R type; + }; +# endif + template<class T, class U> int binary_interpreter(lua_State*& L, T const& lhs, U const& rhs , boost::mpl::true_, boost::mpl::true_) @@ -111,7 +160,7 @@ if (L == 0) return 1; return 0; } - + template<class T, class U> int binary_interpreter(lua_State*& L, T const& x, U const& , boost::mpl::true_, boost::mpl::false_) @@ -141,7 +190,8 @@ #define LUABIND_BINARY_OP_DEF(op, fn) \ template<class LHS, class RHS> \ - bool operator op(LHS const& lhs, RHS const& rhs) \ + typename enable_binary<bool,LHS,RHS>::type \ + operator op(LHS const& lhs, RHS const& rhs) \ { \ lua_State* L = 0; \ switch (binary_interpreter(L, lhs, rhs)) \ @@ -166,38 +216,45 @@ LUABIND_BINARY_OP_DEF(<, lua_lessthan) template<class ValueWrapper> - std::ostream& operator<<(std::ostream& os, ValueWrapper const& v) + std::ostream& operator<<(std::ostream& os + , object_interface<ValueWrapper> const& v) { using namespace luabind; - lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter(v); - value_wrapper_traits<ValueWrapper>::unwrap(interpreter, v); + lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter( + static_cast<ValueWrapper const&>(v)); detail::stack_pop pop(interpreter, 1); - return std::operator<<(os, std::string(lua_tostring(interpreter, -1) - , lua_strlen(interpreter, -1))); + value_wrapper_traits<ValueWrapper>::unwrap(interpreter + , static_cast<ValueWrapper const&>(v)); + return os << std::string(lua_tostring(interpreter, -1) + , lua_strlen(interpreter, -1)); } #undef LUABIND_BINARY_OP_DEF template<class LHS, class RHS> - bool operator>(LHS const& lhs, RHS const& rhs) + typename enable_binary<bool,LHS,RHS>::type + operator>(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs || lhs == rhs); } template<class LHS, class RHS> - bool operator<=(LHS const& lhs, RHS const& rhs) + typename enable_binary<bool,LHS,RHS>::type + operator<=(LHS const& lhs, RHS const& rhs) { return lhs < rhs || lhs == rhs; } template<class LHS, class RHS> - bool operator>=(LHS const& lhs, RHS const& rhs) + typename enable_binary<bool,LHS,RHS>::type + operator>=(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs); } template<class LHS, class RHS> - bool operator!=(LHS const& lhs, RHS const& rhs) + typename enable_binary<bool,LHS,RHS>::type + operator!=(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs); } |
From: Arvid N. <ar...@us...> - 2006-01-01 16:56:08
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3191/luabind Modified Files: Tag: luabind_rc_0_7 object.hpp Log Message: added stream operator for ValueWrappers Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.36.2.1 retrieving revision 1.36.2.2 diff -u -d -r1.36.2.1 -r1.36.2.2 --- object.hpp 30 Dec 2005 16:57:37 -0000 1.36.2.1 +++ object.hpp 1 Jan 2006 16:55:56 -0000 1.36.2.2 @@ -43,6 +43,8 @@ #include <boost/preprocessor/iteration/iterate.hpp> +#include <iosfwd> + namespace luabind { namespace detail @@ -159,10 +161,21 @@ \ return fn(L, -1, -2) != 0; \ } - + LUABIND_BINARY_OP_DEF(==, lua_equal) LUABIND_BINARY_OP_DEF(<, lua_lessthan) + template<class ValueWrapper> + std::ostream& operator<<(std::ostream& os, ValueWrapper const& v) + { + using namespace luabind; + lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter(v); + value_wrapper_traits<ValueWrapper>::unwrap(interpreter, v); + detail::stack_pop pop(interpreter, 1); + return std::operator<<(os, std::string(lua_tostring(interpreter, -1) + , lua_strlen(interpreter, -1))); + } + #undef LUABIND_BINARY_OP_DEF template<class LHS, class RHS> |
From: Arvid N. <ar...@us...> - 2006-01-01 16:56:08
|
Update of /cvsroot/luabind/luabind/luabind/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3191/doc Modified Files: Tag: luabind_rc_0_7 docs.html docs.rst Log Message: added stream operator for ValueWrappers Index: docs.html =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -u -d -r1.54 -r1.54.2.1 --- docs.html 22 Dec 2005 03:06:54 -0000 1.54 +++ docs.html 1 Jan 2006 16:55:56 -0000 1.54.2.1 @@ -1105,11 +1105,6 @@ or not. When created with its default constructor, objects are invalid. To make an object valid, you can assign it a value. If you want to invalidate an object you can simply assign it an invalid object.</p> -<!-- So what? implementation detail, leave out of docs -isn't really an implicit cast to bool, but an implicit cast -to a member pointer, since member pointers don't have any arithmetic operators -on them (which can cause hard to find errors). The functionality of the cast -operator --> <p>The <tt class="docutils literal"><span class="pre">operator</span> <span class="pre">safe_bool_type()</span></tt> is equivalent to <tt class="docutils literal"><span class="pre">is_valid()</span></tt>. This means that these snippets are equivalent:</p> <pre class="literal-block"> @@ -1164,6 +1159,13 @@ <p>If you take a <tt class="docutils literal"><span class="pre">luabind::object</span></tt> as a parameter to a function, any Lua value will match that parameter. That's why we have to make sure it's a table before we index into it.</p> +<pre class="literal-block"> +std::ostream& operator<<(std::ostream&, object const&); +</pre> +<p>There's a stream operator that makes it possible to print objects or use +<tt class="docutils literal"><span class="pre">boost::lexical_cast</span></tt> to convert it to a string. This will use lua's string +conversion function. So if you convert a C++ object with a <tt class="docutils literal"><span class="pre">tostring</span></tt> +operator, the stream operator for that type will be used.</p> <div class="section" id="iterators"> <h2><a name="iterators">9.1 Iterators</a></h2> <p>There are two kinds of iterators. The normal iterator that will use the metamethod Index: docs.rst =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -d -r1.26 -r1.26.2.1 --- docs.rst 28 Nov 2005 20:55:33 -0000 1.26 +++ docs.rst 1 Jan 2006 16:55:56 -0000 1.26.2.1 @@ -1092,12 +1092,6 @@ an object valid, you can assign it a value. If you want to invalidate an object you can simply assign it an invalid object. -.. So what? implementation detail, leave out of docs - isn't really an implicit cast to bool, but an implicit cast - to a member pointer, since member pointers don't have any arithmetic operators - on them (which can cause hard to find errors). The functionality of the cast - operator - The ``operator safe_bool_type()`` is equivalent to ``is_valid()``. This means that these snippets are equivalent:: @@ -1155,6 +1149,14 @@ will match that parameter. That's why we have to make sure it's a table before we index into it. +:: + + std::ostream& operator<<(std::ostream&, object const&); + +There's a stream operator that makes it possible to print objects or use +``boost::lexical_cast`` to convert it to a string. This will use lua's string +conversion function. So if you convert a C++ object with a ``tostring`` +operator, the stream operator for that type will be used. Iterators --------- |
From: Arvid N. <ar...@us...> - 2006-01-01 16:56:07
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3191/test Modified Files: Tag: luabind_rc_0_7 test_object.cpp Log Message: added stream operator for ValueWrappers Index: test_object.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_object.cpp,v retrieving revision 1.28.2.2 retrieving revision 1.28.2.3 diff -u -d -r1.28.2.2 -r1.28.2.3 --- test_object.cpp 30 Dec 2005 16:57:37 -0000 1.28.2.2 +++ test_object.cpp 1 Jan 2006 16:55:56 -0000 1.28.2.3 @@ -28,6 +28,8 @@ #include <luabind/error.hpp> #include <luabind/operator.hpp> +#include <boost/lexical_cast.hpp> + #include <utility> using namespace luabind; @@ -194,6 +196,11 @@ object temp_val = g["temp_val"]; TEST_CHECK(ret_val == temp_val); + g["temp"] = "test string"; + TEST_CHECK(boost::lexical_cast<std::string>(g["temp"]) == "test string"); + g["temp"] = 6; + TEST_CHECK(boost::lexical_cast<std::string>(g["temp"]) == "6"); + TEST_CHECK(object_cast<std::string>(g["glob"]) == "teststring"); TEST_CHECK(object_cast<std::string>(gettable(g, "glob")) == "teststring"); TEST_CHECK(object_cast<std::string>(rawget(g, "glob")) == "teststring"); |
From: Arvid N. <ar...@us...> - 2005-12-30 16:57:45
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23283/luabind/luabind Modified Files: Tag: luabind_rc_0_7 object.hpp Log Message: now allows comparison of uninitialized objects Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -u -d -r1.36 -r1.36.2.1 --- object.hpp 4 Dec 2005 13:56:15 -0000 1.36 +++ object.hpp 30 Dec 2005 16:57:37 -0000 1.36.2.1 @@ -91,24 +91,46 @@ namespace adl { + template<class T, class U> + int binary_interpreter(lua_State*& L, T const& lhs, U const& rhs + , boost::mpl::true_, boost::mpl::true_) + { + L = value_wrapper_traits<T>::interpreter(lhs); + lua_State* L2 = value_wrapper_traits<U>::interpreter(rhs); - template<class T, class U, class V> - lua_State* binary_interpreter(T const& x, U const&, boost::mpl::true_, V) + // you are comparing objects with different interpreters + // that's not allowed. + assert(L == L2 || L == 0 || L2 == 0); + + // if the two objects we compare have different interpreters + // then they + + if (L != L2) return -1; + if (L == 0) return 1; + return 0; + } + + template<class T, class U> + int binary_interpreter(lua_State*& L, T const& x, U const& + , boost::mpl::true_, boost::mpl::false_) { - return value_wrapper_traits<T>::interpreter(x); + L = value_wrapper_traits<T>::interpreter(x); + return 0; } template<class T, class U> - lua_State* binary_interpreter(T const&, U const& x, boost::mpl::false_, boost::mpl::true_) + int binary_interpreter(lua_State*& L, T const&, U const& x, boost::mpl::false_, boost::mpl::true_) { - return value_wrapper_traits<U>::interpreter(x); + L = value_wrapper_traits<U>::interpreter(x); + return 0; } template<class T, class U> - lua_State* binary_interpreter(T const& x, U const& y) + int binary_interpreter(lua_State*& L, T const& x, U const& y) { return binary_interpreter( - x + L + , x , y , is_value_wrapper<T>() , is_value_wrapper<U>() @@ -119,7 +141,14 @@ template<class LHS, class RHS> \ bool operator op(LHS const& lhs, RHS const& rhs) \ { \ - lua_State* L = binary_interpreter(lhs, rhs); \ + lua_State* L = 0; \ + switch (binary_interpreter(L, lhs, rhs)) \ + { \ + case 1: \ + return true; \ + case -1: \ + return false; \ + } \ \ assert(L); \ \ @@ -130,9 +159,9 @@ \ return fn(L, -1, -2) != 0; \ } - - LUABIND_BINARY_OP_DEF(==, lua_equal) - LUABIND_BINARY_OP_DEF(<, lua_lessthan) + +LUABIND_BINARY_OP_DEF(==, lua_equal) +LUABIND_BINARY_OP_DEF(<, lua_lessthan) #undef LUABIND_BINARY_OP_DEF |
From: Arvid N. <ar...@us...> - 2005-12-30 16:57:45
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23283/luabind/test Modified Files: Tag: luabind_rc_0_7 test_object.cpp Log Message: now allows comparison of uninitialized objects Index: test_object.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_object.cpp,v retrieving revision 1.28.2.1 retrieving revision 1.28.2.2 diff -u -d -r1.28.2.1 -r1.28.2.2 --- test_object.cpp 30 Dec 2005 00:04:39 -0000 1.28.2.1 +++ test_object.cpp 30 Dec 2005 16:57:37 -0000 1.28.2.2 @@ -26,6 +26,7 @@ #include <luabind/adopt_policy.hpp> #include <luabind/detail/debug.hpp> #include <luabind/error.hpp> +#include <luabind/operator.hpp> #include <utility> @@ -87,6 +88,9 @@ { luabind::object obj; luabind::object obj2; + + bool operator==(test_param const& rhs) const + { return obj == rhs.obj && obj2 == rhs.obj2; } }; COUNTER_GUARD(test_param); @@ -127,6 +131,7 @@ .def(constructor<>()) .def_readwrite("obj", &test_param::obj) .def_readonly("obj2", &test_param::obj2) + .def(const_self == const_self) ]; object uninitialized; @@ -135,7 +140,10 @@ test_param temp_object; globals(L)["temp"] = temp_object; + TEST_CHECK(object_cast<test_param>(globals(L)["temp"]) == temp_object); globals(L)["temp"] = &temp_object; + TEST_CHECK(object_cast<test_param const*>(globals(L)["temp"]) == &temp_object); + TEST_CHECK(globals(L)["temp"] == temp_object); DOSTRING(L, "t = 2\n" |
From: Arvid N. <ar...@us...> - 2005-12-30 00:04:51
|
Update of /cvsroot/luabind/luabind/luabind/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2291/luabind/test Modified Files: Tag: luabind_rc_0_7 test_object.cpp Log Message: allowes uninitialized handles to be copied, added tests to verify and to make sure by-value and by-reference assignments works on complex types Index: test_object.cpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/test/test_object.cpp,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -d -r1.28 -r1.28.2.1 --- test_object.cpp 28 Nov 2005 20:55:34 -0000 1.28 +++ test_object.cpp 30 Dec 2005 00:04:39 -0000 1.28.2.1 @@ -132,6 +132,10 @@ object uninitialized; TEST_CHECK(!uninitialized); TEST_CHECK(!uninitialized.is_valid()); + + test_param temp_object; + globals(L)["temp"] = temp_object; + globals(L)["temp"] = &temp_object; DOSTRING(L, "t = 2\n" @@ -153,6 +157,9 @@ int a = type(test_param_policies); TEST_CHECK(a == LUA_TFUNCTION); + luabind::object obj; + obj = luabind::object(); + // call the function and tell lua to adopt the pointer passed as first argument test_param_policies(5, new test_param())[adopt(_2)]; |
From: Arvid N. <ar...@us...> - 2005-12-30 00:04:51
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2291/luabind/luabind Modified Files: Tag: luabind_rc_0_7 handle.hpp Log Message: allowes uninitialized handles to be copied, added tests to verify and to make sure by-value and by-reference assignments works on complex types Index: handle.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/handle.hpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- handle.hpp 28 Nov 2005 20:55:34 -0000 1.2 +++ handle.hpp 30 Dec 2005 00:04:39 -0000 1.2.2.1 @@ -62,6 +62,7 @@ : m_interpreter(other.m_interpreter) , m_index(LUA_NOREF) { + if (m_interpreter == 0) return; detail::getref(m_interpreter, other.m_index); m_index = detail::ref(m_interpreter); } |