summaryrefslogtreecommitdiff
path: root/upb/bindings
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2016-04-19 15:41:33 -0700
committerJoshua Haberman <jhaberman@gmail.com>2016-04-19 15:41:33 -0700
commite6fa3f9d869765544b8e424e8573fe8d9af35534 (patch)
tree3e56beb3bd80470ddad130b2c7f703fb5bb6b5fd /upb/bindings
parent68bc62a7fa5febbf5c8ab2fe8f6171121d18690f (diff)
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.
Diffstat (limited to 'upb/bindings')
-rw-r--r--upb/bindings/lua/upb.c17
1 files changed, 17 insertions, 0 deletions
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. */
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback