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;
+ }
+
+ template <class U>
+ Class <T>& addCast (char const* name)
+ {
+ PRINTDOC("Cast", _name << name,
+ type_name< U >(),
+ type_name< U >() << " (" << type_name< T >() << "::*)()")
+
+ assert (lua_istable (L, -1));
+ lua_pushcclosure (L, &CFunc::CastClass <T, U>::f, 0);
+ rawsetfield (L, -3, name); // class table
+
+ lua_pushcclosure (L, &CFunc::CastConstClass <T, U>::f, 0);
+ rawsetfield (L, -4, name); // const table
+ 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("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;
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");
+
+ lua_pushcclosure (L, &CFunc::offsetArray <T>, 0);
+ rawsetfield (L, -3, "offset"); // class table
+
}
else
{
typedef std::map<K, V> LT;
typedef std::pair<const K, V> T;
+ typedef typename std::map<K, V>::size_type T_SIZE;
+
return beginClass<LT> (name)
.addVoidConstructor ()
.addFunction ("empty", <::empty)
.addFunction ("size", <::size)
.addFunction ("clear", (void (LT::*)())<::clear)
- .addFunction ("count", (void (LT::*)())<::count)
+ .addFunction ("count", (T_SIZE (LT::*)(const K&) const)<::count)
.addExtCFunction ("add", &CFunc::tableToMap<K, V>)
.addExtCFunction ("iter", &CFunc::mapIter<K, V>)
.addExtCFunction ("table", &CFunc::mapToTable<K, V>);