Example #1
0
/// Opens a library
///
/// \param s The Lua state.
/// \param name The name of the module to create.
/// \param members The list of member functions to add to the module.
void lutok::registerLib(state& s, const std::map< std::string, cxx_function >& members){
	assert(s.is_table());

    for (std::map< std::string, cxx_function >::const_iterator
         iter = members.begin(); iter != members.end(); iter++) {
        s.push_string((*iter).first);
        s.push_cxx_function((*iter).second);
        s.set_table(-3);
    }
}
Example #2
0
/// Opens a library
///
/// \param s The Lua state.
/// \param name The name of the module to create.
/// \param members The list of member functions to add to the module.
void lutok::registerLib(state& s, const std::string& name, const std::map< std::string, cxx_function >& members, const int nup){
	s.findLib(name, members.size(), nup);
	assert(s.is_table());
    for (std::map< std::string, cxx_function >::const_iterator
         iter = members.begin(); iter != members.end(); iter++) {
        s.push_string((*iter).first);
        s.push_cxx_function((*iter).second);
        s.set_table(-3);
    }
	s.pop(nup);
}
Example #3
0
static void lutok::LObject<T>::TypeInfo::commit(state& s, int methods) {
	s.get_global(typeid(T).name());

	if (s.is_table()) {
		s.set_table(methods);
		return;
	}

	s.new_table();
	int type = s.get_top();

	assert(T::s_lunaTypeInfoPtr);
	s.push_string(T::s_lunaTypeInfoPtr->name());

	set(s, type, "name");

	s.push_value(type);
	set(s, methods, "type");

	s.push_value(methods);
	set(s, LUA_GLOBALSINDEX, T::s_lunaTypeInfoPtr->name());
}