]> git.sesse.net Git - nageru/commitdiff
Add some maybe-helpful comments.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 23 Dec 2015 01:13:08 +0000 (02:13 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 23 Dec 2015 01:13:08 +0000 (02:13 +0100)
theme.cpp

index 2fe9d899f0cafd26b4362683551065ab33f13eae..caedbf4b1899a0bee3d26497142376c81d884440 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -539,12 +539,12 @@ Theme::Theme(const char *filename, ResourcePool *resource_pool, unsigned num_car
 void Theme::register_class(const char *class_name, const luaL_Reg *funcs)
 {
        assert(lua_gettop(L) == 0);
-       luaL_newmetatable(L, class_name);
+       luaL_newmetatable(L, class_name);  // mt = {}
        lua_pushlightuserdata(L, this);
-       luaL_setfuncs(L, funcs, 1);
+       luaL_setfuncs(L, funcs, 1);        // for (name,f in funcs) { mt[name] = f, with upvalue {theme} }
        lua_pushvalue(L, -1);
-       lua_setfield(L, -2, "__index");
-       lua_setglobal(L, class_name);
+       lua_setfield(L, -2, "__index");    // mt.__index = mt
+       lua_setglobal(L, class_name);      // ClassName = mt
        assert(lua_gettop(L) == 0);
 }