summaryrefslogtreecommitdiff
path: root/tools/test_cinit.lua
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-06-26 20:24:32 -0700
committerJosh Haberman <jhaberman@gmail.com>2014-06-26 20:24:32 -0700
commit2d10fa33071d52d7a35ce3b13bc459cd16a0aa33 (patch)
treebf47d38e2e1cc8ddb4711b23b26e7fd10742e07d /tools/test_cinit.lua
parent7d565f1e7a0f107506d3cf31ef2e33e22a504d2b (diff)
Sync from internal Google development.
Diffstat (limited to 'tools/test_cinit.lua')
-rw-r--r--tools/test_cinit.lua21
1 files changed, 6 insertions, 15 deletions
diff --git a/tools/test_cinit.lua b/tools/test_cinit.lua
index 3ed77b5..c181363 100644
--- a/tools/test_cinit.lua
+++ b/tools/test_cinit.lua
@@ -42,28 +42,19 @@ if arg[1] == "generate" then
local appendc = dump_cinit.file_appender(f)
local appendh = dump_cinit.file_appender(f_h)
f:write('#include "lua.h"\n')
- f:write('#define ELEMENTS(array) (sizeof(array)/sizeof(*array))\n')
f:write('#include "upb/bindings/lua/upb.h"\n')
- dump_cinit.dump_defs(symtab, "test", appendh, appendc)
+ dump_cinit.dump_defs(symtab, "testdefs", appendh, appendc)
f:write([[int luaopen_staticdefs(lua_State *L) {
- lua_newtable(L);
- for (int i = 0; i < ELEMENTS(test_msgs); i++) {
- lupb_def_pushnewrapper(L, UPB_UPCAST(&test_msgs[i]), NULL);
- lua_rawseti(L, -2, i + 1);
- }
- for (int i = 0; i < ELEMENTS(test_enums); i++) {
- lupb_def_pushnewrapper(L, UPB_UPCAST(&test_enums[i]), NULL);
- lua_rawseti(L, -2, ELEMENTS(test_msgs) + i + 1);
- }
+ const upb_symtab *s = upbdefs_testdefs(&s);
+ lupb_symtab_pushwrapper(L, s, &s);
return 1;
}]])
f_h:close()
f:close()
elseif arg[1] == "test" then
- local staticdefs = require "staticdefs"
-
- local msg = assert(staticdefs[1])
- local enum = assert(staticdefs[2])
+ local symtab = require "staticdefs"
+ local msg = assert(symtab:lookup("MyMessage"))
+ local enum = assert(symtab:lookup("MyEnum"))
local f2 = assert(msg:field("field2"))
assert(msg:def_type() == upb.DEF_MSG)
assert(msg:full_name() == "MyMessage")
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback