Prepare Lua bindings for std::set::insert

This commit is contained in:
Robin Gareus 2022-10-17 23:09:04 +02:00
parent f6cc01d4f5
commit 46b14498f8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 13 additions and 0 deletions

View File

@ -1401,6 +1401,16 @@ struct CFunc
return 2;
}
template <class T, class C>
static int setInsert (lua_State *L)
{
C* const t = Userdata::get <C> (L, 1, false);
T const * const v = Userdata::get <T> (L, 2, true);
auto rv = t->insert (*v);
Stack <bool>::push (L, rv.second);
return 1;
}
// generate iterator
template <class T, class C>
static int setIter (lua_State *L)

View File

@ -1904,6 +1904,9 @@ public:
.addFunction ("clear", (void (LT::*)())&LT::clear)
.addFunction ("empty", &LT::empty)
.addFunction ("size", &LT::size)
#if 0 // needs work for AutomationTypeSet (T is-a enum not a class instance)
.addExtCFunction ("insert", &CFunc::setInsert<T, LT>)
#endif
.addExtCFunction ("iter", &CFunc::setIter<T, LT>)
.addExtCFunction ("table", &CFunc::setToTable<T, LT>);
}