Update of /cvsroot/luabind/luabind/luabind/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15879/luabind/src
Modified Files:
Jamfile class_info.cpp class_rep.cpp find_best_match.cpp
makefile
Added Files:
overload_rep.cpp
Removed Files:
object.cpp
Log Message:
merged in changes from beta7-devel2 (tag: beta7-devel2-merge)
Index: Jamfile
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/src/Jamfile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Jamfile 7 Aug 2004 13:37:11 -0000 1.6
+++ Jamfile 28 Nov 2005 20:55:34 -0000 1.7
@@ -14,11 +14,11 @@
open.cpp
create_class.cpp
stack_content_by_name.cpp
- object.cpp
object_rep.cpp
class_info.cpp
ref.cpp
class_registry.cpp
+ overload_rep.cpp
link_compatibility.cpp
: <define>LUABIND_BUILDING
;
Index: makefile
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/src/makefile,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- makefile 7 Aug 2004 13:37:11 -0000 1.17
+++ makefile 28 Nov 2005 20:55:34 -0000 1.18
@@ -14,12 +14,12 @@
open.cpp \
create_class.cpp \
stack_content_by_name.cpp \
- object.cpp \
object_rep.cpp \
class_info.cpp \
class_registry.cpp \
link_compatibility.cpp \
weak_ref.cpp \
+ overload_rep.cpp \
link_compatibility.cpp
OBJECTS = $(SOURCES:.cpp=.o)
Index: class_info.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/src/class_info.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- class_info.cpp 7 Aug 2004 13:37:11 -0000 1.4
+++ class_info.cpp 28 Nov 2005 20:55:34 -0000 1.5
@@ -29,18 +29,22 @@
{
class_info get_class_info(const object& o)
{
- lua_State* L = o.lua_state();
+ lua_State* L = o.interpreter();
- class_info result(L);
+ class_info result;
- o.pushvalue();
+ o.push(L);
detail::object_rep* obj = static_cast<detail::object_rep*>(lua_touserdata(L, -1));
lua_pop(L, 1);
result.name = obj->crep()->name();
obj->crep()->get_table(L);
- result.methods.set();
+ object methods(from_stack(L, -1));
+
+ methods.swap(result.methods);
+ lua_pop(L, 1);
+
result.attributes = newtable(L);
typedef detail::class_rep::property_map map_type;
--- NEW FILE: overload_rep.cpp ---
// Copyright (c) 2005 Daniel Wallin and Arvid Norberg
// 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
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#include <luabind/detail/overload_rep.hpp>
namespace luabind { namespace detail
{
int overload_rep::call(lua_State* L, bool force_static_call) const
{
if (force_static_call)
return call_fun_static(L);
else
return call_fun(L);
}
}} // namespace luabind::detail
Index: class_rep.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/src/class_rep.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- class_rep.cpp 10 Aug 2004 06:54:13 -0000 1.49
+++ class_rep.cpp 28 Nov 2005 20:55:34 -0000 1.50
@@ -101,10 +101,10 @@
assert(m_holder_alignment >= 1 && "internal error");
lua_newtable(L);
- m_table_ref.set(L);
-
+ handle(L, -1).swap(m_table);
lua_newtable(L);
- m_default_table_ref.set(L);
+ handle(L, -1).swap(m_default_table);
+ lua_pop(L, 2);
class_registry* r = class_registry::get_registry(L);
assert((r->cpp_class() != LUA_NOREF) && "you must call luabind::open()");
@@ -139,10 +139,10 @@
, m_operator_cache(0)
{
lua_newtable(L);
- m_table_ref.set(L);
-
+ handle(L, -1).swap(m_table);
lua_newtable(L);
- m_default_table_ref.set(L);
+ handle(L, -1).swap(m_default_table);
+ lua_pop(L, 2);
class_registry* r = class_registry::get_registry(L);
assert((r->cpp_class() != LUA_NOREF) && "you must call luabind::open()");
@@ -274,7 +274,7 @@
lua_gettable(L, -2);
if (!lua_isnil(L, -1))
{
- lua_remove(L, -2); // more table
+ lua_remove(L, -2); // remove table
return 1;
}
lua_pop(L, 2);
@@ -287,7 +287,7 @@
if (!lua_isnil(L, -1))
{
- lua_remove(L, -2); // more table
+ lua_remove(L, -2); // remove table
return 1;
}
lua_pop(L, 2);
@@ -615,7 +615,8 @@
#endif
int num_params = lua_gettop(L) /*- 1*/;
- found = find_best_match(L, &rep->overloads().front(), rep->overloads().size(), sizeof(overload_rep), ambiguous, min_match, match_index, num_params);
+ found = find_best_match(L, &rep->overloads().front(), rep->overloads().size()
+ , sizeof(overload_rep), ambiguous, min_match, match_index, num_params);
#ifdef LUABIND_NO_ERROR_CHECKING
@@ -639,7 +640,8 @@
function_name += ":";
function_name += rep->name;
- msg += get_overload_signatures(L, rep->overloads().begin(), rep->overloads().end(), function_name);
+ msg += get_overload_signatures(L, rep->overloads().begin()
+ , rep->overloads().end(), function_name);
lua_pushstring(L, msg.c_str());
}
@@ -657,14 +659,16 @@
msg += ")' is ambiguous\nnone of the overloads have a best conversion:\n";
std::vector<const overload_rep_base*> candidates;
- find_exact_match(L, &rep->overloads().front(), rep->overloads().size(), sizeof(overload_rep), min_match, num_params, candidates);
+ find_exact_match(L, &rep->overloads().front(), rep->overloads().size()
+ , sizeof(overload_rep), min_match, num_params, candidates);
std::string function_name;
function_name += rep->crep->name();
function_name += ":";
function_name += rep->name;
- msg += get_overload_signatures_candidates(L, candidates.begin(), candidates.end(), function_name);
+ msg += get_overload_signatures_candidates(L, candidates.begin()
+ , candidates.end(), function_name);
lua_pushstring(L, msg.c_str());
}
@@ -734,8 +738,8 @@
std::string to_string(luabind::object const& o)
{
using namespace luabind;
- if (o.type() == LUA_TSTRING) return object_cast<std::string>(o);
- lua_State* L = o.lua_state();
+ if (type(o) == LUA_TSTRING) return object_cast<std::string>(o);
+ lua_State* L = o.interpreter();
LUABIND_CHECK_STACK(L);
#ifdef BOOST_NO_STRINGSTREAM
@@ -744,13 +748,13 @@
std::stringstream s;
#endif
- if (o.type() == LUA_TNUMBER)
+ if (type(o) == LUA_TNUMBER)
{
s << object_cast<float>(o);
return s.str();
}
- s << "<" << lua_typename(L, o.type()) << ">";
+ s << "<" << lua_typename(L, type(o)) << ">";
#ifdef BOOST_NO_STRINGSTREAM
s << std::ends;
#endif
@@ -762,12 +766,12 @@
{
#if !defined(LUABIND_NO_ERROR_CHECKING)
using namespace luabind;
- lua_State* L = e.lua_state();
+ lua_State* L = e.interpreter();
LUABIND_CHECK_STACK(L);
- if (e.type() == LUA_TFUNCTION)
+ if (type(e) == LUA_TFUNCTION)
{
- e.pushvalue();
+ e.push(L);
detail::stack_pop p(L, 1);
{
@@ -828,21 +832,17 @@
ret << "dynamic dispatch functions:\n------------------\n";
- get_table(L);
- object t(L);
- t.set();
- for (object::iterator i = t.begin(); i != t.end(); ++i)
+ for (luabind::iterator i(m_table), end; i != end; ++i)
{
- object e = *i;
+ luabind::object e = *i;
ret << " " << to_string(i.key()) << ": " << member_to_string(e) << "\n";
}
ret << "default implementations:\n------------------\n";
- get_default_table(L);
- t.set();
- for (object::iterator i = t.begin(); i != t.end(); ++i)
+
+ for (luabind::iterator i(m_default_table), end; i != end; ++i)
{
- object e = *i;
+ luabind::object e = *i;
ret << " " << to_string(i.key()) << ": " << member_to_string(e) << "\n";
}
#ifdef BOOST_NO_STRINGSTREAM
@@ -1641,8 +1641,8 @@
LUABIND_CHECK_STACK(L);
// insert the function in the normal member table
// and in the default member table
- m_default_table_ref.get(L);
- m_table_ref.get(L);
+ m_default_table.push(L);
+ m_table.push(L);
// pops the tables
detail::stack_pop pop_tables(L, 2);
@@ -1650,7 +1650,7 @@
for (std::list<method_rep>::const_iterator m = m_methods.begin();
m != m_methods.end(); ++m)
{
- // create the function closure in m_table_ref
+ // create the function closure in m_table
lua_pushstring(L, m->name);
lua_pushlightuserdata(L, const_cast<void*>((const void*)&(*m)));
lua_pushboolean(L, 0);
@@ -1658,7 +1658,7 @@
lua_pushcclosure(L, function_dispatcher, 3);
lua_settable(L, -3);
- // create the function closure in m_default_table_ref
+ // create the function closure in m_default_table
lua_pushstring(L, m->name);
lua_pushlightuserdata(L, const_cast<void*>((const void*)&(*m)));
lua_pushboolean(L, 1);
--- object.cpp DELETED ---
Index: find_best_match.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/src/find_best_match.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- find_best_match.cpp 7 Aug 2004 13:37:11 -0000 1.9
+++ find_best_match.cpp 28 Nov 2005 20:55:34 -0000 1.10
@@ -28,7 +28,7 @@
bool luabind::detail::find_best_match(
lua_State* L
- , const overload_rep_base* start
+ , overload_rep_base const* start
, int num_overloads
, size_t orep_size
, bool& ambiguous
@@ -42,6 +42,7 @@
for (int index = 0; index < num_overloads; ++index)
{
int match_value = start->match(L, num_params);
+
reinterpret_cast<const char*&>(start) += orep_size;
if (match_value < 0) continue;
@@ -58,13 +59,14 @@
}
}
- ambiguous = min_match == min_but_one_match && min_match < std::numeric_limits<int>::max();
+ ambiguous = min_match == min_but_one_match
+ && min_match < std::numeric_limits<int>::max();
return found;
}
void luabind::detail::find_exact_match(
lua_State* L
- , const overload_rep_base* start
+ , overload_rep_base const* start
, int num_overloads
, size_t orep_size
, int cmp_match
|