| 1698 | } |
| 1699 | |
| 1700 | static int Lpb_pack(lua_State* L) { |
| 1701 | lpb_State* LS = lpb_lstate(L); |
| 1702 | const pb_Type* t = lpb_type(LS, lpb_checkslice(L, 1)); |
| 1703 | lpb_Env e; |
| 1704 | int idx = 3; |
| 1705 | e.L = L, e.LS = LS, e.b = test_buffer(L, 2); |
| 1706 | if (e.b == NULL) { |
| 1707 | idx = 2; |
| 1708 | pb_resetbuffer(e.b = &LS->buffer); |
| 1709 | } |
| 1710 | lpbE_pack(&e, t, idx); |
| 1711 | if (e.b != &LS->buffer) |
| 1712 | lua_settop(L, 3); |
| 1713 | else { |
| 1714 | lua_pushlstring(L, pb_buffer(e.b), pb_bufflen(e.b)); |
| 1715 | pb_resetbuffer(e.b); |
| 1716 | } |
| 1717 | return 1; |
| 1718 | } |
| 1719 | |
| 1720 | /* protobuf decode */ |
| 1721 |
nothing calls this directly
no test coverage detected