summaryrefslogtreecommitdiff
path: root/upb/bindings
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-09-03 15:06:43 -0700
committerJoshua Haberman <jhaberman@gmail.com>2018-09-03 15:06:43 -0700
commit694d51f4d6cb8adf4a2f7975e5bb899327875de7 (patch)
tree29ea62eeb151c4cfc739522e19ee30dbee57a137 /upb/bindings
parent41379a7064b6488099f203521fb69ceea0f6cc15 (diff)
Changed C API to only define structs, a table, and a few minimal inline functions.
Diffstat (limited to 'upb/bindings')
-rw-r--r--upb/bindings/lua/upb/pb.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/upb/bindings/lua/upb/pb.c b/upb/bindings/lua/upb/pb.c
index 466e8f7..15e8107 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,20 @@ 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