| 1468 | } |
| 1469 | |
| 1470 | static 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 */ |
nothing calls this directly
no test coverage detected