.beginNamespace ("ARDOUR")
.beginClass <AudioBuffer> ("AudioBuffer")
+ .addEqualCheck ()
.addFunction ("data", (Sample*(AudioBuffer::*)(framecnt_t))&AudioBuffer::data)
.addFunction ("silence", &AudioBuffer::silence)
.addFunction ("apply_gain", &AudioBuffer::apply_gain)
.endClass()
.beginClass <MidiBuffer> ("MidiBuffer")
+ .addEqualCheck ()
.addFunction ("silence", &MidiBuffer::silence)
.addFunction ("empty", &MidiBuffer::empty)
// TODO iterators..
.endClass()
.beginClass <BufferSet> ("BufferSet")
+ .addEqualCheck ()
.addFunction ("get_audio", static_cast<AudioBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_audio))
.addFunction ("count", static_cast<const ChanCount&(BufferSet::*)()const>(&BufferSet::count))
.endClass()
}
};
+ template <class T>
+ struct ClassEqualCheck
+ {
+ static int f (lua_State* L)
+ {
+ T const* const t0 = Userdata::get <T> (L, 1, true);
+ T const* const t1 = Userdata::get <T> (L, 2, true);
+ Stack <bool>::push (L, t0 == t1);
+ return 1;
+ }
+ };
+
+
template <class T>
struct PtrNullCheck
{
return addConstructor <void (*) ()> ();
}
+ Class <T>& addEqualCheck ()
+ {
+ PRINTDOC("Member Function", _name << "sameinstance", std::string("bool"), std::string("void (*)(" + type_name <T>() + ")"))
+ assert (lua_istable (L, -1));
+ lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0);
+ rawsetfield (L, -3, "sameinstance");
+ return *this;
+ }
+
};
/** C Array to/from table */
std::string(""), "int (*)(lua_State*)")
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>() + "*)"))
m_stackSize = parent->m_stackSize + 3;
parent->m_stackSize = 0;
lua_pushcclosure (L, &CFunc::setTable <T>, 0);
rawsetfield (L, -3, "set_table"); // class table
+
+ lua_pushcclosure (L, &CFunc::ClassEqualCheck <T>::f, 0);
+ rawsetfield (L, -3, "sameinstance");
+
}
else
{