-- Code generated by protoc-gen-tarantool. DO NOT EDIT.
-- source: conformance.proto
-- syntax: proto3
-- package: conformance
local pb = require("pb")
local wire = pb.wire
local string_byte = string.byte
local utf8_len = require('utf8').len
local band = bit.band
local rshift = bit.rshift
local table_new = require('table.new')
local M = {}
M.options = {go_package = "tarantoolpb_synthetic/conformance", java_package = "com.google.protobuf.conformance", objc_class_prefix = "Conformance"}
-- Enum: conformance.WireFormat
M.WireFormat_descriptor = pb.enum("conformance.WireFormat", {
UNSPECIFIED = 0,
PROTOBUF = 1,
JSON = 2,
JSPB = 3,
TEXT_FORMAT = 4,
})
M.WireFormat = M.WireFormat_descriptor.by_name
-- Enum: conformance.TestCategory
M.TestCategory_descriptor = pb.enum("conformance.TestCategory", {
UNSPECIFIED_TEST = 0,
BINARY_TEST = 1,
JSON_TEST = 2,
-- Similar to JSON_TEST. However, during parsing json, testee should ignore
-- unknown fields. This feature is optional. Each implementation can decide
-- whether to support it. See
-- https://developers.google.com/protocol-buffers/docs/proto3#json_options
-- for more detail.
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3,
-- Test jspb wire format. Only used inside Google. Opensource testees just
-- skip it.
JSPB_TEST = 4,
-- Test text format. For cpp, java and python, testees can already deal with
-- this type. Testees of other languages can simply skip it.
TEXT_FORMAT_TEST = 5,
})
M.TestCategory = M.TestCategory_descriptor.by_name
-- Pre-declare message descriptors so cross-references resolve.
M.TestStatus_descriptor = {name = "conformance.TestStatus"}
M.FailureSet_descriptor = {name = "conformance.FailureSet"}
M.ConformanceRequest_descriptor = {name = "conformance.ConformanceRequest"}
M.ConformanceResponse_descriptor = {name = "conformance.ConformanceResponse"}
M.JspbEncodingConfig_descriptor = {name = "conformance.JspbEncodingConfig"}
-- Message: conformance.TestStatus
M.TestStatus_descriptor.fields = {
{name="name", id=1, kind='scalar', proto_type="string"},
{name="failure_message", id=2, kind='scalar', proto_type="string"},
{name="matched_name", id=3, kind='scalar', proto_type="string"},
}
pb.finalize_message(M.TestStatus_descriptor)
M.TestStatus_fields = pb.field_names({
name = "name",
failure_message = "failure_message",
matched_name = "matched_name",
})
-- Message: conformance.FailureSet
M.FailureSet_descriptor.fields = {
{name="test", id=2, kind='message', message=M.TestStatus_descriptor, repeated=true},
}
pb.finalize_message(M.FailureSet_descriptor)
M.FailureSet_fields = pb.field_names({
test = "test",
})
-- Message: conformance.ConformanceRequest
M.ConformanceRequest_descriptor.fields = {
{name="protobuf_payload", id=1, kind='scalar', proto_type="bytes", oneof="payload"},
{name="json_payload", id=2, kind='scalar', proto_type="string", oneof="payload"},
{name="jspb_payload", id=7, kind='scalar', proto_type="string", oneof="payload"},
{name="text_payload", id=8, kind='scalar', proto_type="string", oneof="payload"},
{name="requested_output_format", id=3, kind='enum', enum=M.WireFormat_descriptor},
{name="message_type", id=4, kind='scalar', proto_type="string"},
{name="test_category", id=5, kind='enum', enum=M.TestCategory_descriptor},
{name="jspb_encoding_options", id=6, kind='message', message=M.JspbEncodingConfig_descriptor},
{name="print_unknown_fields", id=9, kind='scalar', proto_type="bool"},
}
M.ConformanceRequest_descriptor.oneofs = {
payload = {"protobuf_payload", "json_payload", "jspb_payload", "text_payload"},
}
pb.finalize_message(M.ConformanceRequest_descriptor)
M.ConformanceRequest_fields = pb.field_names({
protobuf_payload = "protobuf_payload",
json_payload = "json_payload",
jspb_payload = "jspb_payload",
text_payload = "text_payload",
requested_output_format = "requested_output_format",
message_type = "message_type",
test_category = "test_category",
jspb_encoding_options = "jspb_encoding_options",
print_unknown_fields = "print_unknown_fields",
})
M.ConformanceRequest_oneofs = pb.field_names({
payload = "payload",
})
-- Message: conformance.ConformanceResponse
M.ConformanceResponse_descriptor.fields = {
{name="parse_error", id=1, kind='scalar', proto_type="string", oneof="result"},
{name="serialize_error", id=6, kind='scalar', proto_type="string", oneof="result"},
{name="timeout_error", id=9, kind='scalar', proto_type="string", oneof="result"},
{name="runtime_error", id=2, kind='scalar', proto_type="string", oneof="result"},
{name="protobuf_payload", id=3, kind='scalar', proto_type="bytes", oneof="result"},
{name="json_payload", id=4, kind='scalar', proto_type="string", oneof="result"},
{name="skipped", id=5, kind='scalar', proto_type="string", oneof="result"},
{name="jspb_payload", id=7, kind='scalar', proto_type="string", oneof="result"},
{name="text_payload", id=8, kind='scalar', proto_type="string", oneof="result"},
}
M.ConformanceResponse_descriptor.oneofs = {
result = {"parse_error", "serialize_error", "timeout_error", "runtime_error", "protobuf_payload", "json_payload", "skipped", "jspb_payload", "text_payload"},
}
pb.finalize_message(M.ConformanceResponse_descriptor)
M.ConformanceResponse_fields = pb.field_names({
parse_error = "parse_error",
serialize_error = "serialize_error",
timeout_error = "timeout_error",
runtime_error = "runtime_error",
protobuf_payload = "protobuf_payload",
json_payload = "json_payload",
skipped = "skipped",
jspb_payload = "jspb_payload",
text_payload = "text_payload",
})
M.ConformanceResponse_oneofs = pb.field_names({
result = "result",
})
-- Message: conformance.JspbEncodingConfig
M.JspbEncodingConfig_descriptor.fields = {
{name="use_jspb_array_any_format", id=1, kind='scalar', proto_type="bool"},
}
pb.finalize_message(M.JspbEncodingConfig_descriptor)
M.JspbEncodingConfig_fields = pb.field_names({
use_jspb_array_any_format = "use_jspb_array_any_format",
})
-- EmmyLua / lua-language-server type annotations.
-- These are comments — no runtime effect. They give editors
-- autocomplete and type-checking for the generated wrappers.
---@alias conformance.WireFormat integer
---@alias conformance.TestCategory integer
--- Meant to encapsulate all types of tests: successes, skips, failures, etc.
--- Therefore, this may or may not have a failure message. Failure messages
--- may be truncated for our failure lists.
---@class conformance.TestStatus
---@field name string
---@field failure_message string
---@field matched_name string @ What an actual test name matched to in a failure list. Can be wildcarded or an exact match without wildcards.
--- The conformance runner will request a list of failures as the first request.
--- This will be known by message_type == "conformance.FailureSet", a conformance
--- test should return a serialized FailureSet in protobuf_payload.
---@class conformance.FailureSet
---@field test conformance.TestStatus[]
--- Represents a single test case's input. The testee should:
---
--- 1. parse this proto (which should always succeed)
--- 2. parse the protobuf or JSON payload in "payload" (which may fail)
--- 3. if the parse succeeded, serialize the message in the requested format.
---@class conformance.ConformanceRequest
---@field protobuf_payload? string
---@field json_payload? string
---@field jspb_payload? string @ Only used inside Google. Opensource testees just skip it.
---@field text_payload? string
---@field requested_output_format conformance.WireFormat @ Which format should the testee serialize its message to?
---@field message_type string @ The full name for the test message to use; for the moment, either: protobuf_test_messages.proto3.TestAllTypesProto3 or protobuf_test_messages.proto2.TestAllTypesProto2 or protobuf_test_messages.editions.proto2.TestAllTypesProto2 or protobuf_test_messages.editions.proto3.TestAllTypesProto3 or protobuf_test_messages.editions.TestAllTypesEdition2023 or protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable.
---@field test_category conformance.TestCategory @ Each test is given a specific test category. Some category may need specific support in testee programs. Refer to the definition of TestCategory for more information.
---@field jspb_encoding_options conformance.JspbEncodingConfig @ Specify details for how to encode jspb.
---@field print_unknown_fields boolean @ This can be used in json and text format. If true, testee should print unknown fields instead of ignore. This feature is optional.
--- Represents a single test case's output.
---@class conformance.ConformanceResponse
---@field parse_error? string @ This string should be set to indicate parsing failed. The string can provide more information about the parse error if it is available. Setting this string does not necessarily mean the testee failed the test. Some of the test cases are intentionally invalid input.
---@field serialize_error? string @ If the input was successfully parsed but errors occurred when serializing it to the requested output format, set the error message in this field.
---@field timeout_error? string @ This should be set if the test program timed out. The string should provide more information about what the child process was doing when it was killed.
---@field runtime_error? string @ This should be set if some other error occurred. This will always indicate that the test failed. The string can provide more information about the failure.
---@field protobuf_payload? string @ If the input was successfully parsed and the requested output was protobuf, serialize it to protobuf and set it in this field.
---@field json_payload? string @ If the input was successfully parsed and the requested output was JSON, serialize to JSON and set it in this field.
---@field skipped? string @ For when the testee skipped the test, likely because a certain feature wasn't supported, like JSON input/output.
---@field jspb_payload? string @ If the input was successfully parsed and the requested output was JSPB, serialize to JSPB and set it in this field. JSPB is only used inside Google. Opensource testees can just skip it.
---@field text_payload? string @ If the input was successfully parsed and the requested output was TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.
--- Encoding options for jspb format.
---@class conformance.JspbEncodingConfig
---@field use_jspb_array_any_format boolean @ Encode the value field of Any as jspb array if true, otherwise binary.
---@param t? conformance.TestStatus
---@return conformance.TestStatus
function M.TestStatus_new(t) return t or {} end
---@param t conformance.TestStatus
---@return string
function M.TestStatus_encode(t)
local encode_varint = wire.encode_varint
local _d = M.TestStatus_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.encode(_p, t)
end
if type(t) ~= 'table' then
error("expected table for conformance.TestStatus, got " .. type(t), 0)
end
local out, n = {}, 0
local v
-- field 1: name
v = t.name
if v ~= nil and v ~= '' then
n = n + 1; out[n] = "\x0a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 2: failure_message
v = t.failure_message
if v ~= nil and v ~= '' then
n = n + 1; out[n] = "\x12"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 3: matched_name
v = t.matched_name
if v ~= nil and v ~= '' then
n = n + 1; out[n] = "\x1a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
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 conformance.TestStatus
function M.TestStatus_decode(buf)
local decode_string = wire.decode_string
local _d = M.TestStatus_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.decode(_p, buf)
end
if type(buf) ~= 'string' then
error("expected string for conformance.TestStatus 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 _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.name = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.name = val
end
elseif id == 2 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.failure_message = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.failure_message = val
end
elseif id == 3 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.matched_name = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.matched_name = val
end
else
local _ebid = M.TestStatus_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.TestStatus_decode_lazy(b) return pb.decode_lazy(M.TestStatus_descriptor, b) end
---@param t conformance.TestStatus
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.TestStatus_text(t, opts) return pb.text.encode(M.TestStatus_descriptor, t, opts) end
---@param t? conformance.FailureSet
---@return conformance.FailureSet
function M.FailureSet_new(t) return t or {} end
---@param t conformance.FailureSet
---@return string
function M.FailureSet_encode(t)
local _d = M.FailureSet_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.encode(_p, t)
end
if type(t) ~= 'table' then
error("expected table for conformance.FailureSet, got " .. type(t), 0)
end
local out, n = {}, 0
local v
-- field 2: test
v = t.test
if v ~= nil and #v > 0 then
local _tag = "\x12"
for _i = 1, #v do
local _b = M.TestStatus_encode(v[_i])
n = n + 1; out[n] = _tag
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
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 conformance.FailureSet
function M.FailureSet_decode(buf)
local _d = M.FailureSet_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.decode(_p, buf)
end
if type(buf) ~= 'string' then
error("expected string for conformance.FailureSet decode, got " .. type(buf), 0)
end
local result = {}
local pos, len = 1, #buf
local _uf
local _n_test = 0
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 list = result.test
if list == nil then list = {}; result.test = list end
local payload
payload, pos = wire.decode_len(buf, pos)
_n_test = _n_test + 1; list[_n_test] = M.TestStatus_decode(payload)
else
local _ebid = M.FailureSet_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.FailureSet_decode_lazy(b) return pb.decode_lazy(M.FailureSet_descriptor, b) end
---@param t conformance.FailureSet
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.FailureSet_text(t, opts) return pb.text.encode(M.FailureSet_descriptor, t, opts) end
---@param t? conformance.ConformanceRequest
---@return conformance.ConformanceRequest
function M.ConformanceRequest_new(t) return t or {} end
---@param t conformance.ConformanceRequest
---@return string
function M.ConformanceRequest_encode(t)
local encode_int32 = wire.encode_int32
local encode_varint = wire.encode_varint
local _d = M.ConformanceRequest_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.encode(_p, t)
end
if type(t) ~= 'table' then
error("expected table for conformance.ConformanceRequest, got " .. type(t), 0)
end
local out, n = {}, 0
local v
local _of_payload
if t.protobuf_payload ~= nil then _of_payload = "protobuf_payload" end
if t.json_payload ~= nil then _of_payload = "json_payload" end
if t.jspb_payload ~= nil then _of_payload = "jspb_payload" end
if t.text_payload ~= nil then _of_payload = "text_payload" end
-- field 1: protobuf_payload
v = t.protobuf_payload
if _of_payload == "protobuf_payload" then
n = n + 1; out[n] = "\x0a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 2: json_payload
v = t.json_payload
if _of_payload == "json_payload" then
n = n + 1; out[n] = "\x12"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 7: jspb_payload
v = t.jspb_payload
if _of_payload == "jspb_payload" then
n = n + 1; out[n] = "\x3a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 8: text_payload
v = t.text_payload
if _of_payload == "text_payload" then
n = n + 1; out[n] = "\x42"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 3: requested_output_format
v = t.requested_output_format
if v ~= nil then
local nv = v
if type(v) == 'string' then
nv = M.WireFormat[v]
if nv == nil then error("unknown enum value '" .. v .. "' for conformance.WireFormat", 0) end
end
if nv ~= 0 then
n = n + 1; out[n] = "\x18"
n = n + 1; out[n] = encode_int32(nv)
end
end
-- field 4: message_type
v = t.message_type
if v ~= nil and v ~= '' then
n = n + 1; out[n] = "\x22"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 5: test_category
v = t.test_category
if v ~= nil then
local nv = v
if type(v) == 'string' then
nv = M.TestCategory[v]
if nv == nil then error("unknown enum value '" .. v .. "' for conformance.TestCategory", 0) end
end
if nv ~= 0 then
n = n + 1; out[n] = "\x28"
n = n + 1; out[n] = encode_int32(nv)
end
end
-- field 6: jspb_encoding_options
v = t.jspb_encoding_options
if v ~= nil or type(v) == 'cdata' then
local _b = M.JspbEncodingConfig_encode(v)
n = n + 1; out[n] = "\x32"
local _len = #_b
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = _b
end
-- field 9: print_unknown_fields
v = t.print_unknown_fields
if v ~= nil and v ~= false then
n = n + 1; out[n] = "\x48"
n = n + 1; out[n] = wire.encode_bool(v)
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 conformance.ConformanceRequest
function M.ConformanceRequest_decode(buf)
local decode_string = wire.decode_string
local decode_varint = wire.decode_varint
local varint_to_int32 = wire.varint_to_int32
local _d = M.ConformanceRequest_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.decode(_p, buf)
end
if type(buf) ~= 'string' then
error("expected string for conformance.ConformanceRequest 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 _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
result.protobuf_payload = _s
pos = _epos
else
local val
val, pos = wire.decode_bytes(buf, pos)
result.protobuf_payload = val
end
result.json_payload = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 2 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.json_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.json_payload = val
end
result.protobuf_payload = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 7 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.jspb_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.jspb_payload = val
end
result.protobuf_payload = nil
result.json_payload = nil
result.text_payload = nil
elseif id == 8 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.text_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.text_payload = val
end
result.protobuf_payload = nil
result.json_payload = nil
result.jspb_payload = nil
elseif id == 3 then
local u
u, pos = decode_varint(buf, pos)
result.requested_output_format = varint_to_int32(u)
elseif id == 4 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.message_type = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.message_type = val
end
elseif id == 5 then
local u
u, pos = decode_varint(buf, pos)
result.test_category = varint_to_int32(u)
elseif id == 6 then
local payload
payload, pos = wire.decode_len(buf, pos)
local prev = result.jspb_encoding_options
if prev == nil then
result.jspb_encoding_options = M.JspbEncodingConfig_decode(payload)
else
pb.codec.merge_message(M.JspbEncodingConfig_descriptor, prev, M.JspbEncodingConfig_decode(payload))
end
elseif id == 9 then
local val
val, pos = wire.decode_bool(buf, pos)
result.print_unknown_fields = val
else
local _ebid = M.ConformanceRequest_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.ConformanceRequest_decode_lazy(b) return pb.decode_lazy(M.ConformanceRequest_descriptor, b) end
---@param t conformance.ConformanceRequest
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.ConformanceRequest_text(t, opts) return pb.text.encode(M.ConformanceRequest_descriptor, t, opts) end
---@param t? conformance.ConformanceResponse
---@return conformance.ConformanceResponse
function M.ConformanceResponse_new(t) return t or {} end
---@param t conformance.ConformanceResponse
---@return string
function M.ConformanceResponse_encode(t)
local encode_varint = wire.encode_varint
local _d = M.ConformanceResponse_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.encode(_p, t)
end
if type(t) ~= 'table' then
error("expected table for conformance.ConformanceResponse, got " .. type(t), 0)
end
local out, n = {}, 0
local v
local _of_result
if t.parse_error ~= nil then _of_result = "parse_error" end
if t.serialize_error ~= nil then _of_result = "serialize_error" end
if t.timeout_error ~= nil then _of_result = "timeout_error" end
if t.runtime_error ~= nil then _of_result = "runtime_error" end
if t.protobuf_payload ~= nil then _of_result = "protobuf_payload" end
if t.json_payload ~= nil then _of_result = "json_payload" end
if t.skipped ~= nil then _of_result = "skipped" end
if t.jspb_payload ~= nil then _of_result = "jspb_payload" end
if t.text_payload ~= nil then _of_result = "text_payload" end
-- field 1: parse_error
v = t.parse_error
if _of_result == "parse_error" then
n = n + 1; out[n] = "\x0a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 6: serialize_error
v = t.serialize_error
if _of_result == "serialize_error" then
n = n + 1; out[n] = "\x32"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 9: timeout_error
v = t.timeout_error
if _of_result == "timeout_error" then
n = n + 1; out[n] = "\x4a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 2: runtime_error
v = t.runtime_error
if _of_result == "runtime_error" then
n = n + 1; out[n] = "\x12"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 3: protobuf_payload
v = t.protobuf_payload
if _of_result == "protobuf_payload" then
n = n + 1; out[n] = "\x1a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 4: json_payload
v = t.json_payload
if _of_result == "json_payload" then
n = n + 1; out[n] = "\x22"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 5: skipped
v = t.skipped
if _of_result == "skipped" then
n = n + 1; out[n] = "\x2a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 7: jspb_payload
v = t.jspb_payload
if _of_result == "jspb_payload" then
n = n + 1; out[n] = "\x3a"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
end
-- field 8: text_payload
v = t.text_payload
if _of_result == "text_payload" then
n = n + 1; out[n] = "\x42"
local _len = #v
if _len < 128 then
n = n + 1; out[n] = string.char(_len)
else
n = n + 1; out[n] = encode_varint(_len)
end
n = n + 1; out[n] = v
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 conformance.ConformanceResponse
function M.ConformanceResponse_decode(buf)
local decode_string = wire.decode_string
local _d = M.ConformanceResponse_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.decode(_p, buf)
end
if type(buf) ~= 'string' then
error("expected string for conformance.ConformanceResponse 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 _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.parse_error = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.parse_error = val
end
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 6 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.serialize_error = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.serialize_error = val
end
result.parse_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 9 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.timeout_error = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.timeout_error = val
end
result.parse_error = nil
result.serialize_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 2 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.runtime_error = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.runtime_error = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 3 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
result.protobuf_payload = _s
pos = _epos
else
local val
val, pos = wire.decode_bytes(buf, pos)
result.protobuf_payload = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 4 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.json_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.json_payload = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.skipped = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 5 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.skipped = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.skipped = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.jspb_payload = nil
result.text_payload = nil
elseif id == 7 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.jspb_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.jspb_payload = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.text_payload = nil
elseif id == 8 then
local _lb = string_byte(buf, pos)
if _lb ~= nil and _lb < 0x80 then
local _np = pos + 1
local _epos = _np + _lb
if _epos - 1 > len then error("truncated LEN at offset " .. pos, 0) end
local _s = buf:sub(_np, _epos - 1)
if utf8_len(_s) == nil then error("invalid UTF-8 in string field at offset " .. pos, 0) end
result.text_payload = _s
pos = _epos
else
local val
val, pos = decode_string(buf, pos)
result.text_payload = val
end
result.parse_error = nil
result.serialize_error = nil
result.timeout_error = nil
result.runtime_error = nil
result.protobuf_payload = nil
result.json_payload = nil
result.skipped = nil
result.jspb_payload = nil
else
local _ebid = M.ConformanceResponse_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.ConformanceResponse_decode_lazy(b) return pb.decode_lazy(M.ConformanceResponse_descriptor, b) end
---@param t conformance.ConformanceResponse
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.ConformanceResponse_text(t, opts) return pb.text.encode(M.ConformanceResponse_descriptor, t, opts) end
---@param t? conformance.JspbEncodingConfig
---@return conformance.JspbEncodingConfig
function M.JspbEncodingConfig_new(t) return t or {} end
---@param t conformance.JspbEncodingConfig
---@return string
function M.JspbEncodingConfig_encode(t)
local _d = M.JspbEncodingConfig_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.encode(_p, t)
end
if type(t) ~= 'table' then
error("expected table for conformance.JspbEncodingConfig, got " .. type(t), 0)
end
local out, n = {}, 0
local v
-- field 1: use_jspb_array_any_format
v = t.use_jspb_array_any_format
if v ~= nil and v ~= false then
n = n + 1; out[n] = "\x08"
n = n + 1; out[n] = wire.encode_bool(v)
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 conformance.JspbEncodingConfig
function M.JspbEncodingConfig_decode(buf)
local _d = M.JspbEncodingConfig_descriptor
if pb.c_runtime ~= nil then
local _p = _d.c_plan or pb.c_runtime.compile_plan(_d)
return pb.c_runtime.decode(_p, buf)
end
if type(buf) ~= 'string' then
error("expected string for conformance.JspbEncodingConfig 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 val
val, pos = wire.decode_bool(buf, pos)
result.use_jspb_array_any_format = val
else
local _ebid = M.JspbEncodingConfig_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.JspbEncodingConfig_decode_lazy(b) return pb.decode_lazy(M.JspbEncodingConfig_descriptor, b) end
---@param t conformance.JspbEncodingConfig
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.JspbEncodingConfig_text(t, opts) return pb.text.encode(M.JspbEncodingConfig_descriptor, t, opts) end
return M