-- Code generated by protoc-gen-tarantool. DO NOT EDIT. -- source: c_nested.proto -- syntax: proto3 -- package: c_nested local pb = require("pb") local wire = pb.wire local string_byte = string.byte local band = bit.band local rshift = bit.rshift local M = {} M.options = {go_package = "tarantoolpb_synthetic/c_nested"} -- Pre-declare message descriptors so cross-references resolve. M.L1_descriptor = {name = "c_nested.L1"} M.L2_descriptor = {name = "c_nested.L2"} M.L3_descriptor = {name = "c_nested.L3"} M.L4_descriptor = {name = "c_nested.L4"} M.L5_descriptor = {name = "c_nested.L5"} -- Message: c_nested.L1 M.L1_descriptor.fields = { {name="next", id=1, kind='message', message=M.L2_descriptor}, {name="v", id=2, kind='scalar', proto_type="int32"}, } pb.finalize_message(M.L1_descriptor) M.L1_fields = pb.field_names({ next = "next", v = "v", }) -- Message: c_nested.L2 M.L2_descriptor.fields = { {name="next", id=1, kind='message', message=M.L3_descriptor}, {name="v", id=2, kind='scalar', proto_type="int32"}, } pb.finalize_message(M.L2_descriptor) M.L2_fields = pb.field_names({ next = "next", v = "v", }) -- Message: c_nested.L3 M.L3_descriptor.fields = { {name="next", id=1, kind='message', message=M.L4_descriptor}, {name="v", id=2, kind='scalar', proto_type="int32"}, } pb.finalize_message(M.L3_descriptor) M.L3_fields = pb.field_names({ next = "next", v = "v", }) -- Message: c_nested.L4 M.L4_descriptor.fields = { {name="next", id=1, kind='message', message=M.L5_descriptor}, {name="v", id=2, kind='scalar', proto_type="int32"}, } pb.finalize_message(M.L4_descriptor) M.L4_fields = pb.field_names({ next = "next", v = "v", }) -- Message: c_nested.L5 M.L5_descriptor.fields = { {name="v", id=2, kind='scalar', proto_type="int32"}, } pb.finalize_message(M.L5_descriptor) M.L5_fields = pb.field_names({ v = "v", }) -- EmmyLua / lua-language-server type annotations. -- These are comments — no runtime effect. They give editors -- autocomplete and type-checking for the generated wrappers. --- 5-level chain of singular sub-messages. Used by the bd-hwe (ra6 3d) --- C-runtime tests to verify recursion across non-trivial depth. Each --- level carries an int32 so the encoded body at each level is --- non-empty (catches off-by-one bugs in the length-prefix path). ---@class c_nested.L1 ---@field next c_nested.L2 ---@field v integer ---@class c_nested.L2 ---@field next c_nested.L3 ---@field v integer ---@class c_nested.L3 ---@field next c_nested.L4 ---@field v integer ---@class c_nested.L4 ---@field next c_nested.L5 ---@field v integer ---@class c_nested.L5 ---@field v integer ---@param t? c_nested.L1 ---@return c_nested.L1 function M.L1_new(t) return t or {} end ---@param t c_nested.L1 ---@return string function M.L1_encode(t) if type(t) ~= 'table' then error("expected table for c_nested.L1, got " .. type(t), 0) end local out, n = {}, 0 local v -- field 1: next v = t.next if v ~= nil or type(v) == 'cdata' then local _b = M.L2_encode(v) n = n + 1; out[n] = "\x0a" local _len = #_b if _len < 128 then n = n + 1; out[n] = string.char(_len) else n = n + 1; out[n] = wire.encode_varint(_len) end n = n + 1; out[n] = _b end -- field 2: v v = t.v if v ~= nil and v ~= 0 then n = n + 1; out[n] = "\x10" n = n + 1; out[n] = wire.encode_int32(v) end local _exts = t._extensions if _exts ~= nil then local _elist = M.L1_descriptor.extensions_list if _elist ~= nil then for _i = 1, #_elist do local _ext = _elist[_i] local _ev = _exts[_ext.full_name] if _ev ~= nil then pb.codec.encode_field(_ext, _ev, out, true) end end n = #out end end local _uf = t._unknown_fields if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end return table.concat(out) end ---@param b string ---@return c_nested.L1 function M.L1_decode(buf) if type(buf) ~= 'string' then error("expected string for c_nested.L1 decode, got " .. type(buf), 0) end local result = {} local pos, len = 1, #buf local _uf while pos <= len do local _tag_start = pos local id, wt local _b = string_byte(buf, pos) if _b ~= nil and _b < 0x80 then wt = band(_b, 7) if wt >= 6 then error("illegal wire type " .. wt, 0) end id = rshift(_b, 3) if id == 0 then error("illegal field number 0", 0) end pos = pos + 1 else id, wt, pos = wire.decode_tag(buf, pos) end if id == 1 then local payload payload, pos = wire.decode_len(buf, pos) local prev = result.next if prev == nil then result.next = M.L2_decode(payload) else pb.codec.merge_message(M.L2_descriptor, prev, M.L2_decode(payload)) end elseif id == 2 then local val val, pos = wire.decode_int32(buf, pos) result.v = val else local _ebid = M.L1_descriptor.extensions_by_id local _ext = _ebid and _ebid[id] or nil if _ext ~= nil then pos = pb.codec.decode_extension(_ext, buf, pos, wt, result) else pos = wire.skip_field(buf, pos, wt, id) if _uf == nil then _uf = {} end _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1) end end end if _uf ~= nil then result._unknown_fields = table.concat(_uf) end return result end ---@param b string ---@return pb.MessageView function M.L1_decode_lazy(b) return pb.decode_lazy(M.L1_descriptor, b) end ---@param t c_nested.L1 ---@param opts? {single_line: boolean?, indent: string?} ---@return string function M.L1_text(t, opts) return pb.text.encode(M.L1_descriptor, t, opts) end ---@param t? c_nested.L2 ---@return c_nested.L2 function M.L2_new(t) return t or {} end ---@param t c_nested.L2 ---@return string function M.L2_encode(t) if type(t) ~= 'table' then error("expected table for c_nested.L2, got " .. type(t), 0) end local out, n = {}, 0 local v -- field 1: next v = t.next if v ~= nil or type(v) == 'cdata' then local _b = M.L3_encode(v) n = n + 1; out[n] = "\x0a" local _len = #_b if _len < 128 then n = n + 1; out[n] = string.char(_len) else n = n + 1; out[n] = wire.encode_varint(_len) end n = n + 1; out[n] = _b end -- field 2: v v = t.v if v ~= nil and v ~= 0 then n = n + 1; out[n] = "\x10" n = n + 1; out[n] = wire.encode_int32(v) end local _exts = t._extensions if _exts ~= nil then local _elist = M.L2_descriptor.extensions_list if _elist ~= nil then for _i = 1, #_elist do local _ext = _elist[_i] local _ev = _exts[_ext.full_name] if _ev ~= nil then pb.codec.encode_field(_ext, _ev, out, true) end end n = #out end end local _uf = t._unknown_fields if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end return table.concat(out) end ---@param b string ---@return c_nested.L2 function M.L2_decode(buf) if type(buf) ~= 'string' then error("expected string for c_nested.L2 decode, got " .. type(buf), 0) end local result = {} local pos, len = 1, #buf local _uf while pos <= len do local _tag_start = pos local id, wt local _b = string_byte(buf, pos) if _b ~= nil and _b < 0x80 then wt = band(_b, 7) if wt >= 6 then error("illegal wire type " .. wt, 0) end id = rshift(_b, 3) if id == 0 then error("illegal field number 0", 0) end pos = pos + 1 else id, wt, pos = wire.decode_tag(buf, pos) end if id == 1 then local payload payload, pos = wire.decode_len(buf, pos) local prev = result.next if prev == nil then result.next = M.L3_decode(payload) else pb.codec.merge_message(M.L3_descriptor, prev, M.L3_decode(payload)) end elseif id == 2 then local val val, pos = wire.decode_int32(buf, pos) result.v = val else local _ebid = M.L2_descriptor.extensions_by_id local _ext = _ebid and _ebid[id] or nil if _ext ~= nil then pos = pb.codec.decode_extension(_ext, buf, pos, wt, result) else pos = wire.skip_field(buf, pos, wt, id) if _uf == nil then _uf = {} end _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1) end end end if _uf ~= nil then result._unknown_fields = table.concat(_uf) end return result end ---@param b string ---@return pb.MessageView function M.L2_decode_lazy(b) return pb.decode_lazy(M.L2_descriptor, b) end ---@param t c_nested.L2 ---@param opts? {single_line: boolean?, indent: string?} ---@return string function M.L2_text(t, opts) return pb.text.encode(M.L2_descriptor, t, opts) end ---@param t? c_nested.L3 ---@return c_nested.L3 function M.L3_new(t) return t or {} end ---@param t c_nested.L3 ---@return string function M.L3_encode(t) if type(t) ~= 'table' then error("expected table for c_nested.L3, got " .. type(t), 0) end local out, n = {}, 0 local v -- field 1: next v = t.next if v ~= nil or type(v) == 'cdata' then local _b = M.L4_encode(v) n = n + 1; out[n] = "\x0a" local _len = #_b if _len < 128 then n = n + 1; out[n] = string.char(_len) else n = n + 1; out[n] = wire.encode_varint(_len) end n = n + 1; out[n] = _b end -- field 2: v v = t.v if v ~= nil and v ~= 0 then n = n + 1; out[n] = "\x10" n = n + 1; out[n] = wire.encode_int32(v) end local _exts = t._extensions if _exts ~= nil then local _elist = M.L3_descriptor.extensions_list if _elist ~= nil then for _i = 1, #_elist do local _ext = _elist[_i] local _ev = _exts[_ext.full_name] if _ev ~= nil then pb.codec.encode_field(_ext, _ev, out, true) end end n = #out end end local _uf = t._unknown_fields if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end return table.concat(out) end ---@param b string ---@return c_nested.L3 function M.L3_decode(buf) if type(buf) ~= 'string' then error("expected string for c_nested.L3 decode, got " .. type(buf), 0) end local result = {} local pos, len = 1, #buf local _uf while pos <= len do local _tag_start = pos local id, wt local _b = string_byte(buf, pos) if _b ~= nil and _b < 0x80 then wt = band(_b, 7) if wt >= 6 then error("illegal wire type " .. wt, 0) end id = rshift(_b, 3) if id == 0 then error("illegal field number 0", 0) end pos = pos + 1 else id, wt, pos = wire.decode_tag(buf, pos) end if id == 1 then local payload payload, pos = wire.decode_len(buf, pos) local prev = result.next if prev == nil then result.next = M.L4_decode(payload) else pb.codec.merge_message(M.L4_descriptor, prev, M.L4_decode(payload)) end elseif id == 2 then local val val, pos = wire.decode_int32(buf, pos) result.v = val else local _ebid = M.L3_descriptor.extensions_by_id local _ext = _ebid and _ebid[id] or nil if _ext ~= nil then pos = pb.codec.decode_extension(_ext, buf, pos, wt, result) else pos = wire.skip_field(buf, pos, wt, id) if _uf == nil then _uf = {} end _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1) end end end if _uf ~= nil then result._unknown_fields = table.concat(_uf) end return result end ---@param b string ---@return pb.MessageView function M.L3_decode_lazy(b) return pb.decode_lazy(M.L3_descriptor, b) end ---@param t c_nested.L3 ---@param opts? {single_line: boolean?, indent: string?} ---@return string function M.L3_text(t, opts) return pb.text.encode(M.L3_descriptor, t, opts) end ---@param t? c_nested.L4 ---@return c_nested.L4 function M.L4_new(t) return t or {} end ---@param t c_nested.L4 ---@return string function M.L4_encode(t) if type(t) ~= 'table' then error("expected table for c_nested.L4, got " .. type(t), 0) end local out, n = {}, 0 local v -- field 1: next v = t.next if v ~= nil or type(v) == 'cdata' then local _b = M.L5_encode(v) n = n + 1; out[n] = "\x0a" local _len = #_b if _len < 128 then n = n + 1; out[n] = string.char(_len) else n = n + 1; out[n] = wire.encode_varint(_len) end n = n + 1; out[n] = _b end -- field 2: v v = t.v if v ~= nil and v ~= 0 then n = n + 1; out[n] = "\x10" n = n + 1; out[n] = wire.encode_int32(v) end local _exts = t._extensions if _exts ~= nil then local _elist = M.L4_descriptor.extensions_list if _elist ~= nil then for _i = 1, #_elist do local _ext = _elist[_i] local _ev = _exts[_ext.full_name] if _ev ~= nil then pb.codec.encode_field(_ext, _ev, out, true) end end n = #out end end local _uf = t._unknown_fields if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end return table.concat(out) end ---@param b string ---@return c_nested.L4 function M.L4_decode(buf) if type(buf) ~= 'string' then error("expected string for c_nested.L4 decode, got " .. type(buf), 0) end local result = {} local pos, len = 1, #buf local _uf while pos <= len do local _tag_start = pos local id, wt local _b = string_byte(buf, pos) if _b ~= nil and _b < 0x80 then wt = band(_b, 7) if wt >= 6 then error("illegal wire type " .. wt, 0) end id = rshift(_b, 3) if id == 0 then error("illegal field number 0", 0) end pos = pos + 1 else id, wt, pos = wire.decode_tag(buf, pos) end if id == 1 then local payload payload, pos = wire.decode_len(buf, pos) local prev = result.next if prev == nil then result.next = M.L5_decode(payload) else pb.codec.merge_message(M.L5_descriptor, prev, M.L5_decode(payload)) end elseif id == 2 then local val val, pos = wire.decode_int32(buf, pos) result.v = val else local _ebid = M.L4_descriptor.extensions_by_id local _ext = _ebid and _ebid[id] or nil if _ext ~= nil then pos = pb.codec.decode_extension(_ext, buf, pos, wt, result) else pos = wire.skip_field(buf, pos, wt, id) if _uf == nil then _uf = {} end _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1) end end end if _uf ~= nil then result._unknown_fields = table.concat(_uf) end return result end ---@param b string ---@return pb.MessageView function M.L4_decode_lazy(b) return pb.decode_lazy(M.L4_descriptor, b) end ---@param t c_nested.L4 ---@param opts? {single_line: boolean?, indent: string?} ---@return string function M.L4_text(t, opts) return pb.text.encode(M.L4_descriptor, t, opts) end ---@param t? c_nested.L5 ---@return c_nested.L5 function M.L5_new(t) return t or {} end ---@param t c_nested.L5 ---@return string function M.L5_encode(t) if type(t) ~= 'table' then error("expected table for c_nested.L5, got " .. type(t), 0) end local out, n = {}, 0 local v -- field 2: v v = t.v if v ~= nil and v ~= 0 then n = n + 1; out[n] = "\x10" n = n + 1; out[n] = wire.encode_int32(v) end local _exts = t._extensions if _exts ~= nil then local _elist = M.L5_descriptor.extensions_list if _elist ~= nil then for _i = 1, #_elist do local _ext = _elist[_i] local _ev = _exts[_ext.full_name] if _ev ~= nil then pb.codec.encode_field(_ext, _ev, out, true) end end n = #out end end local _uf = t._unknown_fields if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end return table.concat(out) end ---@param b string ---@return c_nested.L5 function M.L5_decode(buf) if type(buf) ~= 'string' then error("expected string for c_nested.L5 decode, got " .. type(buf), 0) end local result = {} local pos, len = 1, #buf local _uf while pos <= len do local _tag_start = pos local id, wt local _b = string_byte(buf, pos) if _b ~= nil and _b < 0x80 then wt = band(_b, 7) if wt >= 6 then error("illegal wire type " .. wt, 0) end id = rshift(_b, 3) if id == 0 then error("illegal field number 0", 0) end pos = pos + 1 else id, wt, pos = wire.decode_tag(buf, pos) end if id == 2 then local val val, pos = wire.decode_int32(buf, pos) result.v = val else local _ebid = M.L5_descriptor.extensions_by_id local _ext = _ebid and _ebid[id] or nil if _ext ~= nil then pos = pb.codec.decode_extension(_ext, buf, pos, wt, result) else pos = wire.skip_field(buf, pos, wt, id) if _uf == nil then _uf = {} end _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1) end end end if _uf ~= nil then result._unknown_fields = table.concat(_uf) end return result end ---@param b string ---@return pb.MessageView function M.L5_decode_lazy(b) return pb.decode_lazy(M.L5_descriptor, b) end ---@param t c_nested.L5 ---@param opts? {single_line: boolean?, indent: string?} ---@return string function M.L5_text(t, opts) return pb.text.encode(M.L5_descriptor, t, opts) end return M