add_dependency assert problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

add_dependency assert problem

onlyfeng
hi, all:

i get assertion error in object_rep.cpp -- "assert(m_dependency_cnt < sizeof(object_rep));" when i use luabind like this example:

----------------------

class base
{
public:
    virtual void print() {}             // if not use 'virtual', the m_dependency_cnt will not bigger than sizeof(object_rep)
};

class derived : public base {};
class derived_wrap : public derived, public wrap_base {};

class holder
{
public:
    base* member;

    holder(base* p) : member(p) {}
};

module(L)
[
    class_<base>("base")
        .def(constructor<>())
        .def("print", &base::print),

    class_<derived, derived_wrap, base>("derived")    // i want the "derived" in lua can be derived and also have base class "print" function
        .def(constructor<>()),

    class_<holder>("holder")
        .def(constructor<base*>())
        .def_readonly("member", &holder::member)
];

luaL_dostring(L,
    "a = derived() "
    "b = holder(a) "
    "for i = 1, 100 do "
    "    b.member:print() "
    "end "
);

----------------------

any ideas? thanks in advance

onlyfeng
[hidden email]


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: add_dependency assert problem

Ryan Pavlik-4
Try this: Define a virtual destructor in class base. It can be trivial: that is, ~base() {}


On Wed, Aug 17, 2011 at 5:22 AM, 锋 <[hidden email]> wrote:
hi, all:

i get assertion error in object_rep.cpp -- "assert(m_dependency_cnt < sizeof(object_rep));" when i use luabind like this example:

----------------------

class base
{
public:
    virtual void print() {}             // if not use 'virtual', the m_dependency_cnt will not bigger than sizeof(object_rep)
};

class derived : public base {};
class derived_wrap : public derived, public wrap_base {};

class holder
{
public:
    base* member;

    holder(base* p) : member(p) {}
};

module(L)
[
    class_<base>("base")
        .def(constructor<>())
        .def("print", &base::print),

    class_<derived, derived_wrap, base>("derived")    // i want the "derived" in lua can be derived and also have base class "print" function
        .def(constructor<>()),

    class_<holder>("holder")
        .def(constructor<base*>())
        .def_readonly("member", &holder::member)
];

luaL_dostring(L,
    "a = derived() "
    "b = holder(a) "
    "for i = 1, 100 do "
    "    b.member:print() "
    "end "
);

----------------------

any ideas? thanks in advance

onlyfeng
[hidden email]


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user




--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

[hidden email]
http://academic.cleardefinition.com

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: add_dependency assert problem

onlyfeng
In reply to this post by onlyfeng
thanks for Ryan Pavlik reply.
define virtual destructor in class base can't resolve this problem.

i am not know the luabind-inside work well, it looks like luabind hold the 'object_rep'(b.member), every time call the b.member in lua will use the same 'object_rep'. so the m_dependency_cnt is overflow.
how should i avoid it ? (not define the base print function with 'virtual' or remove any one('derived_warp', 'base') in the ' class_<derived, derived_warp, base>("derived") ' well be ok, but the "derived" in lua will not meet my needs)

------------------------------

Message: 6
Date: Wed, 17 Aug 2011 09:52:45 -0500
From: Ryan Pavlik <[hidden email]>
Subject: Re: [luabind] add_dependency assert problem
To: [hidden email]
Message-ID:
       <CABMFTE8-AJ+ha34QWd+xAKRJZrv72wGEEg=ZyGVyfzD=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Try this: Define a virtual destructor in class base. It can be trivial: that
is, ~base() {}


On Wed, Aug 17, 2011 at 5:22 AM, ? <[hidden email]> wrote:

> hi, all:
>
> i get *assertion* error in *object_rep*.cpp -- "assert(m_dependency_cnt <
> sizeof(object_rep));" when i use luabind like this example:
>
> ----------------------
>
> class base
> {
> public:
>     virtual void print() {}             // if not use 'virtual', the
> m_dependency_cnt will not bigger than sizeof(object_rep)
> };
>
> class derived : public base {};
> class derived_wrap : public derived, public wrap_base {};
>
> class holder
> {
> public:
>     base* member;
>
>     holder(base* p) : member(p) {}
> };
>
> module(L)
> [
>     class_<base>("base")
>         .def(constructor<>())
>         .def("print", &base::print),
>
>     class_<derived, derived_wrap, base>("derived")    // i want the
> "derived" in lua can be derived and also have base class "print" function
>         .def(constructor<>()),
>
>     class_<holder>("holder")
>         .def(constructor<base*>())
>         .def_readonly("member", &holder::member)
> ];
>
> luaL_dostring(L,
>     "a = derived() "
>     "b = holder(a) "
>     "for i = 1, 100 do "
>     "    b.member:print() "
>     "end "
> );
>
> ----------------------
>
> any ideas? thanks in advance
>
> onlyfeng
> [hidden email]
>
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>


--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

[hidden email]
http://academic.cleardefinition.com
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user