Fix shared-pointer list creation from Lua
This commit is contained in:
parent
9e048851c1
commit
134b69f267
|
@ -672,7 +672,6 @@ LuaBindings::common (lua_State* L)
|
||||||
.endClass ()
|
.endClass ()
|
||||||
|
|
||||||
.beginWSPtrClass <PluginInfo> ("PluginInfo")
|
.beginWSPtrClass <PluginInfo> ("PluginInfo")
|
||||||
.addVoidConstructor ()
|
|
||||||
.addData ("name", &PluginInfo::name, false)
|
.addData ("name", &PluginInfo::name, false)
|
||||||
.addData ("category", &PluginInfo::category, false)
|
.addData ("category", &PluginInfo::category, false)
|
||||||
.addData ("creator", &PluginInfo::creator, false)
|
.addData ("creator", &PluginInfo::creator, false)
|
||||||
|
@ -1388,6 +1387,7 @@ LuaBindings::common (lua_State* L)
|
||||||
|
|
||||||
// boost::shared_ptr<RouteList>
|
// boost::shared_ptr<RouteList>
|
||||||
.beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
|
.beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
|
||||||
|
.addVoidPtrConstructor<std::list<boost::shared_ptr <Route> > > ()
|
||||||
.endClass ()
|
.endClass ()
|
||||||
|
|
||||||
// typedef std::list<boost::weak_ptr <Route> > WeakRouteList
|
// typedef std::list<boost::weak_ptr <Route> > WeakRouteList
|
||||||
|
@ -1412,6 +1412,7 @@ LuaBindings::common (lua_State* L)
|
||||||
|
|
||||||
// boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
|
// boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
|
||||||
.beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
|
.beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
|
||||||
|
.addVoidPtrConstructor<std::list<boost::shared_ptr <Region> > > ()
|
||||||
.endClass ()
|
.endClass ()
|
||||||
|
|
||||||
//std::list<boost::shared_ptr<Port> > PortList;
|
//std::list<boost::shared_ptr<Port> > PortList;
|
||||||
|
|
|
@ -473,6 +473,15 @@ private:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Params, class T, class C>
|
||||||
|
static int ctorPtrPlacementProxy (lua_State* L)
|
||||||
|
{
|
||||||
|
ArgList <Params, 2> args (L);
|
||||||
|
T newobject (Constructor <C, Params>::call (args));
|
||||||
|
Stack<T>::push (L, newobject);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
Pop the Lua stack.
|
Pop the Lua stack.
|
||||||
|
@ -1037,11 +1046,28 @@ private:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class MemFn, class PT>
|
||||||
|
Class <T>& addPtrConstructor ()
|
||||||
|
{
|
||||||
|
FUNDOC("Constructor", "", MemFn)
|
||||||
|
lua_pushcclosure (L,
|
||||||
|
&ctorPtrPlacementProxy <typename FuncTraits <MemFn>::Params, T, PT>, 0);
|
||||||
|
rawsetfield(L, -2, "__call");
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Class <T>& addVoidConstructor ()
|
Class <T>& addVoidConstructor ()
|
||||||
{
|
{
|
||||||
return addConstructor <void (*) ()> ();
|
return addConstructor <void (*) ()> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class PT>
|
||||||
|
Class <T>& addVoidPtrConstructor ()
|
||||||
|
{
|
||||||
|
return addPtrConstructor <void (*) (), PT> ();
|
||||||
|
}
|
||||||
|
|
||||||
Class <T>& addEqualCheck ()
|
Class <T>& addEqualCheck ()
|
||||||
{
|
{
|
||||||
PRINTDOC("Member Function", _name << "sameinstance", std::string("bool"), std::string("void (*)(" + type_name <T>() + ")"))
|
PRINTDOC("Member Function", _name << "sameinstance", std::string("bool"), std::string("void (*)(" + type_name <T>() + ")"))
|
||||||
|
@ -1235,13 +1261,15 @@ private:
|
||||||
{
|
{
|
||||||
FUNDOC ("Weak/Shared Pointer Constructor", "", MemFn)
|
FUNDOC ("Weak/Shared Pointer Constructor", "", MemFn)
|
||||||
set_weak_class ();
|
set_weak_class ();
|
||||||
|
// NOTE: this constructs an empty weak-ptr,
|
||||||
|
// ideally we'd construct a weak-ptr from a referenced shared-ptr
|
||||||
lua_pushcclosure (L,
|
lua_pushcclosure (L,
|
||||||
&weak. template ctorPlacementProxy <typename FuncTraits <MemFn>::Params, boost::weak_ptr<T> >, 0);
|
&weak. template ctorPlacementProxy <typename FuncTraits <MemFn>::Params, boost::weak_ptr<T> >, 0);
|
||||||
rawsetfield(L, -2, "__call");
|
rawsetfield(L, -2, "__call");
|
||||||
|
|
||||||
set_shared_class ();
|
set_shared_class ();
|
||||||
lua_pushcclosure (L,
|
lua_pushcclosure (L,
|
||||||
&shared. template ctorPlacementProxy <typename FuncTraits <MemFn>::Params, boost::shared_ptr<T> >, 0);
|
&shared. template ctorPtrPlacementProxy <typename FuncTraits <MemFn>::Params, boost::shared_ptr<T>, T >, 0);
|
||||||
rawsetfield(L, -2, "__call");
|
rawsetfield(L, -2, "__call");
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -1831,9 +1859,8 @@ public:
|
||||||
Class<boost::shared_ptr<std::list<T> > > beginPtrStdList (char const* name)
|
Class<boost::shared_ptr<std::list<T> > > beginPtrStdList (char const* name)
|
||||||
{
|
{
|
||||||
typedef std::list<T> LT;
|
typedef std::list<T> LT;
|
||||||
|
|
||||||
return beginClass<boost::shared_ptr<LT> > (name)
|
return beginClass<boost::shared_ptr<LT> > (name)
|
||||||
.addVoidConstructor ()
|
//.addVoidPtrConstructor<LT> ()
|
||||||
.addPtrFunction ("empty", <::empty)
|
.addPtrFunction ("empty", <::empty)
|
||||||
.addPtrFunction ("size", <::size)
|
.addPtrFunction ("size", <::size)
|
||||||
.addPtrFunction ("reverse", <::reverse)
|
.addPtrFunction ("reverse", <::reverse)
|
||||||
|
@ -1852,7 +1879,7 @@ public:
|
||||||
typedef typename std::vector<T>::size_type T_SIZE;
|
typedef typename std::vector<T>::size_type T_SIZE;
|
||||||
|
|
||||||
return beginClass<boost::shared_ptr<LT> > (name)
|
return beginClass<boost::shared_ptr<LT> > (name)
|
||||||
.addVoidConstructor ()
|
//.addVoidPtrConstructor<LT> ()
|
||||||
.addPtrFunction ("empty", <::empty)
|
.addPtrFunction ("empty", <::empty)
|
||||||
.addPtrFunction ("empty", <::empty)
|
.addPtrFunction ("empty", <::empty)
|
||||||
.addPtrFunction ("size", <::size)
|
.addPtrFunction ("size", <::size)
|
||||||
|
|
Loading…
Reference in New Issue