diff options
author | Robin Gareus <robin@gareus.org> | 2017-02-23 22:21:08 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-02-23 22:32:32 +0100 |
commit | 71fd94b422574d1efbcce1ab85c6ce3da22ba450 (patch) | |
tree | 77b781d7684d282ace54f41db092faa331759965 | |
parent | 37dc93b40aba3ab73dc303ccbab5f2b020e64ba0 (diff) |
LuaBridge: Dedicated type for pointer-lists and const version
"class C*" cannot be defined nor resolved, so STL containers
to class instance pointers need to be special-cased.
-rw-r--r-- | libs/lua/LuaBridge/detail/Namespace.h | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h index f4f2ae2135..3644b9e157 100644 --- a/libs/lua/LuaBridge/detail/Namespace.h +++ b/libs/lua/LuaBridge/detail/Namespace.h @@ -1864,7 +1864,34 @@ public: } template <class T> - Class<std::vector<T> > beginStdVector (char const* name) + Class<std::list<T*> > beginConstStdCPtrList (char const* name) + { + typedef T* TP; + typedef std::list<TP> LT; + return beginClass<LT> (name) + .addVoidConstructor () + .addFunction ("empty", <::empty) + .addFunction ("size", <::size) + .addFunction ("reverse", <::reverse) + .addFunction ("front", static_cast<const TP& (LT::*)() const>(<::front)) + .addFunction ("back", static_cast<const TP& (LT::*)() const>(<::back)) + .addExtCFunction ("iter", &CFunc::listIter<T*, LT>) + .addExtCFunction ("table", &CFunc::listToTable<T*, LT>); + } + + template <class T> + Class<std::list<T*> > beginStdCPtrList (char const* name) + { + typedef T* TP; + typedef std::list<TP> LT; + return beginConstStdCPtrList<T> (name) + .addFunction ("unique", (void (LT::*)())<::unique) + .addFunction ("push_back", (void (LT::*)(const TP&))<::push_back); + } + + + template <class T> + Class<std::vector<T> > beginConstStdVector (char const* name) { typedef std::vector<T> LT; typedef typename std::vector<T>::reference T_REF; @@ -1874,13 +1901,23 @@ public: .addVoidConstructor () .addFunction ("empty", <::empty) .addFunction ("size", <::size) - .addFunction ("push_back", (void (LT::*)(const T&))<::push_back) .addFunction ("at", (T_REF (LT::*)(T_SIZE))<::at) - .addExtCFunction ("add", &CFunc::tableToList<T, LT>) .addExtCFunction ("iter", &CFunc::listIter<T, LT>) .addExtCFunction ("table", &CFunc::listToTable<T, LT>); } + template <class T> + Class<std::vector<T> > beginStdVector (char const* name) + { + typedef std::vector<T> LT; + return beginConstStdVector<T> (name) + .addVoidConstructor () + .addFunction ("push_back", (void (LT::*)(const T&))<::push_back) + .addExtCFunction ("add", &CFunc::tableToList<T, LT>); + } + + + //---------------------------------------------------------------------------- template <class T> |