Add Lua typecast from C++ vector to C-Array
This is useful for MIDI bytes amongst other things
This commit is contained in:
@@ -1148,6 +1148,17 @@ struct CFunc
|
||||
if (!t) { return luaL_error (L, "cannot derefencee shared_ptr"); }
|
||||
return tableToListHelper<T, C> (L, t->get());
|
||||
}
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class T, class C>
|
||||
static int vectorToArray (lua_State *L)
|
||||
{
|
||||
C * const t = Userdata::get<C> (L, 1, false);
|
||||
T * a = &((*t)[0]);
|
||||
Stack <T*>::push (L, a);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
template <class T, class C>
|
||||
|
||||
@@ -1938,11 +1938,11 @@ public:
|
||||
return beginConstStdVector<T> (name)
|
||||
.addVoidConstructor ()
|
||||
.addFunction ("push_back", (void (LT::*)(const T&))<::push_back)
|
||||
.addFunction ("clear", (void (LT::*)())<::clear)
|
||||
.addExtCFunction ("to_array", &CFunc::vectorToArray<T, LT>)
|
||||
.addExtCFunction ("add", &CFunc::tableToList<T, LT>);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
|
||||
Reference in New Issue
Block a user