From cd214fe73d4807162a5e85a0faa406b3d8d18881 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 12 Jan 2022 10:43:49 -0800 Subject: [PATCH] upb_TextEncode. --- python/message.c | 5 ++--- rename.sed | 1 + tests/conformance_upb.c | 6 +++--- upb/bindings/lua/msg.c | 8 ++++---- upb/text_encode.c | 6 +++--- upb/text_encode.h | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/python/message.c b/python/message.c index 8cfa4aa674..5de428a2b5 100644 --- a/python/message.c +++ b/python/message.c @@ -680,13 +680,12 @@ static PyObject* PyUpb_CMessage_ToString(PyUpb_CMessage* self) { const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(msgdef)); char buf[1024]; int options = UPB_TXTENC_SKIPUNKNOWN; - size_t size = upb_text_encode(msg, msgdef, symtab, options, buf, sizeof(buf)); + size_t size = upb_TextEncode(msg, msgdef, symtab, options, buf, sizeof(buf)); if (size < sizeof(buf)) { return PyUnicode_FromStringAndSize(buf, size); } else { char* buf2 = malloc(size + 1); - size_t size2 = - upb_text_encode(msg, msgdef, symtab, options, buf2, size + 1); + size_t size2 = upb_TextEncode(msg, msgdef, symtab, options, buf2, size + 1); assert(size == size2); PyObject* ret = PyUnicode_FromStringAndSize(buf2, size2); free(buf2); diff --git a/rename.sed b/rename.sed index 50fde5d935..2648c0029c 100644 --- a/rename.sed +++ b/rename.sed @@ -444,3 +444,4 @@ s/upb_extreg_new/upb_ExtensionRegistry_New/g; s/upb_msg\b/upb_Message/g; s/_upb_decode\b/upb_Decode/g; s/upb_EncodeEx\b/upb_Encode/g; +s/upb_text_encode/upb_TextEncode/g; diff --git a/tests/conformance_upb.c b/tests/conformance_upb.c index d259e4364b..5f912f0c40 100644 --- a/tests/conformance_upb.c +++ b/tests/conformance_upb.c @@ -124,9 +124,9 @@ void serialize_text(const upb_Message* msg, const upb_MessageDef* m, opts |= UPB_TXTENC_SKIPUNKNOWN; } - len = upb_text_encode(msg, m, c->symtab, opts, NULL, 0); + len = upb_TextEncode(msg, m, c->symtab, opts, NULL, 0); data = upb_Arena_Malloc(c->arena, len + 1); - len2 = upb_text_encode(msg, m, c->symtab, opts, data, len + 1); + len2 = upb_TextEncode(msg, m, c->symtab, opts, data, len + 1); UPB_ASSERT(len == len2); conformance_ConformanceResponse_set_text_payload( c->response, upb_StringView_FromDataAndSize(data, len)); @@ -262,7 +262,7 @@ void DoTest(const ctx* c) { void debug_print(const char* label, const upb_Message* msg, const upb_MessageDef* m, const ctx* c) { char buf[512]; - upb_text_encode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf)); + upb_TextEncode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf)); fprintf(stderr, "%s: %s\n", label, buf); } diff --git a/upb/bindings/lua/msg.c b/upb/bindings/lua/msg.c index f40b957ea9..05bf52ae30 100644 --- a/upb/bindings/lua/msg.c +++ b/upb/bindings/lua/msg.c @@ -907,13 +907,13 @@ static int lupb_msg_tostring(lua_State* L) { lua_getiuservalue(L, 1, LUPB_MSGDEF_INDEX); m = lupb_MessageDef_check(L, -1); - size = upb_text_encode(msg, m, NULL, 0, buf, sizeof(buf)); + size = upb_TextEncode(msg, m, NULL, 0, buf, sizeof(buf)); if (size < sizeof(buf)) { lua_pushlstring(L, buf, size); } else { char* ptr = malloc(size + 1); - upb_text_encode(msg, m, NULL, 0, ptr, size + 1); + upb_TextEncode(msg, m, NULL, 0, ptr, size + 1); lua_pushlstring(L, ptr, size); free(ptr); } @@ -1070,13 +1070,13 @@ static int lupb_textencode(lua_State* L) { char buf[1024]; size_t size; - size = upb_text_encode(msg, m, NULL, options, buf, sizeof(buf)); + size = upb_TextEncode(msg, m, NULL, options, buf, sizeof(buf)); if (size < sizeof(buf)) { lua_pushlstring(L, buf, size); } else { char* ptr = malloc(size + 1); - upb_text_encode(msg, m, NULL, options, ptr, size + 1); + upb_TextEncode(msg, m, NULL, options, ptr, size + 1); lua_pushlstring(L, ptr, size); free(ptr); } diff --git a/upb/text_encode.c b/upb/text_encode.c index e51a316a44..5067a27461 100644 --- a/upb/text_encode.c +++ b/upb/text_encode.c @@ -445,9 +445,9 @@ size_t txtenc_nullz(txtenc* e, size_t size) { return ret; } -size_t upb_text_encode(const upb_Message* msg, const upb_MessageDef* m, - const upb_DefPool* ext_pool, int options, char* buf, - size_t size) { +size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, int options, char* buf, + size_t size) { txtenc e; e.buf = buf; diff --git a/upb/text_encode.h b/upb/text_encode.h index c7651b6ce5..2e817a3e50 100644 --- a/upb/text_encode.h +++ b/upb/text_encode.h @@ -53,9 +53,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_text_encode(const upb_Message* msg, const upb_MessageDef* m, - const upb_DefPool* ext_pool, int options, char* buf, - size_t size); +size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m, + const upb_DefPool* ext_pool, int options, char* buf, + size_t size); #ifdef __cplusplus } /* extern "C" */