From e6fa3f9d869765544b8e424e8573fe8d9af35534 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 19 Apr 2016 15:41:33 -0700 Subject: Changed schema for JSON test to be defined in a .proto file. (#54) * Changed schema for JSON test to be defined in a .proto file. Before we had lots of code to build these schemas manually, but this was verbose and made it difficult to add to the schema easily. Now we can just write a .proto file and adding fields is easy. To avoid making the tests depend on upbc (and thus Lua) we check in the generated schema. * Made protobuf-compiler a dependency of "make genfiles." * For genfiles download recent protoc that can handle proto3. * Only use new protoc for genfiles. --- upb/bindings/lua/upb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'upb/bindings/lua/upb.c') diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c index 531967c..7a66180 100644 --- a/upb/bindings/lua/upb.c +++ b/upb/bindings/lua/upb.c @@ -959,6 +959,18 @@ static int lupb_msgdef_fields(lua_State *L) { return 1; } +static int lupb_msgdef_mapentry(lua_State *L) { + const upb_msgdef *m = lupb_msgdef_check(L, 1); + lua_pushboolean(L, upb_msgdef_mapentry(m)); + return 1; +} + +static int lupb_msgdef_syntax(lua_State *L) { + const upb_msgdef *m = lupb_msgdef_check(L, 1); + lua_pushinteger(L, upb_msgdef_syntax(m)); + return 1; +} + static const struct luaL_Reg lupb_msgdef_mm[] = { {"__gc", lupb_msgdef_gc}, {"__len", lupb_msgdef_len}, @@ -970,6 +982,8 @@ static const struct luaL_Reg lupb_msgdef_m[] = { {"add", lupb_msgdef_add}, {"field", lupb_msgdef_field}, {"fields", lupb_msgdef_fields}, + {"syntax", lupb_msgdef_syntax}, + {"_map_entry", lupb_msgdef_mapentry}, {NULL, NULL} }; @@ -2013,5 +2027,8 @@ int luaopen_upb_c(lua_State *L) { lupb_setfieldi(L, "HANDLER_STARTSEQ", UPB_HANDLER_STARTSEQ); lupb_setfieldi(L, "HANDLER_ENDSEQ", UPB_HANDLER_ENDSEQ); + lupb_setfieldi(L, "SYNTAX_PROTO2", UPB_SYNTAX_PROTO2); + lupb_setfieldi(L, "SYNTAX_PROTO3", UPB_SYNTAX_PROTO3); + return 1; /* Return package table. */ } -- cgit v1.2.3