mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
LuaBindings: prefer shared_ptr over weak_ptr
This commit is contained in:
parent
4a5abf61b0
commit
d0b42aee0e
1 changed files with 28 additions and 28 deletions
|
|
@ -1203,8 +1203,8 @@ private:
|
||||||
public:
|
public:
|
||||||
WSPtrClass (char const* name, Namespace const* parent)
|
WSPtrClass (char const* name, Namespace const* parent)
|
||||||
: ClassBase (parent->L)
|
: ClassBase (parent->L)
|
||||||
, weak (name, parent)
|
|
||||||
, shared (name, parent)
|
, shared (name, parent)
|
||||||
|
, weak (name, parent)
|
||||||
{
|
{
|
||||||
#ifdef LUABINDINGDOC
|
#ifdef LUABINDINGDOC
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
@ -1213,21 +1213,21 @@ private:
|
||||||
PRINTDOC ("[C] Weak/Shared Pointer Class",
|
PRINTDOC ("[C] Weak/Shared Pointer Class",
|
||||||
parent->_name + name,
|
parent->_name + name,
|
||||||
std::string(), type_name <T>())
|
std::string(), type_name <T>())
|
||||||
m_stackSize = weak.m_stackSize;
|
m_stackSize = shared.m_stackSize;
|
||||||
parent->m_stackSize = weak.m_stackSize = shared.m_stackSize = 0;
|
parent->m_stackSize = weak.m_stackSize = shared.m_stackSize = 0;
|
||||||
lua_pop (L, 3);
|
lua_pop (L, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
WSPtrClass (char const* name, Namespace const* parent, void const* const sharedkey, void const* const weakkey)
|
WSPtrClass (char const* name, Namespace const* parent, void const* const sharedkey, void const* const weakkey)
|
||||||
: ClassBase (parent->L)
|
: ClassBase (parent->L)
|
||||||
, weak (name, parent, weakkey)
|
|
||||||
, shared (name, parent, sharedkey)
|
, shared (name, parent, sharedkey)
|
||||||
|
, weak (name, parent, weakkey)
|
||||||
{
|
{
|
||||||
#ifdef LUABINDINGDOC
|
#ifdef LUABINDINGDOC
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
_name = parent->_name + name + ":";
|
_name = parent->_name + name + ":";
|
||||||
#endif
|
#endif
|
||||||
m_stackSize = weak.m_stackSize;
|
m_stackSize = shared.m_stackSize;
|
||||||
parent->m_stackSize = weak.m_stackSize = shared.m_stackSize = 0;
|
parent->m_stackSize = weak.m_stackSize = shared.m_stackSize = 0;
|
||||||
lua_pop (L, 3);
|
lua_pop (L, 3);
|
||||||
}
|
}
|
||||||
|
|
@ -1236,11 +1236,11 @@ private:
|
||||||
WSPtrClass <T>& addFunction (char const* name, MemFn mf)
|
WSPtrClass <T>& addFunction (char const* name, MemFn mf)
|
||||||
{
|
{
|
||||||
FUNDOC ("Weak/Shared Pointer Function", name, MemFn)
|
FUNDOC ("Weak/Shared Pointer Function", name, MemFn)
|
||||||
set_weak_class ();
|
|
||||||
CFunc::CallMemberWPtrFunctionHelper <MemFn>::add (L, name, mf);
|
|
||||||
|
|
||||||
set_shared_class ();
|
set_shared_class ();
|
||||||
CFunc::CallMemberPtrFunctionHelper <MemFn>::add (L, name, mf);
|
CFunc::CallMemberPtrFunctionHelper <MemFn>::add (L, name, mf);
|
||||||
|
|
||||||
|
set_weak_class ();
|
||||||
|
CFunc::CallMemberWPtrFunctionHelper <MemFn>::add (L, name, mf);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1248,11 +1248,11 @@ private:
|
||||||
WSPtrClass <T>& addRefFunction (char const* name, MemFn mf)
|
WSPtrClass <T>& addRefFunction (char const* name, MemFn mf)
|
||||||
{
|
{
|
||||||
FUNDOC ("Weak/Shared Pointer Function RefReturn", name, MemFn)
|
FUNDOC ("Weak/Shared Pointer Function RefReturn", name, MemFn)
|
||||||
set_weak_class ();
|
|
||||||
CFunc::CallMemberRefWPtrFunctionHelper <MemFn>::add (L, name, mf);
|
|
||||||
|
|
||||||
set_shared_class ();
|
set_shared_class ();
|
||||||
CFunc::CallMemberRefPtrFunctionHelper <MemFn>::add (L, name, mf);
|
CFunc::CallMemberRefPtrFunctionHelper <MemFn>::add (L, name, mf);
|
||||||
|
|
||||||
|
set_weak_class ();
|
||||||
|
CFunc::CallMemberRefWPtrFunctionHelper <MemFn>::add (L, name, mf);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1260,17 +1260,17 @@ private:
|
||||||
WSPtrClass <T>& addConstructor ()
|
WSPtrClass <T>& addConstructor ()
|
||||||
{
|
{
|
||||||
FUNDOC ("Weak/Shared Pointer Constructor", "", MemFn)
|
FUNDOC ("Weak/Shared Pointer Constructor", "", MemFn)
|
||||||
|
set_shared_class ();
|
||||||
|
lua_pushcclosure (L,
|
||||||
|
&shared. template ctorPtrPlacementProxy <typename FuncTraits <MemFn>::Params, boost::shared_ptr<T>, T >, 0);
|
||||||
|
rawsetfield(L, -2, "__call");
|
||||||
|
|
||||||
set_weak_class ();
|
set_weak_class ();
|
||||||
// NOTE: this constructs an empty weak-ptr,
|
// NOTE: this constructs an empty weak-ptr,
|
||||||
// ideally we'd construct a weak-ptr from a referenced shared-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 ();
|
|
||||||
lua_pushcclosure (L,
|
|
||||||
&shared. template ctorPtrPlacementProxy <typename FuncTraits <MemFn>::Params, boost::shared_ptr<T>, T >, 0);
|
|
||||||
rawsetfield(L, -2, "__call");
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1282,12 +1282,12 @@ private:
|
||||||
WSPtrClass <T>& addExtCFunction (char const* name, int (*const fp)(lua_State*))
|
WSPtrClass <T>& addExtCFunction (char const* name, int (*const fp)(lua_State*))
|
||||||
{
|
{
|
||||||
DATADOC ("Weak/Shared Ext C Function", name, fp)
|
DATADOC ("Weak/Shared Ext C Function", name, fp)
|
||||||
set_weak_class ();
|
set_shared_class ();
|
||||||
assert (lua_istable (L, -1));
|
assert (lua_istable (L, -1));
|
||||||
lua_pushcclosure (L, fp, 0);
|
lua_pushcclosure (L, fp, 0);
|
||||||
rawsetfield (L, -3, name); // class table
|
rawsetfield (L, -3, name); // class table
|
||||||
|
|
||||||
set_shared_class ();
|
set_weak_class ();
|
||||||
assert (lua_istable (L, -1));
|
assert (lua_istable (L, -1));
|
||||||
lua_pushcclosure (L, fp, 0);
|
lua_pushcclosure (L, fp, 0);
|
||||||
rawsetfield (L, -3, name); // class table
|
rawsetfield (L, -3, name); // class table
|
||||||
|
|
@ -1313,32 +1313,32 @@ private:
|
||||||
WSPtrClass <T>& addNullCheck ()
|
WSPtrClass <T>& addNullCheck ()
|
||||||
{
|
{
|
||||||
PRINTDOC("Weak/Shared Null Check", _name << "isnil", std::string("bool"), std::string("void (*)()"))
|
PRINTDOC("Weak/Shared Null Check", _name << "isnil", std::string("bool"), std::string("void (*)()"))
|
||||||
set_weak_class ();
|
|
||||||
assert (lua_istable (L, -1));
|
|
||||||
lua_pushcclosure (L, &CFunc::WPtrNullCheck <T>::f, 0);
|
|
||||||
rawsetfield (L, -3, "isnil"); // class table
|
|
||||||
|
|
||||||
set_shared_class ();
|
set_shared_class ();
|
||||||
assert (lua_istable (L, -1));
|
assert (lua_istable (L, -1));
|
||||||
lua_pushcclosure (L, &CFunc::PtrNullCheck <T>::f, 0);
|
lua_pushcclosure (L, &CFunc::PtrNullCheck <T>::f, 0);
|
||||||
rawsetfield (L, -3, "isnil"); // class table
|
rawsetfield (L, -3, "isnil"); // class table
|
||||||
|
|
||||||
|
set_weak_class ();
|
||||||
|
assert (lua_istable (L, -1));
|
||||||
|
lua_pushcclosure (L, &CFunc::WPtrNullCheck <T>::f, 0);
|
||||||
|
rawsetfield (L, -3, "isnil"); // class table
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
WSPtrClass <T>& addEqualCheck ()
|
WSPtrClass <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>() + ")"))
|
||||||
set_weak_class ();
|
|
||||||
assert (lua_istable (L, -1));
|
|
||||||
lua_pushcclosure (L, &CFunc::WPtrEqualCheck <T>::f, 0);
|
|
||||||
rawsetfield (L, -3, "sameinstance"); // class table
|
|
||||||
|
|
||||||
set_shared_class ();
|
set_shared_class ();
|
||||||
assert (lua_istable (L, -1));
|
assert (lua_istable (L, -1));
|
||||||
lua_pushcclosure (L, &CFunc::PtrEqualCheck <T>::f, 0);
|
lua_pushcclosure (L, &CFunc::PtrEqualCheck <T>::f, 0);
|
||||||
rawsetfield (L, -3, "sameinstance"); // class table
|
rawsetfield (L, -3, "sameinstance"); // class table
|
||||||
|
|
||||||
|
set_weak_class ();
|
||||||
|
assert (lua_istable (L, -1));
|
||||||
|
lua_pushcclosure (L, &CFunc::WPtrEqualCheck <T>::f, 0);
|
||||||
|
rawsetfield (L, -3, "sameinstance"); // class table
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1424,8 +1424,8 @@ private:
|
||||||
lua_insert (L, -3);
|
lua_insert (L, -3);
|
||||||
lua_insert (L, -2);
|
lua_insert (L, -2);
|
||||||
}
|
}
|
||||||
Class<boost::weak_ptr<T> > weak;
|
|
||||||
Class<boost::shared_ptr<T> > shared;
|
Class<boost::shared_ptr<T> > shared;
|
||||||
|
Class<boost::weak_ptr<T> > weak;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue