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

pull/13171/head
Joshua Haberman 5 years ago committed by GitHub
parent bb2db35464
commit 02c89a8b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      BUILD
  2. 4
      CMakeLists.txt
  3. 8
      tests/conformance_upb.c
  4. 6
      upb/bindings/lua/msg.c
  5. 4
      upb/text_encode.c
  6. 2
      upb/text_encode.h

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

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

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

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

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

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