summaryrefslogtreecommitdiff
path: root/upb/bindings
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-09-06 15:04:35 -0700
committerGitHub <noreply@github.com>2018-09-06 15:04:35 -0700
commitef1246d87c2ba7afae44ad3e0e0d62484b0ae1c7 (patch)
treeafe5181a9f26a826a17dec00df914662ee27a275 /upb/bindings
parentbdbc9fbd6d13d41d4bc05fea672d82f96d8e2d07 (diff)
parent3a37b91532eb38fb0494da7d70c10d7da4959981 (diff)
Merge pull request #121 from haberman/minimize
Changed C API to only define structs, a table, and a few minimal inline function.
Diffstat (limited to 'upb/bindings')
-rw-r--r--upb/bindings/lua/upb/pb.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/upb/bindings/lua/upb/pb.c b/upb/bindings/lua/upb/pb.c
index 466e8f7..bca2ee8 100644
--- a/upb/bindings/lua/upb/pb.c
+++ b/upb/bindings/lua/upb/pb.c
@@ -13,21 +13,13 @@
static int lupb_pb_decode(lua_State *L) {
size_t len;
- upb_status status = UPB_STATUS_INIT;
const upb_msglayout *layout;
upb_msg *msg = lupb_msg_checkmsg2(L, 1, &layout);
const char *pb = lua_tolstring(L, 2, &len);
upb_stringview buf = upb_stringview_make(pb, len);
- upb_env env;
- upb_env_init(&env);
- upb_env_reporterrorsto(&env, &status);
-
- upb_decode(buf, msg, (const void*)layout, &env);
-
- /* Free resources before we potentially bail on error. */
- upb_env_uninit(&env);
- lupb_checkstatus(L, &status);
+ upb_decode(buf, msg, layout);
+ /* TODO(haberman): check for error. */
return 0;
}
@@ -35,21 +27,19 @@ static int lupb_pb_decode(lua_State *L) {
static int lupb_pb_encode(lua_State *L) {
const upb_msglayout *layout;
const upb_msg *msg = lupb_msg_checkmsg2(L, 1, &layout);
- upb_env env;
+ upb_arena arena;
size_t size;
- upb_status status = UPB_STATUS_INIT;
char *result;
- upb_env_init(&env);
- upb_env_reporterrorsto(&env, &status);
+ upb_arena_init(&arena);
- result = upb_encode(msg, (const void*)layout, &env, &size);
+ result = upb_encode(msg, (const void*)layout, &arena, &size);
/* Free resources before we potentially bail on error. */
- upb_env_uninit(&env);
- lupb_checkstatus(L, &status);
-
lua_pushlstring(L, result, size);
+ upb_arena_uninit(&arena);
+ /* TODO(haberman): check for error. */
+
return 1;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback