mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
allow lua to access array at an offset
This commit is contained in:
parent
53c188beb3
commit
50d6f146f4
2 changed files with 14 additions and 1 deletions
|
|
@ -969,6 +969,14 @@ struct CFunc
|
|||
return 0;
|
||||
}
|
||||
|
||||
// return same array at an offset
|
||||
template <typename T>
|
||||
static int offsetArray (lua_State* L) {
|
||||
T *v = luabridge::Stack<T*>::get (L, 1);
|
||||
const unsigned int i = luabridge::Stack<unsigned int>::get (L, 2);
|
||||
Stack <T*>::push (L, &v[i]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1070,7 +1070,9 @@ private:
|
|||
PRINTDOC ("Ext C Function", _name << "set_table",
|
||||
std::string(""), "int (*)(lua_State*)")
|
||||
PRINTDOC("Member Function", _name << "sameinstance",
|
||||
std::string("bool"), std::string("void (*)(" + type_name <T>() + "*)"))
|
||||
std::string("bool"), std::string("bool (*)(" + type_name <T>() + "*)"))
|
||||
PRINTDOC("Member Function", _name << "offset",
|
||||
std::string(type_name <T>() + "*"), std::string(type_name <T>() + "* (*)(unsigned int)"))
|
||||
|
||||
m_stackSize = parent->m_stackSize + 3;
|
||||
parent->m_stackSize = 0;
|
||||
|
|
@ -1132,6 +1134,9 @@ private:
|
|||
lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0);
|
||||
rawsetfield (L, -3, "sameinstance");
|
||||
|
||||
lua_pushcclosure (L, &CFunc::offsetArray <T>, 0);
|
||||
rawsetfield (L, -3, "offset"); // class table
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue