コード例 #1
0
	/*! Create table "name" within table at index tindex */
	static void subtable(lua_State *L, int tindex, const char *name, const char *mode) { //> [-0,+1,e]
		int abs_tindex = lua_absindex(L, tindex);
		lua_getfield(L, abs_tindex, name);                       // [-0,+1,e]

		if (lua_isnil(L, -1)) {                              // [-0,+0,-]
			lua_pop(L, 1); // pop(nil)                         // [-1,+0,-]
			lua_checkstack(L, 3);                              // [-0,+0,v]
			weaktable(L, mode); // pushes a table              // [-0,+1,e]
			lua_pushvalue(L, -1); // dup                       // [-0,+1,-]
			rawsetfield(L, abs_tindex, name); // t[name] = table   // [-1,+0,e]
		}
	} // leaves table on stack
コード例 #2
0
ファイル: lunar.hpp プロジェクト: cschreib/lxgui
 static void subtable(lua_State *L, int tindex, const char *name, const char *mode) {
   lua_pushstring(L, name);
   lua_gettable(L, tindex);
   if (lua_isnil(L, -1)) {
     lua_pop(L, 1);
     lua_checkstack(L, 3);
     weaktable(L, mode);
     lua_pushstring(L, name);
     lua_pushvalue(L, -2);
     lua_settable(L, tindex);
   }
 }
コード例 #3
0
ファイル: lobject.cpp プロジェクト: swc4848a/LuaSDL-2.0
static void lutok::LObject<T>::subtable(state& s, Index metatable, const std::string& name,  const std::string& mode) {
	s.push_string(name);
	s.get_table(metatable);

	if (s.is_nil()) {
		s.pop(1);

		lua_checkstack(s._pimpl->lua_state, 3);

		weaktable(s, mode);
		s.push_string(name);
		s.push_value(-2);
		s.set_metatable(metatable);
	}
}