|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
class hierarchies and smart pointersHi,
I have a class hierarchy whose instances need to be managed with a smart pointer Holder<> when passed to/from lua. So I declared the classes like this: class_<Base, Holder<Base> >("Base"); class_<Derived, Holder<Base> >("Derived"); The problem is I also have functions like : Holder<Derived> foo() and I really need to access the result as a Derived instance. Luabind complains at runtime that Holder<Derived> is not registered. I'm curious to know if anyone on the list faced this, and of course how they solved it :) Thanks! - David ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
|
|
Re: class hierarchies and smart pointersOn Mon, 17 Aug 2009 12:06:16 +0200
David Raulo <david.raulo@...> wrote: > Hi, > > I have a class hierarchy whose instances need to be managed with a > smart pointer Holder<> when passed to/from lua. So I declared the > classes like this: > class_<Base, Holder<Base> >("Base"); > class_<Derived, Holder<Base> >("Derived"); > > The problem is I also have functions like : > Holder<Derived> foo() > > and I really need to access the result as a Derived instance. > Luabind complains at runtime that Holder<Derived> is not registered. > I'm curious to know if anyone on the list faced this, and of course > how they solved it :) Thanks! So, anybody knows? Thanks - David ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
|
|
Re: class hierarchies and smart pointersHi,
Try this: class_<Base, Holder<Base> >("Base"); class_<Derived, Base, Holder<Base> >("Derived"); I haven't tried it, but there's an example in luabind docs (in the end of 8.7 Smart Pointers section): ... class_<base, boost::shared_ptr<base> >("base") .def(constructor<>()), class_<derived, base, boost::shared_ptr<base> >("base") .def(constructor<>()) ... Hope this helps On Mon, Aug 31, 2009 at 8:30 PM, David Raulo<david.raulo@...> wrote: > On Mon, 17 Aug 2009 12:06:16 +0200 > David Raulo <david.raulo@...> wrote: > >> Hi, >> >> I have a class hierarchy whose instances need to be managed with a >> smart pointer Holder<> when passed to/from lua. So I declared the >> classes like this: >> class_<Base, Holder<Base> >("Base"); >> class_<Derived, Holder<Base> >("Derived"); >> >> The problem is I also have functions like : >> Holder<Derived> foo() >> >> and I really need to access the result as a Derived instance. >> Luabind complains at runtime that Holder<Derived> is not registered. >> I'm curious to know if anyone on the list faced this, and of course >> how they solved it :) Thanks! > > So, anybody knows? > > Thanks > > - David > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > luabind-user mailing list > luabind-user@... > https://lists.sourceforge.net/lists/listinfo/luabind-user > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
|
|
Re: class hierarchies and smart pointersUhm, scratch that, it's an answer to another question :-/
On Mon, Aug 31, 2009 at 9:03 PM, Ilia Trendafilov<itrend@...> wrote: > Hi, > > Try this: > > class_<Base, Holder<Base> >("Base"); > class_<Derived, Base, Holder<Base> >("Derived"); > > I haven't tried it, but there's an example in luabind docs (in the end > of 8.7 Smart Pointers section): > > ... > class_<base, boost::shared_ptr<base> >("base") > .def(constructor<>()), > class_<derived, base, boost::shared_ptr<base> >("base") > .def(constructor<>()) > ... > > Hope this helps > > > On Mon, Aug 31, 2009 at 8:30 PM, David Raulo<david.raulo@...> wrote: >> On Mon, 17 Aug 2009 12:06:16 +0200 >> David Raulo <david.raulo@...> wrote: >> >>> Hi, >>> >>> I have a class hierarchy whose instances need to be managed with a >>> smart pointer Holder<> when passed to/from lua. So I declared the >>> classes like this: >>> class_<Base, Holder<Base> >("Base"); >>> class_<Derived, Holder<Base> >("Derived"); >>> >>> The problem is I also have functions like : >>> Holder<Derived> foo() >>> >>> and I really need to access the result as a Derived instance. >>> Luabind complains at runtime that Holder<Derived> is not registered. >>> I'm curious to know if anyone on the list faced this, and of course >>> how they solved it :) Thanks! >> >> So, anybody knows? >> >> Thanks >> >> - David >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >> trial. Simplify your report design, integration and deployment - and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> luabind-user mailing list >> luabind-user@... >> https://lists.sourceforge.net/lists/listinfo/luabind-user >> > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
|
|
Re: class hierarchies and smart pointersOn Mon, 31 Aug 2009 21:04:34 +0200
Ilia Trendafilov <itrend@...> wrote: > On Mon, Aug 31, 2009 at 9:03 PM, Ilia Trendafilov<itrend@...> > wrote: > > Hi, > > > > Try this: > > > > class_<Base, Holder<Base> >("Base"); > > class_<Derived, Base, Holder<Base> >("Derived"); > Uhm, scratch that, it's an answer to another question :-/ no, you're right, and that's how I actually defined my bindings, unlike what I wrote in my initial message. Still doesn't work, but thanks anyway :- - David ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
| Free embeddable forum powered by Nabble | Forum Help |