diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-03-26 10:37:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-26 10:37:37 -0700 |
commit | e999afb61255179d563375e2748a02c036e927e3 (patch) | |
tree | 0278856cbd0263bdddd2f0c68259d3ec2ea383d5 /upb | |
parent | a8a0bc73b981bd94509c180ad8cac36143c479ec (diff) | |
parent | 0abf6083b33b13bea895bf5d885c5ec58b2bd986 (diff) |
Merge pull request #150 from haberman/apitweaks
A few small API tweaks.
Diffstat (limited to 'upb')
-rw-r--r-- | upb/bindings/lua/def.c | 3 | ||||
-rw-r--r-- | upb/bindings/lua/upb/pb.c | 3 | ||||
-rw-r--r-- | upb/decode.c | 7 | ||||
-rw-r--r-- | upb/decode.h | 3 | ||||
-rw-r--r-- | upb/def.c | 3 |
5 files changed, 10 insertions, 9 deletions
diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c index 3868179..a9ab9a8 100644 --- a/upb/bindings/lua/def.c +++ b/upb/bindings/lua/def.c @@ -639,8 +639,7 @@ static int lupb_symtab_add(lua_State *L) { lupb_arena_new(L); arena = lupb_arena_check(L, -1); - set = google_protobuf_FileDescriptorSet_parsenew(upb_strview_make(str, len), - arena); + set = google_protobuf_FileDescriptorSet_parse(str, len, arena); if (!set) { luaL_argerror(L, 2, "failed to parse descriptor"); diff --git a/upb/bindings/lua/upb/pb.c b/upb/bindings/lua/upb/pb.c index e60dcde..b02fa3e 100644 --- a/upb/bindings/lua/upb/pb.c +++ b/upb/bindings/lua/upb/pb.c @@ -16,9 +16,8 @@ static int lupb_pb_decode(lua_State *L) { const upb_msglayout *layout; upb_msg *msg = lupb_msg_checkmsg2(L, 1, &layout); const char *pb = lua_tolstring(L, 2, &len); - upb_strview buf = upb_strview_make(pb, len); - upb_decode(buf, msg, layout); + upb_decode(pb, len, msg, layout); /* TODO(haberman): check for error. */ return 0; diff --git a/upb/decode.c b/upb/decode.c index f43f18f..8ea0573 100644 --- a/upb/decode.c +++ b/upb/decode.c @@ -585,11 +585,12 @@ static bool upb_decode_message(upb_decstate *d, const char *limit, return true; } -bool upb_decode(upb_strview buf, void *msg, const upb_msglayout *l) { +bool upb_decode(const char *buf, size_t size, void *msg, + const upb_msglayout *l) { upb_decstate state; - state.ptr = buf.data; + state.ptr = buf; - return upb_decode_message(&state, buf.data + buf.size, 0, msg, l); + return upb_decode_message(&state, buf + size, 0, msg, l); } #undef CHK diff --git a/upb/decode.h b/upb/decode.h index 275f138..d21b659 100644 --- a/upb/decode.h +++ b/upb/decode.h @@ -11,7 +11,8 @@ extern "C" { #endif -bool upb_decode(upb_strview buf, upb_msg *msg, const upb_msglayout *l); +bool upb_decode(const char *buf, size_t size, upb_msg *msg, + const upb_msglayout *l); #ifdef __cplusplus } /* extern "C" */ @@ -1743,7 +1743,8 @@ bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init) { if (!_upb_symtab_loaddefinit(s, *deps)) goto err; } - file = google_protobuf_FileDescriptorProto_parsenew(init->descriptor, arena); + file = google_protobuf_FileDescriptorProto_parse( + init->descriptor.data, init->descriptor.size, arena); if (!file) { upb_status_seterrf( |