Squashed 'third_party/upb/' changes from bb2db35464..02c89a8b15

02c89a8b15 Renamed textencode -> text_encode for greater readability. (#249)

git-subtree-dir: third_party/upb
git-subtree-split: 02c89a8b15d0ce2a4a75ef16fc398913827354fd
pull/23140/head
Mark D. Roth 5 years ago
parent 08435c6784
commit 657bcfb5ad
  1. 4
      BUILD
  2. 4
      CMakeLists.txt
  3. 8
      tests/conformance_upb.c
  4. 6
      upb/bindings/lua/msg.c
  5. 8
      upb/text_encode.c
  6. 6
      upb/text_encode.h

@ -145,10 +145,10 @@ cc_library(
cc_library(
name = "textformat",
srcs = [
"upb/textencode.c",
"upb/text_encode.c",
],
hdrs = [
"upb/textencode.h",
"upb/text_encode.h",
],
visibility = ["//visibility:public"],
deps = [

@ -89,8 +89,8 @@ target_link_libraries(reflection
table
upb)
add_library(textformat
upb/textencode.c
upb/textencode.h)
upb/text_encode.c
upb/text_encode.h)
target_link_libraries(textformat
reflection)
add_library(table INTERFACE)

@ -15,7 +15,7 @@
#include "upb/decode.h"
#include "upb/encode.h"
#include "upb/reflection.h"
#include "upb/textencode.h"
#include "upb/text_encode.h"
int test_count = 0;
bool verbose = false; /* Set to true to get req/resp printed on stderr. */
@ -87,9 +87,9 @@ void serialize_text(const upb_msg *msg, const upb_msgdef *m, const ctx *c) {
if (!conformance_ConformanceRequest_print_unknown_fields(c->request)) {
opts |= UPB_TXTENC_SKIPUNKNOWN;
}
len = upb_textencode(msg, m, c->symtab, opts, NULL, 0);
len = upb_text_encode(msg, m, c->symtab, opts, NULL, 0);
data = upb_arena_malloc(c->arena, len + 1);
len2 = upb_textencode(msg, m, c->symtab, opts, data, len + 1);
len2 = upb_text_encode(msg, m, c->symtab, opts, data, len + 1);
assert(len == len2);
conformance_ConformanceResponse_set_text_payload(
c->response, upb_strview_make(data, len));
@ -153,7 +153,7 @@ void DoTest(const ctx* c) {
void debug_print(const char *label, const upb_msg *msg, const upb_msgdef *m,
const ctx *c) {
char buf[512];
upb_textencode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf));
upb_text_encode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf));
fprintf(stderr, "%s: %s\n", label, buf);
}

@ -13,7 +13,7 @@
#include "lauxlib.h"
#include "upb/bindings/lua/upb.h"
#include "upb/reflection.h"
#include "upb/textencode.h"
#include "upb/text_encode.h"
#include "upb/port_def.inc"
@ -905,13 +905,13 @@ static int lupb_msg_tostring(lua_State *L) {
lua_getiuservalue(L, 1, LUPB_MSGDEF_INDEX);
m = lupb_msgdef_check(L, -1);
size = upb_textencode(msg, m, NULL, 0, buf, sizeof(buf));
size = upb_text_encode(msg, m, NULL, 0, buf, sizeof(buf));
if (size < sizeof(buf)) {
lua_pushlstring(L, buf, size);
} else {
char *ptr = malloc(size + 1);
upb_textencode(msg, m, NULL, 0, ptr, size + 1);
upb_text_encode(msg, m, NULL, 0, ptr, size + 1);
lua_pushlstring(L, ptr, size);
free(ptr);
}

@ -1,5 +1,5 @@
#include "upb/textencode.h"
#include "upb/text_encode.h"
#include <ctype.h>
#include <float.h>
@ -376,9 +376,9 @@ size_t txtenc_nullz(txtenc *e, size_t size) {
return ret;
}
size_t upb_textencode(const upb_msg *msg, const upb_msgdef *m,
const upb_symtab *ext_pool, int options, char *buf,
size_t size) {
size_t upb_text_encode(const upb_msg *msg, const upb_msgdef *m,
const upb_symtab *ext_pool, int options, char *buf,
size_t size) {
txtenc e;
e.buf = buf;

@ -24,9 +24,9 @@ enum {
* size (excluding NULL) is returned. This means that a return value >= |size|
* implies that the output was truncated. (These are the same semantics as
* snprintf()). */
size_t upb_textencode(const upb_msg *msg, const upb_msgdef *m,
const upb_symtab *ext_pool, int options, char *buf,
size_t size);
size_t upb_text_encode(const upb_msg *msg, const upb_msgdef *m,
const upb_symtab *ext_pool, int options, char *buf,
size_t size);
#ifdef __cplusplus
} /* extern "C" */
Loading…
Cancel
Save