Sign in to follow this  
rudeness

SWIG/Lua wrapping boost::shared_ptr?

Recommended Posts

Hello everyone. Suppose I have the following Cpp code:
class Foo
{
  const char * bar();
  ...
};

typedef boost::shared_ptr<Foo> pFoo;

// And:

pFoo make_foo()
{
 // .. somehow created.
}

What do I write in the SWIG interface file, so that pFoo can be used i Lua code? Naively, I tried to just include boost/shared_ptr.hpp, but the result was horrible (glue code did not compile). I also simply tried this, after some googling.
namespace boost {
  template<class T> class shared_ptr
  {
    public:
      T * operator-> () const;
  };
}

I can call make_foo() without problems, but the returned object is only recognized as general userdata, and I get an error when I try to call foovarname:bar(). Is it impossible, or am I simply retarded? (Hopfully the latter). rude

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this