| 1767 | } |
| 1768 | |
| 1769 | static void lpbD_rawfield(lpb_Env *e, const pb_Field *f) { |
| 1770 | lua_State *L = e->L; |
| 1771 | pb_Slice sv, *s = e->s; |
| 1772 | const pb_Field *ev = NULL; |
| 1773 | uint64_t u64; |
| 1774 | switch (f->type_id) { |
| 1775 | case PB_Tenum: |
| 1776 | if (pb_readvarint64(s, &u64) == 0) |
| 1777 | luaL_error(L, "invalid varint value at offset %d", pb_pos(*s)+1); |
| 1778 | if (!lpb_lstate(L)->enum_as_value) |
| 1779 | ev = pb_field(f->type, (int32_t)u64); |
| 1780 | if (ev) lua_pushstring(L, (const char*)ev->name); |
| 1781 | else lpb_pushinteger(L, (lua_Integer)u64, 1, lpb_lstate(L)->int64_mode); |
| 1782 | if (e->LS->use_dec_hooks) lpb_usedechooks(L, e->LS, f->type); |
| 1783 | break; |
| 1784 | |
| 1785 | case PB_Tmessage: |
| 1786 | lpb_readbytes(L, s, &sv); |
| 1787 | if (f->type == NULL || f->type->is_dead) |
| 1788 | lua_pushnil(L); |
| 1789 | else { |
| 1790 | lpb_pushtypetable(L, e->LS, f->type); |
| 1791 | lpb_withinput(e, &sv, lpbD_message(e, f->type)); |
| 1792 | } |
| 1793 | break; |
| 1794 | |
| 1795 | default: |
| 1796 | lpb_readtype(L, e->LS, f->type_id, s); |
| 1797 | } |
| 1798 | } |
| 1799 | |
| 1800 | static void lpbD_checktype(lpb_Env *e, const pb_Field *f, uint32_t tag) { |
| 1801 | if (pb_wtypebytype(f->type_id) == (int)pb_gettype(tag)) return; |
no test coverage detected