Problem with boost::shared_ptr auto conversion

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

Problem with boost::shared_ptr auto conversion

Daniel Herb-2
Hello,
I'm pretty new to luabind and got a problem with boost::shared_ptr:

If you have the following functions:
Foo getFoo();
void setFoo(boost::shared_ptr<Foo> foo);

which are registered with luabind:
     luabind::class_<Foo, boost::shared_ptr<Foo> >("Foo"),
     luabind::def("getFoo", &getFoo),
     luabind::def("setFoo", &setFoo)

this lua-code doesn't work:
setFoo(getFoo());

Why? All other conversions are handled completely automatically (which is pretty nice).
Have I missed something?


Thanks


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Debug version when compiling luabind with Darwin target?

Nicolas Goles-2
Hello,

I compiled Luabind on my OS X machine I built it and I think I got a debug version:


( here's a link to the attached image in case it doesn't display http://img844.imageshack.us/img844/703/screenshot20100826at112.png )

I'm not really sure if this is correct , could someone tell me if this is normal or if I should aim for other build ?

I just went 

username$ bjam
warning: No toolsets are configured.
warning: Configuring default toolset "darwin".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
...patience...
...found 788 targets...
...updating 22 targets...
common.mkdir bin
common.mkdir bin/darwin-4.2.1
common.mkdir bin/darwin-4.2.1/debug
common.mkdir bin/darwin-4.2.1/debug/src
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_info.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_registry.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_rep.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/create_class.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/error.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/exception_handler.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/function.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/inheritance.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/link_compatibility.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/object_rep.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/open.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/pcall.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/scope.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/stack_content_by_name.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/weak_ref.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/wrapper_base.o
darwin.link.dll bin/darwin-4.2.1/debug/libluabindd.dylib
...updated 22 targets...

Thanks!
--------------------------------------------------------------
Nicolas Goles Domic
Founder & Lead Programmer of Gando Games


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Debug version when compiling luabind with Darwin target?

Tony Kostanjsek
Don't forget you can statically link luabind and don't need to use bjam to build it. Just put the required cpp files in your project. This will make sure you get the correct debug/release version because it directly uses your project settings/build configuration. Also ... no dylibs allowed on the iPhone IIRC :)



Von: Nicolas Goles <[hidden email]>
An: [hidden email]
Gesendet: Freitag, den 27. August 2010, 5:34:02 Uhr
Betreff: [luabind] Debug version when compiling luabind with Darwin target?

Hello,

I compiled Luabind on my OS X machine I built it and I think I got a debug version:


( here's a link to the attached image in case it doesn't display http://img844.imageshack.us/img844/703/screenshot20100826at112.png )

I'm not really sure if this is correct , could someone tell me if this is normal or if I should aim for other build ?

I just went 

username$ bjam
warning: No toolsets are configured.
warning: Configuring default toolset "darwin".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
...patience...
...found 788 targets...
...updating 22 targets...
common.mkdir bin
common.mkdir bin/darwin-4.2.1
common.mkdir bin/darwin-4.2.1/debug
common.mkdir bin/darwin-4.2.1/debug/src
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_info.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_registry.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/class_rep.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/create_class.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/error.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/exception_handler.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/function.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/inheritance.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/link_compatibility.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/object_rep.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/open.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/pcall.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/scope.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/stack_content_by_name.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/weak_ref.o
darwin.compile.c++ bin/darwin-4.2.1/debug/src/wrapper_base.o
darwin.link.dll bin/darwin-4.2.1/debug/libluabindd.dylib
...updated 22 targets...

Thanks!
--------------------------------------------------------------
Nicolas Goles Domic
Founder & Lead Programmer of Gando Games



------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem with boost::shared_ptr auto conversion

Daniel Wallin
In reply to this post by Daniel Herb-2
On Wed, Aug 25, 2010 at 1:13 PM, Daniel Herb <[hidden email]> wrote:

> Hello,
> I'm pretty new to luabind and got a problem with boost::shared_ptr:
>
> If you have the following functions:
> Foo getFoo();
> void setFoo(boost::shared_ptr<Foo> foo);
>
> which are registered with luabind:
>      luabind::class_<Foo, boost::shared_ptr<Foo> >("Foo"),
>      luabind::def("getFoo", &getFoo),
>      luabind::def("setFoo", &setFoo)
>
> this lua-code doesn't work:
> setFoo(getFoo());
>
> Why? All other conversions are handled completely automatically (which is
> pretty nice).
> Have I missed something?

Well, the object returned by getFoo() isn't held by a shared_ptr<Foo>.
The copy is actually held in a std::auto_ptr<Foo>, but that's an
implementation detail. Specifically for shared_ptr, it's actually
possible to get this to work. Simply including
<luabind/shared_ptr_converter.hpp> should work for you.

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user