MCPcopy Create free account
hub / github.com/Tencent/UnLua / Lpb_typefmt

Function Lpb_typefmt

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.cpp:1470–1496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470static int Lpb_typefmt(lua_State *L) {
1471 pb_Slice s = lpb_checkslice(L, 1);
1472 const char *r = NULL;
1473 char buf[2] = {0};
1474 int type;
1475 if (pb_len(s) == 1)
1476 r = pb_typename(type = lpb_typefmt(*s.p), "!");
1477 else if (lpb_type(lpb_lstate(L), s))
1478 r = "message", type = PB_TBYTES;
1479 else if ((type = pb_typebyname(s.p, PB_Tmessage)) != PB_Tmessage) {
1480 switch (type) {
1481#define X(name,type,fmt) case PB_T##name: buf[0] = fmt, r = buf; break;
1482 PB_TYPES(X)
1483#undef X
1484 }
1485 type = pb_wtypebytype(type);
1486 } else if ((type = pb_wtypebyname(s.p, PB_Tmessage)) != PB_Tmessage) {
1487 switch (type) {
1488#define X(id,name,fmt) case PB_T##id: buf[0] = fmt, r = buf; break;
1489 PB_WIRETYPES(X)
1490#undef X
1491 }
1492 }
1493 lua_pushstring(L, r ? r : "!");
1494 lua_pushinteger(L, type);
1495 return 2;
1496}
1497
1498
1499/* protobuf encode */

Callers

nothing calls this directly

Calls 11

lpb_checksliceFunction · 0.85
pb_lenFunction · 0.85
pb_typenameFunction · 0.85
lpb_typefmtFunction · 0.85
lpb_typeFunction · 0.85
lpb_lstateFunction · 0.85
pb_typebynameFunction · 0.85
pb_wtypebytypeFunction · 0.85
pb_wtypebynameFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected