projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove lot of code, round 1
[apps/madmutt.git]
/
tools
/
cpkg2c.mll
diff --git
a/tools/cpkg2c.mll
b/tools/cpkg2c.mll
index
b5ef25a
..
82be124
100644
(file)
--- a/
tools/cpkg2c.mll
+++ b/
tools/cpkg2c.mll
@@
-511,7
+511,6
@@
and ext_member m f = parse
printf "static int luaM_%s_index(lua_State *L)\n{\n" pkg.name;
printf " const char *idx = luaL_checkstring(L, 2);\n\n";
printf " switch (mlua_which_token(idx, -1)) {\n";
printf "static int luaM_%s_index(lua_State *L)\n{\n" pkg.name;
printf " const char *idx = luaL_checkstring(L, 2);\n\n";
printf " switch (mlua_which_token(idx, -1)) {\n";
- printf " default:\n";
List.iter (function (m, _, _) ->
printf " case LTK_%s:\n" (upper m.mname);
let push, f, l = (snd m.typ).push in
List.iter (function (m, _, _) ->
printf " case LTK_%s:\n" (upper m.mname);
let push, f, l = (snd m.typ).push in
@@
-519,7
+518,8
@@
and ext_member m f = parse
printf " %s;\n" (tplize push (sprintf "%s.%s" pkg.name m.mname));
printf " return 1;\n"
) pkg.members;
printf " %s;\n" (tplize push (sprintf "%s.%s" pkg.name m.mname));
printf " return 1;\n"
) pkg.members;
- printf " lua_rawget(L, lua_upvalueindex(2));\n";
+ printf " default:\n";
+ printf " lua_rawget(L, lua_upvalueindex(1));\n";
printf " return 1;\n";
printf " }\n}\n\n";
printf " return 1;\n";
printf " }\n}\n\n";
@@
-561,6
+561,7
@@
and ext_member m f = parse
printf " return 1;\n"
) pkg.members;
printf " default:\n";
printf " return 1;\n"
) pkg.members;
printf " default:\n";
+ printf " lua_rawset(L, lua_upvalueindex(1));\n";
printf " return 1;\n";
printf " }\n}\n";
printf " return 1;\n";
printf " }\n}\n";
@@
-576,7
+577,7
@@
and ext_member m f = parse
int luaopen_%s(lua_State *L)
{
int luaopen_%s(lua_State *L)
{
- int mt, methods;
+ int mt, me
mbers, me
thods;
%s_init();
%s_init();
@@
-584,18
+585,20
@@
int luaopen_%s(lua_State *L)
luaL_openlib(L, \"%s\", luaM_%s_methods, 0);
methods = lua_gettop(L);
luaL_openlib(L, \"%s\", luaM_%s_methods, 0);
methods = lua_gettop(L);
+ lua_newtable(L); /* for new members */
+ members = lua_gettop(L);
+
/* create metatable for %s, add it to the registry */
luaL_newmetatable(L, \"%s\");
mt = lua_gettop(L);
lua_pushliteral(L, \"__index\");
/* create metatable for %s, add it to the registry */
luaL_newmetatable(L, \"%s\");
mt = lua_gettop(L);
lua_pushliteral(L, \"__index\");
- lua_pushvalue(L, mt); /* upvalue 1 */
- lua_pushvalue(L, methods); /* upvalue 2 */
- lua_pushcclosure(L, &luaM_%s_index, 2);
+ lua_pushvalue(L, members); /* upvalue 1 */
+ lua_pushcclosure(L, &luaM_%s_index, 1);
lua_rawset(L, mt); /* set mt.__index */
lua_pushliteral(L, \"__newindex\");
lua_rawset(L, mt); /* set mt.__index */
lua_pushliteral(L, \"__newindex\");
- lua_
newtable(L); /* for new members
*/
+ lua_
pushvalue(L, members); /* upvalue 1
*/
lua_pushcclosure(L, &luaM_%s_newindex, 1);
lua_rawset(L, mt); /* set mt.__newindex */
lua_pushcclosure(L, &luaM_%s_newindex, 1);
lua_rawset(L, mt); /* set mt.__newindex */
@@
-605,7
+608,7
@@
int luaopen_%s(lua_State *L)
lua_setmetatable(L, methods);
lua_setmetatable(L, methods);
- lua_pop(L,
2); /* drop mt + methods */
+ lua_pop(L,
3);
return 1;
}
return 1;
}