From 694d51f4d6cb8adf4a2f7975e5bb899327875de7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 3 Sep 2018 15:06:43 -0700 Subject: Changed C API to only define structs, a table, and a few minimal inline functions. --- upb/bindings/lua/upb/pb.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'upb/bindings') 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; } -- cgit v1.2.3 From ba03d65a8f94b4146b6afc0e46238cfcb08da2d4 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 6 Sep 2018 13:29:46 -0700 Subject: Removed unused variable. --- CMakeLists.txt | 1 + tests/conformance_upb.c | 2 +- upb/bindings/lua/upb/pb.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'upb/bindings') diff --git a/CMakeLists.txt b/CMakeLists.txt index 236fd4d..2b068e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ endif() include_directories(.) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_CXX_FLAGS "-std=c++11 -W -Wall -Wno-sign-compare") +set(CMAKE_C_FLAGS "-std=c89 -W -Wall -Wno-sign-compare") if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace") diff --git a/tests/conformance_upb.c b/tests/conformance_upb.c index a2e1d7a..ccc8a94 100644 --- a/tests/conformance_upb.c +++ b/tests/conformance_upb.c @@ -141,7 +141,7 @@ bool DoTestIo() { conformance_ConformanceResponse *response; if (!CheckedRead(STDIN_FILENO, &input_size, sizeof(uint32_t))) { - // EOF. + /* EOF. */ return false; } diff --git a/upb/bindings/lua/upb/pb.c b/upb/bindings/lua/upb/pb.c index 15e8107..bca2ee8 100644 --- a/upb/bindings/lua/upb/pb.c +++ b/upb/bindings/lua/upb/pb.c @@ -29,7 +29,6 @@ static int lupb_pb_encode(lua_State *L) { const upb_msg *msg = lupb_msg_checkmsg2(L, 1, &layout); upb_arena arena; size_t size; - upb_status status = UPB_STATUS_INIT; char *result; upb_arena_init(&arena); -- cgit v1.2.3