summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2018-09-11 10:59:08 -0700
committerJosh Haberman <jhaberman@gmail.com>2018-09-11 10:59:08 -0700
commitb79fd65a83e6563393807efbc44be3e2bdb16537 (patch)
tree257b56a8c38292e3f78a7793e4f362f9d66013f5
parentb2a388212a208095300f1ff2f767af82dd9e59b2 (diff)
WIP.
-rw-r--r--CMakeLists.txt19
-rw-r--r--tools/dump_cinit.lua725
-rw-r--r--tools/make_c_api.lua1
-rw-r--r--tools/test_cinit.lua64
-rw-r--r--upb/bindings/lua/def.c64
-rw-r--r--upb/bindings/lua/upb/table.c211
-rw-r--r--upb/bindings/lua/upb/table.lua3
-rw-r--r--upb/decode.c1
-rw-r--r--upb/def.c1445
-rw-r--r--upb/def.h1183
-rw-r--r--upb/descriptor/descriptor.pbbin6420 -> 0 bytes
-rw-r--r--upb/descriptor/descriptor.proto788
-rw-r--r--upb/descriptor/descriptor.upbdefs.c927
-rw-r--r--upb/descriptor/descriptor.upbdefs.h608
-rw-r--r--upb/descriptor/reader.c900
-rw-r--r--upb/descriptor/reader.h83
-rw-r--r--upb/encode.c1
-rw-r--r--upb/handlers.c34
-rw-r--r--upb/handlers.h1
-rw-r--r--upb/msg.c2
-rw-r--r--upb/msg.h5
-rw-r--r--upb/msgfactory.c1
-rw-r--r--upb/pb/decoder.int.h1
-rw-r--r--upb/pb/glue.c54
-rw-r--r--upb/pb/glue.h72
-rw-r--r--upb/structdefs.int.h191
-rw-r--r--upb/table.int.h81
-rw-r--r--upb/upb.h71
28 files changed, 422 insertions, 7114 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2909931..2e94bd3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,11 +79,6 @@ if(LUA_FOUND)
upbdef_pic
upbhandlers_pic upb_pic )
- add_library(table_c SHARED
- upb/bindings/lua/upb/table.c
- )
- target_link_libraries(table_c LINK_PRIVATE upb_c upb_pic)
-
add_library(pb_c SHARED
upb/bindings/lua/upb/pb.c
)
@@ -94,7 +89,7 @@ if(LUA_FOUND)
LIBRARY_OUTPUT_DIRECTORY "upb/bindings/lua"
PREFIX ""
SUFFIX ".so")
- set_target_properties(table_c pb_c
+ set_target_properties(pb_c
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "upb/bindings/lua/upb"
PREFIX ""
@@ -104,18 +99,14 @@ if(LUA_FOUND)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tools/upbc
DEPENDS ${CMAKE_SOURCE_DIR}/tools/upbc
${CMAKE_SOURCE_DIR}/tools/upbc.lua
- ${CMAKE_SOURCE_DIR}/tools/dump_cinit.lua
${CMAKE_SOURCE_DIR}/tools/make_c_api.lua
${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb.lua
- ${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/table.lua
${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/pb.lua
upb_c
- table_c
pb_c
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/tools/upbc
${CMAKE_SOURCE_DIR}/tools/upbc.lua
- ${CMAKE_SOURCE_DIR}/tools/dump_cinit.lua
${CMAKE_SOURCE_DIR}/tools/make_c_api.lua
${CMAKE_CURRENT_BINARY_DIR}/tools)
add_custom_command(
@@ -126,10 +117,8 @@ if(LUA_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/upb/bindings/lua)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lua/upb/pb.lua
- DEPENDS ${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/table.lua
- ${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/pb.lua
+ DEPENDS ${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/pb.lua
COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/table.lua
${CMAKE_SOURCE_DIR}/upb/bindings/lua/upb/pb.lua
${CMAKE_CURRENT_BINARY_DIR}/upb/bindings/lua/upb)
@@ -262,11 +251,8 @@ set(UPB_SRCS
)
set (UPBDEF_SRCS
- upb/descriptor/descriptor.upbdefs.c
- upb/descriptor/reader.c
upb/def.c
upb/msgfactory.c
- upb/refcounted.c
)
set(UPBHANDLERS_SRCS
@@ -278,7 +264,6 @@ set(UPBPB_SRCS
upb/pb/compile_decoder.c
upb/pb/decoder.c
upb/pb/encoder.c
- upb/pb/glue.c
upb/pb/textprinter.c
upb/pb/varint.c
)
diff --git a/tools/dump_cinit.lua b/tools/dump_cinit.lua
deleted file mode 100644
index 56c47ea..0000000
--- a/tools/dump_cinit.lua
+++ /dev/null
@@ -1,725 +0,0 @@
---[[
-
- Routines for dumping internal data structures into C initializers
- that can be compiled into a .o file.
-
---]]
-
-local upbtable = require "upb.table"
-local upb = require "upb"
-local export = {}
-
--- A tiny little abstraction that decouples the dump_* functions from
--- what they're writing to (appending to a string, writing to file I/O, etc).
--- This could possibly matter since naive string building is O(n^2) in the
--- number of appends.
-function export.str_appender()
- local str = ""
- local function append(fmt, ...)
- str = str .. string.format(fmt, ...)
- end
- local function get()
- return str
- end
- return append, get
-end
-
-function export.file_appender(file)
- local f = file
- local function append(fmt, ...)
- f:write(string.format(fmt, ...))
- end
- return append
-end
-
-function handler_types(base)
- local ret = {}
- for k, _ in pairs(base) do
- if string.find(k, "^" .. "HANDLER_") then
- ret[#ret + 1] = k
- end
- end
- return ret
-end
-
-function octchar(num)
- assert(num < 8)
- local idx = num + 1 -- 1-based index
- return string.sub("01234567", idx, idx)
-end
-
-function c_escape(num)
- assert(num < 256)
- return string.format("\\%s%s%s",
- octchar(math.floor(num / 64)),
- octchar(math.floor(num / 8) % 8),
- octchar(num % 8));
-end
-
--- const(f, label) -> UPB_LABEL_REPEATED, where f:label() == upb.LABEL_REPEATED
-function const(obj, name, base)
- local val = obj[name]
- base = base or upb
-
- -- Support both f:label() and f.label.
- if type(val) == "function" then
- val = val(obj)
- end
-
- for k, v in pairs(base) do
- if v == val and string.find(k, "^" .. string.upper(name)) then
- return "UPB_" .. k
- end
- end
- assert(false, "Couldn't find UPB_" .. string.upper(name) ..
- " constant for value: " .. val)
-end
-
-function sortedkeys(tab)
- arr = {}
- for key in pairs(tab) do
- arr[#arr + 1] = key
- end
- table.sort(arr)
- return arr
-end
-
-function sorted_defs(defs)
- local sorted = {}
-
- for def in defs do
- if def.type == deftype then
- sorted[#sorted + 1] = def
- end
- end
-
- table.sort(sorted,
- function(a, b) return a:full_name() < b:full_name() end)
-
- return sorted
-end
-
-function constlist(pattern)
- local ret = {}
- for k, v in pairs(upb) do
- if string.find(k, "^" .. pattern) then
- ret[k] = v
- end
- end
- return ret
-end
-
-function boolstr(val)
- if val == true then
- return "true"
- elseif val == false then
- return "false"
- else
- assert(false, "Bad bool value: " .. tostring(val))
- end
-end
-
---[[
-
- LinkTable: an object that tracks all linkable objects and their offsets to
- facilitate linking.
-
---]]
-
-local LinkTable = {}
-function LinkTable:new(types)
- local linktab = {
- types = types,
- table = {}, -- ptr -> {type, 0-based offset}
- obj_arrays = {} -- Establishes the ordering for each object type
- }
- for type, _ in pairs(types) do
- linktab.obj_arrays[type] = {}
- end
- setmetatable(linktab, {__index = LinkTable}) -- Inheritance
- return linktab
-end
-
--- Adds a new object to the sequence of objects of this type.
-function LinkTable:add(objtype, ptr, obj)
- obj = obj or ptr
- assert(self.table[obj] == nil)
- assert(self.types[objtype])
- local arr = self.obj_arrays[objtype]
- self.table[ptr] = {objtype, #arr}
- arr[#arr + 1] = obj
-end
-
--- Returns a C symbol name for the given objtype and offset.
-function LinkTable:csym(objtype, offset)
- local typestr = assert(self.types[objtype])
- return string.format("%s[%d]", typestr, offset)
-end
-
--- Returns the address of the given C object.
-function LinkTable:addr(obj)
- if obj == upbtable.NULL then
- return "NULL"
- else
- local tabent = assert(self.table[obj], "unknown object: " .. tostring(obj))
- return "&" .. self:csym(tabent[1], tabent[2])
- end
-end
-
--- Returns an array declarator indicating how many objects have been added.
-function LinkTable:cdecl(objtype)
- return self:csym(objtype, #self.obj_arrays[objtype])
-end
-
-function LinkTable:objs(objtype)
- -- Return iterator function, allowing use as:
- -- for obj in linktable:objs(type) do
- -- -- ...
- -- done
- local array = self.obj_arrays[objtype]
- local i = 0
- return function()
- i = i + 1
- if array[i] then return array[i] end
- end
-end
-
-function LinkTable:empty(objtype)
- return #self.obj_arrays[objtype] == 0
-end
-
---[[
-
- Dumper: an object that can dump C initializers for several constructs.
- Uses a LinkTable to resolve references when necessary.
-
---]]
-
-local Dumper = {}
-function Dumper:new(linktab)
- local obj = {linktab = linktab}
- setmetatable(obj, {__index = Dumper}) -- Inheritance
- return obj
-end
-
--- Dumps a upb_tabval, eg:
--- UPB_TABVALUE_INIT(5)
-function Dumper:_value(val, upbtype)
- if type(val) == "nil" then
- return "UPB_TABVALUE_EMPTY_INIT"
- elseif type(val) == "number" then
- -- Use upbtype to disambiguate what kind of number it is.
- if upbtype == upbtable.CTYPE_INT32 then
- return string.format("UPB_TABVALUE_INT_INIT(%d)", val)
- else
- -- TODO(haberman): add support for these so we can properly support
- -- default values.
- error("Unsupported number type " .. upbtype)
- end
- elseif type(val) == "string" then
- return string.format('UPB_TABVALUE_PTR_INIT("%s")', val)
- else
- -- We take this as an object reference that has an entry in the link table.
- return string.format("UPB_TABVALUE_PTR_INIT(%s)", self.linktab:addr(val))
- end
-end
-
--- Dumps a table key.
-function Dumper:tabkey(key)
- if type(key) == "nil" then
- return "UPB_TABKEY_NONE"
- elseif type(key) == "string" then
- local len = #key
- local len1 = c_escape(len % 256)
- local len2 = c_escape(math.floor(len / 256) % 256)
- local len3 = c_escape(math.floor(len / (256 * 256)) % 256)
- local len4 = c_escape(math.floor(len / (256 * 256 * 256)) % 256)
- return string.format('UPB_TABKEY_STR("%s", "%s", "%s", "%s", "%s")',
- len1, len2, len3, len4, key)
- else
- return string.format("UPB_TABKEY_NUM(%d)", key)
- end
-end
-
--- Dumps a table entry.
-function Dumper:tabent(ent)
- local key = self:tabkey(ent.key)
- local val = self:_value(ent.value, ent.valtype)
- local next = self.linktab:addr(ent.next)
- return string.format(' {%s, %s, %s},\n', key, val, next)
-end
-
--- Dumps an inttable array entry. This is almost the same as value() above,
--- except that nil values have a special value to indicate "empty".
-function Dumper:arrayval(val)
- if val.val then
- return string.format(" %s,\n", self:_value(val.val, val.valtype))
- else
- return " UPB_TABVALUE_EMPTY_INIT,\n"
- end
-end
-
--- Dumps an initializer for the given strtable/inttable (respectively). Its
--- entries must have previously been added to the linktable.
-function Dumper:strtable(t)
- -- UPB_STRTABLE_INIT(count, mask, type, size_lg2, entries)
- return string.format(
- "UPB_STRTABLE_INIT(%d, %d, %s, %d, %s)",
- t.count, t.mask, const(t, "ctype", upbtable) , t.size_lg2,
- self.linktab:addr(t.entries[1].ptr))
-end
-
-function Dumper:inttable(t)
- local lt = assert(self.linktab)
- -- UPB_INTTABLE_INIT(count, mask, type, size_lg2, ent, a, asize, acount)
- local entries = "NULL"
- if #t.entries > 0 then
- entries = lt:addr(t.entries[1].ptr)
- end
- return string.format(
- "UPB_INTTABLE_INIT(%d, %d, %s, %d, %s, %s, %d, %d)",
- t.count, t.mask, const(t, "ctype", upbtable), t.size_lg2, entries,
- lt:addr(t.array[1].ptr), t.array_size, t.array_count)
-end
-
--- A visitor for visiting all tables of a def. Used first to count entries
--- and later to dump them.
-local function gettables(def)
- if def:def_type() == upb.DEF_MSG then
- return {int = upbtable.msgdef_itof(def), str = upbtable.msgdef_ntof(def)}
- elseif def:def_type() == upb.DEF_ENUM then
- return {int = upbtable.enumdef_iton(def), str = upbtable.enumdef_ntoi(def)}
- end
-end
-
-local function emit_file_warning(filedef, append)
- append('/* This file was generated by upbc (the upb compiler) from the input\n')
- append(' * file:\n')
- append(' *\n')
- append(' * %s\n', filedef:name())
- append(' *\n')
- append(' * Do not edit -- your changes will be discarded when the file is\n')
- append(' * regenerated. */\n\n')
-end
-
-local function join(...)
- return table.concat({...}, ".")
-end
-
-local function split(str)
- local ret = {}
- for word in string.gmatch(str, "%w+") do
- table.insert(ret, word)
- end
- return ret
-end
-
-local function to_cident(...)
- return string.gsub(join(...), "[%./]", "_")
-end
-
-local function to_preproc(...)
- return string.upper(to_cident(...))
-end
-
--- Strips away last path element, ie:
--- foo.Bar.Baz -> foo.Bar
-local function remove_name(name)
- local package_end = 0
- for i=1,string.len(name) do
- if string.byte(name, i) == string.byte(".", 1) then
- package_end = i - 1
- end
- end
- return string.sub(name, 1, package_end)
-end
-
-local function start_namespace(package, append)
- local package_components = split(package)
- for _, component in ipairs(package_components) do
- append("namespace %s {\n", component)
- end
-end
-
-local function end_namespace(package, append)
- local package_components = split(package)
- for i=#package_components,1,-1 do
- append("} /* namespace %s */\n", package_components[i])
- end
-end
-
---[[
-
- Top-level, exported dumper functions
-
---]]
-
-local function dump_defs_c(filedef, append)
- local defs = {}
- for def in filedef:defs(upb.DEF_ANY) do
- defs[#defs + 1] = def
- if (def:def_type() == upb.DEF_MSG) then
- for field in def:fields() do
- defs[#defs + 1] = field
- end
- end
- end
-
- -- Sort all defs by (type, name).
- -- This gives us a linear ordering that we can use to create offsets into
- -- shared arrays like REFTABLES, hash table entries, and arrays.
- table.sort(defs, function(a, b)
- if a:def_type() ~= b:def_type() then
- return a:def_type() < b:def_type()
- else
- return a:full_name() < b:full_name() end
- end
- )
-
- -- Perform pre-pass to build the link table.
- local linktab = LinkTable:new{
- [upb.DEF_MSG] = "msgs",
- [upb.DEF_FIELD] = "fields",
- [upb.DEF_ENUM] = "enums",
- intentries = "intentries",
- strentries = "strentries",
- arrays = "arrays",
- }
- local reftable_count = 0
-
- for _, def in ipairs(defs) do
- assert(def:is_frozen(), "can only dump frozen defs.")
- linktab:add(def:def_type(), def)
- reftable_count = reftable_count + 2
- local tables = gettables(def)
- if tables then
- for _, e in ipairs(tables.str.entries) do
- linktab:add("strentries", e.ptr, e)
- end
- for _, e in ipairs(tables.int.entries) do
- linktab:add("intentries", e.ptr, e)
- end
- for _, e in ipairs(tables.int.array) do
- linktab:add("arrays", e.ptr, e)
- end
- end
- end
-
- -- Emit forward declarations.
- emit_file_warning(filedef, append)
- append('#include "upb/def.h"\n')
- append('#include "upb/structdefs.int.h"\n\n')
- append("static const upb_msgdef %s;\n", linktab:cdecl(upb.DEF_MSG))
- append("static const upb_fielddef %s;\n", linktab:cdecl(upb.DEF_FIELD))
- if not linktab:empty(upb.DEF_ENUM) then
- append("static const upb_enumdef %s;\n", linktab:cdecl(upb.DEF_ENUM))
- end
- append("static const upb_tabent %s;\n", linktab:cdecl("strentries"))
- if not linktab:empty("intentries") then
- append("static const upb_tabent %s;\n", linktab:cdecl("intentries"))
- end
- append("static const upb_tabval %s;\n", linktab:cdecl("arrays"))
- append("\n")
- append("#ifdef UPB_DEBUG_REFS\n")
- append("static upb_inttable reftables[%d];\n", reftable_count)
- append("#endif\n")
- append("\n")
-
- -- Emit defs.
- local dumper = Dumper:new(linktab)
-
- local reftable = 0
-
- append("static const upb_msgdef %s = {\n", linktab:cdecl(upb.DEF_MSG))
- for m in linktab:objs(upb.DEF_MSG) do
- local tables = gettables(m)
- -- UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof,
- -- refs, ref2s)
- append(' UPB_MSGDEF_INIT("%s", %d, %d, %s, %s, %s, %s,' ..
- ' &reftables[%d], &reftables[%d]),\n',
- m:full_name(),
- upbtable.msgdef_selector_count(m),
- upbtable.msgdef_submsg_field_count(m),
- dumper:inttable(tables.int),
- dumper:strtable(tables.str),
- boolstr(m:_map_entry()),
- const(m, "syntax"),
- reftable, reftable + 1)
- reftable = reftable + 2
- end
- append("};\n\n")
-
- append("static const upb_fielddef %s = {\n", linktab:cdecl(upb.DEF_FIELD))
- for f in linktab:objs(upb.DEF_FIELD) do
- local subdef = "NULL"
- if f:has_subdef() then
- subdef = string.format("(const upb_def*)(%s)", linktab:addr(f:subdef()))
- end
- local intfmt
- if f:type() == upb.TYPE_UINT32 or
- f:type() == upb.TYPE_INT32 or
- f:type() == upb.TYPE_UINT64 or
- f:type() == upb.TYPE_INT64 then
- intfmt = const(f, "intfmt")
- else
- intfmt = "0"
- end
- -- UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy,
- -- packed, name, num, msgdef, subdef, selector_base,
- -- index, -- default_value)
- append(' UPB_FIELDDEF_INIT(%s, %s, %s, %s, %s, %s, %s, "%s", %d, %s, ' ..
- '%s, %d, %d, {0},' .. -- TODO: support default value
- '&reftables[%d], &reftables[%d]),\n',
- const(f, "label"), const(f, "type"), intfmt,
- boolstr(f:istagdelim()), boolstr(f:is_extension()),
- boolstr(f:lazy()), boolstr(f:packed()), f:name(), f:number(),
- linktab:addr(f:containing_type()), subdef,
- upbtable.fielddef_selector_base(f), f:index(),
- reftable, reftable + 1
- )
- reftable = reftable + 2
- end
- append("};\n\n")
-
- if not linktab:empty(upb.DEF_ENUM) then
- append("static const upb_enumdef %s = {\n", linktab:cdecl(upb.DEF_ENUM))
- for e in linktab:objs(upb.DEF_ENUM) do
- local tables = gettables(e)
- -- UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval)
- append(' UPB_ENUMDEF_INIT("%s", %s, %s, %d, ' ..
- '&reftables[%d], &reftables[%d]),\n',
- e:full_name(),
- dumper:strtable(tables.str),
- dumper:inttable(tables.int),
- --e:default())
- 0,
- reftable, reftable + 1)
- reftable = reftable + 2
- end
- append("};\n\n")
- end
-
- append("static const upb_tabent %s = {\n", linktab:cdecl("strentries"))
- for ent in linktab:objs("strentries") do
- append(dumper:tabent(ent))
- end
- append("};\n\n");
-
- if not linktab:empty("intentries") then
- append("static const upb_tabent %s = {\n", linktab:cdecl("intentries"))
- for ent in linktab:objs("intentries") do
- append(dumper:tabent(ent))
- end
- append("};\n\n");
- end
-
- append("static const upb_tabval %s = {\n", linktab:cdecl("arrays"))
- for ent in linktab:objs("arrays") do
- append(dumper:arrayval(ent))
- end
- append("};\n\n");
-
- append("#ifdef UPB_DEBUG_REFS\n")
- append("static upb_inttable reftables[%d] = {\n", reftable_count)
- for i = 1,reftable_count do
- append(" UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),\n")
- end
- append("};\n")
- append("#endif\n\n")
-
- append("static const upb_msgdef *refm(const upb_msgdef *m, const void *owner) {\n")
- append(" upb_msgdef_ref(m, owner);\n")
- append(" return m;\n")
- append("}\n\n")
- append("static const upb_enumdef *refe(const upb_enumdef *e, const void *owner) {\n")
- append(" upb_enumdef_ref(e, owner);\n")
- append(" return e;\n")
- append("}\n\n")
-
- append("/* Public API. */\n")
-
- for m in linktab:objs(upb.DEF_MSG) do
- append("const upb_msgdef *upbdefs_%s_get(const void *owner)" ..
- " { return refm(%s, owner); }\n",
- to_cident(m:full_name()), linktab:addr(m))
- end
-
- append("\n")
-
- for e in linktab:objs(upb.DEF_ENUM) do
- append("const upb_enumdef *upbdefs_%s_get(const void *owner)" ..
- " { return refe(%s, owner); }\n",
- to_cident(e:full_name()), linktab:addr(e))
- end
-
- return linktab
-end
-
-local function dump_defs_for_type(format, defs, append)
- local sorted = sorted_defs(defs)
- for _, def in ipairs(sorted) do
- append(format, to_cident(def:full_name()), def:full_name())
- end
-
- append("\n")
-end
-
-local function make_children_map(file)
- -- Maps file:package() or msg:full_name() -> children.
- local map = {}
- for def in file:defs(upb.DEF_ANY) do
- local container = remove_name(def:full_name())
- if not map[container] then
- map[container] = {}
- end
- table.insert(map[container], def)
- end
-
- -- Sort all the lists for a consistent ordering.
- for name, children in pairs(map) do
- table.sort(children, function(a, b) return a:name() < b:name() end)
- end
-
- return map
-end
-
-local print_classes
-
-local function print_message(def, map, indent, append)
- append("\n")
- append("%sclass %s : public ::upb::reffed_ptr<const ::upb::MessageDef> {\n",
- indent, def:name())
- append("%s public:\n", indent)
- append("%s %s(const ::upb::MessageDef* m, const void *ref_donor = NULL)\n",
- indent, def:name())
- append("%s : reffed_ptr(m, ref_donor) {\n", indent)
- append("%s UPB_ASSERT(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name()))
- append("%s }\n", indent)
- append("\n")
- append("%s static %s get() {\n", indent, def:name())
- append("%s const ::upb::MessageDef* m = upbdefs_%s_get(&m);\n", indent, to_cident(def:full_name()))
- append("%s return %s(m, &m);\n", indent, def:name())
- append("%s }\n", indent)
- -- TODO(haberman): add fields
- print_classes(def:full_name(), map, indent .. " ", append)
- append("%s};\n", indent)
-end
-
-local function print_enum(def, indent, append)
- append("\n")
- append("%sclass %s : public ::upb::reffed_ptr<const ::upb::EnumDef> {\n",
- indent, def:name())
- append("%s public:\n", indent)
- append("%s %s(const ::upb::EnumDef* e, const void *ref_donor = NULL)\n",
- indent, def:name())
- append("%s : reffed_ptr(e, ref_donor) {\n", indent)
- append("%s UPB_ASSERT(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name()))
- append("%s }\n", indent)
- append("%s static %s get() {\n", indent, def:name())
- append("%s const ::upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name()))
- append("%s return %s(e, &e);\n", indent, def:name())
- append("%s }\n", indent)
- append("%s};\n", indent)
-end
-
-function print_classes(name, map, indent, append)
- if not map[name] then
- return
- end
-
- for _, def in ipairs(map[name]) do
- if def:def_type() == upb.DEF_MSG then
- print_message(def, map, indent, append)
- elseif def:def_type() == upb.DEF_ENUM then
- print_enum(def, indent, append)
- else
- error("Unknown def type for " .. def:full_name())
- end
- end
-end
-
-local function dump_defs_h(file, append, linktab)
- local basename_preproc = to_preproc(file:name())
- append("/* This file contains accessors for a set of compiled-in defs.\n")
- append(" * Note that unlike Google's protobuf, it does *not* define\n")
- append(" * generated classes or any other kind of data structure for\n")
- append(" * actually storing protobufs. It only contains *defs* which\n")
- append(" * let you reflect over a protobuf *schema*.\n")
- append(" */\n")
- emit_file_warning(file, append)
- append('#ifndef %s_UPB_H_\n', basename_preproc)
- append('#define %s_UPB_H_\n\n', basename_preproc)
- append('#include "upb/def.h"\n\n')
- append('UPB_BEGIN_EXTERN_C\n\n')
-
- -- Dump C enums for proto enums.
-
- append("/* MessageDefs: call these functions to get a ref to a msgdef. */\n")
- dump_defs_for_type(
- "const upb_msgdef *upbdefs_%s_get(const void *owner);\n",
- file:defs(upb.DEF_MSG), append)
-
- append("/* EnumDefs: call these functions to get a ref to an enumdef. */\n")
- dump_defs_for_type(
- "const upb_enumdef *upbdefs_%s_get(const void *owner);\n",
- file:defs(upb.DEF_ENUM), append)
-
- append("/* Functions to test whether this message is of a certain type. */\n")
- dump_defs_for_type(
- "UPB_INLINE bool upbdefs_%s_is(const upb_msgdef *m) {\n" ..
- " return strcmp(upb_msgdef_fullname(m), \"%s\") == 0;\n}\n",
- file:defs(upb.DEF_MSG), append)
-
- append("/* Functions to test whether this enum is of a certain type. */\n")
- dump_defs_for_type(
- "UPB_INLINE bool upbdefs_%s_is(const upb_enumdef *e) {\n" ..
- " return strcmp(upb_enumdef_fullname(e), \"%s\") == 0;\n}\n",
- file:defs(upb.DEF_ENUM), append)
-
- append("\n")
-
- -- fields
- local fields = {}
-
- for f in linktab:objs(upb.DEF_FIELD) do
- local symname = f:containing_type():full_name() .. "." .. f:name()
- fields[#fields + 1] = {to_cident(symname), f}
- end
-
- table.sort(fields, function(a, b) return a[1] < b[1] end)
-
- append("/* Functions to get a fielddef from a msgdef reference. */\n")
- for _, field in ipairs(fields) do
- local f = field[2]
- local msg_cident = to_cident(f:containing_type():full_name())
- local field_cident = to_cident(f:name())
- append("UPB_INLINE const upb_fielddef *upbdefs_%s_f_%s(const upb_msgdef *m) {" ..
- " UPB_ASSERT(upbdefs_%s_is(m));" ..
- " return upb_msgdef_itof(m, %d); }\n",
- msg_cident, field_cident, msg_cident, f:number())
- end
-
- append('\nUPB_END_EXTERN_C\n\n')
-
- -- C++ wrappers.
- local children_map = make_children_map(file)
-
- append("#ifdef __cplusplus\n\n")
- append("namespace upbdefs {\n")
- start_namespace(file:package(), append)
- print_classes(file:package(), children_map, "", append)
- append("\n")
- end_namespace(file:package(), append)
- append("} /* namespace upbdefs */\n\n")
- append("#endif /* __cplusplus */\n")
-
- append("\n")
- append('#endif /* %s_UPB_H_ */\n', basename_preproc)
-end
-
-function export.dump_defs(filedef, append_h, append_c)
- local linktab = dump_defs_c(filedef, append_c)
- dump_defs_h(filedef, append_h, linktab)
-end
-
-return export
diff --git a/tools/make_c_api.lua b/tools/make_c_api.lua
index bf79b26..c333ff0 100644
--- a/tools/make_c_api.lua
+++ b/tools/make_c_api.lua
@@ -333,6 +333,7 @@ local function write_h_file(filedef, append)
append('#ifndef %s_UPB_H_\n', basename_preproc)
append('#define %s_UPB_H_\n\n', basename_preproc)
+ append('#include <string.h>\n\n')
append('#include "upb/msg.h"\n\n')
append('#include "upb/decode.h"\n')
append('#include "upb/encode.h"\n')
diff --git a/tools/test_cinit.lua b/tools/test_cinit.lua
deleted file mode 100644
index 8356d63..0000000
--- a/tools/test_cinit.lua
+++ /dev/null
@@ -1,64 +0,0 @@
---[[
-
- Tests for dump_cinit.lua. Runs first in a mode that generates
- some C code for an extension. The C code is compiled and then
- loaded by a second invocation of the test which checks that the
- generated defs are as expected.
-
---]]
-
-local dump_cinit = require "dump_cinit"
-local upb = require "upb"
-
--- Once APIs for loading descriptors are fleshed out, we should replace this
--- with a descriptor for a meaty protobuf like descriptor.proto.
-local symtab = upb.SymbolTable{
- upb.EnumDef{full_name = "MyEnum",
- values = {
- {"FOO", 1},
- {"BAR", 77}
- }
- },
- upb.MessageDef{full_name = "MyMessage",
- fields = {
- upb.FieldDef{label = upb.LABEL_REQUIRED, name = "field1", number = 1,
- type = upb.TYPE_INT32},
- upb.FieldDef{label = upb.LABEL_REPEATED, name = "field2", number = 2,
- type = upb.TYPE_ENUM, subdef_name = ".MyEnum"},
- upb.FieldDef{name = "field3", number = 3, type = upb.TYPE_MESSAGE,
- subdef_name = ".MyMessage"}
- }
- }
-}
-
-if arg[1] == "generate" then
- local f = assert(io.open(arg[2], "w"))
- local f_h = assert(io.open(arg[2] .. ".h", "w"))
- local appendc = dump_cinit.file_appender(f)
- local appendh = dump_cinit.file_appender(f_h)
- f:write('#include "lua.h"\n')
- f:write('#include "upb/bindings/lua/upb.h"\n')
- dump_cinit.dump_defs(symtab, "testdefs", appendh, appendc)
- f:write([[int luaopen_staticdefs(lua_State *L) {
- const upb_symtab *s = upbdefs_testdefs(&s);
- lupb_symtab_pushwrapper(L, s, &s);
- return 1;
- }]])
- f_h:close()
- f:close()
-elseif arg[1] == "test" then
- local symtab = require "staticdefs"
- local msg = assert(symtab:lookup("MyMessage"))
- local enum = assert(symtab:lookup("MyEnum"))
- local f2 = assert(msg:field("field2"))
- assert(msg:def_type() == upb.DEF_MSG)
- assert(msg:full_name() == "MyMessage")
- assert(enum:def_type() == upb.DEF_ENUM)
- assert(enum:full_name() == "MyEnum")
- assert(enum:value("FOO") == 1)
- assert(f2:name() == "field2")
- assert(f2:containing_type() == msg)
- assert(f2:subdef() == enum)
-else
- error("Unknown operation " .. arg[1])
-end
diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c
index 194acc3..7b3f612 100644
--- a/upb/bindings/lua/def.c
+++ b/upb/bindings/lua/def.c
@@ -6,7 +6,6 @@
#include "lauxlib.h"
#include "upb/bindings/lua/upb.h"
#include "upb/def.h"
-#include "upb/pb/glue.h"
#define LUPB_ENUMDEF "lupb.enumdef"
#define LUPB_FIELDDEF "lupb.fielddef"
@@ -1196,37 +1195,27 @@ static int lupb_symtab_gc(lua_State *L) {
}
static int lupb_symtab_add(lua_State *L) {
+ size_t len;
upb_symtab *s = lupb_symtab_check(L, 1);
- int n;
- upb_def **defs;
-
- luaL_checktype(L, 2, LUA_TTABLE);
- /* Iterate over table twice. First iteration to count entries and
- * check constraints. */
- n = 0;
- for (lua_pushnil(L); lua_next(L, 2); lua_pop(L, 1)) {
- lupb_def_checkmutable(L, -1);
- ++n;
- }
+ const char *str = luaL_checklstring(L, 2, &len);
+ google_protobuf_FileDescriptorSet *set =
+ google_protobuf_FileDescriptorSet_parsenew(upb_stringview_make(str, len),
+ upb_symtab_arena(s));
+ size_t i;
+ upb_array *file_arr;
- /* Second iteration to build deflist.
- * Allocate list with lua_newuserdata() so it is anchored as a GC root in
- * case any Lua functions longjmp(). */
- defs = lua_newuserdata(L, n * sizeof(*defs));
- n = 0;
- for (lua_pushnil(L); lua_next(L, 2); lua_pop(L, 1)) {
- upb_def *def = lupb_def_checkmutable(L, -1);
- defs[n++] = def;
+ if (!set) {
+ luaL_argerror(L, 2, "failed to parse descriptor");
}
- CHK(upb_symtab_add(s, defs, n, NULL, &status));
- return 0;
-}
+ file_arr = (upb_array*)google_protobuf_FileDescriptorSet_file(set);
+ for (i = 0; i < upb_array_size(file_arr); i++) {
+ upb_msgval entry = upb_array_get(file_arr, i);
+ google_protobuf_FileDescriptorProto *file =
+ (void *)upb_msgval_getmsg(entry);
+ CHK(upb_symtab_addfile(s, file, &status));
+ }
-static int lupb_symtab_addfile(lua_State *L) {
- upb_symtab *s = lupb_symtab_check(L, 1);
- upb_filedef *f = lupb_filedef_checkmutable(L, 2);
- CHK(upb_symtab_addfile(s, f, &status));
return 0;
}
@@ -1262,7 +1251,6 @@ static int lupb_symtab_defs(lua_State *L) {
static const struct luaL_Reg lupb_symtab_m[] = {
{"add", lupb_symtab_add},
- {"add_file", lupb_symtab_addfile},
{"defs", lupb_symtab_defs},
{"lookup", lupb_symtab_lookup},
{NULL, NULL}
@@ -1290,25 +1278,6 @@ static int lupb_freeze(lua_State *L) {
return 0;
}
-/* This is a *temporary* API that will be removed once pending refactorings are
- * complete (it does not belong here in core because it depends on both
- * the descriptor.proto schema and the protobuf binary format. */
-static int lupb_loaddescriptor(lua_State *L) {
- size_t len;
- const char *str = luaL_checklstring(L, 1, &len);
- size_t i;
- upb_filedef **files = NULL;
- CHK(files = upb_loaddescriptor(str, len, &files, &status));
-
- lua_newtable(L);
- for (i = 1; *files; i++, files++) {
- lupb_filedef_pushnewrapper(L, *files, &files);
- lua_rawseti(L, -2, i);
- }
-
- return 1;
-}
-
static void lupb_setfieldi(lua_State *L, const char *field, int i) {
lua_pushinteger(L, i);
lua_setfield(L, -2, field);
@@ -1322,7 +1291,6 @@ static const struct luaL_Reg lupbdef_toplevel_m[] = {
{"OneofDef", lupb_oneofdef_new},
{"SymbolTable", lupb_symtab_new},
{"freeze", lupb_freeze},
- {"load_descriptor", lupb_loaddescriptor},
{NULL, NULL}
};
diff --git a/upb/bindings/lua/upb/table.c b/upb/bindings/lua/upb/table.c
deleted file mode 100644
index 79120c7..0000000
--- a/upb/bindings/lua/upb/table.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-** require("upb.table") -- a Lua extension for accessing upb_table
-**
-** This is an internal-only interface and exists for the sole purpose of
-** writing a C code generator in Lua that can dump a upb_table as static C
-** initializers. This lets us use Lua for convenient string manipulation while
-** saving us from re-implementing the upb_table hash function and hash table
-** layout / collision strategy in Lua.
-**
-** Since this is used only as part of the toolchain (and not part of the
-** runtime) we do not hold this module to the same stringent requirements as
-** the main Lua modules (for example that misbehaving Lua programs cannot
-** crash the interpreter).
-*/
-
-#include <float.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "lauxlib.h"
-#include "upb/bindings/lua/upb.h"
-#include "upb/def.h"
-#include "upb/structdefs.int.h"
-#include "upb/table.int.h"
-
-static void lupbtable_setnum(lua_State *L, int tab, const char *key,
- lua_Number val) {
- lua_pushnumber(L, val);
- lua_setfield(L, tab - 1, key);
-}
-
-static void lupbtable_pushval(lua_State *L, upb_tabval val, upb_ctype_t ctype) {
- switch (ctype) {
- case UPB_CTYPE_INT32:
- lua_pushnumber(L, val.val);
- break;
- case UPB_CTYPE_PTR:
- lupb_def_pushwrapper(L, (void*)val.val, NULL);
- break;
- case UPB_CTYPE_CSTR:
- lua_pushstring(L, (const char*)val.val);
- break;
- default:
- luaL_error(L, "Unexpected type: %d", ctype);
- }
-}
-
-/* Sets a few fields common to both hash table entries and arrays. */
-static void lupbtable_setmetafields(lua_State *L, int ctype, const void *ptr) {
- /* We tack this onto every entry so we know it even if the entries
- * don't stay with the table. */
- lua_pushnumber(L, ctype);
- lua_setfield(L, -2, "valtype");
-
- /* Set this to facilitate linking. */
- lua_pushlightuserdata(L, (void*)ptr);
- lua_setfield(L, -2, "ptr");
-}
-
-static void lupbtable_pushent(lua_State *L, const upb_tabent *e,
- bool inttab, int ctype) {
- lua_newtable(L);
- if (!upb_tabent_isempty(e)) {
- if (inttab) {
- lua_pushnumber(L, e->key);
- } else {
- uint32_t len;
- const char *str = upb_tabstr(e->key, &len);
- lua_pushlstring(L, str, len);
- }
- lua_setfield(L, -2, "key");
- lupbtable_pushval(L, e->val, ctype);
- lua_setfield(L, -2, "value");
- }
- lua_pushlightuserdata(L, (void*)e->next);
- lua_setfield(L, -2, "next");
- lupbtable_setmetafields(L, ctype, e);
-}
-
-/* Dumps the shared part of upb_table into a Lua table. */
-static void lupbtable_pushtable(lua_State *L, const upb_table *t, bool inttab) {
- size_t i;
-
- lua_newtable(L);
- lupbtable_setnum(L, -1, "count", t->count);
- lupbtable_setnum(L, -1, "mask", t->mask);
- lupbtable_setnum(L, -1, "ctype", t->ctype);
- lupbtable_setnum(L, -1, "size_lg2", t->size_lg2);
-
- lua_newtable(L);
- for (i = 0; i < upb_table_size(t); i++) {
- lupbtable_pushent(L, &t->entries[i], inttab, t->ctype);
- lua_rawseti(L, -2, i + 1);
- }
- lua_setfield(L, -2, "entries");
-}
-
-/* Dumps a upb_inttable to a Lua table. */
-static void lupbtable_pushinttable(lua_State *L, const upb_inttable *t) {
- size_t i;
-
- lupbtable_pushtable(L, &t->t, true);
- lupbtable_setnum(L, -1, "array_size", t->array_size);
- lupbtable_setnum(L, -1, "array_count", t->array_count);
-
- lua_newtable(L);
- for (i = 0; i < t->array_size; i++) {
- lua_newtable(L);
- if (upb_arrhas(t->array[i])) {
- lupbtable_pushval(L, t->array[i], t->t.ctype);
- lua_setfield(L, -2, "val");
- }
- lupbtable_setmetafields(L, t->t.ctype, &t->array[i]);
- lua_rawseti(L, -2, i + 1);
- }
- lua_setfield(L, -2, "array");
-}
-
-static void lupbtable_pushstrtable(lua_State *L, const upb_strtable *t) {
- lupbtable_pushtable(L, &t->t, false);
-}
-
-static int lupbtable_msgdef_itof(lua_State *L) {
- const upb_msgdef *m = lupb_msgdef_check(L, 1);
- lupbtable_pushinttable(L, &m->itof);
- return 1;
-}
-
-static int lupbtable_msgdef_ntof(lua_State *L) {
- const upb_msgdef *m = lupb_msgdef_check(L, 1);
- lupbtable_pushstrtable(L, &m->ntof);
- return 1;
-}
-
-static int lupbtable_enumdef_iton(lua_State *L) {
- const upb_enumdef *e = lupb_enumdef_check(L, 1);
- lupbtable_pushinttable(L, &e->iton);
- return 1;
-}
-
-static int lupbtable_enumdef_ntoi(lua_State *L) {
- const upb_enumdef *e = lupb_enumdef_check(L, 1);
- lupbtable_pushstrtable(L, &e->ntoi);
- return 1;
-}
-
-static int lupbtable_symtab_symtab(lua_State *L) {
- const upb_symtab *s = lupb_symtab_check(L, 1);
- lupbtable_pushstrtable(L, &s->symtab);
- return 1;
-}
-
-static void lupbtable_setfieldi(lua_State *L, const char *field, int i) {
- lua_pushnumber(L, i);
- lua_setfield(L, -2, field);
-}
-
-/* These aren't from the table, but they access other internal-only
- * definitions. */
-static int lupb_fielddef_selectorbase(lua_State *L) {
- const upb_fielddef *f = lupb_fielddef_check(L, 1);
- if (!upb_fielddef_isfrozen(f))
- luaL_error(L, "_selectorbase is only defined for frozen fielddefs");
- lua_pushinteger(L, f->selector_base);
- return 1;
-}
-
-static int lupb_msgdef_selectorcount(lua_State *L) {
- const upb_msgdef *m = lupb_msgdef_check(L, 1);
- lua_pushinteger(L, m->selector_count);
- return 1;
-}
-
-static int lupb_msgdef_submsgfieldcount(lua_State *L) {
- const upb_msgdef *m = lupb_msgdef_check(L, 1);
- lua_pushinteger(L, m->submsg_field_count);
- return 1;
-}
-
-static const struct luaL_Reg lupbtable_toplevel_m[] = {
- {"msgdef_itof", lupbtable_msgdef_itof},
- {"msgdef_ntof", lupbtable_msgdef_ntof},
- {"enumdef_iton", lupbtable_enumdef_iton},
- {"enumdef_ntoi", lupbtable_enumdef_ntoi},
- {"symtab_symtab", lupbtable_symtab_symtab},
-
- {"msgdef_selector_count", lupb_msgdef_selectorcount},
- {"msgdef_submsg_field_count", lupb_msgdef_submsgfieldcount},
-
- {"fielddef_selector_base", lupb_fielddef_selectorbase},
-
- {NULL, NULL}
-};
-
-int luaopen_upb_table_c(lua_State *L) {
- static char module_key;
- if (lupb_openlib(L, &module_key, "upb.table", lupbtable_toplevel_m)) {
- return 1;
- }
-
- /* We define these here because they are not public. */
- lupbtable_setfieldi(L, "CTYPE_PTR", UPB_CTYPE_PTR);
- lupbtable_setfieldi(L, "CTYPE_CSTR", UPB_CTYPE_CSTR);
- lupbtable_setfieldi(L, "CTYPE_INT32", UPB_CTYPE_INT32);
-
- lua_pushlightuserdata(L, NULL);
- lua_setfield(L, -2, "NULL");
-
- return 1; /* Return a single Lua value, the package table created above. */
-}
diff --git a/upb/bindings/lua/upb/table.lua b/upb/bindings/lua/upb/table.lua
deleted file mode 100644
index ad8b066..0000000
--- a/upb/bindings/lua/upb/table.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-
-require "upb"
-return require "upb.table_c"
diff --git a/upb/decode.c b/upb/decode.c
index fc0e644..0f62326 100644
--- a/upb/decode.c
+++ b/upb/decode.c
@@ -1,4 +1,5 @@
+#include <string.h>
#include "upb/upb.h"
#include "upb/decode.h"
#include "upb/structs.int.h"
diff --git a/upb/def.c b/upb/def.c
index 0c154e6..2e53cf7 100644
--- a/upb/def.c
+++ b/upb/def.c
@@ -4,9 +4,82 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-#include "upb/structdefs.int.h"
#include "upb/handlers.h"
+struct upb_fielddef {
+ union {
+ int64_t sint;
+ uint64_t uint;
+ double dbl;
+ float flt;
+ void *bytes;
+ } defaultval;
+ const upb_msgdef *msgdef;
+ union {
+ const upb_msgdef *msgdef;
+ const upb_msgdef *enumdef;
+ char *unresolved_name;
+ } sub;
+ union {
+ const upb_oneofdef *oneof;
+ }
+ uint32_t number_;
+ uint32_t selector_base; /* Used to index into a upb::Handlers table. */
+ bool is_extension_;
+ bool lazy_;
+ bool packed_;
+ upb_descriptortype_t type_;
+ upb_label_t label_;
+};
+
+struct upb_msgdef {
+ upb_filedef *file;
+ const char *full_name;
+ uint32_t selector_count;
+ uint32_t submsg_field_count;
+
+ upb_fielddef **fields;
+ upb_oneofdef **oneofs;
+
+ /* Tables for looking up fields by number and name. Built lazily. */
+ upb_inttable *itof; /* int to field */
+ upb_strtable *ntof; /* name to field/oneof */
+
+ /* Is this a map-entry message? */
+ bool map_entry;
+
+ /* TODO(haberman): proper extension ranges (there can be multiple). */
+};
+
+struct upb_enumdef {
+ upb_strtable ntoi;
+ upb_inttable iton;
+ int32_t defaultval;
+};
+
+struct upb_oneofdef {
+ const upb_msgdef *parent;
+ const char *name;
+ upb_strtable *ntof;
+ upb_inttable *itof;
+};
+
+struct upb_symtab {
+ upb_arena arena;
+ upb_strtable symtab;
+};
+
+struct upb_filedef {
+ const char *name;
+ const char *package;
+ const char *phpprefix;
+ const char *phpnamespace;
+ upb_syntax_t syntax;
+
+ upb_inttable defs;
+ upb_inttable deps;
+};
+
typedef struct {
size_t len;
char str[1]; /* Null-terminated string data follows. */
@@ -66,186 +139,24 @@ static bool upb_isident(const char *str, size_t len, bool full, upb_status *s) {
return !start;
}
-static bool upb_isoneof(const upb_refcounted *def) {
- return def->vtbl == &upb_oneofdef_vtbl;
-}
-
-static bool upb_isfield(const upb_refcounted *def) {
- return def->vtbl == &upb_fielddef_vtbl;
-}
-
-static const upb_oneofdef *upb_trygetoneof(const upb_refcounted *def) {
- return upb_isoneof(def) ? (const upb_oneofdef*)def : NULL;
-}
-
-static const upb_fielddef *upb_trygetfield(const upb_refcounted *def) {
- return upb_isfield(def) ? (const upb_fielddef*)def : NULL;
-}
-
-
-/* upb_def ********************************************************************/
-
-upb_deftype_t upb_def_type(const upb_def *d) { return d->type; }
-
-const char *upb_def_fullname(const upb_def *d) { return d->fullname; }
-
-const char *upb_def_name(const upb_def *d) {
- const char *p;
-
- if (d->fullname == NULL) {
- return NULL;
- } else if ((p = strrchr(d->fullname, '.')) == NULL) {
- /* No '.' in the name, return the full string. */
- return d->fullname;
- } else {
- /* Return one past the last '.'. */
- return p + 1;
- }
-}
-
-bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
- UPB_ASSERT(!upb_def_isfrozen(def));
- if (!upb_isident(fullname, strlen(fullname), true, s)) {
- return false;
- }
-
- fullname = upb_gstrdup(fullname);
- if (!fullname) {
- upb_upberr_setoom(s);
- return false;
- }
-
- upb_gfree((void*)def->fullname);
- def->fullname = fullname;
+static bool upb_isoneof(const void *def) {
+ UPB_UNUSED(def);
return true;
}
-const upb_filedef *upb_def_file(const upb_def *d) { return d->file; }
-
-static bool upb_def_init(upb_def *def, upb_deftype_t type,
- const struct upb_refcounted_vtbl *vtbl,
- const void *owner) {
- if (!upb_refcounted_init(upb_def_upcast_mutable(def), vtbl, owner)) return false;
- def->type = type;
- def->fullname = NULL;
- def->came_from_user = false;
- def->file = NULL;
+static bool upb_isfield(const void *def) {
+ UPB_UNUSED(def);
return true;
}
-static void upb_def_uninit(upb_def *def) {
- upb_gfree((void*)def->fullname);
-}
-
-static const char *msgdef_name(const upb_msgdef *m) {
- const char *name = upb_def_fullname(upb_msgdef_upcast(m));
- return name ? name : "(anonymous)";
+static const upb_oneofdef *upb_trygetoneof(const void *def) {
+ return upb_isoneof(def) ? (const upb_oneofdef*)def : NULL;
}
-static bool upb_validate_field(upb_fielddef *f, upb_status *s) {
- if (upb_fielddef_name(f) == NULL || upb_fielddef_number(f) == 0) {
- upb_status_seterrmsg(s, "fielddef must have name and number set");
- return false;
- }
-
- if (!f->type_is_set_) {
- upb_status_seterrmsg(s, "fielddef type was not initialized");
- return false;
- }
-
- if (upb_fielddef_lazy(f) &&
- upb_fielddef_descriptortype(f) != UPB_DESCRIPTOR_TYPE_MESSAGE) {
- upb_status_seterrmsg(s,
- "only length-delimited submessage fields may be lazy");
- return false;
- }
-
- if (upb_fielddef_hassubdef(f)) {
- const upb_def *subdef;
-
- if (f->subdef_is_symbolic) {
- upb_status_seterrf(s, "field '%s.%s' has not been resolved",
- msgdef_name(f->msg.def), upb_fielddef_name(f));
- return false;
- }
-
- subdef = upb_fielddef_subdef(f);
- if (subdef == NULL) {
- upb_status_seterrf(s, "field %s.%s is missing required subdef",
- msgdef_name(f->msg.def), upb_fielddef_name(f));
- return false;
- }
-
- if (!upb_def_isfrozen(subdef) && !subdef->came_from_user) {
- upb_status_seterrf(s,
- "subdef of field %s.%s is not frozen or being frozen",
- msgdef_name(f->msg.def), upb_fielddef_name(f));
- return false;
- }
- }
-
- if (upb_fielddef_type(f) == UPB_TYPE_ENUM) {
- bool has_default_name = upb_fielddef_enumhasdefaultstr(f);
- bool has_default_number = upb_fielddef_enumhasdefaultint32(f);
-
- /* Previously verified by upb_validate_enumdef(). */
- UPB_ASSERT(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0);
-
- /* We've already validated that we have an associated enumdef and that it
- * has at least one member, so at least one of these should be true.
- * Because if the user didn't set anything, we'll pick up the enum's
- * default, but if the user *did* set something we should at least pick up
- * the one they set (int32 or string). */
- UPB_ASSERT(has_default_name || has_default_number);
-
- if (!has_default_name) {
- upb_status_seterrf(s,
- "enum default for field %s.%s (%d) is not in the enum",
- msgdef_name(f->msg.def), upb_fielddef_name(f),
- upb_fielddef_defaultint32(f));
- return false;
- }
-
- if (!has_default_number) {
- upb_status_seterrf(s,
- "enum default for field %s.%s (%s) is not in the enum",
- msgdef_name(f->msg.def), upb_fielddef_name(f),
- upb_fielddef_defaultstr(f, NULL));
- return false;
- }
-
- /* Lift the effective numeric default into the field's default slot, in case
- * we were only getting it "by reference" from the enumdef. */
- upb_fielddef_setdefaultint32(f, upb_fielddef_defaultint32(f));
- }
-
- /* Ensure that MapEntry submessages only appear as repeated fields, not
- * optional/required (singular) fields. */
- if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE &&
- upb_fielddef_msgsubdef(f) != NULL) {
- const upb_msgdef *subdef = upb_fielddef_msgsubdef(f);
- if (upb_msgdef_mapentry(subdef) && !upb_fielddef_isseq(f)) {
- upb_status_seterrf(s,
- "Field %s refers to mapentry message but is not "
- "a repeated field",
- upb_fielddef_name(f) ? upb_fielddef_name(f) :
- "(unnamed)");
- return false;
- }
- }
-
- return true;
+static const upb_fielddef *upb_trygetfield(const void *def) {
+ return upb_isfield(def) ? (const upb_fielddef*)def : NULL;
}
-static bool upb_validate_enumdef(const upb_enumdef *e, upb_status *s) {
- if (upb_enumdef_numvals(e) == 0) {
- upb_status_seterrf(s, "enum %s has no members (must have at least one)",
- upb_enumdef_fullname(e));
- return false;
- }
-
- return true;
-}
/* All submessage fields are lower than all other fields.
* Secondly, fields are increasing in order. */
@@ -291,11 +202,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
!upb_msg_field_done(&j);
upb_msg_field_next(&j), i++) {
upb_fielddef *f = upb_msg_iter_field(&j);
- UPB_ASSERT(f->msg.def == m);
- if (!upb_validate_field(f, s)) {
- upb_gfree(fields);
- return false;
- }
+ UPB_ASSERT(f->msgdef == m);
if (upb_fielddef_issubmsg(f)) {
m->submsg_field_count++;
}
@@ -365,6 +272,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
return true;
}
+#if 0
bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) {
size_t i;
@@ -416,73 +324,20 @@ err:
UPB_ASSERT(!(s && upb_ok(s)));
return false;
}
-
-bool upb_def_freeze(upb_def *const* defs, size_t n, upb_status *s) {
- /* Def graph contains FieldDefs between each MessageDef, so double the
- * limit. */
- const size_t maxdepth = UPB_MAX_MESSAGE_DEPTH * 2;
-
- if (!_upb_def_validate(defs, n, s)) {
- return false;
- }
-
-
- /* Validation all passed; freeze the objects. */
- return upb_refcounted_freeze((upb_refcounted *const*)defs, n, s, maxdepth);
-}
+#endif
/* upb_enumdef ****************************************************************/
-static void visitenum(const upb_refcounted *r, upb_refcounted_visit *visit,
- void *closure) {
- const upb_enumdef *e = (const upb_enumdef*)r;
- const upb_def *def = upb_enumdef_upcast(e);
- if (upb_def_file(def)) {
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
- }
-}
-
-static void freeenum(upb_refcounted *r) {
- upb_enumdef *e = (upb_enumdef*)r;
- upb_inttable_iter i;
- upb_inttable_begin(&i, &e->iton);
- for( ; !upb_inttable_done(&i); upb_inttable_next(&i)) {
- /* To clean up the upb_gstrdup() from upb_enumdef_addval(). */
- upb_gfree(upb_value_getcstr(upb_inttable_iter_value(&i)));
- }
- upb_strtable_uninit(&e->ntoi);
- upb_inttable_uninit(&e->iton);
- upb_def_uninit(upb_enumdef_upcast_mutable(e));
- upb_gfree(e);
-}
-
-const struct upb_refcounted_vtbl upb_enumdef_vtbl = {&visitenum, &freeenum};
-
-upb_enumdef *upb_enumdef_new(const void *owner) {
- upb_enumdef *e = upb_gmalloc(sizeof(*e));
- if (!e) return NULL;
-
- if (!upb_def_init(upb_enumdef_upcast_mutable(e), UPB_DEF_ENUM,
- &upb_enumdef_vtbl, owner)) {
- goto err2;
- }
+#if 0
+bool upb_enumdef_init(upb_enumdef *e) {
+ upb_def_init(&e->base, UPB_DEF_ENUM);
if (!upb_strtable_init(&e->ntoi, UPB_CTYPE_INT32)) goto err2;
if (!upb_inttable_init(&e->iton, UPB_CTYPE_CSTR)) goto err1;
- return e;
-
-err1:
- upb_strtable_uninit(&e->ntoi);
-err2:
- upb_gfree(e);
- return NULL;
-}
-
-bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status) {
- upb_def *d = upb_enumdef_upcast_mutable(e);
- return upb_def_freeze(&d, 1, status);
+ return true;
}
+#endif
const char *upb_enumdef_fullname(const upb_enumdef *e) {
return upb_def_fullname(upb_enumdef_upcast(e));
@@ -492,11 +347,7 @@ const char *upb_enumdef_name(const upb_enumdef *e) {
return upb_def_name(upb_enumdef_upcast(e));
}
-bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
- upb_status *s) {
- return upb_def_setfullname(upb_enumdef_upcast_mutable(e), fullname, s);
-}
-
+#if 0
bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
upb_status *status) {
char *name2;
@@ -531,12 +382,14 @@ bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
return true;
}
+#endif
int32_t upb_enumdef_default(const upb_enumdef *e) {
UPB_ASSERT(upb_enumdef_iton(e, e->defaultval));
return e->defaultval;
}
+#if 0
bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) {
UPB_ASSERT(!upb_enumdef_isfrozen(e));
if (!upb_enumdef_iton(e, val)) {
@@ -546,6 +399,7 @@ bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) {
e->defaultval = val;
return true;
}
+#endif
int upb_enumdef_numvals(const upb_enumdef *e) {
return upb_strtable_count(&e->ntoi);
@@ -588,110 +442,19 @@ int32_t upb_enum_iter_number(upb_enum_iter *iter) {
static void upb_fielddef_init_default(upb_fielddef *f);
-static void upb_fielddef_uninit_default(upb_fielddef *f) {
- if (f->type_is_set_ && f->default_is_string && f->defaultval.bytes)
- freestr(f->defaultval.bytes);
-}
-
const char *upb_fielddef_fullname(const upb_fielddef *e) {
return upb_def_fullname(upb_fielddef_upcast(e));
}
-static void visitfield(const upb_refcounted *r, upb_refcounted_visit *visit,
- void *closure) {
- const upb_fielddef *f = (const upb_fielddef*)r;
- const upb_def *def = upb_fielddef_upcast(f);
- if (upb_fielddef_containingtype(f)) {
- visit(r, upb_msgdef_upcast2(upb_fielddef_containingtype(f)), closure);
- }
- if (upb_fielddef_containingoneof(f)) {
- visit(r, upb_oneofdef_upcast(upb_fielddef_containingoneof(f)), closure);
- }
- if (upb_fielddef_subdef(f)) {
- visit(r, upb_def_upcast(upb_fielddef_subdef(f)), closure);
- }
- if (upb_def_file(def)) {
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
- }
-}
-
-static void freefield(upb_refcounted *r) {
- upb_fielddef *f = (upb_fielddef*)r;
- upb_fielddef_uninit_default(f);
- if (f->subdef_is_symbolic)
- upb_gfree(f->sub.name);
- upb_def_uninit(upb_fielddef_upcast_mutable(f));
- upb_gfree(f);
-}
-
-static const char *enumdefaultstr(const upb_fielddef *f) {
- const upb_enumdef *e;
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
- e = upb_fielddef_enumsubdef(f);
- if (f->default_is_string && f->defaultval.bytes) {
- /* Default was explicitly set as a string. */
- str_t *s = f->defaultval.bytes;
- return s->str;
- } else if (e) {
- if (!f->default_is_string) {
- /* Default was explicitly set as an integer; look it up in enumdef. */
- const char *name = upb_enumdef_iton(e, f->defaultval.sint);
- if (name) {
- return name;
- }
- } else {
- /* Default is completely unset; pull enumdef default. */
- if (upb_enumdef_numvals(e) > 0) {
- const char *name = upb_enumdef_iton(e, upb_enumdef_default(e));
- UPB_ASSERT(name);
- return name;
- }
- }
- }
- return NULL;
-}
-
-static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) {
- const upb_enumdef *e;
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
- e = upb_fielddef_enumsubdef(f);
- if (!f->default_is_string) {
- /* Default was explicitly set as an integer. */
- *val = f->defaultval.sint;
- return true;
- } else if (e) {
- if (f->defaultval.bytes) {
- /* Default was explicitly set as a str; try to lookup corresponding int. */
- str_t *s = f->defaultval.bytes;
- if (upb_enumdef_ntoiz(e, s->str, val)) {
- return true;
- }
- } else {
- /* Default is unset; try to pull in enumdef default. */
- if (upb_enumdef_numvals(e) > 0) {
- *val = upb_enumdef_default(e);
- return true;
- }
- }
- }
- return false;
-}
-
-const struct upb_refcounted_vtbl upb_fielddef_vtbl = {visitfield, freefield};
-
+#if 0
upb_fielddef *upb_fielddef_new(const void *o) {
upb_fielddef *f = upb_gmalloc(sizeof(*f));
if (!f) return NULL;
- if (!upb_def_init(upb_fielddef_upcast_mutable(f), UPB_DEF_FIELD,
- &upb_fielddef_vtbl, o)) {
- upb_gfree(f);
- return NULL;
- }
+ upb_def_init(&f->base, UPB_DEF_FIELD);
f->msg.def = NULL;
f->sub.def = NULL;
f->oneof = NULL;
f->subdef_is_symbolic = false;
- f->msg_is_symbolic = false;
f->label_ = UPB_LABEL_OPTIONAL;
f->type_ = UPB_TYPE_INT32;
f->number_ = 0;
@@ -712,13 +475,9 @@ upb_fielddef *upb_fielddef_new(const void *o) {
f->intfmt = UPB_INTFMT_VARIABLE;
return f;
}
-
-bool upb_fielddef_typeisset(const upb_fielddef *f) {
- return f->type_is_set_;
-}
+#endif
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) {
- UPB_ASSERT(f->type_is_set_);
return f->type_;
}
@@ -798,60 +557,16 @@ size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len) {
}
const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f) {
- return f->msg_is_symbolic ? NULL : f->msg.def;
+ return f->msgdef;
}
const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f) {
return f->oneof;
}
-upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f) {
- return (upb_msgdef*)upb_fielddef_containingtype(f);
-}
-
-const char *upb_fielddef_containingtypename(upb_fielddef *f) {
- return f->msg_is_symbolic ? f->msg.name : NULL;
-}
-
-static void release_containingtype(upb_fielddef *f) {
- if (f->msg_is_symbolic) upb_gfree(f->msg.name);
-}
-
-bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
- upb_status *s) {
- char *name_copy;
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- if (upb_fielddef_containingtype(f)) {
- upb_status_seterrmsg(s, "field has already been added to a message.");
- return false;
- }
- /* TODO: validate name (upb_isident() doesn't quite work atm because this name
- * may have a leading "."). */
-
- name_copy = upb_gstrdup(name);
- if (!name_copy) {
- upb_upberr_setoom(s);
- return false;
- }
-
- release_containingtype(f);
- f->msg.name = name_copy;
- f->msg_is_symbolic = true;
- return true;
-}
-
-bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) {
- if (upb_fielddef_containingtype(f) || upb_fielddef_containingoneof(f)) {
- upb_status_seterrmsg(s, "Already added to message or oneof");
- return false;
- }
- return upb_def_setfullname(upb_fielddef_upcast_mutable(f), name, s);
-}
-
-static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) {
+static void chkdefaulttype(const upb_fielddef *f, int ctype) {
UPB_UNUSED(f);
- UPB_UNUSED(type);
- UPB_ASSERT(f->type_is_set_ && upb_fielddef_type(f) == type);
+ UPB_UNUSED(ctype);
}
int64_t upb_fielddef_defaultint64(const upb_fielddef *f) {
@@ -860,15 +575,8 @@ int64_t upb_fielddef_defaultint64(const upb_fielddef *f) {
}
int32_t upb_fielddef_defaultint32(const upb_fielddef *f) {
- if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) {
- int32_t val;
- bool ok = enumdefaultint32(f, &val);
- UPB_ASSERT(ok);
- return val;
- } else {
- chkdefaulttype(f, UPB_TYPE_INT32);
- return f->defaultval.sint;
- }
+ chkdefaulttype(f, UPB_TYPE_INT32);
+ return f->defaultval.sint;
}
uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f) {
@@ -943,10 +651,6 @@ static void upb_fielddef_init_default(upb_fielddef *f) {
}
}
-const upb_def *upb_fielddef_subdef(const upb_fielddef *f) {
- return f->subdef_is_symbolic ? NULL : f->sub.def;
-}
-
const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f) {
const upb_def *def = upb_fielddef_subdef(f);
return def ? upb_dyncast_msgdef(def) : NULL;
@@ -957,10 +661,6 @@ const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f) {
return def ? upb_dyncast_enumdef(def) : NULL;
}
-upb_def *upb_fielddef_subdef_mutable(upb_fielddef *f) {
- return (upb_def*)upb_fielddef_subdef(f);
-}
-
const char *upb_fielddef_subdefname(const upb_fielddef *f) {
if (f->subdef_is_symbolic) {
return f->sub.name;
@@ -985,237 +685,8 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) {
return true;
}
-void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- UPB_ASSERT(upb_fielddef_checktype(type));
- upb_fielddef_uninit_default(f);
- f->type_ = type;
- f->type_is_set_ = true;
- upb_fielddef_init_default(f);
-}
-
-void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- switch (type) {
- case UPB_DESCRIPTOR_TYPE_DOUBLE:
- upb_fielddef_settype(f, UPB_TYPE_DOUBLE);
- break;
- case UPB_DESCRIPTOR_TYPE_FLOAT:
- upb_fielddef_settype(f, UPB_TYPE_FLOAT);
- break;
- case UPB_DESCRIPTOR_TYPE_INT64:
- case UPB_DESCRIPTOR_TYPE_SFIXED64:
- case UPB_DESCRIPTOR_TYPE_SINT64:
- upb_fielddef_settype(f, UPB_TYPE_INT64);
- break;
- case UPB_DESCRIPTOR_TYPE_UINT64:
- case UPB_DESCRIPTOR_TYPE_FIXED64:
- upb_fielddef_settype(f, UPB_TYPE_UINT64);
- break;
- case UPB_DESCRIPTOR_TYPE_INT32:
- case UPB_DESCRIPTOR_TYPE_SFIXED32:
- case UPB_DESCRIPTOR_TYPE_SINT32:
- upb_fielddef_settype(f, UPB_TYPE_INT32);
- break;
- case UPB_DESCRIPTOR_TYPE_UINT32:
- case UPB_DESCRIPTOR_TYPE_FIXED32:
- upb_fielddef_settype(f, UPB_TYPE_UINT32);
- break;
- case UPB_DESCRIPTOR_TYPE_BOOL:
- upb_fielddef_settype(f, UPB_TYPE_BOOL);
- break;
- case UPB_DESCRIPTOR_TYPE_STRING:
- upb_fielddef_settype(f, UPB_TYPE_STRING);
- break;
- case UPB_DESCRIPTOR_TYPE_BYTES:
- upb_fielddef_settype(f, UPB_TYPE_BYTES);
- break;
- case UPB_DESCRIPTOR_TYPE_GROUP:
- case UPB_DESCRIPTOR_TYPE_MESSAGE:
- upb_fielddef_settype(f, UPB_TYPE_MESSAGE);
- break;
- case UPB_DESCRIPTOR_TYPE_ENUM:
- upb_fielddef_settype(f, UPB_TYPE_ENUM);
- break;
- default: UPB_ASSERT(false);
- }
-
- if (type == UPB_DESCRIPTOR_TYPE_FIXED64 ||
- type == UPB_DESCRIPTOR_TYPE_FIXED32 ||
- type == UPB_DESCRIPTOR_TYPE_SFIXED64 ||
- type == UPB_DESCRIPTOR_TYPE_SFIXED32) {
- upb_fielddef_setintfmt(f, UPB_INTFMT_FIXED);
- } else if (type == UPB_DESCRIPTOR_TYPE_SINT64 ||
- type == UPB_DESCRIPTOR_TYPE_SINT32) {
- upb_fielddef_setintfmt(f, UPB_INTFMT_ZIGZAG);
- } else {
- upb_fielddef_setintfmt(f, UPB_INTFMT_VARIABLE);
- }
-
- upb_fielddef_settagdelim(f, type == UPB_DESCRIPTOR_TYPE_GROUP);
-}
-
upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) {
- switch (upb_fielddef_type(f)) {
- case UPB_TYPE_FLOAT: return UPB_DESCRIPTOR_TYPE_FLOAT;
- case UPB_TYPE_DOUBLE: return UPB_DESCRIPTOR_TYPE_DOUBLE;
- case UPB_TYPE_BOOL: return UPB_DESCRIPTOR_TYPE_BOOL;
- case UPB_TYPE_STRING: return UPB_DESCRIPTOR_TYPE_STRING;
- case UPB_TYPE_BYTES: return UPB_DESCRIPTOR_TYPE_BYTES;
- case UPB_TYPE_ENUM: return UPB_DESCRIPTOR_TYPE_ENUM;
- case UPB_TYPE_INT32:
- switch (upb_fielddef_intfmt(f)) {
- case UPB_INTFMT_VARIABLE: return UPB_DESCRIPTOR_TYPE_INT32;
- case UPB_INTFMT_FIXED: return UPB_DESCRIPTOR_TYPE_SFIXED32;
- case UPB_INTFMT_ZIGZAG: return UPB_DESCRIPTOR_TYPE_SINT32;
- }
- case UPB_TYPE_INT64:
- switch (upb_fielddef_intfmt(f)) {
- case UPB_INTFMT_VARIABLE: return UPB_DESCRIPTOR_TYPE_INT64;
- case UPB_INTFMT_FIXED: return UPB_DESCRIPTOR_TYPE_SFIXED64;
- case UPB_INTFMT_ZIGZAG: return UPB_DESCRIPTOR_TYPE_SINT64;
- }
- case UPB_TYPE_UINT32:
- switch (upb_fielddef_intfmt(f)) {
- case UPB_INTFMT_VARIABLE: return UPB_DESCRIPTOR_TYPE_UINT32;
- case UPB_INTFMT_FIXED: return UPB_DESCRIPTOR_TYPE_FIXED32;
- case UPB_INTFMT_ZIGZAG: return -1;
- }
- case UPB_TYPE_UINT64:
- switch (upb_fielddef_intfmt(f)) {
- case UPB_INTFMT_VARIABLE: return UPB_DESCRIPTOR_TYPE_UINT64;
- case UPB_INTFMT_FIXED: return UPB_DESCRIPTOR_TYPE_FIXED64;
- case UPB_INTFMT_ZIGZAG: return -1;
- }
- case UPB_TYPE_MESSAGE:
- return upb_fielddef_istagdelim(f) ?
- UPB_DESCRIPTOR_TYPE_GROUP : UPB_DESCRIPTOR_TYPE_MESSAGE;
- }
- return 0;
-}
-
-void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- f->is_extension_ = is_extension;
-}
-
-void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- f->lazy_ = lazy;
-}
-
-void upb_fielddef_setpacked(upb_fielddef *f, bool packed) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- f->packed_ = packed;
-}
-
-void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- UPB_ASSERT(upb_fielddef_checklabel(label));
- f->label_ = label;
-}
-
-void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- UPB_ASSERT(upb_fielddef_checkintfmt(fmt));
- f->intfmt = fmt;
-}
-
-void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- f->tagdelim = tag_delim;
- f->tagdelim = tag_delim;
-}
-
-static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) {
- if (!f->type_is_set_ || upb_fielddef_isfrozen(f) ||
- upb_fielddef_type(f) != type) {
- UPB_ASSERT(false);
- return false;
- }
- if (f->default_is_string) {
- str_t *s = f->defaultval.bytes;
- UPB_ASSERT(s || type == UPB_TYPE_ENUM);
- if (s) freestr(s);
- }
- f->default_is_string = false;
- return true;
-}
-
-void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t value) {
- if (checksetdefault(f, UPB_TYPE_INT64))
- f->defaultval.sint = value;
-}
-
-void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t value) {
- if ((upb_fielddef_type(f) == UPB_TYPE_ENUM &&
- checksetdefault(f, UPB_TYPE_ENUM)) ||
- checksetdefault(f, UPB_TYPE_INT32)) {
- f->defaultval.sint = value;
- }
-}
-
-void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t value) {
- if (checksetdefault(f, UPB_TYPE_UINT64))
- f->defaultval.uint = value;
-}
-
-void upb_fielddef_setdefaultuint32(upb_fielddef *f, uint32_t value) {
- if (checksetdefault(f, UPB_TYPE_UINT32))
- f->defaultval.uint = value;
-}
-
-void upb_fielddef_setdefaultbool(upb_fielddef *f, bool value) {
- if (checksetdefault(f, UPB_TYPE_BOOL))
- f->defaultval.uint = value;
-}
-
-void upb_fielddef_setdefaultfloat(upb_fielddef *f, float value) {
- if (checksetdefault(f, UPB_TYPE_FLOAT))
- f->defaultval.flt = value;
-}
-
-void upb_fielddef_setdefaultdouble(upb_fielddef *f, double value) {
- if (checksetdefault(f, UPB_TYPE_DOUBLE))
- f->defaultval.dbl = value;
-}
-
-bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
- upb_status *s) {
- str_t *str2;
- UPB_ASSERT(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM);
- if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s))
- return false;
-
- if (f->default_is_string) {
- str_t *s = f->defaultval.bytes;
- UPB_ASSERT(s || f->type_ == UPB_TYPE_ENUM);
- if (s) freestr(s);
- } else {
- UPB_ASSERT(f->type_ == UPB_TYPE_ENUM);
- }
-
- str2 = newstr(str, len);
- f->defaultval.bytes = str2;
- f->default_is_string = true;
- return true;
-}
-
-void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str,
- upb_status *s) {
- UPB_ASSERT(f->type_is_set_);
- upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s);
-}
-
-bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) {
- int32_t val;
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
- return enumdefaultint32(f, &val);
-}
-
-bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) {
- UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
- return enumdefaultstr(f) != NULL;
+ return f->type;
}
static bool upb_subdef_typecheck(upb_fielddef *f, const upb_def *subdef,
@@ -1234,59 +705,6 @@ static bool upb_subdef_typecheck(upb_fielddef *f, const upb_def *subdef,
}
}
-static void release_subdef(upb_fielddef *f) {
- if (f->subdef_is_symbolic) {
- upb_gfree(f->sub.name);
- } else if (f->sub.def) {
- upb_unref2(f->sub.def, f);
- }
-}
-
-bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef,
- upb_status *s) {
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- UPB_ASSERT(upb_fielddef_hassubdef(f));
- if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false;
- release_subdef(f);
- f->sub.def = subdef;
- f->subdef_is_symbolic = false;
- if (f->sub.def) upb_ref2(f->sub.def, f);
- return true;
-}
-
-bool upb_fielddef_setmsgsubdef(upb_fielddef *f, const upb_msgdef *subdef,
- upb_status *s) {
- return upb_fielddef_setsubdef(f, upb_msgdef_upcast(subdef), s);
-}
-
-bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef,
- upb_status *s) {
- return upb_fielddef_setsubdef(f, upb_enumdef_upcast(subdef), s);
-}
-
-bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name,
- upb_status *s) {
- char *name_copy;
- UPB_ASSERT(!upb_fielddef_isfrozen(f));
- if (!upb_fielddef_hassubdef(f)) {
- upb_status_seterrmsg(s, "field type does not accept a subdef");
- return false;
- }
-
- name_copy = upb_gstrdup(name);
- if (!name_copy) {
- upb_upberr_setoom(s);
- return false;
- }
-
- /* TODO: validate name (upb_isident() doesn't quite work atm because this name
- * may have a leading "."). */
- release_subdef(f);
- f->sub.name = name_copy;
- f->subdef_is_symbolic = true;
- return true;
-}
-
bool upb_fielddef_issubmsg(const upb_fielddef *f) {
return upb_fielddef_type(f) == UPB_TYPE_MESSAGE;
}
@@ -1343,66 +761,6 @@ static const char *kValueFullMessageName = "google.protobuf.Value";
static const char *kListValueFullMessageName = "google.protobuf.ListValue";
static const char *kStructFullMessageName = "google.protobuf.Struct";
-static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit,
- void *closure) {
- upb_msg_oneof_iter o;
- const upb_msgdef *m = (const upb_msgdef*)r;
- const upb_def *def = upb_msgdef_upcast(m);
- upb_msg_field_iter i;
- for(upb_msg_field_begin(&i, m);
- !upb_msg_field_done(&i);
- upb_msg_field_next(&i)) {
- upb_fielddef *f = upb_msg_iter_field(&i);
- visit(r, upb_fielddef_upcast2(f), closure);
- }
- for(upb_msg_oneof_begin(&o, m);
- !upb_msg_oneof_done(&o);
- upb_msg_oneof_next(&o)) {
- upb_oneofdef *f = upb_msg_iter_oneof(&o);
- visit(r, upb_oneofdef_upcast(f), closure);
- }
- if (upb_def_file(def)) {
- visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
- }
-}
-
-static void freemsg(upb_refcounted *r) {
- upb_msgdef *m = (upb_msgdef*)r;
- upb_strtable_uninit(&m->ntof);
- upb_inttable_uninit(&m->itof);
- upb_def_uninit(upb_msgdef_upcast_mutable(m));
- upb_gfree(m);
-}
-
-const struct upb_refcounted_vtbl upb_msgdef_vtbl = {visitmsg, freemsg};
-
-upb_msgdef *upb_msgdef_new(const void *owner) {
- upb_msgdef *m = upb_gmalloc(sizeof(*m));
- if (!m) return NULL;
-
- if (!upb_def_init(upb_msgdef_upcast_mutable(m), UPB_DEF_MSG, &upb_msgdef_vtbl,
- owner)) {
- goto err2;
- }
-
- if (!upb_inttable_init(&m->itof, UPB_CTYPE_PTR)) goto err2;
- if (!upb_strtable_init(&m->ntof, UPB_CTYPE_PTR)) goto err1;
- m->map_entry = false;
- m->syntax = UPB_SYNTAX_PROTO2;
- return m;
-
-err1:
- upb_inttable_uninit(&m->itof);
-err2:
- upb_gfree(m);
- return NULL;
-}
-
-bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status) {
- upb_def *d = upb_msgdef_upcast_mutable(m);
- return upb_def_freeze(&d, 1, status);
-}
-
const char *upb_msgdef_fullname(const upb_msgdef *m) {
return upb_def_fullname(upb_msgdef_upcast(m));
}
@@ -1411,20 +769,6 @@ const char *upb_msgdef_name(const upb_msgdef *m) {
return upb_def_name(upb_msgdef_upcast(m));
}
-bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname,
- upb_status *s) {
- return upb_def_setfullname(upb_msgdef_upcast_mutable(m), fullname, s);
-}
-
-bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax) {
- if (syntax != UPB_SYNTAX_PROTO2 && syntax != UPB_SYNTAX_PROTO3) {
- return false;
- }
-
- m->syntax = syntax;
- return true;
-}
-
upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m) {
return m->syntax;
}
@@ -1449,17 +793,6 @@ static bool check_field_add(const upb_msgdef *m, const upb_fielddef *f,
return true;
}
-static void add_field(upb_msgdef *m, upb_fielddef *f, const void *ref_donor) {
- release_containingtype(f);
- f->msg.def = m;
- f->msg_is_symbolic = false;
- upb_inttable_insert(&m->itof, upb_fielddef_number(f), upb_value_ptr(f));
- upb_strtable_insert(&m->ntof, upb_fielddef_name(f), upb_value_ptr(f));
- upb_ref2(f, m);
- upb_ref2(m, f);
- if (ref_donor) upb_fielddef_unref(f, ref_donor);
-}
-
bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
upb_status *s) {
/* TODO: extensions need to have a separate namespace, because proto2 allows a
@@ -1590,11 +923,6 @@ int upb_msgdef_numoneofs(const upb_msgdef *m) {
return upb_strtable_count(&m->ntof) - upb_inttable_count(&m->itof);
}
-void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) {
- UPB_ASSERT(!upb_msgdef_isfrozen(m));
- m->map_entry = map_entry;
-}
-
bool upb_msgdef_mapentry(const upb_msgdef *m) {
return m->map_entry;
}
@@ -1668,80 +996,8 @@ void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter *iter) {
/* upb_oneofdef ***************************************************************/
-static void visitoneof(const upb_refcounted *r, upb_refcounted_visit *visit,
- void *closure) {
- const upb_oneofdef *o = (const upb_oneofdef*)r;
- upb_oneof_iter i;
- for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) {
- const upb_fielddef *f = upb_oneof_iter_field(&i);
- visit(r, upb_fielddef_upcast2(f), closure);
- }
- if (o->parent) {
- visit(r, upb_msgdef_upcast2(o->parent), closure);
- }
-}
-
-static void freeoneof(upb_refcounted *r) {
- upb_oneofdef *o = (upb_oneofdef*)r;
- upb_strtable_uninit(&o->ntof);
- upb_inttable_uninit(&o->itof);
- upb_gfree((void*)o->name);
- upb_gfree(o);
-}
-
-const struct upb_refcounted_vtbl upb_oneofdef_vtbl = {visitoneof, freeoneof};
-
-upb_oneofdef *upb_oneofdef_new(const void *owner) {
- upb_oneofdef *o = upb_gmalloc(sizeof(*o));
-
- if (!o) {
- return NULL;
- }
-
- o->parent = NULL;
- o->name = NULL;
-
- if (!upb_refcounted_init(upb_oneofdef_upcast_mutable(o), &upb_oneofdef_vtbl,
- owner)) {
- goto err2;
- }
-
- if (!upb_inttable_init(&o->itof, UPB_CTYPE_PTR)) goto err2;
- if (!upb_strtable_init(&o->ntof, UPB_CTYPE_PTR)) goto err1;
-
- return o;
-
-err1:
- upb_inttable_uninit(&o->itof);
-err2:
- upb_gfree(o);
- return NULL;
-}
-
const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; }
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) {
- UPB_ASSERT(!upb_oneofdef_isfrozen(o));
- if (upb_oneofdef_containingtype(o)) {
- upb_status_seterrmsg(s, "oneof already added to a message");
- return false;
- }
-
- if (!upb_isident(name, strlen(name), true, s)) {
- return false;
- }
-
- name = upb_gstrdup(name);
- if (!name) {
- upb_status_seterrmsg(s, "One of memory");
- return false;
- }
-
- upb_gfree((void*)o->name);
- o->name = name;
- return true;
-}
-
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o) {
return o->parent;
}
@@ -1818,7 +1074,6 @@ bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
}
}
- release_containingtype(f);
f->oneof = o;
upb_inttable_insert(&o->itof, upb_fielddef_number(f), upb_value_ptr(f));
upb_strtable_insert(&o->ntof, upb_fielddef_name(f), upb_value_ptr(f));
@@ -1864,35 +1119,6 @@ void upb_oneof_iter_setdone(upb_oneof_iter *iter) {
/* upb_filedef ****************************************************************/
-static void visitfiledef(const upb_refcounted *r, upb_refcounted_visit *visit,
- void *closure) {
- const upb_filedef *f = (const upb_filedef*)r;
- size_t i;
-
- for(i = 0; i < upb_filedef_defcount(f); i++) {
- visit(r, upb_def_upcast(upb_filedef_def(f, i)), closure);
- }
-}
-
-static void freefiledef(upb_refcounted *r) {
- upb_filedef *f = (upb_filedef*)r;
- size_t i;
-
- for(i = 0; i < upb_filedef_depcount(f); i++) {
- upb_filedef_unref(upb_filedef_dep(f, i), f);
- }
-
- upb_inttable_uninit(&f->defs);
- upb_inttable_uninit(&f->deps);
- upb_gfree((void*)f->name);
- upb_gfree((void*)f->package);
- upb_gfree((void*)f->phpprefix);
- upb_gfree((void*)f->phpnamespace);
- upb_gfree(f);
-}
-
-const struct upb_refcounted_vtbl upb_filedef_vtbl = {visitfiledef, freefiledef};
-
upb_filedef *upb_filedef_new(const void *owner) {
upb_filedef *f = upb_gmalloc(sizeof(*f));
@@ -1906,11 +1132,6 @@ upb_filedef *upb_filedef_new(const void *owner) {
f->phpnamespace = NULL;
f->syntax = UPB_SYNTAX_PROTO2;
- if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &upb_filedef_vtbl,
- owner)) {
- goto err;
- }
-
if (!upb_inttable_init(&f->defs, UPB_CTYPE_CONSTPTR)) {
goto err;
}
@@ -1978,122 +1199,8 @@ const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i) {
}
}
-bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s) {
- name = upb_gstrdup(name);
- if (!name) {
- upb_upberr_setoom(s);
- return false;
- }
- upb_gfree((void*)f->name);
- f->name = name;
- return true;
-}
-
-bool upb_filedef_setpackage(upb_filedef *f, const char *package,
- upb_status *s) {
- if (!upb_isident(package, strlen(package), true, s)) return false;
- package = upb_gstrdup(package);
- if (!package) {
- upb_upberr_setoom(s);
- return false;
- }
- upb_gfree((void*)f->package);
- f->package = package;
- return true;
-}
-
-bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix,
- upb_status *s) {
- phpprefix = upb_gstrdup(phpprefix);
- if (!phpprefix) {
- upb_upberr_setoom(s);
- return false;
- }
- upb_gfree((void*)f->phpprefix);
- f->phpprefix = phpprefix;
- return true;
-}
-
-bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace,
- upb_status *s) {
- phpnamespace = upb_gstrdup(phpnamespace);
- if (!phpnamespace) {
- upb_upberr_setoom(s);
- return false;
- }
- upb_gfree((void*)f->phpnamespace);
- f->phpnamespace = phpnamespace;
- return true;
-}
-
-bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax,
- upb_status *s) {
- UPB_UNUSED(s);
- if (syntax != UPB_SYNTAX_PROTO2 &&
- syntax != UPB_SYNTAX_PROTO3) {
- upb_status_seterrmsg(s, "Unknown syntax value.");
- return false;
- }
- f->syntax = syntax;
-
- {
- /* Set all messages in this file to match. */
- size_t i;
- for (i = 0; i < upb_filedef_defcount(f); i++) {
- /* Casting const away is safe since all defs in mutable filedef must
- * also be mutable. */
- upb_def *def = (upb_def*)upb_filedef_def(f, i);
-
- upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
- if (m) {
- m->syntax = syntax;
- }
- }
- }
-
- return true;
-}
-
-bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
- upb_status *s) {
- if (def->file) {
- upb_status_seterrmsg(s, "Def is already part of another filedef.");
- return false;
- }
-
- if (upb_inttable_push(&f->defs, upb_value_constptr(def))) {
- def->file = f;
- upb_ref2(def, f);
- upb_ref2(f, def);
- if (ref_donor) upb_def_unref(def, ref_donor);
- if (def->type == UPB_DEF_MSG) {
- upb_downcast_msgdef_mutable(def)->syntax = f->syntax;
- }
- return true;
- } else {
- upb_upberr_setoom(s);
- return false;
- }
-}
-
-bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep) {
- if (upb_inttable_push(&f->deps, upb_value_constptr(dep))) {
- /* Regular ref instead of ref2 because files can't form cycles. */
- upb_filedef_ref(dep, f);
- return true;
- } else {
- return false;
- }
-}
-
void upb_symtab_free(upb_symtab *s) {
- upb_strtable_iter i;
- upb_strtable_begin(&i, &s->symtab);
- for (; !upb_strtable_done(&i); upb_strtable_next(&i)) {
- const upb_def *def = upb_value_getptr(upb_strtable_iter_value(&i));
- upb_def_unref(def, s);
- }
- upb_strtable_uninit(&s->symtab);
+ upb_arena_uninit(&s->arena);
upb_gfree(s);
}
@@ -2103,7 +1210,17 @@ upb_symtab *upb_symtab_new() {
return NULL;
}
- upb_strtable_init(&s->symtab, UPB_CTYPE_PTR);
+ if (!upb_arena_init(&s->arena)) goto err2;
+ if (!upb_strtable_init2(&s->symtab, UPB_CTYPE_PTR,
+ upb_arena_alloc(&s->arena))) {
+ goto err1;
+ }
+ return s;
+
+err1:
+ upb_arena_uninit(&s->arena);
+err2:
+ upb_gfree(s);
return s;
}
@@ -2153,77 +1270,7 @@ const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
return ret;
}
-/* TODO(haberman): we need a lot more testing of error conditions. */
-static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_refcounted *freeze_also,
- upb_status *status) {
- size_t i;
- size_t add_n;
- size_t freeze_n;
- upb_strtable_iter iter;
- upb_refcounted **add_objs = NULL;
- upb_def **add_defs = NULL;
- size_t add_objs_size;
- upb_strtable addtab;
-
- if (n == 0 && !freeze_also) {
- return true;
- }
-
- if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
- upb_status_seterrmsg(status, "out of memory");
- return false;
- }
-
- /* Add new defs to our "add" set. */
- for (i = 0; i < n; i++) {
- upb_def *def = defs[i];
- const char *fullname;
- upb_fielddef *f;
-
- if (upb_def_isfrozen(def)) {
- upb_status_seterrmsg(status, "added defs must be mutable");
- goto err;
- }
- UPB_ASSERT(!upb_def_isfrozen(def));
- fullname = upb_def_fullname(def);
- if (!fullname) {
- upb_status_seterrmsg(
- status, "Anonymous defs cannot be added to a symtab");
- goto err;
- }
-
- f = upb_dyncast_fielddef_mutable(def);
-
- if (f) {
- if (!upb_fielddef_containingtypename(f)) {
- upb_status_seterrmsg(status,
- "Standalone fielddefs must have a containing type "
- "(extendee) name set");
- goto err;
- }
- } else {
- if (upb_strtable_lookup(&addtab, fullname, NULL)) {
- upb_status_seterrf(status, "Conflicting defs named '%s'", fullname);
- goto err;
- }
- if (upb_strtable_lookup(&s->symtab, fullname, NULL)) {
- upb_status_seterrf(status, "Symtab already has a def named '%s'",
- fullname);
- goto err;
- }
- if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
- goto oom_err;
- upb_def_donateref(def, ref_donor, s);
- }
-
- if (upb_dyncast_fielddef_mutable(def)) {
- /* TODO(haberman): allow adding extensions attached to files. */
- upb_status_seterrf(status, "Can't add extensions to symtab.\n");
- goto err;
- }
- }
-
+#if 0
/* Now using the table, resolve symbolic references for subdefs. */
upb_strtable_begin(&iter, &addtab);
for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
@@ -2258,132 +1305,202 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
}
}
}
+#endif
- /* We need an array of the defs in addtab, for passing to
- * upb_refcounted_freeze(). */
- add_objs_size = upb_strtable_count(&addtab);
- if (freeze_also) {
- add_objs_size++;
- }
+static bool create_oneofdef(
+ upb_symtab *s, const google_protobuf_OneofDescriptorProto *oneof_proto,
+ upb_msgdef *m, upb_status *s) {
+ upb_alloc *alloc = upb_arena_alloc(&s->arena);
+ upb_oneofdef *o = upb_malloc(alloc, sizeof(upb_oneofdef));
+ upb_stringview name = google_protobuf_OneofDescriptorProto_name(oneof_proto);
+ upb_value o_ptr = upb_value_ptr(o);
- add_defs = upb_gmalloc(sizeof(void*) * add_objs_size);
- if (add_defs == NULL) goto oom_err;
- upb_strtable_begin(&iter, &addtab);
- for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
- }
+ CHK(o);
+ CHK(upb_inttable_init2(&o->itof, UPB_CTYPE_PTR, alloc));
+ CHK(upb_strtable_init2(&o->ntof, UPB_CTYPE_PTR, alloc));
- /* Validate defs. */
- if (!_upb_def_validate(add_defs, add_n, status)) {
- goto err;
+ o->index = upb_strtable_count(&m->ntof);
+ o->name = upb_strdup2(name.data, name.size, alloc);
+ o->parent = m;
+
+ CHK(upb_strtable_insert3(&m->ntof, name.data, name.size, o_ptr, alloc));
+
+ return true;
+}
+
+static bool create_field(
+ upb_symtab *s, const google_protobuf_FieldDescriptorProto *field_proto,
+ upb_msgdef *m, upb_status *s) {
+ upb_alloc *alloc = upb_arena_alloc(&s->arena);
+ upb_fielddef *f = upb_malloc(alloc, sizeof(upb_fielddef));
+ const google_protobuf_MessageOptions *options;
+ const upb_array *arr;
+
+ CHK(f);
+
+ f->msgdef = m;
+
+ union {
+ int64_t sint;
+ uint64_t uint;
+ double dbl;
+ float flt;
+ void *bytes;
+ } defaultval;
+ const upb_msgdef *msgdef;
+ union {
+ const upb_msgdef *msgdef;
+ const upb_msgdef *enumdef;
+ } sub;
+ const upb_oneofdef *oneof;
+ bool is_extension_;
+ bool lazy_;
+ bool packed_;
+ upb_intfmt_t intfmt;
+ bool tagdelim;
+ upb_fieldtype_t type_;
+ upb_label_t label_;
+ uint32_t number_;
+ uint32_t selector_base; /* Used to index into a upb::Handlers table. */
+ uint32_t index_;
+}
+
+static bool create_msgdef(upb_symtab *s,
+ const google_protobuf_DescriptorProto *msg_proto,
+ upb_symtab *addtab, upb_status *status) {
+ upb_alloc *alloc = upb_arena_alloc(&s->arena);
+ upb_msgdef *m = upb_malloc(alloc, sizeof(upb_msgdef));
+ const google_protobuf_MessageOptions *options;
+ const upb_array *arr;
+
+ CHK(m);
+ CHK(upb_inttable_init2(&m->itof, UPB_CTYPE_PTR, alloc));
+ CHK(upb_strtable_init2(&m->ntof, UPB_CTYPE_PTR, alloc));
+
+ m->map_entry = false;
+
+ options = google_protobuf_DescriptorProto_options(msg_proto);
+
+ if (options) {
+ m->map_entry = google_protobuf_MessageOptions_map_entry(options);
}
- /* Cheat a little and give the array a new type.
- * This is probably undefined behavior, but this code will be deleted soon. */
- add_objs = (upb_refcounted**)add_defs;
+ arr = google_protobuf_DescriptorProto_oneof_decl(msg_proto);
- freeze_n = add_n;
- if (freeze_also) {
- add_objs[freeze_n++] = freeze_also;
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_OneofDescriptorProto *oneof_proto =
+ (const void *)upb_array_get(arr, i);
+ CHK(create_oneofdef(s, oneof_proto, m, status));
}
- if (!upb_refcounted_freeze(add_objs, freeze_n, status,
- UPB_MAX_MESSAGE_DEPTH * 2)) {
- goto err;
+ arr = google_protobuf_DescriptorProto_field(msg_proto);
+
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_FieldDescriptorProto *field_proto =
+ (const void *)upb_array_get(arr, i);
+ CHK(create_fielddef(s, field_proto, m, status));
}
- /* This must be delayed until all errors have been detected, since error
- * recovery code uses this table to cleanup defs. */
- upb_strtable_uninit(&addtab);
-
- /* TODO(haberman) we don't properly handle errors after this point (like
- * OOM in upb_strtable_insert() below). */
- for (i = 0; i < add_n; i++) {
- upb_def *def = (upb_def*)add_objs[i];
- const char *name = upb_def_fullname(def);
- bool success;
- success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
- UPB_ASSERT(success);
+ arr = google_protobuf_DescriptorProto_enum_type(msg_proto);
+
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_EnumDescriptorProto *enum_proto =
+ (const void *)upb_array_get(arr, i);
+ CHK(create_enumdef(s, enum_proto, addtab, status));
}
- upb_gfree(add_defs);
- return true;
-oom_err:
- upb_status_seterrmsg(status, "out of memory");
-err: {
- /* We need to donate the refs back. */
- upb_strtable_begin(&iter, &addtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- upb_def_donateref(def, s, ref_donor);
- }
+ arr = google_protobuf_DescriptorProto_nested_type(msg_proto);
+
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_DescriptorProto *msg_proto2 =
+ (const void *)upb_array_get(arr, i);
+ CHK(create_msgdef(s, msg_proto2, addtab, status));
}
- upb_strtable_uninit(&addtab);
- upb_gfree(add_defs);
- UPB_ASSERT(!upb_ok(status));
- return false;
+
+ return true;
}
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status) {
- return symtab_add(s, defs, n, ref_donor, NULL, status);
+static char* strviewdup(upb_symtab *symtab, upb_stringview view) {
+ if (view.size == 0) {
+ return NULL;
+ }
+ return upb_strdup2(view.data, view.size, upb_arena_alloc(&symtab->arena));
}
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
- size_t n;
+bool upb_symtab_addfile(upb_symtab *s, const char *buf, size_t len,
+ upb_status *status) {
+ upb_arena tmparena;
+ upb_strtable addtab;
+ upb_alloc *alloc = upb_arena_alloc(&s->arena);
+ upb_stringview serialized = upb_stringview_make(buf, len);
+ const google_protobuf_FileDescriptorProto *file_proto;
+ const google_protobuf_FileOptions *file_options_proto;
+ upb_filedef *file = upb_malloc(alloc, sizeof(*file));
+ const upb_array *arr;
+ upb_strtable_iter iter;
size_t i;
- upb_def **defs;
- bool ret;
- n = upb_filedef_defcount(file);
- if (n == 0) {
- return true;
- }
- defs = upb_gmalloc(sizeof(*defs) * n);
+ upb_arena_init(&tmparena);
+ upb_strtable_init2(&addtab, UPB_CTYPE_PTR, upb_arena_alloc(&tmparena));
+ file_proto =
+ google_protobuf_FileDescriptorProto_parsenew(serialized, &tmparena);
- if (defs == NULL) {
- upb_status_seterrmsg(status, "Out of memory");
- return false;
- }
- for (i = 0; i < n; i++) {
- defs[i] = upb_filedef_mutabledef(file, i);
+ if (!file_proto || !file) goto err;
+
+ file->name =
+ strviewdup(s, google_protobuf_FileDescriptorProto_name(file_proto));
+ file->package =
+ strviewdup(s, google_protobuf_FileDescriptorProto_package(file_proto));
+ file->phpprefix = NULL;
+ file->phpnamespace = NULL;
+
+ file_options_proto = google_protobuf_FileDescriptorProto_options(file_proto);
+ if (file_options_proto) {
+ file->phpprefix =
+ strviewdup(s, google_protobuf_FileOptions_php_class_prefix(file_proto));
+ file->phpnamespace =
+ strviewdup(s, google_protobuf_FileOptions_php_namespace(file_proto));
}
- ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+ arr = google_protobuf_FileDescriptorProto_message_type(file_proto);
- upb_gfree(defs);
- return ret;
-}
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_DescriptorProto *msg_proto =
+ (const void *)upb_array_get(arr, i);
+ if (!create_msgdef(s, msg_proto, &addtab, status)) goto err;
+ }
-/* Iteration. */
+ arr = google_protobuf_FileDescriptorProto_enum_type(file_proto);
-static void advance_to_matching(upb_symtab_iter *iter) {
- if (iter->type == UPB_DEF_ANY)
- return;
+ for (i = 0; i < upb_array_size(arr); i++) {
+ const google_protobuf_EnumDescriptorProto *enum_proto =
+ (const void *)upb_array_get(arr, i);
+ if (!create_enumdef(s, enum_proto, &addtab, status)) goto err;
+ }
- while (!upb_strtable_done(&iter->iter) &&
- iter->type != upb_symtab_iter_def(iter)->type) {
- upb_strtable_next(&iter->iter);
+ /* Now that all names are in the table, resolve references. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
}
-}
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type) {
- upb_strtable_begin(&iter->iter, &s->symtab);
- iter->type = type;
- advance_to_matching(iter);
-}
+ /* Success; add addtab to symtab. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ const char *key = upb_strtable_iter_key(&iter);
+ size_t keylen = upb_strtable_iter_keylen(&iter);
+ upb_value value = upb_strtable_iter_value(&iter);
+ upb_strtable_insert3(&s->symtab, key, keylen, value, alloc);
+ }
-void upb_symtab_next(upb_symtab_iter *iter) {
- upb_strtable_next(&iter->iter);
- advance_to_matching(iter);
-}
+ return true;
-bool upb_symtab_done(const upb_symtab_iter *iter) {
- return upb_strtable_done(&iter->iter);
+err:
+ upb_arena_uninit(&tmparena);
+ return false;
}
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
- return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
+bool upb_symtab_addset(upb_symtab *s, const char *buf, size_t len,
+ upb_status *status) {
+ return true;
}
diff --git a/upb/def.h b/upb/def.h
index 3886417..c229ca4 100644
--- a/upb/def.h
+++ b/upb/def.h
@@ -7,13 +7,9 @@
** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
** - upb::EnumDef (upb_enumdef): describes an enum.
** - upb::OneofDef (upb_oneofdef): describes a oneof.
-** - upb::Def (upb_def): base class of all the others.
**
** TODO: definitions of services.
**
-** Like upb_refcounted objects, defs are mutable only until frozen, and are
-** only thread-safe once frozen.
-**
** This is a mixed C/C++ interface that offers a full API to both languages.
** See the top-level README for more information.
*/
@@ -21,7 +17,8 @@
#ifndef UPB_DEF_H_
#define UPB_DEF_H_
-#include "upb/refcounted.h"
+#include "upb/upb.h"
+#include "upb/table.int.h"
#ifdef __cplusplus
#include <cstring>
@@ -29,7 +26,6 @@
#include <vector>
namespace upb {
-class Def;
class EnumDef;
class FieldDef;
class FileDef;
@@ -39,249 +35,16 @@ class SymbolTable;
}
#endif
-UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
-UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
- upb_refcounted)
-UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
- upb_refcounted)
+UPB_DECLARE_TYPE(upb::EnumDef, upb_enumdef)
+UPB_DECLARE_TYPE(upb::FieldDef, upb_fielddef)
+UPB_DECLARE_TYPE(upb::FileDef, upb_filedef)
+UPB_DECLARE_TYPE(upb::MessageDef, upb_msgdef)
+UPB_DECLARE_TYPE(upb::OneofDef, upb_oneofdef)
UPB_DECLARE_TYPE(upb::SymbolTable, upb_symtab)
-/* The maximum message depth that the type graph can have. This is a resource
- * limit for the C stack since we sometimes need to recursively traverse the
- * graph. Cycles are ok; the traversal will stop when it detects a cycle, but
- * we must hit the cycle before the maximum depth is reached.
- *
- * If having a single static limit is too inflexible, we can add another variant
- * of Def::Freeze that allows specifying this as a parameter. */
-#define UPB_MAX_MESSAGE_DEPTH 64
-
-
-/* upb::Def: base class for top-level defs ***********************************/
-
-/* All the different kind of defs that can be defined at the top-level and put
- * in a SymbolTable or appear in a FileDef::defs() list. This excludes some
- * defs (like oneofs and files). It only includes fields because they can be
- * defined as extensions. */
-typedef enum {
- UPB_DEF_MSG,
- UPB_DEF_FIELD,
- UPB_DEF_ENUM,
- UPB_DEF_SERVICE, /* Not yet implemented. */
- UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */
-} upb_deftype_t;
-
-#ifdef __cplusplus
-
-/* The base class of all defs. Its base is upb::RefCounted (use upb::upcast()
- * to convert). */
-class upb::Def {
- public:
- typedef upb_deftype_t Type;
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
- Type def_type() const;
-
- /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */
- const char *full_name() const;
-
- /* The final part of a def's name (eg. Message). */
- const char *name() const;
-
- /* The def must be mutable. Caller retains ownership of fullname. Defs are
- * not required to have a name; if a def has no name when it is frozen, it
- * will remain an anonymous def. On failure, returns false and details in "s"
- * if non-NULL. */
- bool set_full_name(const char* fullname, upb::Status* s);
- bool set_full_name(const std::string &fullname, upb::Status* s);
-
- /* The file in which this def appears. It is not necessary to add a def to a
- * file (and consequently the accessor may return NULL). Set this by calling
- * file->Add(def). */
- FileDef* file() const;
-
- /* Freezes the given defs; this validates all constraints and marks the defs
- * as frozen (read-only). "defs" may not contain any fielddefs, but fields
- * of any msgdefs will be frozen.
- *
- * Symbolic references to sub-types and enum defaults must have already been
- * resolved. Any mutable defs reachable from any of "defs" must also be in
- * the list; more formally, "defs" must be a transitive closure of mutable
- * defs.
- *
- * After this operation succeeds, the finalized defs must only be accessed
- * through a const pointer! */
- static bool Freeze(Def* const* defs, size_t n, Status* status);
- static bool Freeze(const std::vector<Def*>& defs, Status* status);
-
- private:
- UPB_DISALLOW_POD_OPS(Def, upb::Def)
-};
-
-#endif /* __cplusplus */
-
-UPB_BEGIN_EXTERN_C
-
-/* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */
-UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
-
-upb_deftype_t upb_def_type(const upb_def *d);
-const char *upb_def_fullname(const upb_def *d);
-const char *upb_def_name(const upb_def *d);
-const upb_filedef *upb_def_file(const upb_def *d);
-bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s);
-bool upb_def_freeze(upb_def *const *defs, size_t n, upb_status *s);
-
-/* Temporary API: for internal use only. */
-bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s);
-
-UPB_END_EXTERN_C
-
-
-/* upb::Def casts *************************************************************/
-
-#ifdef __cplusplus
-#define UPB_CPP_CASTS(cname, cpptype) \
- namespace upb { \
- template <> \
- inline cpptype *down_cast<cpptype *, Def>(Def * def) { \
- return upb_downcast_##cname##_mutable(def); \
- } \
- template <> \
- inline cpptype *dyn_cast<cpptype *, Def>(Def * def) { \
- return upb_dyncast_##cname##_mutable(def); \
- } \
- template <> \
- inline const cpptype *down_cast<const cpptype *, const Def>( \
- const Def *def) { \
- return upb_downcast_##cname(def); \
- } \
- template <> \
- inline const cpptype *dyn_cast<const cpptype *, const Def>(const Def *def) { \
- return upb_dyncast_##cname(def); \
- } \
- template <> \
- inline const cpptype *down_cast<const cpptype *, Def>(Def * def) { \
- return upb_downcast_##cname(def); \
- } \
- template <> \
- inline const cpptype *dyn_cast<const cpptype *, Def>(Def * def) { \
- return upb_dyncast_##cname(def); \
- } \
- } /* namespace upb */
-#else
-#define UPB_CPP_CASTS(cname, cpptype)
-#endif /* __cplusplus */
-
-/* Dynamic casts, for determining if a def is of a particular type at runtime.
- * Downcasts, for when some wants to assert that a def is of a particular type.
- * These are only checked if we are building debug. */
-#define UPB_DEF_CASTS(lower, upper, cpptype) \
- UPB_INLINE const upb_##lower *upb_dyncast_##lower(const upb_def *def) { \
- if (upb_def_type(def) != UPB_DEF_##upper) return NULL; \
- return (upb_##lower *)def; \
- } \
- UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \
- UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \
- return (const upb_##lower *)def; \
- } \
- UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \
- return (upb_##lower *)upb_dyncast_##lower(def); \
- } \
- UPB_INLINE upb_##lower *upb_downcast_##lower##_mutable(upb_def *def) { \
- return (upb_##lower *)upb_downcast_##lower(def); \
- } \
- UPB_CPP_CASTS(lower, cpptype)
-
-#define UPB_DEFINE_DEF(cppname, lower, upper, cppmethods, members) \
- UPB_DEFINE_CLASS2(cppname, upb::Def, upb::RefCounted, cppmethods, \
- members) \
- UPB_DEF_CASTS(lower, upper, cppname)
-
-#define UPB_DECLARE_DEF_TYPE(cppname, lower, upper) \
- UPB_DECLARE_DERIVED_TYPE2(cppname, upb::Def, upb::RefCounted, \
- upb_ ## lower, upb_def, upb_refcounted) \
- UPB_DEF_CASTS(lower, upper, cppname)
-
-UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD)
-UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG)
-UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
-
-#undef UPB_DECLARE_DEF_TYPE
-#undef UPB_DEF_CASTS
-#undef UPB_CPP_CASTS
-
-
/* upb::FieldDef **************************************************************/
-/* The types a field can have. Note that this list is not identical to the
- * types defined in descriptor.proto, which gives INT32 and SINT32 separate
- * types (we distinguish the two with the "integer encoding" enum below). */
-typedef enum {
- /* Types stored in 1 byte. */
- UPB_TYPE_BOOL = 1,
- /* Types stored in 4 bytes. */
- UPB_TYPE_FLOAT = 2,
- UPB_TYPE_INT32 = 3,
- UPB_TYPE_UINT32 = 4,
- UPB_TYPE_ENUM = 5, /* Enum values are int32. */
- /* Types stored as pointers (probably 4 or 8 bytes). */
- UPB_TYPE_STRING = 6,
- UPB_TYPE_BYTES = 7,
- UPB_TYPE_MESSAGE = 8,
- /* Types stored as 8 bytes. */
- UPB_TYPE_DOUBLE = 9,
- UPB_TYPE_INT64 = 10,
- UPB_TYPE_UINT64 = 11
-} upb_fieldtype_t;
-
-/* The repeated-ness of each field; this matches descriptor.proto. */
-typedef enum {
- UPB_LABEL_OPTIONAL = 1,
- UPB_LABEL_REQUIRED = 2,
- UPB_LABEL_REPEATED = 3
-} upb_label_t;
-
-/* How integers should be encoded in serializations that offer multiple
- * integer encoding methods. */
-typedef enum {
- UPB_INTFMT_VARIABLE = 1,
- UPB_INTFMT_FIXED = 2,
- UPB_INTFMT_ZIGZAG = 3 /* Only for signed types (INT32/INT64). */
-} upb_intfmt_t;
-
-/* Descriptor types, as defined in descriptor.proto. */
-typedef enum {
- UPB_DESCRIPTOR_TYPE_DOUBLE = 1,
- UPB_DESCRIPTOR_TYPE_FLOAT = 2,
- UPB_DESCRIPTOR_TYPE_INT64 = 3,
- UPB_DESCRIPTOR_TYPE_UINT64 = 4,
- UPB_DESCRIPTOR_TYPE_INT32 = 5,
- UPB_DESCRIPTOR_TYPE_FIXED64 = 6,
- UPB_DESCRIPTOR_TYPE_FIXED32 = 7,
- UPB_DESCRIPTOR_TYPE_BOOL = 8,
- UPB_DESCRIPTOR_TYPE_STRING = 9,
- UPB_DESCRIPTOR_TYPE_GROUP = 10,
- UPB_DESCRIPTOR_TYPE_MESSAGE = 11,
- UPB_DESCRIPTOR_TYPE_BYTES = 12,
- UPB_DESCRIPTOR_TYPE_UINT32 = 13,
- UPB_DESCRIPTOR_TYPE_ENUM = 14,
- UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
- UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
- UPB_DESCRIPTOR_TYPE_SINT32 = 17,
- UPB_DESCRIPTOR_TYPE_SINT64 = 18
-} upb_descriptortype_t;
-
-typedef enum {
- UPB_SYNTAX_PROTO2 = 2,
- UPB_SYNTAX_PROTO3 = 3
-} upb_syntax_t;
-
-/* Maps descriptor type -> upb field type. */
-extern const uint8_t upb_desctype_to_fieldtype[];
-
/* Maximum field number allowed for FieldDefs. This is an inherent limit of the
* protobuf wire format. */
#define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
@@ -300,33 +63,12 @@ class upb::FieldDef {
typedef upb_intfmt_t IntegerFormat;
typedef upb_descriptortype_t DescriptorType;
- /* These return true if the given value is a valid member of the enumeration. */
- static bool CheckType(int32_t val);
- static bool CheckLabel(int32_t val);
- static bool CheckDescriptorType(int32_t val);
- static bool CheckIntegerFormat(int32_t val);
-
- /* These convert to the given enumeration; they require that the value is
- * valid. */
- static Type ConvertType(int32_t val);
- static Label ConvertLabel(int32_t val);
- static DescriptorType ConvertDescriptorType(int32_t val);
- static IntegerFormat ConvertIntegerFormat(int32_t val);
-
- /* Returns NULL if memory allocation failed. */
- static reffed_ptr<FieldDef> New();
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
- /* Functionality from upb::Def. */
const char* full_name() const;
- bool type_is_set() const; /* set_[descriptor_]type() has been called? */
- Type type() const; /* Requires that type_is_set() == true. */
- Label label() const; /* Defaults to UPB_LABEL_OPTIONAL. */
- const char* name() const; /* NULL if uninitialized. */
- uint32_t number() const; /* Returns 0 if uninitialized. */
+ Type type() const;
+ Label label() const;
+ const char* name() const;
+ uint32_t number() const;
bool is_extension() const;
/* Copies the JSON name for this field into the given buffer. Returns the
@@ -381,7 +123,6 @@ class upb::FieldDef {
* of the containing type symbolically instead. This is mostly useful for
* extensions, where the extension is declared separately from the message. */
const MessageDef* containing_type() const;
- const char* containing_type_name();
/* The OneofDef to which this field belongs, or NULL if this field is not part
* of a oneof. */
@@ -391,8 +132,7 @@ class upb::FieldDef {
* the same as UPB_TYPE_*, because it distinguishes between (for example)
* INT32 and SINT32, whereas our "type" enum does not. This return of
* descriptor_type() is a function of type(), integer_format(), and
- * is_tag_delimited(). Likewise set_descriptor_type() sets all three
- * appropriately. */
+ * is_tag_delimited(). */
DescriptorType descriptor_type() const;
/* Convenient field type tests. */
@@ -471,89 +211,6 @@ class upb::FieldDef {
* been resolved to a specific subdef, returns the name from that subdef. */
const char* subdef_name() const;
- /* Setters (non-const methods), only valid for mutable FieldDefs! ***********/
-
- bool set_full_name(const char* fullname, upb::Status* s);
- bool set_full_name(const std::string& fullname, upb::Status* s);
-
- /* This may only be called if containing_type() == NULL (ie. the field has not
- * been added to a message yet). */
- bool set_containing_type_name(const char *name, Status* status);
- bool set_containing_type_name(const std::string& name, Status* status);
-
- /* Defaults to false. When we freeze, we ensure that this can only be true
- * for length-delimited message fields. Prior to freezing this can be true or
- * false with no restrictions. */
- void set_lazy(bool lazy);
-
- /* Defaults to true. Sets whether this field is encoded in packed format. */
- void set_packed(bool packed);
-
- /* "type" or "descriptor_type" MUST be set explicitly before the fielddef is
- * finalized. These setters require that the enum value is valid; if the
- * value did not come directly from an enum constant, the caller should
- * validate it first with the functions above (CheckFieldType(), etc). */
- void set_type(Type type);
- void set_label(Label label);
- void set_descriptor_type(DescriptorType type);
- void set_is_extension(bool is_extension);
-
- /* "number" and "name" must be set before the FieldDef is added to a
- * MessageDef, and may not be set after that.
- *
- * "name" is the same as full_name()/set_full_name(), but since fielddefs
- * most often use simple, non-qualified names, we provide this accessor
- * also. Generally only extensions will want to think of this name as
- * fully-qualified. */
- bool set_number(uint32_t number, upb::Status* s);
- bool set_name(const char* name, upb::Status* s);
- bool set_name(const std::string& name, upb::Status* s);
-
- /* Sets the JSON name to the given string. */
- /* TODO(haberman): implement. Right now only default json_name (camelCase)
- * is supported. */
- bool set_json_name(const char* json_name, upb::Status* s);
- bool set_json_name(const std::string& name, upb::Status* s);
-
- /* Clears the JSON name. This will make it revert to its default, which is
- * a camelCased version of the regular field name. */
- void clear_json_name();
-
- void set_integer_format(IntegerFormat format);
- bool set_tag_delimited(bool tag_delimited, upb::Status* s);
-
- /* Sets default value for the field. The call must exactly match the type
- * of the field. Enum fields may use either setint32 or setstring to set
- * the default numerically or symbolically, respectively, but symbolic
- * defaults must be resolved before finalizing (see ResolveEnumDefault()).
- *
- * Changing the type of a field will reset its default. */
- void set_default_int64(int64_t val);
- void set_default_int32(int32_t val);
- void set_default_uint64(uint64_t val);
- void set_default_uint32(uint32_t val);
- void set_default_bool(bool val);
- void set_default_float(float val);
- void set_default_double(double val);
- bool set_default_string(const void *str, size_t len, Status *s);
- bool set_default_string(const std::string &str, Status *s);
- void set_default_cstr(const char *str, Status *s);
-
- /* Before a fielddef is frozen, its subdef may be set either directly (with a
- * upb::Def*) or symbolically. Symbolic refs must be resolved before the
- * containing msgdef can be frozen (see upb_resolve() above). upb always
- * guarantees that any def reachable from a live def will also be kept alive.
- *
- * Both methods require that upb_hassubdef(f) (so the type must be set prior
- * to calling these methods). Returns false if this is not the case, or if
- * the given subdef is not of the correct type. The subdef is reset if the
- * field's type is changed. The subdef can be set to NULL to clear it. */
- bool set_subdef(const Def* subdef, Status* s);
- bool set_enum_subdef(const EnumDef* subdef, Status* s);
- bool set_message_subdef(const MessageDef* subdef, Status* s);
- bool set_subdef_name(const char* name, Status* s);
- bool set_subdef_name(const std::string &name, Status* s);
-
private:
UPB_DISALLOW_POD_OPS(FieldDef, upb::FieldDef)
};
@@ -563,16 +220,7 @@ class upb::FieldDef {
UPB_BEGIN_EXTERN_C
/* Native C API. */
-upb_fielddef *upb_fielddef_new(const void *owner);
-
-/* Include upb_refcounted methods like upb_fielddef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_fielddef, upb_fielddef_upcast2)
-
-/* Methods from upb_def. */
const char *upb_fielddef_fullname(const upb_fielddef *f);
-bool upb_fielddef_setfullname(upb_fielddef *f, const char *fullname,
- upb_status *s);
-
bool upb_fielddef_typeisset(const upb_fielddef *f);
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f);
upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f);
@@ -586,7 +234,6 @@ size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len);
const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
-const char *upb_fielddef_containingtypename(upb_fielddef *f);
upb_intfmt_t upb_fielddef_intfmt(const upb_fielddef *f);
uint32_t upb_fielddef_index(const upb_fielddef *f);
bool upb_fielddef_istagdelim(const upb_fielddef *f);
@@ -604,52 +251,13 @@ bool upb_fielddef_defaultbool(const upb_fielddef *f);
float upb_fielddef_defaultfloat(const upb_fielddef *f);
double upb_fielddef_defaultdouble(const upb_fielddef *f);
const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len);
-bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f);
-bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f);
bool upb_fielddef_hassubdef(const upb_fielddef *f);
-const upb_def *upb_fielddef_subdef(const upb_fielddef *f);
const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
const char *upb_fielddef_subdefname(const upb_fielddef *f);
-void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type);
-void upb_fielddef_setdescriptortype(upb_fielddef *f, int type);
-void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label);
-bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s);
-bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s);
-bool upb_fielddef_setjsonname(upb_fielddef *f, const char *name, upb_status *s);
-bool upb_fielddef_clearjsonname(upb_fielddef *f);
-bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
- upb_status *s);
-void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension);
-void upb_fielddef_setlazy(upb_fielddef *f, bool lazy);
-void upb_fielddef_setpacked(upb_fielddef *f, bool packed);
-void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt);
-void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim);
-void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t val);
-void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t val);
-void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t val);
-void upb_fielddef_setdefaultuint32(upb_fielddef *f, uint32_t val);
-void upb_fielddef_setdefaultbool(upb_fielddef *f, bool val);
-void upb_fielddef_setdefaultfloat(upb_fielddef *f, float val);
-void upb_fielddef_setdefaultdouble(upb_fielddef *f, double val);
-bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
- upb_status *s);
-void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str,
- upb_status *s);
-bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef,
- upb_status *s);
-bool upb_fielddef_setmsgsubdef(upb_fielddef *f, const upb_msgdef *subdef,
- upb_status *s);
-bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef,
- upb_status *s);
-bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name,
- upb_status *s);
-
-bool upb_fielddef_checklabel(int32_t label);
-bool upb_fielddef_checktype(int32_t type);
-bool upb_fielddef_checkdescriptortype(int32_t type);
-bool upb_fielddef_checkintfmt(int32_t fmt);
+/* Internal only. */
+uint32_t upb_fielddef_selectorbase(const upb_fielddef *f);
UPB_END_EXTERN_C
@@ -678,22 +286,8 @@ typedef upb_strtable_iter upb_msg_oneof_iter;
* Its base class is upb::Def (use upb::upcast() to convert). */
class upb::MessageDef {
public:
- /* Returns NULL if memory allocation failed. */
- static reffed_ptr<MessageDef> New();
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
- /* Functionality from upb::Def. */
const char* full_name() const;
const char* name() const;
- bool set_full_name(const char* fullname, Status* s);
- bool set_full_name(const std::string& fullname, Status* s);
-
- /* Call to freeze this MessageDef.
- * WARNING: this will fail if this message has any unfrozen submessages!
- * Messages with cycles must be frozen as a batch using upb::Def::Freeze(). */
- bool Freeze(Status* s);
/* The number of fields that belong to the MessageDef. */
int field_count() const;
@@ -701,63 +295,18 @@ class upb::MessageDef {
/* The number of oneofs that belong to the MessageDef. */
int oneof_count() const;
- /* Adds a field (upb_fielddef object) to a msgdef. Requires that the msgdef
- * and the fielddefs are mutable. The fielddef's name and number must be
- * set, and the message may not already contain any field with this name or
- * number, and this fielddef may not be part of another message. In error
- * cases false is returned and the msgdef is unchanged.
- *
- * If the given field is part of a oneof, this call succeeds if and only if
- * that oneof is already part of this msgdef. (Note that adding a oneof to a
- * msgdef automatically adds all of its fields to the msgdef at the time that
- * the oneof is added, so it is usually more idiomatic to add the oneof's
- * fields first then add the oneof to the msgdef. This case is supported for
- * convenience.)
- *
- * If |f| is already part of this MessageDef, this method performs no action
- * and returns true (success). Thus, this method is idempotent. */
- bool AddField(FieldDef* f, Status* s);
- bool AddField(const reffed_ptr<FieldDef>& f, Status* s);
-
- /* Adds a oneof (upb_oneofdef object) to a msgdef. Requires that the msgdef,
- * oneof, and any fielddefs are mutable, that the fielddefs contained in the
- * oneof do not have any name or number conflicts with existing fields in the
- * msgdef, and that the oneof's name is unique among all oneofs in the msgdef.
- * If the oneof is added successfully, all of its fields will be added
- * directly to the msgdef as well. In error cases, false is returned and the
- * msgdef is unchanged. */
- bool AddOneof(OneofDef* o, Status* s);
- bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
-
upb_syntax_t syntax() const;
- /* Returns false if we don't support this syntax value. */
- bool set_syntax(upb_syntax_t syntax);
-
- /* Set this to false to indicate that primitive fields should not have
- * explicit presence information associated with them. This will affect all
- * fields added to this message. Defaults to true. */
- void SetPrimitivesHavePresence(bool have_presence);
-
/* These return NULL if the field is not found. */
- FieldDef* FindFieldByNumber(uint32_t number);
- FieldDef* FindFieldByName(const char *name, size_t len);
const FieldDef* FindFieldByNumber(uint32_t number) const;
const FieldDef* FindFieldByName(const char* name, size_t len) const;
- FieldDef* FindFieldByName(const char *name) {
- return FindFieldByName(name, strlen(name));
- }
const FieldDef* FindFieldByName(const char *name) const {
return FindFieldByName(name, strlen(name));
}
template <class T>
- FieldDef* FindFieldByName(const T& str) {
- return FindFieldByName(str.c_str(), str.size());
- }
- template <class T>
const FieldDef* FindFieldByName(const T& str) const {
return FindFieldByName(str.c_str(), str.size());
}
@@ -765,18 +314,11 @@ class upb::MessageDef {
OneofDef* FindOneofByName(const char* name, size_t len);
const OneofDef* FindOneofByName(const char* name, size_t len) const;
- OneofDef* FindOneofByName(const char* name) {
- return FindOneofByName(name, strlen(name));
- }
const OneofDef* FindOneofByName(const char* name) const {
return FindOneofByName(name, strlen(name));
}
template<class T>
- OneofDef* FindOneofByName(const T& str) {
- return FindOneofByName(str.c_str(), str.size());
- }
- template<class T>
const OneofDef* FindOneofByName(const T& str) const {
return FindOneofByName(str.c_str(), str.size());
}
@@ -801,21 +343,6 @@ class upb::MessageDef {
bool structvalue() const;
/* Iteration over fields. The order is undefined. */
- class field_iterator
- : public std::iterator<std::forward_iterator_tag, FieldDef*> {
- public:
- explicit field_iterator(MessageDef* md);
- static field_iterator end(MessageDef* md);
-
- void operator++();
- FieldDef* operator*() const;
- bool operator!=(const field_iterator& other) const;
- bool operator==(const field_iterator& other) const;
-
- private:
- upb_msg_field_iter iter_;
- };
-
class const_field_iterator
: public std::iterator<std::forward_iterator_tag, const FieldDef*> {
public:
@@ -832,21 +359,6 @@ class upb::MessageDef {
};
/* Iteration over oneofs. The order is undefined. */
- class oneof_iterator
- : public std::iterator<std::forward_iterator_tag, FieldDef*> {
- public:
- explicit oneof_iterator(MessageDef* md);
- static oneof_iterator end(MessageDef* md);
-
- void operator++();
- OneofDef* operator*() const;
- bool operator!=(const oneof_iterator& other) const;
- bool operator==(const oneof_iterator& other) const;
-
- private:
- upb_msg_oneof_iter iter_;
- };
-
class const_oneof_iterator
: public std::iterator<std::forward_iterator_tag, const FieldDef*> {
public:
@@ -862,15 +374,6 @@ class upb::MessageDef {
upb_msg_oneof_iter iter_;
};
- class FieldAccessor {
- public:
- explicit FieldAccessor(MessageDef* msg) : msg_(msg) {}
- field_iterator begin() { return msg_->field_begin(); }
- field_iterator end() { return msg_->field_end(); }
- private:
- MessageDef* msg_;
- };
-
class ConstFieldAccessor {
public:
explicit ConstFieldAccessor(const MessageDef* msg) : msg_(msg) {}
@@ -880,15 +383,6 @@ class upb::MessageDef {
const MessageDef* msg_;
};
- class OneofAccessor {
- public:
- explicit OneofAccessor(MessageDef* msg) : msg_(msg) {}
- oneof_iterator begin() { return msg_->oneof_begin(); }
- oneof_iterator end() { return msg_->oneof_end(); }
- private:
- MessageDef* msg_;
- };
-
class ConstOneofAccessor {
public:
explicit ConstOneofAccessor(const MessageDef* msg) : msg_(msg) {}
@@ -898,19 +392,13 @@ class upb::MessageDef {
const MessageDef* msg_;
};
- field_iterator field_begin();
- field_iterator field_end();
const_field_iterator field_begin() const;
const_field_iterator field_end() const;
- oneof_iterator oneof_begin();
- oneof_iterator oneof_end();
const_oneof_iterator oneof_begin() const;
const_oneof_iterator oneof_end() const;
- FieldAccessor fields() { return FieldAccessor(this); }
ConstFieldAccessor fields() const { return ConstFieldAccessor(this); }
- OneofAccessor oneofs() { return OneofAccessor(this); }
ConstOneofAccessor oneofs() const { return ConstOneofAccessor(this); }
private:
@@ -921,32 +409,20 @@ class upb::MessageDef {
UPB_BEGIN_EXTERN_C
-/* Returns NULL if memory allocation failed. */
-upb_msgdef *upb_msgdef_new(const void *owner);
-
-/* Include upb_refcounted methods like upb_msgdef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
-
-bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
-
const char *upb_msgdef_fullname(const upb_msgdef *m);
const char *upb_msgdef_name(const upb_msgdef *m);
int upb_msgdef_numoneofs(const upb_msgdef *m);
upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
-
-bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
- upb_status *s);
-bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
- upb_status *s);
-bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
-void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
bool upb_msgdef_mapentry(const upb_msgdef *m);
bool upb_msgdef_duration(const upb_msgdef *m);
bool upb_msgdef_timestamp(const upb_msgdef *m);
bool upb_msgdef_value(const upb_msgdef *m);
bool upb_msgdef_listvalue(const upb_msgdef *m);
bool upb_msgdef_structvalue(const upb_msgdef *m);
-bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax);
+
+/* Internal-only. */
+size_t upb_msgdef_selectorcount(const upb_msgdef *m);
+uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m);
/* Field lookup in a couple of different variations:
* - itof = int to field
@@ -962,15 +438,6 @@ UPB_INLINE const upb_fielddef *upb_msgdef_ntofz(const upb_msgdef *m,
return upb_msgdef_ntof(m, name, strlen(name));
}
-UPB_INLINE upb_fielddef *upb_msgdef_itof_mutable(upb_msgdef *m, uint32_t i) {
- return (upb_fielddef*)upb_msgdef_itof(m, i);
-}
-
-UPB_INLINE upb_fielddef *upb_msgdef_ntof_mutable(upb_msgdef *m,
- const char *name, size_t len) {
- return (upb_fielddef *)upb_msgdef_ntof(m, name, len);
-}
-
/* Oneof lookup:
* - ntoo = name to oneof
* - ntooz = name to oneof, null-terminated string. */
@@ -983,11 +450,6 @@ UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m,
return upb_msgdef_ntoo(m, name, strlen(name));
}
-UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m,
- const char *name, size_t len) {
- return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len);
-}
-
/* Lookup of either field or oneof by name. Returns whether either was found.
* If the return is true, then the found def will be set, and the non-found
* one set to NULL. */
@@ -1040,41 +502,19 @@ typedef upb_strtable_iter upb_enum_iter;
* upb::upcast()). */
class upb::EnumDef {
public:
- /* Returns NULL if memory allocation failed. */
- static reffed_ptr<EnumDef> New();
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
- /* Functionality from upb::Def. */
const char* full_name() const;
const char* name() const;
- bool set_full_name(const char* fullname, Status* s);
- bool set_full_name(const std::string& fullname, Status* s);
-
- /* Call to freeze this EnumDef. */
- bool Freeze(Status* s);
-
/* The value that is used as the default when no field default is specified.
* If not set explicitly, the first value that was added will be used.
* The default value must be a member of the enum.
* Requires that value_count() > 0. */
int32_t default_value() const;
- /* Sets the default value. If this value is not valid, returns false and an
- * error message in status. */
- bool set_default_value(int32_t val, Status* status);
-
/* Returns the number of values currently defined in the enum. Note that
* multiple names can refer to the same number, so this may be greater than
* the total number of unique numbers. */
int value_count() const;
- /* Adds a single name/number pair to the enum. Fails if this name has
- * already been used by another value. */
- bool AddValue(const char* name, int32_t num, Status* status);
- bool AddValue(const std::string& name, int32_t num, Status* status);
-
/* Lookups from name to integer, returning true if found. */
bool FindValueByName(const char* name, int32_t* num) const;
@@ -1108,25 +548,10 @@ class upb::EnumDef {
UPB_BEGIN_EXTERN_C
-/* Native C API. */
-upb_enumdef *upb_enumdef_new(const void *owner);
-
-/* Include upb_refcounted methods like upb_enumdef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2)
-
-bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status);
-
-/* From upb_def. */
const char *upb_enumdef_fullname(const upb_enumdef *e);
const char *upb_enumdef_name(const upb_enumdef *e);
-bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
- upb_status *s);
-
int32_t upb_enumdef_default(const upb_enumdef *e);
-bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s);
int upb_enumdef_numvals(const upb_enumdef *e);
-bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
- upb_status *status);
/* Enum lookups:
* - ntoi: look up a name with specified length.
@@ -1164,54 +589,24 @@ typedef upb_inttable_iter upb_oneof_iter;
/* Class that represents a oneof. */
class upb::OneofDef {
public:
- /* Returns NULL if memory allocation failed. */
- static reffed_ptr<OneofDef> New();
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
/* Returns the MessageDef that owns this OneofDef. */
const MessageDef* containing_type() const;
/* Returns the name of this oneof. This is the name used to look up the oneof
* by name once added to a message def. */
const char* name() const;
- bool set_name(const char* name, Status* s);
- bool set_name(const std::string& name, Status* s);
/* Returns the number of fields currently defined in the oneof. */
int field_count() const;
- /* Adds a field to the oneof. The field must not have been added to any other
- * oneof or msgdef. If the oneof is not yet part of a msgdef, then when the
- * oneof is eventually added to a msgdef, all fields added to the oneof will
- * also be added to the msgdef at that time. If the oneof is already part of a
- * msgdef, the field must either be a part of that msgdef already, or must not
- * be a part of any msgdef; in the latter case, the field is added to the
- * msgdef as a part of this operation.
- *
- * The field may only have an OPTIONAL label, never REQUIRED or REPEATED.
- *
- * If |f| is already part of this MessageDef, this method performs no action
- * and returns true (success). Thus, this method is idempotent. */
- bool AddField(FieldDef* field, Status* s);
- bool AddField(const reffed_ptr<FieldDef>& field, Status* s);
-
/* Looks up by name. */
const FieldDef* FindFieldByName(const char* name, size_t len) const;
FieldDef* FindFieldByName(const char* name, size_t len);
const FieldDef* FindFieldByName(const char* name) const {
return FindFieldByName(name, strlen(name));
}
- FieldDef* FindFieldByName(const char* name) {
- return FindFieldByName(name, strlen(name));
- }
template <class T>
- FieldDef* FindFieldByName(const T& str) {
- return FindFieldByName(str.c_str(), str.size());
- }
- template <class T>
const FieldDef* FindFieldByName(const T& str) const {
return FindFieldByName(str.c_str(), str.size());
}
@@ -1219,21 +614,6 @@ class upb::OneofDef {
/* Looks up by tag number. */
const FieldDef* FindFieldByNumber(uint32_t num) const;
- /* Iteration over fields. The order is undefined. */
- class iterator : public std::iterator<std::forward_iterator_tag, FieldDef*> {
- public:
- explicit iterator(OneofDef* md);
- static iterator end(OneofDef* md);
-
- void operator++();
- FieldDef* operator*() const;
- bool operator!=(const iterator& other) const;
- bool operator==(const iterator& other) const;
-
- private:
- upb_oneof_iter iter_;
- };
-
class const_iterator
: public std::iterator<std::forward_iterator_tag, const FieldDef*> {
public:
@@ -1262,22 +642,11 @@ class upb::OneofDef {
UPB_BEGIN_EXTERN_C
-/* Native C API. */
-upb_oneofdef *upb_oneofdef_new(const void *owner);
-
-/* Include upb_refcounted methods like upb_oneofdef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
-
const char *upb_oneofdef_name(const upb_oneofdef *o);
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
int upb_oneofdef_numfields(const upb_oneofdef *o);
uint32_t upb_oneofdef_index(const upb_oneofdef *o);
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
-bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
- const void *ref_donor,
- upb_status *s);
-
/* Oneof lookups:
* - ntof: look up a field by name.
* - ntofz: look up a field by name (as a null-terminated string).
@@ -1314,35 +683,23 @@ UPB_END_EXTERN_C
* read the values of file-level options. */
class upb::FileDef {
public:
- /* Returns NULL if memory allocation failed. */
- static reffed_ptr<FileDef> New();
-
- /* upb::RefCounted methods like Ref()/Unref(). */
- UPB_REFCOUNTED_CPPMETHODS
-
/* Get/set name of the file (eg. "foo/bar.proto"). */
const char* name() const;
- bool set_name(const char* name, Status* s);
- bool set_name(const std::string& name, Status* s);
/* Package name for definitions inside the file (eg. "foo.bar"). */
const char* package() const;
- bool set_package(const char* package, Status* s);
/* Sets the php class prefix which is prepended to all php generated classes
* from this .proto. Default is empty. */
const char* phpprefix() const;
- bool set_phpprefix(const char* phpprefix, Status* s);
/* Use this option to change the namespace of php generated classes. Default
* is empty. When this option is empty, the package name will be used for
* determining the namespace. */
const char* phpnamespace() const;
- bool set_phpnamespace(const char* phpnamespace, Status* s);
/* Syntax for the file. Defaults to proto2. */
upb_syntax_t syntax() const;
- void set_syntax(upb_syntax_t syntax);
/* Get the list of defs from the file. These are returned in the order that
* they were added to the FileDef. */
@@ -1355,29 +712,6 @@ class upb::FileDef {
int dependency_count() const;
const FileDef* dependency(int index) const;
- /* Adds defs to this file. The def must not already belong to another
- * file.
- *
- * Note: this does *not* ensure that this def's name is unique in this file!
- * Use a SymbolTable if you want to check this property. Especially since
- * properly checking uniqueness would require a check across *all* files
- * (including dependencies). */
- bool AddDef(Def* def, Status* s);
- bool AddMessage(MessageDef* m, Status* s);
- bool AddEnum(EnumDef* e, Status* s);
- bool AddExtension(FieldDef* f, Status* s);
-
- /* Adds a dependency of this file. */
- bool AddDependency(const FileDef* file);
-
- /* Freezes this FileDef and all messages/enums under it. All subdefs must be
- * resolved and all messages/enums must validate. Returns true if this
- * succeeded.
- *
- * TODO(haberman): should we care whether the file's dependencies are frozen
- * already? */
- bool Freeze(Status* s);
-
private:
UPB_DISALLOW_POD_OPS(FileDef, upb::FileDef)
};
@@ -1386,60 +720,14 @@ class upb::FileDef {
UPB_BEGIN_EXTERN_C
-upb_filedef *upb_filedef_new(const void *owner);
-
-/* Include upb_refcounted methods like upb_msgdef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast)
-
const char *upb_filedef_name(const upb_filedef *f);
const char *upb_filedef_package(const upb_filedef *f);
const char *upb_filedef_phpprefix(const upb_filedef *f);
const char *upb_filedef_phpnamespace(const upb_filedef *f);
upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
-size_t upb_filedef_defcount(const upb_filedef *f);
-size_t upb_filedef_depcount(const upb_filedef *f);
-const upb_def *upb_filedef_def(const upb_filedef *f, size_t i);
-const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i);
-
-bool upb_filedef_freeze(upb_filedef *f, upb_status *s);
-bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s);
-bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s);
-bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix,
- upb_status *s);
-bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace,
- upb_status *s);
-bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s);
-
-bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
- upb_status *s);
-bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep);
-
-UPB_INLINE bool upb_filedef_addmsg(upb_filedef *f, upb_msgdef *m,
- const void *ref_donor, upb_status *s) {
- return upb_filedef_adddef(f, upb_msgdef_upcast_mutable(m), ref_donor, s);
-}
-
-UPB_INLINE bool upb_filedef_addenum(upb_filedef *f, upb_enumdef *e,
- const void *ref_donor, upb_status *s) {
- return upb_filedef_adddef(f, upb_enumdef_upcast_mutable(e), ref_donor, s);
-}
-
-UPB_INLINE bool upb_filedef_addext(upb_filedef *file, upb_fielddef *f,
- const void *ref_donor, upb_status *s) {
- return upb_filedef_adddef(file, upb_fielddef_upcast_mutable(f), ref_donor, s);
-}
-UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
- return (upb_def*)upb_filedef_def(f, i);
-}
UPB_END_EXTERN_C
-typedef struct {
- UPB_PRIVATE_FOR_CPP
- upb_strtable_iter iter;
- upb_deftype_t type;
-} upb_symtab_iter;
-
#ifdef __cplusplus
/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
@@ -1450,68 +738,19 @@ class upb::SymbolTable {
static SymbolTable* New();
static void Free(upb::SymbolTable* table);
- /* For all lookup functions, the returned pointer is not owned by the
- * caller; it may be invalidated by any non-const call or unref of the
- * SymbolTable! To protect against this, take a ref if desired. */
-
- /* Freezes the symbol table: prevents further modification of it.
- * After the Freeze() operation is successful, the SymbolTable must only be
- * accessed via a const pointer.
- *
- * Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
- * a necessary step in using a SymbolTable. If you have no need for it to be
- * immutable, there is no need to freeze it ever. However sometimes it is
- * useful, and SymbolTables that are statically compiled into the binary are
- * always frozen by nature. */
- void Freeze();
-
- /* Resolves the given symbol using the rules described in descriptor.proto,
- * namely:
- *
- * If the name starts with a '.', it is fully-qualified. Otherwise,
- * C++-like scoping rules are used to find the type (i.e. first the nested
- * types within this message are searched, then within the parent, on up
- * to the root namespace).
- *
- * If not found, returns NULL. */
- const Def* Resolve(const char* base, const char* sym) const;
-
/* Finds an entry in the symbol table with this exact name. If not found,
* returns NULL. */
const Def* Lookup(const char *sym) const;
const MessageDef* LookupMessage(const char *sym) const;
const EnumDef* LookupEnum(const char *sym) const;
- /* TODO: introduce a C++ iterator, but make it nice and templated so that if
- * you ask for an iterator of MessageDef the iterated elements are strongly
- * typed as MessageDef*. */
+ /* TODO: iteration? */
- /* Adds the given mutable defs to the symtab, resolving all symbols (including
- * enum default values) and finalizing the defs. Only one def per name may be
- * in the list, and the defs may not duplicate any name already in the symtab.
- * All defs must have a name -- anonymous defs are not allowed. Anonymous
- * defs can still be frozen by calling upb_def_freeze() directly.
- *
- * The entire operation either succeeds or fails. If the operation fails,
- * the symtab is unchanged, false is returned, and status indicates the
- * error. The caller passes a ref on all defs to the symtab (even if the
- * operation fails).
- *
- * TODO(haberman): currently failure will leave the symtab unchanged, but may
- * leave the defs themselves partially resolved. Does this matter? If so we
- * could do a prepass that ensures that all symbols are resolvable and bail
- * if not, so we don't mutate anything until we know the operation will
- * succeed. */
- bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
-
- bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
- return Add((Def*const*)&defs[0], defs.size(), owner, status);
- }
+ /* Adds the given serialized FileDescriptorProto to the pool. */
+ bool AddFile(const char *file, size_t len, Status *status);
- /* Resolves all subdefs for messages in this file and attempts to freeze the
- * file. If this succeeds, adds all the symbols to this SymbolTable
- * (replacing any existing ones with the same names). */
- bool AddFile(FileDef* file, Status* s);
+ /* Adds the given serialized FileDescriptorSet to the pool. */
+ bool AddSet(const char *set, size_t len, Status *status);
private:
UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
@@ -1525,30 +764,12 @@ UPB_BEGIN_EXTERN_C
upb_symtab *upb_symtab_new();
void upb_symtab_free(upb_symtab* s);
-const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
- const char *sym);
-const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status);
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
-
-/* upb_symtab_iter i;
- * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
- * upb_symtab_next(&i)) {
- * const upb_def *def = upb_symtab_iter_def(&i);
- * // ...
- * }
- *
- * For C we don't have separate iterators for const and non-const.
- * It is the caller's responsibility to cast the upb_fielddef* to
- * const if the upb_msgdef* is const. */
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type);
-void upb_symtab_next(upb_symtab_iter *iter);
-bool upb_symtab_done(const upb_symtab_iter *iter);
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
+bool upb_symtab_addfile(upb_symtab *s, const char *buf, size_t len,
+ upb_status *status);
+bool upb_symtab_addset(upb_symtab *s, const char *buf, size_t len,
+ upb_status *status);
UPB_END_EXTERN_C
@@ -1561,23 +782,12 @@ inline SymbolTable* SymbolTable::New() {
inline void SymbolTable::Free(SymbolTable* s) {
upb_symtab_free(s);
}
-inline const Def *SymbolTable::Resolve(const char *base,
- const char *sym) const {
- return upb_symtab_resolve(this, base, sym);
-}
inline const Def* SymbolTable::Lookup(const char *sym) const {
return upb_symtab_lookup(this, sym);
}
inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
return upb_symtab_lookupmsg(this, sym);
}
-inline bool SymbolTable::Add(
- Def*const* defs, size_t n, void* ref_donor, Status* status) {
- return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
-}
-inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
- return upb_symtab_addfile(this, file, s);
-}
} /* namespace upb */
#endif
@@ -1594,64 +804,10 @@ namespace upb {
inline Def::Type Def::def_type() const { return upb_def_type(this); }
inline const char* Def::full_name() const { return upb_def_fullname(this); }
inline const char* Def::name() const { return upb_def_name(this); }
-inline bool Def::set_full_name(const char* fullname, Status* s) {
- return upb_def_setfullname(this, fullname, s);
-}
-inline bool Def::set_full_name(const std::string& fullname, Status* s) {
- return upb_def_setfullname(this, upb_safecstr(fullname), s);
-}
-inline bool Def::Freeze(Def* const* defs, size_t n, Status* status) {
- return upb_def_freeze(defs, n, status);
-}
-inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) {
- return upb_def_freeze((Def* const*)&defs[0], defs.size(), status);
-}
-inline bool FieldDef::CheckType(int32_t val) {
- return upb_fielddef_checktype(val);
-}
-inline bool FieldDef::CheckLabel(int32_t val) {
- return upb_fielddef_checklabel(val);
-}
-inline bool FieldDef::CheckDescriptorType(int32_t val) {
- return upb_fielddef_checkdescriptortype(val);
-}
-inline bool FieldDef::CheckIntegerFormat(int32_t val) {
- return upb_fielddef_checkintfmt(val);
-}
-inline FieldDef::Type FieldDef::ConvertType(int32_t val) {
- UPB_ASSERT(CheckType(val));
- return static_cast<FieldDef::Type>(val);
-}
-inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) {
- UPB_ASSERT(CheckLabel(val));
- return static_cast<FieldDef::Label>(val);
-}
-inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) {
- UPB_ASSERT(CheckDescriptorType(val));
- return static_cast<FieldDef::DescriptorType>(val);
-}
-inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) {
- UPB_ASSERT(CheckIntegerFormat(val));
- return static_cast<FieldDef::IntegerFormat>(val);
-}
-
-inline reffed_ptr<FieldDef> FieldDef::New() {
- upb_fielddef *f = upb_fielddef_new(&f);
- return reffed_ptr<FieldDef>(f, &f);
-}
inline const char* FieldDef::full_name() const {
return upb_fielddef_fullname(this);
}
-inline bool FieldDef::set_full_name(const char* fullname, Status* s) {
- return upb_fielddef_setfullname(this, fullname, s);
-}
-inline bool FieldDef::set_full_name(const std::string& fullname, Status* s) {
- return upb_fielddef_setfullname(this, upb_safecstr(fullname), s);
-}
-inline bool FieldDef::type_is_set() const {
- return upb_fielddef_typeisset(this);
-}
inline FieldDef::Type FieldDef::type() const { return upb_fielddef_type(this); }
inline FieldDef::DescriptorType FieldDef::descriptor_type() const {
return upb_fielddef_descriptortype(this);
@@ -1670,64 +826,21 @@ inline size_t FieldDef::GetJsonName(char* buf, size_t len) const {
inline bool FieldDef::lazy() const {
return upb_fielddef_lazy(this);
}
-inline void FieldDef::set_lazy(bool lazy) {
- upb_fielddef_setlazy(this, lazy);
-}
inline bool FieldDef::packed() const {
return upb_fielddef_packed(this);
}
inline uint32_t FieldDef::index() const {
return upb_fielddef_index(this);
}
-inline void FieldDef::set_packed(bool packed) {
- upb_fielddef_setpacked(this, packed);
-}
inline const MessageDef* FieldDef::containing_type() const {
return upb_fielddef_containingtype(this);
}
inline const OneofDef* FieldDef::containing_oneof() const {
return upb_fielddef_containingoneof(this);
}
-inline const char* FieldDef::containing_type_name() {
- return upb_fielddef_containingtypename(this);
-}
-inline bool FieldDef::set_number(uint32_t number, Status* s) {
- return upb_fielddef_setnumber(this, number, s);
-}
-inline bool FieldDef::set_name(const char *name, Status* s) {
- return upb_fielddef_setname(this, name, s);
-}
-inline bool FieldDef::set_name(const std::string& name, Status* s) {
- return upb_fielddef_setname(this, upb_safecstr(name), s);
-}
-inline bool FieldDef::set_json_name(const char *name, Status* s) {
- return upb_fielddef_setjsonname(this, name, s);
-}
-inline bool FieldDef::set_json_name(const std::string& name, Status* s) {
- return upb_fielddef_setjsonname(this, upb_safecstr(name), s);
-}
inline void FieldDef::clear_json_name() {
upb_fielddef_clearjsonname(this);
}
-inline bool FieldDef::set_containing_type_name(const char *name, Status* s) {
- return upb_fielddef_setcontainingtypename(this, name, s);
-}
-inline bool FieldDef::set_containing_type_name(const std::string &name,
- Status *s) {
- return upb_fielddef_setcontainingtypename(this, upb_safecstr(name), s);
-}
-inline void FieldDef::set_type(upb_fieldtype_t type) {
- upb_fielddef_settype(this, type);
-}
-inline void FieldDef::set_is_extension(bool is_extension) {
- upb_fielddef_setisextension(this, is_extension);
-}
-inline void FieldDef::set_descriptor_type(FieldDef::DescriptorType type) {
- upb_fielddef_setdescriptortype(this, type);
-}
-inline void FieldDef::set_label(upb_label_t label) {
- upb_fielddef_setlabel(this, label);
-}
inline bool FieldDef::IsSubMessage() const {
return upb_fielddef_issubmsg(this);
}
@@ -1758,37 +871,6 @@ inline double FieldDef::default_double() const {
inline const char* FieldDef::default_string(size_t* len) const {
return upb_fielddef_defaultstr(this, len);
}
-inline void FieldDef::set_default_int64(int64_t value) {
- upb_fielddef_setdefaultint64(this, value);
-}
-inline void FieldDef::set_default_int32(int32_t value) {
- upb_fielddef_setdefaultint32(this, value);
-}
-inline void FieldDef::set_default_uint64(uint64_t value) {
- upb_fielddef_setdefaultuint64(this, value);
-}
-inline void FieldDef::set_default_uint32(uint32_t value) {
- upb_fielddef_setdefaultuint32(this, value);
-}
-inline void FieldDef::set_default_bool(bool value) {
- upb_fielddef_setdefaultbool(this, value);
-}
-inline void FieldDef::set_default_float(float value) {
- upb_fielddef_setdefaultfloat(this, value);
-}
-inline void FieldDef::set_default_double(double value) {
- upb_fielddef_setdefaultdouble(this, value);
-}
-inline bool FieldDef::set_default_string(const void *str, size_t len,
- Status *s) {
- return upb_fielddef_setdefaultstr(this, str, len, s);
-}
-inline bool FieldDef::set_default_string(const std::string& str, Status* s) {
- return upb_fielddef_setdefaultstr(this, str.c_str(), str.size(), s);
-}
-inline void FieldDef::set_default_cstr(const char* str, Status* s) {
- return upb_fielddef_setdefaultcstr(this, str, s);
-}
inline bool FieldDef::HasSubDef() const { return upb_fielddef_hassubdef(this); }
inline const Def* FieldDef::subdef() const { return upb_fielddef_subdef(this); }
inline const MessageDef *FieldDef::message_subdef() const {
@@ -1800,26 +882,7 @@ inline const EnumDef *FieldDef::enum_subdef() const {
inline const char* FieldDef::subdef_name() const {
return upb_fielddef_subdefname(this);
}
-inline bool FieldDef::set_subdef(const Def* subdef, Status* s) {
- return upb_fielddef_setsubdef(this, subdef, s);
-}
-inline bool FieldDef::set_enum_subdef(const EnumDef* subdef, Status* s) {
- return upb_fielddef_setenumsubdef(this, subdef, s);
-}
-inline bool FieldDef::set_message_subdef(const MessageDef* subdef, Status* s) {
- return upb_fielddef_setmsgsubdef(this, subdef, s);
-}
-inline bool FieldDef::set_subdef_name(const char* name, Status* s) {
- return upb_fielddef_setsubdefname(this, name, s);
-}
-inline bool FieldDef::set_subdef_name(const std::string& name, Status* s) {
- return upb_fielddef_setsubdefname(this, upb_safecstr(name), s);
-}
-inline reffed_ptr<MessageDef> MessageDef::New() {
- upb_msgdef *m = upb_msgdef_new(&m);
- return reffed_ptr<MessageDef>(m, &m);
-}
inline const char *MessageDef::full_name() const {
return upb_msgdef_fullname(this);
}
@@ -1829,42 +892,12 @@ inline const char *MessageDef::name() const {
inline upb_syntax_t MessageDef::syntax() const {
return upb_msgdef_syntax(this);
}
-inline bool MessageDef::set_full_name(const char* fullname, Status* s) {
- return upb_msgdef_setfullname(this, fullname, s);
-}
-inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) {
- return upb_msgdef_setfullname(this, upb_safecstr(fullname), s);
-}
-inline bool MessageDef::set_syntax(upb_syntax_t syntax) {
- return upb_msgdef_setsyntax(this, syntax);
-}
-inline bool MessageDef::Freeze(Status* status) {
- return upb_msgdef_freeze(this, status);
-}
inline int MessageDef::field_count() const {
return upb_msgdef_numfields(this);
}
inline int MessageDef::oneof_count() const {
return upb_msgdef_numoneofs(this);
}
-inline bool MessageDef::AddField(upb_fielddef* f, Status* s) {
- return upb_msgdef_addfield(this, f, NULL, s);
-}
-inline bool MessageDef::AddField(const reffed_ptr<FieldDef>& f, Status* s) {
- return upb_msgdef_addfield(this, f.get(), NULL, s);
-}
-inline bool MessageDef::AddOneof(upb_oneofdef* o, Status* s) {
- return upb_msgdef_addoneof(this, o, NULL, s);
-}
-inline bool MessageDef::AddOneof(const reffed_ptr<OneofDef>& o, Status* s) {
- return upb_msgdef_addoneof(this, o.get(), NULL, s);
-}
-inline FieldDef* MessageDef::FindFieldByNumber(uint32_t number) {
- return upb_msgdef_itof_mutable(this, number);
-}
-inline FieldDef* MessageDef::FindFieldByName(const char* name, size_t len) {
- return upb_msgdef_ntof_mutable(this, name, len);
-}
inline const FieldDef* MessageDef::FindFieldByNumber(uint32_t number) const {
return upb_msgdef_itof(this, number);
}
@@ -1872,16 +905,10 @@ inline const FieldDef *MessageDef::FindFieldByName(const char *name,
size_t len) const {
return upb_msgdef_ntof(this, name, len);
}
-inline OneofDef* MessageDef::FindOneofByName(const char* name, size_t len) {
- return upb_msgdef_ntoo_mutable(this, name, len);
-}
inline const OneofDef* MessageDef::FindOneofByName(const char* name,
size_t len) const {
return upb_msgdef_ntoo(this, name, len);
}
-inline void MessageDef::setmapentry(bool map_entry) {
- upb_msgdef_setmapentry(this, map_entry);
-}
inline bool MessageDef::mapentry() const {
return upb_msgdef_mapentry(this);
}
@@ -1900,12 +927,6 @@ inline bool MessageDef::listvalue() const {
inline bool MessageDef::structvalue() const {
return upb_msgdef_structvalue(this);
}
-inline MessageDef::field_iterator MessageDef::field_begin() {
- return field_iterator(this);
-}
-inline MessageDef::field_iterator MessageDef::field_end() {
- return field_iterator::end(this);
-}
inline MessageDef::const_field_iterator MessageDef::field_begin() const {
return const_field_iterator(this);
}
@@ -1913,12 +934,6 @@ inline MessageDef::const_field_iterator MessageDef::field_end() const {
return const_field_iterator::end(this);
}
-inline MessageDef::oneof_iterator MessageDef::oneof_begin() {
- return oneof_iterator(this);
-}
-inline MessageDef::oneof_iterator MessageDef::oneof_end() {
- return oneof_iterator::end(this);
-}
inline MessageDef::const_oneof_iterator MessageDef::oneof_begin() const {
return const_oneof_iterator(this);
}
@@ -1926,30 +941,6 @@ inline MessageDef::const_oneof_iterator MessageDef::oneof_end() const {
return const_oneof_iterator::end(this);
}
-inline MessageDef::field_iterator::field_iterator(MessageDef* md) {
- upb_msg_field_begin(&iter_, md);
-}
-inline MessageDef::field_iterator MessageDef::field_iterator::end(
- MessageDef* md) {
- MessageDef::field_iterator iter(md);
- upb_msg_field_iter_setdone(&iter.iter_);
- return iter;
-}
-inline FieldDef* MessageDef::field_iterator::operator*() const {
- return upb_msg_iter_field(&iter_);
-}
-inline void MessageDef::field_iterator::operator++() {
- return upb_msg_field_next(&iter_);
-}
-inline bool MessageDef::field_iterator::operator==(
- const field_iterator &other) const {
- return upb_inttable_iter_isequal(&iter_, &other.iter_);
-}
-inline bool MessageDef::field_iterator::operator!=(
- const field_iterator &other) const {
- return !(*this == other);
-}
-
inline MessageDef::const_field_iterator::const_field_iterator(
const MessageDef* md) {
upb_msg_field_begin(&iter_, md);
@@ -1975,30 +966,6 @@ inline bool MessageDef::const_field_iterator::operator!=(
return !(*this == other);
}
-inline MessageDef::oneof_iterator::oneof_iterator(MessageDef* md) {
- upb_msg_oneof_begin(&iter_, md);
-}
-inline MessageDef::oneof_iterator MessageDef::oneof_iterator::end(
- MessageDef* md) {
- MessageDef::oneof_iterator iter(md);
- upb_msg_oneof_iter_setdone(&iter.iter_);
- return iter;
-}
-inline OneofDef* MessageDef::oneof_iterator::operator*() const {
- return upb_msg_iter_oneof(&iter_);
-}
-inline void MessageDef::oneof_iterator::operator++() {
- return upb_msg_oneof_next(&iter_);
-}
-inline bool MessageDef::oneof_iterator::operator==(
- const oneof_iterator &other) const {
- return upb_strtable_iter_isequal(&iter_, &other.iter_);
-}
-inline bool MessageDef::oneof_iterator::operator!=(
- const oneof_iterator &other) const {
- return !(*this == other);
-}
-
inline MessageDef::const_oneof_iterator::const_oneof_iterator(
const MessageDef* md) {
upb_msg_oneof_begin(&iter_, md);
@@ -2024,39 +991,16 @@ inline bool MessageDef::const_oneof_iterator::operator!=(
return !(*this == other);
}
-inline reffed_ptr<EnumDef> EnumDef::New() {
- upb_enumdef *e = upb_enumdef_new(&e);
- return reffed_ptr<EnumDef>(e, &e);
-}
inline const char* EnumDef::full_name() const {
return upb_enumdef_fullname(this);
}
inline const char* EnumDef::name() const {
return upb_enumdef_name(this);
}
-inline bool EnumDef::set_full_name(const char* fullname, Status* s) {
- return upb_enumdef_setfullname(this, fullname, s);
-}
-inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) {
- return upb_enumdef_setfullname(this, upb_safecstr(fullname), s);
-}
-inline bool EnumDef::Freeze(Status* status) {
- return upb_enumdef_freeze(this, status);
-}
inline int32_t EnumDef::default_value() const {
return upb_enumdef_default(this);
}
-inline bool EnumDef::set_default_value(int32_t val, Status* status) {
- return upb_enumdef_setdefault(this, val, status);
-}
inline int EnumDef::value_count() const { return upb_enumdef_numvals(this); }
-inline bool EnumDef::AddValue(const char* name, int32_t num, Status* status) {
- return upb_enumdef_addval(this, name, num, status);
-}
-inline bool EnumDef::AddValue(const std::string& name, int32_t num,
- Status* status) {
- return upb_enumdef_addval(this, upb_safecstr(name), num, status);
-}
inline bool EnumDef::FindValueByName(const char* name, int32_t *num) const {
return upb_enumdef_ntoiz(this, name, num);
}
@@ -2076,32 +1020,15 @@ inline const char* EnumDef::Iterator::name() {
inline bool EnumDef::Iterator::Done() { return upb_enum_done(&iter_); }
inline void EnumDef::Iterator::Next() { return upb_enum_next(&iter_); }
-inline reffed_ptr<OneofDef> OneofDef::New() {
- upb_oneofdef *o = upb_oneofdef_new(&o);
- return reffed_ptr<OneofDef>(o, &o);
-}
-
inline const MessageDef* OneofDef::containing_type() const {
return upb_oneofdef_containingtype(this);
}
inline const char* OneofDef::name() const {
return upb_oneofdef_name(this);
}
-inline bool OneofDef::set_name(const char* name, Status* s) {
- return upb_oneofdef_setname(this, name, s);
-}
-inline bool OneofDef::set_name(const std::string& name, Status* s) {
- return upb_oneofdef_setname(this, upb_safecstr(name), s);
-}
inline int OneofDef::field_count() const {
return upb_oneofdef_numfields(this);
}
-inline bool OneofDef::AddField(FieldDef* field, Status* s) {
- return upb_oneofdef_addfield(this, field, NULL, s);
-}
-inline bool OneofDef::AddField(const reffed_ptr<FieldDef>& field, Status* s) {
- return upb_oneofdef_addfield(this, field.get(), NULL, s);
-}
inline const FieldDef* OneofDef::FindFieldByName(const char* name,
size_t len) const {
return upb_oneofdef_ntof(this, name, len);
@@ -2109,8 +1036,6 @@ inline const FieldDef* OneofDef::FindFieldByName(const char* name,
inline const FieldDef* OneofDef::FindFieldByNumber(uint32_t num) const {
return upb_oneofdef_itof(this, num);
}
-inline OneofDef::iterator OneofDef::begin() { return iterator(this); }
-inline OneofDef::iterator OneofDef::end() { return iterator::end(this); }
inline OneofDef::const_iterator OneofDef::begin() const {
return const_iterator(this);
}
@@ -2118,25 +1043,6 @@ inline OneofDef::const_iterator OneofDef::end() const {
return const_iterator::end(this);
}
-inline OneofDef::iterator::iterator(OneofDef* o) {
- upb_oneof_begin(&iter_, o);
-}
-inline OneofDef::iterator OneofDef::iterator::end(OneofDef* o) {
- OneofDef::iterator iter(o);
- upb_oneof_iter_setdone(&iter.iter_);
- return iter;
-}
-inline FieldDef* OneofDef::iterator::operator*() const {
- return upb_oneof_iter_field(&iter_);
-}
-inline void OneofDef::iterator::operator++() { return upb_oneof_next(&iter_); }
-inline bool OneofDef::iterator::operator==(const iterator &other) const {
- return upb_inttable_iter_isequal(&iter_, &other.iter_);
-}
-inline bool OneofDef::iterator::operator!=(const iterator &other) const {
- return !(*this == other);
-}
-
inline OneofDef::const_iterator::const_iterator(const OneofDef* md) {
upb_oneof_begin(&iter_, md);
}
@@ -2161,38 +1067,18 @@ inline bool OneofDef::const_iterator::operator!=(
return !(*this == other);
}
-inline reffed_ptr<FileDef> FileDef::New() {
- upb_filedef *f = upb_filedef_new(&f);
- return reffed_ptr<FileDef>(f, &f);
-}
-
inline const char* FileDef::name() const {
return upb_filedef_name(this);
}
-inline bool FileDef::set_name(const char* name, Status* s) {
- return upb_filedef_setname(this, name, s);
-}
-inline bool FileDef::set_name(const std::string& name, Status* s) {
- return upb_filedef_setname(this, upb_safecstr(name), s);
-}
inline const char* FileDef::package() const {
return upb_filedef_package(this);
}
-inline bool FileDef::set_package(const char* package, Status* s) {
- return upb_filedef_setpackage(this, package, s);
-}
inline const char* FileDef::phpprefix() const {
return upb_filedef_phpprefix(this);
}
-inline bool FileDef::set_phpprefix(const char* phpprefix, Status* s) {
- return upb_filedef_setphpprefix(this, phpprefix, s);
-}
inline const char* FileDef::phpnamespace() const {
return upb_filedef_phpnamespace(this);
}
-inline bool FileDef::set_phpnamespace(const char* phpnamespace, Status* s) {
- return upb_filedef_setphpnamespace(this, phpnamespace, s);
-}
inline int FileDef::def_count() const {
return upb_filedef_defcount(this);
}
@@ -2208,21 +1094,6 @@ inline int FileDef::dependency_count() const {
inline const FileDef* FileDef::dependency(int index) const {
return upb_filedef_dep(this, index);
}
-inline bool FileDef::AddDef(Def* def, Status* s) {
- return upb_filedef_adddef(this, def, NULL, s);
-}
-inline bool FileDef::AddMessage(MessageDef* m, Status* s) {
- return upb_filedef_addmsg(this, m, NULL, s);
-}
-inline bool FileDef::AddEnum(EnumDef* e, Status* s) {
- return upb_filedef_addenum(this, e, NULL, s);
-}
-inline bool FileDef::AddExtension(FieldDef* f, Status* s) {
- return upb_filedef_addext(this, f, NULL, s);
-}
-inline bool FileDef::AddDependency(const FileDef* file) {
- return upb_filedef_adddep(this, file);
-}
} /* namespace upb */
#endif
diff --git a/upb/descriptor/descriptor.pb b/upb/descriptor/descriptor.pb
deleted file mode 100644
index 74bc3bc..0000000
--- a/upb/descriptor/descriptor.pb
+++ /dev/null
Binary files differ
diff --git a/upb/descriptor/descriptor.proto b/upb/descriptor/descriptor.proto
deleted file mode 100644
index b6e303e..0000000
--- a/upb/descriptor/descriptor.proto
+++ /dev/null
@@ -1,788 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// The messages in this file describe the definitions found in .proto files.
-// A valid .proto file can be translated directly to a FileDescriptorProto
-// without any other information (e.g. without reading its imports).
-
-
-syntax = "proto2";
-
-package google.protobuf;
-option go_package = "descriptor";
-option java_package = "com.google.protobuf";
-option java_outer_classname = "DescriptorProtos";
-option csharp_namespace = "Google.Protobuf.Reflection";
-option objc_class_prefix = "GPB";
-
-// descriptor.proto must be optimized for speed because reflection-based
-// algorithms don't work during bootstrapping.
-option optimize_for = SPEED;
-
-// The protocol compiler can output a FileDescriptorSet containing the .proto
-// files it parses.
-message FileDescriptorSet {
- repeated FileDescriptorProto file = 1;
-}
-
-// Describes a complete .proto file.
-message FileDescriptorProto {
- optional string name = 1; // file name, relative to root of source tree
- optional string package = 2; // e.g. "foo", "foo.bar", etc.
-
- // Names of files imported by this file.
- repeated string dependency = 3;
- // Indexes of the public imported files in the dependency list above.
- repeated int32 public_dependency = 10;
- // Indexes of the weak imported files in the dependency list.
- // For Google-internal migration only. Do not use.
- repeated int32 weak_dependency = 11;
-
- // All top-level definitions in this file.
- repeated DescriptorProto message_type = 4;
- repeated EnumDescriptorProto enum_type = 5;
- repeated ServiceDescriptorProto service = 6;
- repeated FieldDescriptorProto extension = 7;
-
- optional FileOptions options = 8;
-
- // This field contains optional information about the original source code.
- // You may safely remove this entire field without harming runtime
- // functionality of the descriptors -- the information is needed only by
- // development tools.
- optional SourceCodeInfo source_code_info = 9;
-
- // The syntax of the proto file.
- // The supported values are "proto2" and "proto3".
- optional string syntax = 12;
-}
-
-// Describes a message type.
-message DescriptorProto {
- optional string name = 1;
-
- repeated FieldDescriptorProto field = 2;
- repeated FieldDescriptorProto extension = 6;
-
- repeated DescriptorProto nested_type = 3;
- repeated EnumDescriptorProto enum_type = 4;
-
- message ExtensionRange {
- optional int32 start = 1;
- optional int32 end = 2;
- }
- repeated ExtensionRange extension_range = 5;
-
- repeated OneofDescriptorProto oneof_decl = 8;
-
- optional MessageOptions options = 7;
-
- // Range of reserved tag numbers. Reserved tag numbers may not be used by
- // fields or extension ranges in the same message. Reserved ranges may
- // not overlap.
- message ReservedRange {
- optional int32 start = 1; // Inclusive.
- optional int32 end = 2; // Exclusive.
- }
- repeated ReservedRange reserved_range = 9;
- // Reserved field names, which may not be used by fields in the same message.
- // A given name may only be reserved once.
- repeated string reserved_name = 10;
-}
-
-// Describes a field within a message.
-message FieldDescriptorProto {
- enum Type {
- // 0 is reserved for errors.
- // Order is weird for historical reasons.
- TYPE_DOUBLE = 1;
- TYPE_FLOAT = 2;
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
- // negative values are likely.
- TYPE_INT64 = 3;
- TYPE_UINT64 = 4;
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
- // negative values are likely.
- TYPE_INT32 = 5;
- TYPE_FIXED64 = 6;
- TYPE_FIXED32 = 7;
- TYPE_BOOL = 8;
- TYPE_STRING = 9;
- TYPE_GROUP = 10; // Tag-delimited aggregate.
- TYPE_MESSAGE = 11; // Length-delimited aggregate.
-
- // New in version 2.
- TYPE_BYTES = 12;
- TYPE_UINT32 = 13;
- TYPE_ENUM = 14;
- TYPE_SFIXED32 = 15;
- TYPE_SFIXED64 = 16;
- TYPE_SINT32 = 17; // Uses ZigZag encoding.
- TYPE_SINT64 = 18; // Uses ZigZag encoding.
- };
-
- enum Label {
- // 0 is reserved for errors
- LABEL_OPTIONAL = 1;
- LABEL_REQUIRED = 2;
- LABEL_REPEATED = 3;
- // TODO(sanjay): Should we add LABEL_MAP?
- };
-
- optional string name = 1;
- optional int32 number = 3;
- optional Label label = 4;
-
- // If type_name is set, this need not be set. If both this and type_name
- // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
- optional Type type = 5;
-
- // For message and enum types, this is the name of the type. If the name
- // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
- // rules are used to find the type (i.e. first the nested types within this
- // message are searched, then within the parent, on up to the root
- // namespace).
- optional string type_name = 6;
-
- // For extensions, this is the name of the type being extended. It is
- // resolved in the same manner as type_name.
- optional string extendee = 2;
-
- // For numeric types, contains the original text representation of the value.
- // For booleans, "true" or "false".
- // For strings, contains the default text contents (not escaped in any way).
- // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
- // TODO(kenton): Base-64 encode?
- optional string default_value = 7;
-
- // If set, gives the index of a oneof in the containing type's oneof_decl
- // list. This field is a member of that oneof.
- optional int32 oneof_index = 9;
-
- // JSON name of this field. The value is set by protocol compiler. If the
- // user has set a "json_name" option on this field, that option's value
- // will be used. Otherwise, it's deduced from the field's name by converting
- // it to camelCase.
- optional string json_name = 10;
-
- optional FieldOptions options = 8;
-}
-
-// Describes a oneof.
-message OneofDescriptorProto {
- optional string name = 1;
-}
-
-// Describes an enum type.
-message EnumDescriptorProto {
- optional string name = 1;
-
- repeated EnumValueDescriptorProto value = 2;
-
- optional EnumOptions options = 3;
-}
-
-// Describes a value within an enum.
-message EnumValueDescriptorProto {
- optional string name = 1;
- optional int32 number = 2;
-
- optional EnumValueOptions options = 3;
-}
-
-// Describes a service.
-message ServiceDescriptorProto {
- optional string name = 1;
- repeated MethodDescriptorProto method = 2;
-
- optional ServiceOptions options = 3;
-}
-
-// Describes a method of a service.
-message MethodDescriptorProto {
- optional string name = 1;
-
- // Input and output type names. These are resolved in the same way as
- // FieldDescriptorProto.type_name, but must refer to a message type.
- optional string input_type = 2;
- optional string output_type = 3;
-
- optional MethodOptions options = 4;
-
- // Identifies if client streams multiple client messages
- optional bool client_streaming = 5 [default=false];
- // Identifies if server streams multiple server messages
- optional bool server_streaming = 6 [default=false];
-}
-
-
-// ===================================================================
-// Options
-
-// Each of the definitions above may have "options" attached. These are
-// just annotations which may cause code to be generated slightly differently
-// or may contain hints for code that manipulates protocol messages.
-//
-// Clients may define custom options as extensions of the *Options messages.
-// These extensions may not yet be known at parsing time, so the parser cannot
-// store the values in them. Instead it stores them in a field in the *Options
-// message called uninterpreted_option. This field must have the same name
-// across all *Options messages. We then use this field to populate the
-// extensions when we build a descriptor, at which point all protos have been
-// parsed and so all extensions are known.
-//
-// Extension numbers for custom options may be chosen as follows:
-// * For options which will only be used within a single application or
-// organization, or for experimental options, use field numbers 50000
-// through 99999. It is up to you to ensure that you do not use the
-// same number for multiple options.
-// * For options which will be published and used publicly by multiple
-// independent entities, e-mail protobuf-global-extension-registry@google.com
-// to reserve extension numbers. Simply provide your project name (e.g.
-// Objective-C plugin) and your project website (if available) -- there's no
-// need to explain how you intend to use them. Usually you only need one
-// extension number. You can declare multiple options with only one extension
-// number by putting them in a sub-message. See the Custom Options section of
-// the docs for examples:
-// https://developers.google.com/protocol-buffers/docs/proto#options
-// If this turns out to be popular, a web service will be set up
-// to automatically assign option numbers.
-
-
-message FileOptions {
-
- // Sets the Java package where classes generated from this .proto will be
- // placed. By default, the proto package is used, but this is often
- // inappropriate because proto packages do not normally start with backwards
- // domain names.
- optional string java_package = 1;
-
-
- // If set, all the classes from the .proto file are wrapped in a single
- // outer class with the given name. This applies to both Proto1
- // (equivalent to the old "--one_java_file" option) and Proto2 (where
- // a .proto always translates to a single class, but you may want to
- // explicitly choose the class name).
- optional string java_outer_classname = 8;
-
- // If set true, then the Java code generator will generate a separate .java
- // file for each top-level message, enum, and service defined in the .proto
- // file. Thus, these types will *not* be nested inside the outer class
- // named by java_outer_classname. However, the outer class will still be
- // generated to contain the file's getDescriptor() method as well as any
- // top-level extensions defined in the file.
- optional bool java_multiple_files = 10 [default=false];
-
- // If set true, then the Java code generator will generate equals() and
- // hashCode() methods for all messages defined in the .proto file.
- // This increases generated code size, potentially substantially for large
- // protos, which may harm a memory-constrained application.
- // - In the full runtime this is a speed optimization, as the
- // AbstractMessage base class includes reflection-based implementations of
- // these methods.
- // - In the lite runtime, setting this option changes the semantics of
- // equals() and hashCode() to more closely match those of the full runtime;
- // the generated methods compute their results based on field values rather
- // than object identity. (Implementations should not assume that hashcodes
- // will be consistent across runtimes or versions of the protocol compiler.)
- optional bool java_generate_equals_and_hash = 20 [default=false];
-
- // If set true, then the Java2 code generator will generate code that
- // throws an exception whenever an attempt is made to assign a non-UTF-8
- // byte sequence to a string field.
- // Message reflection will do the same.
- // However, an extension field still accepts non-UTF-8 byte sequences.
- // This option has no effect on when used with the lite runtime.
- optional bool java_string_check_utf8 = 27 [default=false];
-
-
- // Generated classes can be optimized for speed or code size.
- enum OptimizeMode {
- SPEED = 1; // Generate complete code for parsing, serialization,
- // etc.
- CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
- LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
- }
- optional OptimizeMode optimize_for = 9 [default=SPEED];
-
- // Sets the Go package where structs generated from this .proto will be
- // placed. If omitted, the Go package will be derived from the following:
- // - The basename of the package import path, if provided.
- // - Otherwise, the package statement in the .proto file, if present.
- // - Otherwise, the basename of the .proto file, without extension.
- optional string go_package = 11;
-
-
-
- // Should generic services be generated in each language? "Generic" services
- // are not specific to any particular RPC system. They are generated by the
- // main code generators in each language (without additional plugins).
- // Generic services were the only kind of service generation supported by
- // early versions of google.protobuf.
- //
- // Generic services are now considered deprecated in favor of using plugins
- // that generate code specific to your particular RPC system. Therefore,
- // these default to false. Old code which depends on generic services should
- // explicitly set them to true.
- optional bool cc_generic_services = 16 [default=false];
- optional bool java_generic_services = 17 [default=false];
- optional bool py_generic_services = 18 [default=false];
-
- // Is this file deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for everything in the file, or it will be completely ignored; in the very
- // least, this is a formalization for deprecating files.
- optional bool deprecated = 23 [default=false];
-
- // Enables the use of arenas for the proto messages in this file. This applies
- // only to generated classes for C++.
- optional bool cc_enable_arenas = 31 [default=false];
-
-
- // Sets the objective c class prefix which is prepended to all objective c
- // generated classes from this .proto. There is no default.
- optional string objc_class_prefix = 36;
-
- // Namespace for generated classes; defaults to the package.
- optional string csharp_namespace = 37;
-
- // Whether the nano proto compiler should generate in the deprecated non-nano
- // suffixed package.
- optional bool javanano_use_deprecated_package = 38;
-
- // Sets the php class prefix which is prepended to all php generated classes
- // from this .proto. Default is empty.
- optional string php_class_prefix = 40;
-
- // Use this option to change the namespace of php generated classes. Default
- // is empty. When this option is empty, the package name will be used for
- // determining the namespace.
- optional string php_namespace = 41;
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message MessageOptions {
- // Set true to use the old proto1 MessageSet wire format for extensions.
- // This is provided for backwards-compatibility with the MessageSet wire
- // format. You should not use this for any other reason: It's less
- // efficient, has fewer features, and is more complicated.
- //
- // The message must be defined exactly as follows:
- // message Foo {
- // option message_set_wire_format = true;
- // extensions 4 to max;
- // }
- // Note that the message cannot have any defined fields; MessageSets only
- // have extensions.
- //
- // All extensions of your type must be singular messages; e.g. they cannot
- // be int32s, enums, or repeated messages.
- //
- // Because this is an option, the above two restrictions are not enforced by
- // the protocol compiler.
- optional bool message_set_wire_format = 1 [default=false];
-
- // Disables the generation of the standard "descriptor()" accessor, which can
- // conflict with a field of the same name. This is meant to make migration
- // from proto1 easier; new code should avoid fields named "descriptor".
- optional bool no_standard_descriptor_accessor = 2 [default=false];
-
- // Is this message deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the message, or it will be completely ignored; in the very least,
- // this is a formalization for deprecating messages.
- optional bool deprecated = 3 [default=false];
-
- // Whether the message is an automatically generated map entry type for the
- // maps field.
- //
- // For maps fields:
- // map<KeyType, ValueType> map_field = 1;
- // The parsed descriptor looks like:
- // message MapFieldEntry {
- // option map_entry = true;
- // optional KeyType key = 1;
- // optional ValueType value = 2;
- // }
- // repeated MapFieldEntry map_field = 1;
- //
- // Implementations may choose not to generate the map_entry=true message, but
- // use a native map in the target language to hold the keys and values.
- // The reflection APIs in such implementions still need to work as
- // if the field is a repeated message field.
- //
- // NOTE: Do not set the option in .proto files. Always use the maps syntax
- // instead. The option should only be implicitly set by the proto compiler
- // parser.
- optional bool map_entry = 7;
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message FieldOptions {
- // The ctype option instructs the C++ code generator to use a different
- // representation of the field than it normally would. See the specific
- // options below. This option is not yet implemented in the open source
- // release -- sorry, we'll try to include it in a future version!
- optional CType ctype = 1 [default = STRING];
- enum CType {
- // Default mode.
- STRING = 0;
-
- CORD = 1;
-
- STRING_PIECE = 2;
- }
- // The packed option can be enabled for repeated primitive fields to enable
- // a more efficient representation on the wire. Rather than repeatedly
- // writing the tag and type for each element, the entire array is encoded as
- // a single length-delimited blob. In proto3, only explicit setting it to
- // false will avoid using packed encoding.
- optional bool packed = 2;
-
-
- // The jstype option determines the JavaScript type used for values of the
- // field. The option is permitted only for 64 bit integral and fixed types
- // (int64, uint64, sint64, fixed64, sfixed64). By default these types are
- // represented as JavaScript strings. This avoids loss of precision that can
- // happen when a large value is converted to a floating point JavaScript
- // numbers. Specifying JS_NUMBER for the jstype causes the generated
- // JavaScript code to use the JavaScript "number" type instead of strings.
- // This option is an enum to permit additional types to be added,
- // e.g. goog.math.Integer.
- optional JSType jstype = 6 [default = JS_NORMAL];
- enum JSType {
- // Use the default type.
- JS_NORMAL = 0;
-
- // Use JavaScript strings.
- JS_STRING = 1;
-
- // Use JavaScript numbers.
- JS_NUMBER = 2;
- }
-
- // Should this field be parsed lazily? Lazy applies only to message-type
- // fields. It means that when the outer message is initially parsed, the
- // inner message's contents will not be parsed but instead stored in encoded
- // form. The inner message will actually be parsed when it is first accessed.
- //
- // This is only a hint. Implementations are free to choose whether to use
- // eager or lazy parsing regardless of the value of this option. However,
- // setting this option true suggests that the protocol author believes that
- // using lazy parsing on this field is worth the additional bookkeeping
- // overhead typically needed to implement it.
- //
- // This option does not affect the public interface of any generated code;
- // all method signatures remain the same. Furthermore, thread-safety of the
- // interface is not affected by this option; const methods remain safe to
- // call from multiple threads concurrently, while non-const methods continue
- // to require exclusive access.
- //
- //
- // Note that implementations may choose not to check required fields within
- // a lazy sub-message. That is, calling IsInitialized() on the outher message
- // may return true even if the inner message has missing required fields.
- // This is necessary because otherwise the inner message would have to be
- // parsed in order to perform the check, defeating the purpose of lazy
- // parsing. An implementation which chooses not to check required fields
- // must be consistent about it. That is, for any particular sub-message, the
- // implementation must either *always* check its required fields, or *never*
- // check its required fields, regardless of whether or not the message has
- // been parsed.
- optional bool lazy = 5 [default=false];
-
- // Is this field deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for accessors, or it will be completely ignored; in the very least, this
- // is a formalization for deprecating fields.
- optional bool deprecated = 3 [default=false];
-
- // For Google-internal migration only. Do not use.
- optional bool weak = 10 [default=false];
-
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message EnumOptions {
-
- // Set this option to true to allow mapping different tag names to the same
- // value.
- optional bool allow_alias = 2;
-
- // Is this enum deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the enum, or it will be completely ignored; in the very least, this
- // is a formalization for deprecating enums.
- optional bool deprecated = 3 [default=false];
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message EnumValueOptions {
- // Is this enum value deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the enum value, or it will be completely ignored; in the very least,
- // this is a formalization for deprecating enum values.
- optional bool deprecated = 1 [default=false];
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message ServiceOptions {
-
- // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
- // framework. We apologize for hoarding these numbers to ourselves, but
- // we were already using them long before we decided to release Protocol
- // Buffers.
-
- // Is this service deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the service, or it will be completely ignored; in the very least,
- // this is a formalization for deprecating services.
- optional bool deprecated = 33 [default=false];
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-message MethodOptions {
-
- // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
- // framework. We apologize for hoarding these numbers to ourselves, but
- // we were already using them long before we decided to release Protocol
- // Buffers.
-
- // Is this method deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the method, or it will be completely ignored; in the very least,
- // this is a formalization for deprecating methods.
- optional bool deprecated = 33 [default=false];
-
- // The parser stores options it doesn't recognize here. See above.
- repeated UninterpretedOption uninterpreted_option = 999;
-
- // Clients can define custom options in extensions of this message. See above.
- extensions 1000 to max;
-}
-
-
-// A message representing a option the parser does not recognize. This only
-// appears in options protos created by the compiler::Parser class.
-// DescriptorPool resolves these when building Descriptor objects. Therefore,
-// options protos in descriptor objects (e.g. returned by Descriptor::options(),
-// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
-// in them.
-message UninterpretedOption {
- // The name of the uninterpreted option. Each string represents a segment in
- // a dot-separated name. is_extension is true iff a segment represents an
- // extension (denoted with parentheses in options specs in .proto files).
- // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
- // "foo.(bar.baz).qux".
- message NamePart {
- required string name_part = 1;
- required bool is_extension = 2;
- }
- repeated NamePart name = 2;
-
- // The value of the uninterpreted option, in whatever type the tokenizer
- // identified it as during parsing. Exactly one of these should be set.
- optional string identifier_value = 3;
- optional uint64 positive_int_value = 4;
- optional int64 negative_int_value = 5;
- optional double double_value = 6;
- optional bytes string_value = 7;
- optional string aggregate_value = 8;
-}
-
-// ===================================================================
-// Optional source code info
-
-// Encapsulates information about the original source file from which a
-// FileDescriptorProto was generated.
-message SourceCodeInfo {
- // A Location identifies a piece of source code in a .proto file which
- // corresponds to a particular definition. This information is intended
- // to be useful to IDEs, code indexers, documentation generators, and similar
- // tools.
- //
- // For example, say we have a file like:
- // message Foo {
- // optional string foo = 1;
- // }
- // Let's look at just the field definition:
- // optional string foo = 1;
- // ^ ^^ ^^ ^ ^^^
- // a bc de f ghi
- // We have the following locations:
- // span path represents
- // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
- // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
- // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
- // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
- // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
- //
- // Notes:
- // - A location may refer to a repeated field itself (i.e. not to any
- // particular index within it). This is used whenever a set of elements are
- // logically enclosed in a single code segment. For example, an entire
- // extend block (possibly containing multiple extension definitions) will
- // have an outer location whose path refers to the "extensions" repeated
- // field without an index.
- // - Multiple locations may have the same path. This happens when a single
- // logical declaration is spread out across multiple places. The most
- // obvious example is the "extend" block again -- there may be multiple
- // extend blocks in the same scope, each of which will have the same path.
- // - A location's span is not always a subset of its parent's span. For
- // example, the "extendee" of an extension declaration appears at the
- // beginning of the "extend" block and is shared by all extensions within
- // the block.
- // - Just because a location's span is a subset of some other location's span
- // does not mean that it is a descendent. For example, a "group" defines
- // both a type and a field in a single declaration. Thus, the locations
- // corresponding to the type and field and their components will overlap.
- // - Code which tries to interpret locations should probably be designed to
- // ignore those that it doesn't understand, as more types of locations could
- // be recorded in the future.
- repeated Location location = 1;
- message Location {
- // Identifies which part of the FileDescriptorProto was defined at this
- // location.
- //
- // Each element is a field number or an index. They form a path from
- // the root FileDescriptorProto to the place where the definition. For
- // example, this path:
- // [ 4, 3, 2, 7, 1 ]
- // refers to:
- // file.message_type(3) // 4, 3
- // .field(7) // 2, 7
- // .name() // 1
- // This is because FileDescriptorProto.message_type has field number 4:
- // repeated DescriptorProto message_type = 4;
- // and DescriptorProto.field has field number 2:
- // repeated FieldDescriptorProto field = 2;
- // and FieldDescriptorProto.name has field number 1:
- // optional string name = 1;
- //
- // Thus, the above path gives the location of a field name. If we removed
- // the last element:
- // [ 4, 3, 2, 7 ]
- // this path refers to the whole field declaration (from the beginning
- // of the label to the terminating semicolon).
- repeated int32 path = 1 [packed=true];
-
- // Always has exactly three or four elements: start line, start column,
- // end line (optional, otherwise assumed same as start line), end column.
- // These are packed into a single field for efficiency. Note that line
- // and column numbers are zero-based -- typically you will want to add
- // 1 to each before displaying to a user.
- repeated int32 span = 2 [packed=true];
-
- // If this SourceCodeInfo represents a complete declaration, these are any
- // comments appearing before and after the declaration which appear to be
- // attached to the declaration.
- //
- // A series of line comments appearing on consecutive lines, with no other
- // tokens appearing on those lines, will be treated as a single comment.
- //
- // leading_detached_comments will keep paragraphs of comments that appear
- // before (but not connected to) the current element. Each paragraph,
- // separated by empty lines, will be one comment element in the repeated
- // field.
- //
- // Only the comment content is provided; comment markers (e.g. //) are
- // stripped out. For block comments, leading whitespace and an asterisk
- // will be stripped from the beginning of each line other than the first.
- // Newlines are included in the output.
- //
- // Examples:
- //
- // optional int32 foo = 1; // Comment attached to foo.
- // // Comment attached to bar.
- // optional int32 bar = 2;
- //
- // optional string baz = 3;
- // // Comment attached to baz.
- // // Another line attached to baz.
- //
- // // Comment attached to qux.
- // //
- // // Another line attached to qux.
- // optional double qux = 4;
- //
- // // Detached comment for corge. This is not leading or trailing comments
- // // to qux or corge because there are blank lines separating it from
- // // both.
- //
- // // Detached comment for corge paragraph 2.
- //
- // optional string corge = 5;
- // /* Block comment attached
- // * to corge. Leading asterisks
- // * will be removed. */
- // /* Block comment attached to
- // * grault. */
- // optional int32 grault = 6;
- //
- // // ignored detached comments.
- optional string leading_comments = 3;
- optional string trailing_comments = 4;
- repeated string leading_detached_comments = 6;
- }
-}
diff --git a/upb/descriptor/descriptor.upbdefs.c b/upb/descriptor/descriptor.upbdefs.c
deleted file mode 100644
index ceba74e..0000000
--- a/upb/descriptor/descriptor.upbdefs.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* This file was generated by upbc (the upb compiler) from the input
- * file:
- *
- * upb/descriptor/descriptor.proto
- *
- * Do not edit -- your changes will be discarded when the file is
- * regenerated. */
-
-#include "upb/def.h"
-#include "upb/structdefs.int.h"
-
-static const upb_msgdef msgs[22];
-static const upb_fielddef fields[107];
-static const upb_enumdef enums[5];
-static const upb_tabent strentries[236];
-static const upb_tabent intentries[18];
-static const upb_tabval arrays[187];
-
-#ifdef UPB_DEBUG_REFS
-static upb_inttable reftables[268];
-#endif
-
-static const upb_msgdef msgs[22] = {
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", 41, 8, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[0], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[0]), false, UPB_SYNTAX_PROTO2, &reftables[0], &reftables[1]),
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[11], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[16]), false, UPB_SYNTAX_PROTO2, &reftables[2], &reftables[3]),
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ReservedRange", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[14], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[20]), false, UPB_SYNTAX_PROTO2, &reftables[4], &reftables[5]),
- UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", 12, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[17], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[24]), false, UPB_SYNTAX_PROTO2, &reftables[6], &reftables[7]),
- UPB_MSGDEF_INIT("google.protobuf.EnumOptions", 9, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[0], &arrays[21], 4, 2), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[28]), false, UPB_SYNTAX_PROTO2, &reftables[8], &reftables[9]),
- UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", 9, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[25], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[32]), false, UPB_SYNTAX_PROTO2, &reftables[10], &reftables[11]),
- UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", 8, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[2], &arrays[29], 2, 1), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[36]), false, UPB_SYNTAX_PROTO2, &reftables[12], &reftables[13]),
- UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", 24, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[31], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[40]), false, UPB_SYNTAX_PROTO2, &reftables[14], &reftables[15]),
- UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 13, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]),
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 43, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]),
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 7, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]),
- UPB_MSGDEF_INIT("google.protobuf.FileOptions", 38, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 42, 17), UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]),
- UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 11, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[110], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]),
- UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 16, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[118], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]),
- UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 8, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[125], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]),
- UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[126], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]),
- UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 12, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[128], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]),
- UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 8, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[132], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]),
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 7, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[133], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]),
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 20, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[135], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]),
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 19, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[142], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]),
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 7, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[151], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]),
-};
-
-static const upb_fielddef fields[107] = {
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 16, 6, {0},&reftables[44], &reftables[45]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 7, 1, {0},&reftables[46], &reftables[47]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 24, 12, {0},&reftables[48], &reftables[49]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_generic_services", 16, &msgs[11], NULL, 18, 6, {0},&reftables[50], &reftables[51]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "client_streaming", 5, &msgs[13], NULL, 14, 4, {0},&reftables[52], &reftables[53]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "csharp_namespace", 37, &msgs[11], NULL, 28, 14, {0},&reftables[54], &reftables[55]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 7, 1, {0},&reftables[56], &reftables[57]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 17, 7, {0},&reftables[58], &reftables[59]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 31, 8, {0},&reftables[60], &reftables[61]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 9, 3, {0},&reftables[62], &reftables[63]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 7, 1, {0},&reftables[64], &reftables[65]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 9, 3, {0},&reftables[66], &reftables[67]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 22, 10, {0},&reftables[68], &reftables[69]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 7, 1, {0},&reftables[70], &reftables[71]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 8, 2, {0},&reftables[72], &reftables[73]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 7, 1, {0},&reftables[74], &reftables[75]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 12, 4, {0},&reftables[76], &reftables[77]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 4, 1, {0},&reftables[78], &reftables[79]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 4, 1, {0},&reftables[80], &reftables[81]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 14, 1, {0},&reftables[82], &reftables[83]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 19, 2, {0},&reftables[84], &reftables[85]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 8, 2, {0},&reftables[86], &reftables[87]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 25, 4, {0},&reftables[88], &reftables[89]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 20, 3, {0},&reftables[90], &reftables[91]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension_range", 5, &msgs[0], (const upb_def*)(&msgs[1]), 22, 3, {0},&reftables[92], &reftables[93]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "field", 2, &msgs[0], (const upb_def*)(&msgs[7]), 13, 0, {0},&reftables[94], &reftables[95]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "file", 1, &msgs[10], (const upb_def*)(&msgs[9]), 6, 0, {0},&reftables[96], &reftables[97]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "go_package", 11, &msgs[11], NULL, 15, 5, {0},&reftables[98], &reftables[99]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "identifier_value", 3, &msgs[20], NULL, 7, 1, {0},&reftables[100], &reftables[101]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "input_type", 2, &msgs[13], NULL, 8, 2, {0},&reftables[102], &reftables[103]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, false, false, false, "is_extension", 2, &msgs[21], NULL, 6, 1, {0},&reftables[104], &reftables[105]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generate_equals_and_hash", 20, &msgs[11], NULL, 21, 9, {0},&reftables[106], &reftables[107]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generic_services", 17, &msgs[11], NULL, 19, 7, {0},&reftables[108], &reftables[109]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_multiple_files", 10, &msgs[11], NULL, 14, 4, {0},&reftables[110], &reftables[111]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_outer_classname", 8, &msgs[11], NULL, 10, 2, {0},&reftables[112], &reftables[113]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_package", 1, &msgs[11], NULL, 7, 1, {0},&reftables[114], &reftables[115]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_string_check_utf8", 27, &msgs[11], NULL, 23, 11, {0},&reftables[116], &reftables[117]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "javanano_use_deprecated_package", 38, &msgs[11], NULL, 31, 15, {0},&reftables[118], &reftables[119]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "json_name", 10, &msgs[7], NULL, 21, 9, {0},&reftables[120], &reftables[121]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "jstype", 6, &msgs[8], (const upb_def*)(&enums[3]), 11, 5, {0},&reftables[122], &reftables[123]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "label", 4, &msgs[7], (const upb_def*)(&enums[0]), 12, 4, {0},&reftables[124], &reftables[125]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "lazy", 5, &msgs[8], NULL, 10, 4, {0},&reftables[126], &reftables[127]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "leading_comments", 3, &msgs[19], NULL, 9, 2, {0},&reftables[128], &reftables[129]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "leading_detached_comments", 6, &msgs[19], NULL, 17, 4, {0},&reftables[130], &reftables[131]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "location", 1, &msgs[18], (const upb_def*)(&msgs[19]), 6, 0, {0},&reftables[132], &reftables[133]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "map_entry", 7, &msgs[12], NULL, 10, 4, {0},&reftables[134], &reftables[135]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 7, 1, {0},&reftables[136], &reftables[137]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 11, 0, {0},&reftables[138], &reftables[139]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 7, 0, {0},&reftables[140], &reftables[141]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 6, 0, {0},&reftables[142], &reftables[143]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 5, 1, {0},&reftables[144], &reftables[145]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 23, 6, {0},&reftables[146], &reftables[147]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 9, 2, {0},&reftables[148], &reftables[149]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 9, 2, {0},&reftables[150], &reftables[151]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 3, 0, {0},&reftables[152], &reftables[153]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 5, 1, {0},&reftables[154], &reftables[155]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 5, 1, {0},&reftables[156], &reftables[157]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 33, 8, {0},&reftables[158], &reftables[159]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 3, 0, {0},&reftables[160], &reftables[161]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 11, 3, {0},&reftables[162], &reftables[163]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 16, 1, {0},&reftables[164], &reftables[165]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 8, 2, {0},&reftables[166], &reftables[167]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 11, 3, {0},&reftables[168], &reftables[169]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 8, 2, {0},&reftables[170], &reftables[171]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 25, 13, {0},&reftables[172], &reftables[173]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 29, 6, {0},&reftables[174], &reftables[175]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 20, 8, {0},&reftables[176], &reftables[177]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 13, 3, {0},&reftables[178], &reftables[179]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 26, 5, {0},&reftables[180], &reftables[181]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 21, 4, {0},&reftables[182], &reftables[183]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 4, 0, {0},&reftables[184], &reftables[185]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 4, 0, {0},&reftables[186], &reftables[187]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 8, 1, {0},&reftables[188], &reftables[189]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 8, 1, {0},&reftables[190], &reftables[191]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 4, 0, {0},&reftables[192], &reftables[193]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 11, 3, {0},&reftables[194], &reftables[195]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 26, 7, {0},&reftables[196], &reftables[197]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 8, 2, {0},&reftables[198], &reftables[199]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 5, 0, {0},&reftables[200], &reftables[201]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_class_prefix", 40, &msgs[11], NULL, 32, 16, {0},&reftables[202], &reftables[203]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_namespace", 41, &msgs[11], NULL, 35, 17, {0},&reftables[204], &reftables[205]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 10, 2, {0},&reftables[206], &reftables[207]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 36, 9, {0},&reftables[208], &reftables[209]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 20, 8, {0},&reftables[210], &reftables[211]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 38, 9, {0},&reftables[212], &reftables[213]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 32, 7, {0},&reftables[214], &reftables[215]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 15, 5, {0},&reftables[216], &reftables[217]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 17, 2, {0},&reftables[218], &reftables[219]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 22, 5, {0},&reftables[220], &reftables[221]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 8, 1, {0},&reftables[222], &reftables[223]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 3, 0, {0},&reftables[224], &reftables[225]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 3, 0, {0},&reftables[226], &reftables[227]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 13, 5, {0},&reftables[228], &reftables[229]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 40, 11, {0},&reftables[230], &reftables[231]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 12, 3, {0},&reftables[232], &reftables[233]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 13, 5, {0},&reftables[234], &reftables[235]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 14, 6, {0},&reftables[236], &reftables[237]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[238], &reftables[239]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[240], &reftables[241]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[242], &reftables[243]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[244], &reftables[245]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[246], &reftables[247]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[248], &reftables[249]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[250], &reftables[251]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 7, 0, {0},&reftables[252], &reftables[253]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 12, 6, {0},&reftables[254], &reftables[255]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 39, 10, {0},&reftables[256], &reftables[257]),
-};
-
-static const upb_enumdef enums[5] = {
- UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[154], 4, 3), 0, &reftables[258], &reftables[259]),
- UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[158], 19, 18), 0, &reftables[260], &reftables[261]),
- UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[177], 3, 3), 0, &reftables[262], &reftables[263]),
- UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 3, 3), 0, &reftables[264], &reftables[265]),
- UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[183], 4, 3), 0, &reftables[266], &reftables[267]),
-};
-
-static const upb_tabent strentries[236] = {
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "field"), UPB_TABVALUE_PTR_INIT(&fields[25]), &strentries[12]},
- {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "extension_range"), UPB_TABVALUE_PTR_INIT(&fields[24]), &strentries[14]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "oneof_decl"), UPB_TABVALUE_PTR_INIT(&fields[65]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), &strentries[13]},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[91]), NULL},
- {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[90]), NULL},
- {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), &strentries[26]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), &strentries[34]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "oneof_index"), UPB_TABVALUE_PTR_INIT(&fields[66]), NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_TABVALUE_PTR_INIT(&fields[40]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), &strentries[53]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "json_name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[95]), &strentries[50]},
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[105]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "packed"), UPB_TABVALUE_PTR_INIT(&fields[77]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "lazy"), UPB_TABVALUE_PTR_INIT(&fields[41]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_TABVALUE_PTR_INIT(&fields[6]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "jstype"), UPB_TABVALUE_PTR_INIT(&fields[39]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[23]), NULL},
- {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[106]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[87]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[93]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[86]},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), NULL},
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[82]), &strentries[85]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "cc_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[3]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "csharp_namespace"), UPB_TABVALUE_PTR_INIT(&fields[5]), &strentries[116]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "go_package"), UPB_TABVALUE_PTR_INIT(&fields[27]), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "java_package"), UPB_TABVALUE_PTR_INIT(&fields[35]), &strentries[120]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL},
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "php_namespace"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[113]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_TABVALUE_PTR_INIT(&fields[33]), &strentries[117]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL},
- {UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[32]), &strentries[118]},
- {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_TABVALUE_PTR_INIT(&fields[31]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "php_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL},
- {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "javanano_use_deprecated_package"), UPB_TABVALUE_PTR_INIT(&fields[37]), &strentries[123]},
- {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[67]), NULL},
- {UPB_TABKEY_STR("\026", "\000", "\000", "\000", "java_string_check_utf8"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), &strentries[119]},
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "objc_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[64]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "cc_enable_arenas"), UPB_TABVALUE_PTR_INIT(&fields[2]), NULL},
- {UPB_TABKEY_STR("\027", "\000", "\000", "\000", "message_set_wire_format"), UPB_TABVALUE_PTR_INIT(&fields[46]), &strentries[128]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "map_entry"), UPB_TABVALUE_PTR_INIT(&fields[45]), NULL},
- {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[61]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "client_streaming"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[29]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[150]},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[149]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "location"), UPB_TABVALUE_PTR_INIT(&fields[44]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[89]), &strentries[167]},
- {UPB_TABKEY_STR("\031", "\000", "\000", "\000", "leading_detached_comments"), UPB_TABVALUE_PTR_INIT(&fields[43]), &strentries[165]},
- {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_TABVALUE_PTR_INIT(&fields[42]), &strentries[164]},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_TABVALUE_PTR_INIT(&fields[78]), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "negative_int_value"), UPB_TABVALUE_PTR_INIT(&fields[59]), NULL},
- {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "aggregate_value"), UPB_TABVALUE_PTR_INIT(&fields[0]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL},
- {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_TABVALUE_PTR_INIT(&fields[28]), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[92]), &strentries[182]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_TABVALUE_PTR_INIT(&fields[30]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "name_part"), UPB_TABVALUE_PTR_INIT(&fields[58]), NULL},
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REQUIRED"), UPB_TABVALUE_INT_INIT(2), &strentries[190]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REPEATED"), UPB_TABVALUE_INT_INIT(3), NULL},
- {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_OPTIONAL"), UPB_TABVALUE_INT_INIT(1), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_FIXED64"), UPB_TABVALUE_INT_INIT(6), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_STRING"), UPB_TABVALUE_INT_INIT(9), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_FLOAT"), UPB_TABVALUE_INT_INIT(2), &strentries[221]},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_DOUBLE"), UPB_TABVALUE_INT_INIT(1), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT32"), UPB_TABVALUE_INT_INIT(5), NULL},
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED32"), UPB_TABVALUE_INT_INIT(15), NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_FIXED32"), UPB_TABVALUE_INT_INIT(7), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_MESSAGE"), UPB_TABVALUE_INT_INIT(11), &strentries[222]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT64"), UPB_TABVALUE_INT_INIT(3), &strentries[219]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "TYPE_ENUM"), UPB_TABVALUE_INT_INIT(14), NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT32"), UPB_TABVALUE_INT_INIT(13), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT64"), UPB_TABVALUE_INT_INIT(4), &strentries[218]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED64"), UPB_TABVALUE_INT_INIT(16), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_BYTES"), UPB_TABVALUE_INT_INIT(12), NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_SINT64"), UPB_TABVALUE_INT_INIT(18), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "TYPE_BOOL"), UPB_TABVALUE_INT_INIT(8), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_GROUP"), UPB_TABVALUE_INT_INIT(10), NULL},
- {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_SINT32"), UPB_TABVALUE_INT_INIT(17), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "CORD"), UPB_TABVALUE_INT_INIT(1), NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "STRING"), UPB_TABVALUE_INT_INIT(0), &strentries[225]},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "STRING_PIECE"), UPB_TABVALUE_INT_INIT(2), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_NORMAL"), UPB_TABVALUE_INT_INIT(0), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_NUMBER"), UPB_TABVALUE_INT_INIT(2), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "JS_STRING"), UPB_TABVALUE_INT_INIT(1), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "CODE_SIZE"), UPB_TABVALUE_INT_INIT(2), NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "SPEED"), UPB_TABVALUE_INT_INIT(1), &strentries[235]},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "LITE_RUNTIME"), UPB_TABVALUE_INT_INIT(3), NULL},
-};
-
-static const upb_tabent intentries[18] = {
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
-};
-
-static const upb_tabval arrays[187] = {
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[57]),
- UPB_TABVALUE_PTR_INIT(&fields[25]),
- UPB_TABVALUE_PTR_INIT(&fields[60]),
- UPB_TABVALUE_PTR_INIT(&fields[20]),
- UPB_TABVALUE_PTR_INIT(&fields[24]),
- UPB_TABVALUE_PTR_INIT(&fields[22]),
- UPB_TABVALUE_PTR_INIT(&fields[68]),
- UPB_TABVALUE_PTR_INIT(&fields[65]),
- UPB_TABVALUE_PTR_INIT(&fields[85]),
- UPB_TABVALUE_PTR_INIT(&fields[84]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[91]),
- UPB_TABVALUE_PTR_INIT(&fields[18]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[90]),
- UPB_TABVALUE_PTR_INIT(&fields[17]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[52]),
- UPB_TABVALUE_PTR_INIT(&fields[104]),
- UPB_TABVALUE_PTR_INIT(&fields[73]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[1]),
- UPB_TABVALUE_PTR_INIT(&fields[14]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[50]),
- UPB_TABVALUE_PTR_INIT(&fields[63]),
- UPB_TABVALUE_PTR_INIT(&fields[74]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[13]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[56]),
- UPB_TABVALUE_PTR_INIT(&fields[21]),
- UPB_TABVALUE_PTR_INIT(&fields[62]),
- UPB_TABVALUE_PTR_INIT(&fields[40]),
- UPB_TABVALUE_PTR_INIT(&fields[95]),
- UPB_TABVALUE_PTR_INIT(&fields[96]),
- UPB_TABVALUE_PTR_INIT(&fields[7]),
- UPB_TABVALUE_PTR_INIT(&fields[70]),
- UPB_TABVALUE_PTR_INIT(&fields[66]),
- UPB_TABVALUE_PTR_INIT(&fields[38]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[6]),
- UPB_TABVALUE_PTR_INIT(&fields[77]),
- UPB_TABVALUE_PTR_INIT(&fields[9]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[41]),
- UPB_TABVALUE_PTR_INIT(&fields[39]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[105]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[51]),
- UPB_TABVALUE_PTR_INIT(&fields[76]),
- UPB_TABVALUE_PTR_INIT(&fields[8]),
- UPB_TABVALUE_PTR_INIT(&fields[47]),
- UPB_TABVALUE_PTR_INIT(&fields[19]),
- UPB_TABVALUE_PTR_INIT(&fields[87]),
- UPB_TABVALUE_PTR_INIT(&fields[23]),
- UPB_TABVALUE_PTR_INIT(&fields[69]),
- UPB_TABVALUE_PTR_INIT(&fields[88]),
- UPB_TABVALUE_PTR_INIT(&fields[82]),
- UPB_TABVALUE_PTR_INIT(&fields[106]),
- UPB_TABVALUE_PTR_INIT(&fields[93]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[26]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[35]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[34]),
- UPB_TABVALUE_PTR_INIT(&fields[67]),
- UPB_TABVALUE_PTR_INIT(&fields[33]),
- UPB_TABVALUE_PTR_INIT(&fields[27]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[3]),
- UPB_TABVALUE_PTR_INIT(&fields[32]),
- UPB_TABVALUE_PTR_INIT(&fields[83]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[31]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[12]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[36]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[2]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[64]),
- UPB_TABVALUE_PTR_INIT(&fields[5]),
- UPB_TABVALUE_PTR_INIT(&fields[37]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[79]),
- UPB_TABVALUE_PTR_INIT(&fields[80]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[46]),
- UPB_TABVALUE_PTR_INIT(&fields[61]),
- UPB_TABVALUE_PTR_INIT(&fields[11]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[45]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[55]),
- UPB_TABVALUE_PTR_INIT(&fields[29]),
- UPB_TABVALUE_PTR_INIT(&fields[75]),
- UPB_TABVALUE_PTR_INIT(&fields[71]),
- UPB_TABVALUE_PTR_INIT(&fields[4]),
- UPB_TABVALUE_PTR_INIT(&fields[86]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[54]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[53]),
- UPB_TABVALUE_PTR_INIT(&fields[48]),
- UPB_TABVALUE_PTR_INIT(&fields[72]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[44]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[78]),
- UPB_TABVALUE_PTR_INIT(&fields[89]),
- UPB_TABVALUE_PTR_INIT(&fields[42]),
- UPB_TABVALUE_PTR_INIT(&fields[94]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[43]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[49]),
- UPB_TABVALUE_PTR_INIT(&fields[28]),
- UPB_TABVALUE_PTR_INIT(&fields[81]),
- UPB_TABVALUE_PTR_INIT(&fields[59]),
- UPB_TABVALUE_PTR_INIT(&fields[16]),
- UPB_TABVALUE_PTR_INIT(&fields[92]),
- UPB_TABVALUE_PTR_INIT(&fields[0]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[58]),
- UPB_TABVALUE_PTR_INIT(&fields[30]),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT("LABEL_OPTIONAL"),
- UPB_TABVALUE_PTR_INIT("LABEL_REQUIRED"),
- UPB_TABVALUE_PTR_INIT("LABEL_REPEATED"),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT("TYPE_DOUBLE"),
- UPB_TABVALUE_PTR_INIT("TYPE_FLOAT"),
- UPB_TABVALUE_PTR_INIT("TYPE_INT64"),
- UPB_TABVALUE_PTR_INIT("TYPE_UINT64"),
- UPB_TABVALUE_PTR_INIT("TYPE_INT32"),
- UPB_TABVALUE_PTR_INIT("TYPE_FIXED64"),
- UPB_TABVALUE_PTR_INIT("TYPE_FIXED32"),
- UPB_TABVALUE_PTR_INIT("TYPE_BOOL"),
- UPB_TABVALUE_PTR_INIT("TYPE_STRING"),
- UPB_TABVALUE_PTR_INIT("TYPE_GROUP"),
- UPB_TABVALUE_PTR_INIT("TYPE_MESSAGE"),
- UPB_TABVALUE_PTR_INIT("TYPE_BYTES"),
- UPB_TABVALUE_PTR_INIT("TYPE_UINT32"),
- UPB_TABVALUE_PTR_INIT("TYPE_ENUM"),
- UPB_TABVALUE_PTR_INIT("TYPE_SFIXED32"),
- UPB_TABVALUE_PTR_INIT("TYPE_SFIXED64"),
- UPB_TABVALUE_PTR_INIT("TYPE_SINT32"),
- UPB_TABVALUE_PTR_INIT("TYPE_SINT64"),
- UPB_TABVALUE_PTR_INIT("STRING"),
- UPB_TABVALUE_PTR_INIT("CORD"),
- UPB_TABVALUE_PTR_INIT("STRING_PIECE"),
- UPB_TABVALUE_PTR_INIT("JS_NORMAL"),
- UPB_TABVALUE_PTR_INIT("JS_STRING"),
- UPB_TABVALUE_PTR_INIT("JS_NUMBER"),
- UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT("SPEED"),
- UPB_TABVALUE_PTR_INIT("CODE_SIZE"),
- UPB_TABVALUE_PTR_INIT("LITE_RUNTIME"),
-};
-
-#ifdef UPB_DEBUG_REFS
-static upb_inttable reftables[268] = {
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
-};
-#endif
-
-static const upb_msgdef *refm(const upb_msgdef *m, const void *owner) {
- upb_msgdef_ref(m, owner);
- return m;
-}
-
-static const upb_enumdef *refe(const upb_enumdef *e, const void *owner) {
- upb_enumdef_ref(e, owner);
- return e;
-}
-
-/* Public API. */
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner) { return refm(&msgs[0], owner); }
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner) { return refm(&msgs[1], owner); }
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner) { return refm(&msgs[2], owner); }
-const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner) { return refm(&msgs[3], owner); }
-const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner) { return refm(&msgs[4], owner); }
-const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner) { return refm(&msgs[5], owner); }
-const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner) { return refm(&msgs[6], owner); }
-const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner) { return refm(&msgs[7], owner); }
-const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner) { return refm(&msgs[8], owner); }
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner) { return refm(&msgs[9], owner); }
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner) { return refm(&msgs[10], owner); }
-const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner) { return refm(&msgs[11], owner); }
-const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner) { return refm(&msgs[12], owner); }
-const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner) { return refm(&msgs[13], owner); }
-const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner) { return refm(&msgs[14], owner); }
-const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner) { return refm(&msgs[15], owner); }
-const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner) { return refm(&msgs[16], owner); }
-const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner) { return refm(&msgs[17], owner); }
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner) { return refm(&msgs[18], owner); }
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner) { return refm(&msgs[19], owner); }
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner) { return refm(&msgs[20], owner); }
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner) { return refm(&msgs[21], owner); }
-
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner) { return refe(&enums[0], owner); }
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner) { return refe(&enums[1], owner); }
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner) { return refe(&enums[2], owner); }
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner) { return refe(&enums[3], owner); }
-const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner) { return refe(&enums[4], owner); }
diff --git a/upb/descriptor/descriptor.upbdefs.h b/upb/descriptor/descriptor.upbdefs.h
deleted file mode 100644
index dd118a0..0000000
--- a/upb/descriptor/descriptor.upbdefs.h
+++ /dev/null
@@ -1,608 +0,0 @@
-/* This file contains accessors for a set of compiled-in defs.
- * Note that unlike Google's protobuf, it does *not* define
- * generated classes or any other kind of data structure for
- * actually storing protobufs. It only contains *defs* which
- * let you reflect over a protobuf *schema*.
- */
-/* This file was generated by upbc (the upb compiler) from the input
- * file:
- *
- * upb/descriptor/descriptor.proto
- *
- * Do not edit -- your changes will be discarded when the file is
- * regenerated. */
-
-#ifndef UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
-#define UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
-
-#include "upb/def.h"
-
-UPB_BEGIN_EXTERN_C
-
-/* MessageDefs: call these functions to get a ref to a msgdef. */
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner);
-const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner);
-
-/* EnumDefs: call these functions to get a ref to an enumdef. */
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner);
-const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner);
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner);
-const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner);
-const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner);
-
-/* Functions to test whether this message is of a certain type. */
-UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ExtensionRange") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ReservedRange") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_EnumDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_EnumOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_EnumValueDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_EnumValueOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorSet_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorSet") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FileOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_MessageOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.MessageOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_MethodDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_MethodOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_OneofDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.OneofDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_ServiceDescriptorProto_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceDescriptorProto") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_ServiceOptions_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceOptions") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_Location_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo.Location") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_NamePart_is(const upb_msgdef *m) {
- return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption.NamePart") == 0;
-}
-
-/* Functions to test whether this enum is of a certain type. */
-UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Label_is(const upb_enumdef *e) {
- return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Label") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Type_is(const upb_enumdef *e) {
- return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Type") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_CType_is(const upb_enumdef *e) {
- return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.CType") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_JSType_is(const upb_enumdef *e) {
- return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.JSType") == 0;
-}
-UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_enumdef *e) {
- return strcmp(upb_enumdef_fullname(e), "google.protobuf.FileOptions.OptimizeMode") == 0;
-}
-
-
-/* Functions to get a fielddef from a msgdef reference. */
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 40); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 41); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
-
-UPB_END_EXTERN_C
-
-#ifdef __cplusplus
-
-namespace upbdefs {
-namespace google {
-namespace protobuf {
-
-class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m));
- }
-
- static DescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_get(&m);
- return DescriptorProto(m, &m);
- }
-
- class ExtensionRange : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
- }
-
- static ExtensionRange get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(&m);
- return ExtensionRange(m, &m);
- }
- };
-
- class ReservedRange : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
- }
-
- static ReservedRange get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(&m);
- return ReservedRange(m, &m);
- }
- };
-};
-
-class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
- }
-
- static EnumDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumDescriptorProto_get(&m);
- return EnumDescriptorProto(m, &m);
- }
-};
-
-class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m));
- }
-
- static EnumOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumOptions_get(&m);
- return EnumOptions(m, &m);
- }
-};
-
-class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
- }
-
- static EnumValueDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueDescriptorProto_get(&m);
- return EnumValueDescriptorProto(m, &m);
- }
-};
-
-class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m));
- }
-
- static EnumValueOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueOptions_get(&m);
- return EnumValueOptions(m, &m);
- }
-};
-
-class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
- }
-
- static FieldDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldDescriptorProto_get(&m);
- return FieldDescriptorProto(m, &m);
- }
-
- class Label : public ::upb::reffed_ptr<const ::upb::EnumDef> {
- public:
- Label(const ::upb::EnumDef* e, const void *ref_donor = NULL)
- : reffed_ptr(e, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
- }
- static Label get() {
- const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
- return Label(e, &e);
- }
- };
-
- class Type : public ::upb::reffed_ptr<const ::upb::EnumDef> {
- public:
- Type(const ::upb::EnumDef* e, const void *ref_donor = NULL)
- : reffed_ptr(e, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
- }
- static Type get() {
- const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
- return Type(e, &e);
- }
- };
-};
-
-class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m));
- }
-
- static FieldOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldOptions_get(&m);
- return FieldOptions(m, &m);
- }
-
- class CType : public ::upb::reffed_ptr<const ::upb::EnumDef> {
- public:
- CType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
- : reffed_ptr(e, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e));
- }
- static CType get() {
- const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
- return CType(e, &e);
- }
- };
-
- class JSType : public ::upb::reffed_ptr<const ::upb::EnumDef> {
- public:
- JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
- : reffed_ptr(e, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
- }
- static JSType get() {
- const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
- return JSType(e, &e);
- }
- };
-};
-
-class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m));
- }
-
- static FileDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorProto_get(&m);
- return FileDescriptorProto(m, &m);
- }
-};
-
-class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m));
- }
-
- static FileDescriptorSet get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorSet_get(&m);
- return FileDescriptorSet(m, &m);
- }
-};
-
-class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m));
- }
-
- static FileOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_FileOptions_get(&m);
- return FileOptions(m, &m);
- }
-
- class OptimizeMode : public ::upb::reffed_ptr<const ::upb::EnumDef> {
- public:
- OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL)
- : reffed_ptr(e, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
- }
- static OptimizeMode get() {
- const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
- return OptimizeMode(e, &e);
- }
- };
-};
-
-class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m));
- }
-
- static MessageOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_MessageOptions_get(&m);
- return MessageOptions(m, &m);
- }
-};
-
-class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
- }
-
- static MethodDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodDescriptorProto_get(&m);
- return MethodDescriptorProto(m, &m);
- }
-};
-
-class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m));
- }
-
- static MethodOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodOptions_get(&m);
- return MethodOptions(m, &m);
- }
-};
-
-class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
- }
-
- static OneofDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_OneofDescriptorProto_get(&m);
- return OneofDescriptorProto(m, &m);
- }
-};
-
-class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
- }
-
- static ServiceDescriptorProto get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceDescriptorProto_get(&m);
- return ServiceDescriptorProto(m, &m);
- }
-};
-
-class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m));
- }
-
- static ServiceOptions get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceOptions_get(&m);
- return ServiceOptions(m, &m);
- }
-};
-
-class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m));
- }
-
- static SourceCodeInfo get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_get(&m);
- return SourceCodeInfo(m, &m);
- }
-
- class Location : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
- }
-
- static Location get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_Location_get(&m);
- return Location(m, &m);
- }
- };
-};
-
-class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m));
- }
-
- static UninterpretedOption get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_get(&m);
- return UninterpretedOption(m, &m);
- }
-
- class NamePart : public ::upb::reffed_ptr<const ::upb::MessageDef> {
- public:
- NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
- : reffed_ptr(m, ref_donor) {
- UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
- }
-
- static NamePart get() {
- const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_NamePart_get(&m);
- return NamePart(m, &m);
- }
- };
-};
-
-} /* namespace protobuf */
-} /* namespace google */
-} /* namespace upbdefs */
-
-#endif /* __cplusplus */
-
-#endif /* UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ */
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c
deleted file mode 100644
index da89622..0000000
--- a/upb/descriptor/reader.c
+++ /dev/null
@@ -1,900 +0,0 @@
-/*
-** XXX: The routines in this file that consume a string do not currently
-** support having the string span buffers. In the future, as upb_sink and
-** its buffering/sharing functionality evolve there should be an easy and
-** idiomatic way of correctly handling this case. For now, we accept this
-** limitation since we currently only parse descriptors from single strings.
-*/
-
-#include "upb/descriptor/reader.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "upb/def.h"
-#include "upb/sink.h"
-#include "upb/descriptor/descriptor.upbdefs.h"
-
-/* Compares a NULL-terminated string with a non-NULL-terminated string. */
-static bool upb_streq(const char *str, const char *buf, size_t n) {
- return strlen(str) == n && memcmp(str, buf, n) == 0;
-}
-
-/* We keep a stack of all the messages scopes we are currently in, as well as
- * the top-level file scope. This is necessary to correctly qualify the
- * definitions that are contained inside. "name" tracks the name of the
- * message or package (a bare name -- not qualified by any enclosing scopes). */
-typedef struct {
- char *name;
- /* Index of the first def that is under this scope. For msgdefs, the
- * msgdef itself is at start-1. */
- int start;
- uint32_t oneof_start;
- uint32_t oneof_index;
-} upb_descreader_frame;
-
-/* The maximum number of nested declarations that are allowed, ie.
- * message Foo {
- * message Bar {
- * message Baz {
- * }
- * }
- * }
- *
- * This is a resource limit that affects how big our runtime stack can grow.
- * TODO: make this a runtime-settable property of the Reader instance. */
-#define UPB_MAX_MESSAGE_NESTING 64
-
-struct upb_descreader {
- upb_sink sink;
- upb_inttable files;
- upb_strtable files_by_name;
- upb_filedef *file; /* The last file in files. */
- upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING];
- int stack_len;
- upb_inttable oneofs;
-
- uint32_t number;
- char *name;
- bool saw_number;
- bool saw_name;
-
- char *default_string;
-
- upb_fielddef *f;
-};
-
-static char *upb_gstrndup(const char *buf, size_t n) {
- char *ret = upb_gmalloc(n + 1);
- if (!ret) return NULL;
- memcpy(ret, buf, n);
- ret[n] = '\0';
- return ret;
-}
-
-/* Returns a newly allocated string that joins input strings together, for
- * example:
- * join("Foo.Bar", "Baz") -> "Foo.Bar.Baz"
- * join("", "Baz") -> "Baz"
- * Caller owns a ref on the returned string. */
-static char *upb_join(const char *base, const char *name) {
- if (!base || strlen(base) == 0) {
- return upb_gstrdup(name);
- } else {
- char *ret = upb_gmalloc(strlen(base) + strlen(name) + 2);
- if (!ret) {
- return NULL;
- }
- ret[0] = '\0';
- strcat(ret, base);
- strcat(ret, ".");
- strcat(ret, name);
- return ret;
- }
-}
-
-/* Qualify the defname for all defs starting with offset "start" with "str". */
-static bool upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) {
- size_t i;
- for (i = start; i < upb_filedef_defcount(f); i++) {
- upb_def *def = upb_filedef_mutabledef(f, i);
- char *name = upb_join(str, upb_def_fullname(def));
- if (!name) {
- /* Need better logic here; at this point we've qualified some names but
- * not others. */
- return false;
- }
- upb_def_setfullname(def, name, NULL);
- upb_gfree(name);
- }
- return true;
-}
-
-
-/* upb_descreader ************************************************************/
-
-static upb_msgdef *upb_descreader_top(upb_descreader *r) {
- int index;
- UPB_ASSERT(r->stack_len > 1);
- index = r->stack[r->stack_len-1].start - 1;
- UPB_ASSERT(index >= 0);
- return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index));
-}
-
-static upb_def *upb_descreader_last(upb_descreader *r) {
- return upb_filedef_mutabledef(r->file, upb_filedef_defcount(r->file) - 1);
-}
-
-/* Start/end handlers for FileDescriptorProto and DescriptorProto (the two
- * entities that have names and can contain sub-definitions. */
-void upb_descreader_startcontainer(upb_descreader *r) {
- upb_descreader_frame *f = &r->stack[r->stack_len++];
- f->start = upb_filedef_defcount(r->file);
- f->oneof_start = upb_inttable_count(&r->oneofs);
- f->oneof_index = 0;
- f->name = NULL;
-}
-
-bool upb_descreader_endcontainer(upb_descreader *r) {
- upb_descreader_frame *f = &r->stack[r->stack_len - 1];
-
- while (upb_inttable_count(&r->oneofs) > f->oneof_start) {
- upb_oneofdef *o = upb_value_getptr(upb_inttable_pop(&r->oneofs));
- bool ok = upb_msgdef_addoneof(upb_descreader_top(r), o, &r->oneofs, NULL);
- UPB_ASSERT(ok);
- }
-
- if (!upb_descreader_qualify(r->file, f->name, f->start)) {
- return false;
- }
- upb_gfree(f->name);
- f->name = NULL;
-
- r->stack_len--;
- return true;
-}
-
-void upb_descreader_setscopename(upb_descreader *r, char *str) {
- upb_descreader_frame *f = &r->stack[r->stack_len-1];
- upb_gfree(f->name);
- f->name = str;
-}
-
-static upb_oneofdef *upb_descreader_getoneof(upb_descreader *r,
- uint32_t index) {
- bool found;
- upb_value val;
- upb_descreader_frame *f = &r->stack[r->stack_len-1];
-
- /* DescriptorProto messages can be nested, so we will see the nested messages
- * between when we see the FieldDescriptorProto and the OneofDescriptorProto.
- * We need to preserve the oneofs in between these two things. */
- index += f->oneof_start;
-
- while (upb_inttable_count(&r->oneofs) <= index) {
- upb_inttable_push(&r->oneofs, upb_value_ptr(upb_oneofdef_new(&r->oneofs)));
- }
-
- found = upb_inttable_lookup(&r->oneofs, index, &val);
- UPB_ASSERT(found);
- return upb_value_getptr(val);
-}
-
-/** Handlers for google.protobuf.FileDescriptorSet. ***************************/
-
-static void *fileset_startfile(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- r->file = upb_filedef_new(&r->files);
- upb_inttable_push(&r->files, upb_value_ptr(r->file));
- return r;
-}
-
-/** Handlers for google.protobuf.FileDescriptorProto. *************************/
-
-static bool file_start(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- upb_descreader_startcontainer(r);
- return true;
-}
-
-static bool file_end(void *closure, const void *hd, upb_status *status) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- UPB_UNUSED(status);
- return upb_descreader_endcontainer(r);
-}
-
-static size_t file_onname(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *name;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- name = upb_gstrndup(buf, n);
- upb_strtable_insert(&r->files_by_name, name, upb_value_ptr(r->file));
- /* XXX: see comment at the top of the file. */
- ok = upb_filedef_setname(r->file, name, NULL);
- upb_gfree(name);
- UPB_ASSERT(ok);
- return n;
-}
-
-static size_t file_onpackage(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *package;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- package = upb_gstrndup(buf, n);
- /* XXX: see comment at the top of the file. */
- upb_descreader_setscopename(r, package);
- ok = upb_filedef_setpackage(r->file, package, NULL);
- UPB_ASSERT(ok);
- return n;
-}
-
-static void *file_startphpnamespace(void *closure, const void *hd,
- size_t size_hint) {
- upb_descreader *r = closure;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(size_hint);
-
- ok = upb_filedef_setphpnamespace(r->file, "", NULL);
- UPB_ASSERT(ok);
- return closure;
-}
-
-static size_t file_onphpnamespace(void *closure, const void *hd,
- const char *buf, size_t n,
- const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *php_namespace;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- php_namespace = upb_gstrndup(buf, n);
- ok = upb_filedef_setphpnamespace(r->file, php_namespace, NULL);
- upb_gfree(php_namespace);
- UPB_ASSERT(ok);
- return n;
-}
-
-static size_t file_onphpprefix(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *prefix;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- prefix = upb_gstrndup(buf, n);
- ok = upb_filedef_setphpprefix(r->file, prefix, NULL);
- upb_gfree(prefix);
- UPB_ASSERT(ok);
- return n;
-}
-
-static size_t file_onsyntax(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- bool ok;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
- /* XXX: see comment at the top of the file. */
- if (upb_streq("proto2", buf, n)) {
- ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO2, NULL);
- } else if (upb_streq("proto3", buf, n)) {
- ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO3, NULL);
- } else {
- ok = false;
- }
-
- UPB_ASSERT(ok);
- return n;
-}
-
-static void *file_startmsg(void *closure, const void *hd) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_msgdef_new(&m);
- bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
- UPB_UNUSED(hd);
- UPB_ASSERT(ok);
- return r;
-}
-
-static void *file_startenum(void *closure, const void *hd) {
- upb_descreader *r = closure;
- upb_enumdef *e = upb_enumdef_new(&e);
- bool ok = upb_filedef_addenum(r->file, e, &e, NULL);
- UPB_UNUSED(hd);
- UPB_ASSERT(ok);
- return r;
-}
-
-static void *file_startext(void *closure, const void *hd) {
- upb_descreader *r = closure;
- bool ok;
- r->f = upb_fielddef_new(r);
- ok = upb_filedef_addext(r->file, r->f, r, NULL);
- UPB_UNUSED(hd);
- UPB_ASSERT(ok);
- return r;
-}
-
-static size_t file_ondep(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- upb_value val;
- if (upb_strtable_lookup2(&r->files_by_name, buf, n, &val)) {
- upb_filedef_adddep(r->file, upb_value_getptr(val));
- }
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
- return n;
-}
-
-/** Handlers for google.protobuf.EnumValueDescriptorProto. *********************/
-
-static bool enumval_startmsg(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- r->saw_number = false;
- r->saw_name = false;
- return true;
-}
-
-static size_t enumval_onname(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
- /* XXX: see comment at the top of the file. */
- upb_gfree(r->name);
- r->name = upb_gstrndup(buf, n);
- r->saw_name = true;
- return n;
-}
-
-static bool enumval_onnumber(void *closure, const void *hd, int32_t val) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- r->number = val;
- r->saw_number = true;
- return true;
-}
-
-static bool enumval_endmsg(void *closure, const void *hd, upb_status *status) {
- upb_descreader *r = closure;
- upb_enumdef *e;
- UPB_UNUSED(hd);
-
- if(!r->saw_number || !r->saw_name) {
- upb_status_seterrmsg(status, "Enum value missing name or number.");
- return false;
- }
- e = upb_downcast_enumdef_mutable(upb_descreader_last(r));
- upb_enumdef_addval(e, r->name, r->number, status);
- upb_gfree(r->name);
- r->name = NULL;
- return true;
-}
-
-/** Handlers for google.protobuf.EnumDescriptorProto. *************************/
-
-static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
- upb_descreader *r = closure;
- upb_enumdef *e;
- UPB_UNUSED(hd);
-
- e = upb_downcast_enumdef_mutable(upb_descreader_last(r));
- if (upb_def_fullname(upb_descreader_last(r)) == NULL) {
- upb_status_seterrmsg(status, "Enum had no name.");
- return false;
- }
- if (upb_enumdef_numvals(e) == 0) {
- upb_status_seterrmsg(status, "Enum had no values.");
- return false;
- }
- return true;
-}
-
-static size_t enum_onname(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *fullname = upb_gstrndup(buf, n);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
- /* XXX: see comment at the top of the file. */
- upb_def_setfullname(upb_descreader_last(r), fullname, NULL);
- upb_gfree(fullname);
- return n;
-}
-
-/** Handlers for google.protobuf.FieldDescriptorProto *************************/
-
-static bool field_startmsg(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- UPB_ASSERT(r->f);
- upb_gfree(r->default_string);
- r->default_string = NULL;
-
- /* fielddefs default to packed, but descriptors default to non-packed. */
- upb_fielddef_setpacked(r->f, false);
- return true;
-}
-
-/* Converts the default value in string "str" into "d". Passes a ref on str.
- * Returns true on success. */
-static bool parse_default(char *str, upb_fielddef *f) {
- bool success = true;
- char *end;
- switch (upb_fielddef_type(f)) {
- case UPB_TYPE_INT32: {
- long val = strtol(str, &end, 0);
- if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultint32(f, val);
- break;
- }
- case UPB_TYPE_INT64: {
- /* XXX: Need to write our own strtoll, since it's not available in c89. */
- long long val = strtol(str, &end, 0);
- if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultint64(f, val);
- break;
- }
- case UPB_TYPE_UINT32: {
- unsigned long val = strtoul(str, &end, 0);
- if (val > UINT32_MAX || errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultuint32(f, val);
- break;
- }
- case UPB_TYPE_UINT64: {
- /* XXX: Need to write our own strtoull, since it's not available in c89. */
- unsigned long long val = strtoul(str, &end, 0);
- if (val > UINT64_MAX || errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultuint64(f, val);
- break;
- }
- case UPB_TYPE_DOUBLE: {
- double val = strtod(str, &end);
- if (errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultdouble(f, val);
- break;
- }
- case UPB_TYPE_FLOAT: {
- /* XXX: Need to write our own strtof, since it's not available in c89. */
- float val = strtod(str, &end);
- if (errno == ERANGE || *end)
- success = false;
- else
- upb_fielddef_setdefaultfloat(f, val);
- break;
- }
- case UPB_TYPE_BOOL: {
- if (strcmp(str, "false") == 0)
- upb_fielddef_setdefaultbool(f, false);
- else if (strcmp(str, "true") == 0)
- upb_fielddef_setdefaultbool(f, true);
- else
- success = false;
- break;
- }
- default: abort();
- }
- return success;
-}
-
-static bool field_endmsg(void *closure, const void *hd, upb_status *status) {
- upb_descreader *r = closure;
- upb_fielddef *f = r->f;
- UPB_UNUSED(hd);
-
- /* TODO: verify that all required fields were present. */
- UPB_ASSERT(upb_fielddef_number(f) != 0);
- UPB_ASSERT(upb_fielddef_name(f) != NULL);
- UPB_ASSERT((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f));
-
- if (r->default_string) {
- if (upb_fielddef_issubmsg(f)) {
- upb_status_seterrmsg(status, "Submessages cannot have defaults.");
- return false;
- }
- if (upb_fielddef_isstring(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM) {
- upb_fielddef_setdefaultcstr(f, r->default_string, NULL);
- } else {
- if (r->default_string && !parse_default(r->default_string, f)) {
- /* We don't worry too much about giving a great error message since the
- * compiler should have ensured this was correct. */
- upb_status_seterrmsg(status, "Error converting default value.");
- return false;
- }
- }
- }
- return true;
-}
-
-static bool field_onlazy(void *closure, const void *hd, bool val) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
-
- upb_fielddef_setlazy(r->f, val);
- return true;
-}
-
-static bool field_onpacked(void *closure, const void *hd, bool val) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
-
- upb_fielddef_setpacked(r->f, val);
- return true;
-}
-
-static bool field_ontype(void *closure, const void *hd, int32_t val) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
-
- upb_fielddef_setdescriptortype(r->f, val);
- return true;
-}
-
-static bool field_onlabel(void *closure, const void *hd, int32_t val) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
-
- upb_fielddef_setlabel(r->f, val);
- return true;
-}
-
-static bool field_onnumber(void *closure, const void *hd, int32_t val) {
- upb_descreader *r = closure;
- bool ok;
- UPB_UNUSED(hd);
-
- ok = upb_fielddef_setnumber(r->f, val, NULL);
- UPB_ASSERT(ok);
- return true;
-}
-
-static size_t field_onname(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *name = upb_gstrndup(buf, n);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- /* XXX: see comment at the top of the file. */
- upb_fielddef_setname(r->f, name, NULL);
- upb_gfree(name);
- return n;
-}
-
-static size_t field_ontypename(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *name = upb_gstrndup(buf, n);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- /* XXX: see comment at the top of the file. */
- upb_fielddef_setsubdefname(r->f, name, NULL);
- upb_gfree(name);
- return n;
-}
-
-static size_t field_onextendee(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- char *name = upb_gstrndup(buf, n);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- /* XXX: see comment at the top of the file. */
- upb_fielddef_setcontainingtypename(r->f, name, NULL);
- upb_gfree(name);
- return n;
-}
-
-static size_t field_ondefaultval(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- /* Have to convert from string to the correct type, but we might not know the
- * type yet, so we save it as a string until the end of the field.
- * XXX: see comment at the top of the file. */
- upb_gfree(r->default_string);
- r->default_string = upb_gstrndup(buf, n);
- return n;
-}
-
-static bool field_ononeofindex(void *closure, const void *hd, int32_t index) {
- upb_descreader *r = closure;
- upb_oneofdef *o = upb_descreader_getoneof(r, index);
- bool ok = upb_oneofdef_addfield(o, r->f, &r->f, NULL);
- UPB_UNUSED(hd);
-
- UPB_ASSERT(ok);
- return true;
-}
-
-/** Handlers for google.protobuf.OneofDescriptorProto. ************************/
-
-static size_t oneof_name(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- upb_descreader_frame *f = &r->stack[r->stack_len-1];
- upb_oneofdef *o = upb_descreader_getoneof(r, f->oneof_index++);
- char *name_null_terminated = upb_gstrndup(buf, n);
- bool ok = upb_oneofdef_setname(o, name_null_terminated, NULL);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- UPB_ASSERT(ok);
- free(name_null_terminated);
- return n;
-}
-
-/** Handlers for google.protobuf.DescriptorProto ******************************/
-
-static bool msg_start(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
-
- upb_descreader_startcontainer(r);
- return true;
-}
-
-static bool msg_end(void *closure, const void *hd, upb_status *status) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_descreader_top(r);
- UPB_UNUSED(hd);
-
- if(!upb_def_fullname(upb_msgdef_upcast_mutable(m))) {
- upb_status_seterrmsg(status, "Encountered message with no name.");
- return false;
- }
- return upb_descreader_endcontainer(r);
-}
-
-static size_t msg_name(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_descreader_top(r);
- /* XXX: see comment at the top of the file. */
- char *name = upb_gstrndup(buf, n);
- UPB_UNUSED(hd);
- UPB_UNUSED(handle);
-
- upb_def_setfullname(upb_msgdef_upcast_mutable(m), name, NULL);
- upb_descreader_setscopename(r, name); /* Passes ownership of name. */
- return n;
-}
-
-static void *msg_startmsg(void *closure, const void *hd) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_msgdef_new(&m);
- bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
- UPB_UNUSED(hd);
- UPB_ASSERT(ok);
- return r;
-}
-
-static void *msg_startext(void *closure, const void *hd) {
- upb_descreader *r = closure;
- upb_fielddef *f = upb_fielddef_new(&f);
- bool ok = upb_filedef_addext(r->file, f, &f, NULL);
- UPB_UNUSED(hd);
- UPB_ASSERT(ok);
- return r;
-}
-
-static void *msg_startfield(void *closure, const void *hd) {
- upb_descreader *r = closure;
- r->f = upb_fielddef_new(&r->f);
- /* We can't add the new field to the message until its name/number are
- * filled in. */
- UPB_UNUSED(hd);
- return r;
-}
-
-static bool msg_endfield(void *closure, const void *hd) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_descreader_top(r);
- bool ok;
- UPB_UNUSED(hd);
-
- /* Oneof fields are added to the msgdef through their oneof, so don't need to
- * be added here. */
- if (upb_fielddef_containingoneof(r->f) == NULL) {
- ok = upb_msgdef_addfield(m, r->f, &r->f, NULL);
- UPB_ASSERT(ok);
- }
- r->f = NULL;
- return true;
-}
-
-static bool msg_onmapentry(void *closure, const void *hd, bool mapentry) {
- upb_descreader *r = closure;
- upb_msgdef *m = upb_descreader_top(r);
- UPB_UNUSED(hd);
-
- upb_msgdef_setmapentry(m, mapentry);
- r->f = NULL;
- return true;
-}
-
-
-
-/** Code to register handlers *************************************************/
-
-#define F(msg, field) upbdefs_google_protobuf_ ## msg ## _f_ ## field(m)
-
-static void reghandlers(const void *closure, upb_handlers *h) {
- const upb_msgdef *m = upb_handlers_msgdef(h);
- UPB_UNUSED(closure);
-
- if (upbdefs_google_protobuf_FileDescriptorSet_is(m)) {
- upb_handlers_setstartsubmsg(h, F(FileDescriptorSet, file),
- &fileset_startfile, NULL);
- } else if (upbdefs_google_protobuf_DescriptorProto_is(m)) {
- upb_handlers_setstartmsg(h, &msg_start, NULL);
- upb_handlers_setendmsg(h, &msg_end, NULL);
- upb_handlers_setstring(h, F(DescriptorProto, name), &msg_name, NULL);
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, extension), &msg_startext,
- NULL);
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, nested_type),
- &msg_startmsg, NULL);
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, field),
- &msg_startfield, NULL);
- upb_handlers_setendsubmsg(h, F(DescriptorProto, field),
- &msg_endfield, NULL);
- upb_handlers_setstartsubmsg(h, F(DescriptorProto, enum_type),
- &file_startenum, NULL);
- } else if (upbdefs_google_protobuf_FileDescriptorProto_is(m)) {
- upb_handlers_setstartmsg(h, &file_start, NULL);
- upb_handlers_setendmsg(h, &file_end, NULL);
- upb_handlers_setstring(h, F(FileDescriptorProto, name), &file_onname,
- NULL);
- upb_handlers_setstring(h, F(FileDescriptorProto, package), &file_onpackage,
- NULL);
- upb_handlers_setstring(h, F(FileDescriptorProto, syntax), &file_onsyntax,
- NULL);
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, message_type),
- &file_startmsg, NULL);
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, enum_type),
- &file_startenum, NULL);
- upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, extension),
- &file_startext, NULL);
- upb_handlers_setstring(h, F(FileDescriptorProto, dependency),
- &file_ondep, NULL);
- } else if (upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)) {
- upb_handlers_setstartmsg(h, &enumval_startmsg, NULL);
- upb_handlers_setendmsg(h, &enumval_endmsg, NULL);
- upb_handlers_setstring(h, F(EnumValueDescriptorProto, name), &enumval_onname, NULL);
- upb_handlers_setint32(h, F(EnumValueDescriptorProto, number), &enumval_onnumber,
- NULL);
- } else if (upbdefs_google_protobuf_EnumDescriptorProto_is(m)) {
- upb_handlers_setendmsg(h, &enum_endmsg, NULL);
- upb_handlers_setstring(h, F(EnumDescriptorProto, name), &enum_onname, NULL);
- } else if (upbdefs_google_protobuf_FieldDescriptorProto_is(m)) {
- upb_handlers_setstartmsg(h, &field_startmsg, NULL);
- upb_handlers_setendmsg(h, &field_endmsg, NULL);
- upb_handlers_setint32(h, F(FieldDescriptorProto, type), &field_ontype,
- NULL);
- upb_handlers_setint32(h, F(FieldDescriptorProto, label), &field_onlabel,
- NULL);
- upb_handlers_setint32(h, F(FieldDescriptorProto, number), &field_onnumber,
- NULL);
- upb_handlers_setstring(h, F(FieldDescriptorProto, name), &field_onname,
- NULL);
- upb_handlers_setstring(h, F(FieldDescriptorProto, type_name),
- &field_ontypename, NULL);
- upb_handlers_setstring(h, F(FieldDescriptorProto, extendee),
- &field_onextendee, NULL);
- upb_handlers_setstring(h, F(FieldDescriptorProto, default_value),
- &field_ondefaultval, NULL);
- upb_handlers_setint32(h, F(FieldDescriptorProto, oneof_index),
- &field_ononeofindex, NULL);
- } else if (upbdefs_google_protobuf_OneofDescriptorProto_is(m)) {
- upb_handlers_setstring(h, F(OneofDescriptorProto, name), &oneof_name, NULL);
- } else if (upbdefs_google_protobuf_FieldOptions_is(m)) {
- upb_handlers_setbool(h, F(FieldOptions, lazy), &field_onlazy, NULL);
- upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL);
- } else if (upbdefs_google_protobuf_MessageOptions_is(m)) {
- upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL);
- } else if (upbdefs_google_protobuf_FileOptions_is(m)) {
- upb_handlers_setstring(h, F(FileOptions, php_class_prefix),
- &file_onphpprefix, NULL);
- upb_handlers_setstartstr(h, F(FileOptions, php_namespace),
- &file_startphpnamespace, NULL);
- upb_handlers_setstring(h, F(FileOptions, php_namespace),
- &file_onphpnamespace, NULL);
- }
-
- UPB_ASSERT(upb_ok(upb_handlers_status(h)));
-}
-
-#undef F
-
-void descreader_cleanup(void *_r) {
- upb_descreader *r = _r;
- size_t i;
-
- for (i = 0; i < upb_descreader_filecount(r); i++) {
- upb_filedef_unref(upb_descreader_file(r, i), &r->files);
- }
-
- upb_gfree(r->name);
- upb_inttable_uninit(&r->files);
- upb_strtable_uninit(&r->files_by_name);
- upb_inttable_uninit(&r->oneofs);
- upb_gfree(r->default_string);
- while (r->stack_len > 0) {
- upb_descreader_frame *f = &r->stack[--r->stack_len];
- upb_gfree(f->name);
- }
-}
-
-
-/* Public API ****************************************************************/
-
-upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) {
- upb_descreader *r = upb_env_malloc(e, sizeof(upb_descreader));
- if (!r || !upb_env_addcleanup(e, descreader_cleanup, r)) {
- return NULL;
- }
-
- upb_inttable_init(&r->files, UPB_CTYPE_PTR);
- upb_strtable_init(&r->files_by_name, UPB_CTYPE_PTR);
- upb_inttable_init(&r->oneofs, UPB_CTYPE_PTR);
- upb_sink_reset(upb_descreader_input(r), h, r);
- r->stack_len = 0;
- r->name = NULL;
- r->default_string = NULL;
-
- return r;
-}
-
-size_t upb_descreader_filecount(const upb_descreader *r) {
- return upb_inttable_count(&r->files);
-}
-
-upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i) {
- upb_value v;
- if (upb_inttable_lookup(&r->files, i, &v)) {
- return upb_value_getptr(v);
- } else {
- return NULL;
- }
-}
-
-upb_sink *upb_descreader_input(upb_descreader *r) {
- return &r->sink;
-}
-
-const upb_handlers *upb_descreader_newhandlers(const void *owner) {
- const upb_msgdef *m = upbdefs_google_protobuf_FileDescriptorSet_get(&m);
- const upb_handlers *h = upb_handlers_newfrozen(m, owner, reghandlers, NULL);
- upb_msgdef_unref(m, &m);
- return h;
-}
diff --git a/upb/descriptor/reader.h b/upb/descriptor/reader.h
deleted file mode 100644
index e8ede0d..0000000
--- a/upb/descriptor/reader.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-** upb::descriptor::Reader (upb_descreader)
-**
-** Provides a way of building upb::Defs from data in descriptor.proto format.
-*/
-
-#ifndef UPB_DESCRIPTOR_H
-#define UPB_DESCRIPTOR_H
-
-#include "upb/sink.h"
-
-#ifdef __cplusplus
-namespace upb {
-namespace descriptor {
-class Reader;
-} /* namespace descriptor */
-} /* namespace upb */
-#endif
-
-UPB_DECLARE_TYPE(upb::descriptor::Reader, upb_descreader)
-
-#ifdef __cplusplus
-
-/* Class that receives descriptor data according to the descriptor.proto schema
- * and use it to build upb::Defs corresponding to that schema. */
-class upb::descriptor::Reader {
- public:
- /* These handlers must have come from NewHandlers() and must outlive the
- * Reader.
- *
- * TODO: generate the handlers statically (like we do with the
- * descriptor.proto defs) so that there is no need to pass this parameter (or
- * to build/memory-manage the handlers at runtime at all). Unfortunately this
- * is a bit tricky to implement for Handlers, but necessary to simplify this
- * interface. */
- static Reader* Create(Environment* env, const Handlers* handlers);
-
- /* The reader's input; this is where descriptor.proto data should be sent. */
- Sink* input();
-
- /* Use to get the FileDefs that have been parsed. */
- size_t file_count() const;
- FileDef* file(size_t i) const;
-
- /* Builds and returns handlers for the reader, owned by "owner." */
- static Handlers* NewHandlers(const void* owner);
-
- private:
- UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader)
-};
-
-#endif
-
-UPB_BEGIN_EXTERN_C
-
-/* C API. */
-upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h);
-upb_sink *upb_descreader_input(upb_descreader *r);
-size_t upb_descreader_filecount(const upb_descreader *r);
-upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i);
-const upb_handlers *upb_descreader_newhandlers(const void *owner);
-
-UPB_END_EXTERN_C
-
-#ifdef __cplusplus
-/* C++ implementation details. ************************************************/
-namespace upb {
-namespace descriptor {
-inline Reader* Reader::Create(Environment* e, const Handlers *h) {
- return upb_descreader_create(e, h);
-}
-inline Sink* Reader::input() { return upb_descreader_input(this); }
-inline size_t Reader::file_count() const {
- return upb_descreader_filecount(this);
-}
-inline FileDef* Reader::file(size_t i) const {
- return upb_descreader_file(this, i);
-}
-} /* namespace descriptor */
-} /* namespace upb */
-#endif
-
-#endif /* UPB_DESCRIPTOR_H */
diff --git a/upb/encode.c b/upb/encode.c
index bff8262..c874281 100644
--- a/upb/encode.c
+++ b/upb/encode.c
@@ -1,5 +1,6 @@
/* We encode backwards, to avoid pre-computing lengths (one-pass encode). */
+#include <string.h>
#include "upb/upb.h"
#include "upb/encode.h"
#include "upb/structs.int.h"
diff --git a/upb/handlers.c b/upb/handlers.c
index 0022c32..7382e0c 100644
--- a/upb/handlers.c
+++ b/upb/handlers.c
@@ -4,7 +4,6 @@
*/
#include "upb/handlers.h"
-#include "upb/structdefs.int.h"
#include <string.h>
@@ -35,7 +34,6 @@ static void freehandlers(upb_refcounted *r) {
}
upb_inttable_uninit(&h->cleanup_);
- upb_msgdef_unref(h->msg, h);
upb_gfree(h->sub);
upb_gfree(h);
}
@@ -108,7 +106,7 @@ oom:
#define SUBH(h, selector) (h->sub[selector])
/* The selector for a submessage field is the field index. */
-#define SUBH_F(h, f) SUBH(h, f->index_)
+#define SUBH_F(h, f) SUBH(h, upb_fielddef_index(f))
static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) {
@@ -284,18 +282,15 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const void *owner) {
int extra;
upb_handlers *h;
- UPB_ASSERT(upb_msgdef_isfrozen(md));
-
- extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1);
+ extra = sizeof(upb_handlers_tabent) * (upb_msgdef_selectorcount(md) - 1);
h = upb_calloc(sizeof(*h) + extra);
if (!h) return NULL;
h->msg = md;
- upb_msgdef_ref(h->msg, h);
upb_status_clear(&h->status_);
- if (md->submsg_field_count > 0) {
- h->sub = upb_calloc(md->submsg_field_count * sizeof(*h->sub));
+ if (upb_msgdef_submsgfieldcount(md) > 0) {
+ h->sub = upb_calloc(upb_msgdef_submsgfieldcount(md) * sizeof(*h->sub));
if (!h->sub) goto oom;
} else {
h->sub = 0;
@@ -540,6 +535,7 @@ upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) {
bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
upb_selector_t *s) {
+ uint32_t selector_base = upb_fielddef_selectorbase(f);
switch (type) {
case UPB_HANDLER_INT32:
case UPB_HANDLER_INT64:
@@ -551,38 +547,38 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
if (!upb_fielddef_isprimitive(f) ||
upb_handlers_getprimitivehandlertype(f) != type)
return false;
- *s = f->selector_base;
+ *s = selector_base;
break;
case UPB_HANDLER_STRING:
if (upb_fielddef_isstring(f)) {
- *s = f->selector_base;
+ *s = selector_base;
} else if (upb_fielddef_lazy(f)) {
- *s = f->selector_base + 3;
+ *s = selector_base + 3;
} else {
return false;
}
break;
case UPB_HANDLER_STARTSTR:
if (upb_fielddef_isstring(f) || upb_fielddef_lazy(f)) {
- *s = f->selector_base + 1;
+ *s = selector_base + 1;
} else {
return false;
}
break;
case UPB_HANDLER_ENDSTR:
if (upb_fielddef_isstring(f) || upb_fielddef_lazy(f)) {
- *s = f->selector_base + 2;
+ *s = selector_base + 2;
} else {
return false;
}
break;
case UPB_HANDLER_STARTSEQ:
if (!upb_fielddef_isseq(f)) return false;
- *s = f->selector_base - 2;
+ *s = selector_base - 2;
break;
case UPB_HANDLER_ENDSEQ:
if (!upb_fielddef_isseq(f)) return false;
- *s = f->selector_base - 1;
+ *s = selector_base - 1;
break;
case UPB_HANDLER_STARTSUBMSG:
if (!upb_fielddef_issubmsg(f)) return false;
@@ -590,14 +586,14 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
* selector can also be used as an index into the "sub" array of
* subhandlers. The indexes for the two into these two tables are the
* same, except that in the handler table the static selectors come first. */
- *s = f->index_ + UPB_STATIC_SELECTOR_COUNT;
+ *s = upb_fielddef_index(f) + UPB_STATIC_SELECTOR_COUNT;
break;
case UPB_HANDLER_ENDSUBMSG:
if (!upb_fielddef_issubmsg(f)) return false;
- *s = f->selector_base;
+ *s = selector_base;
break;
}
- UPB_ASSERT((size_t)*s < upb_fielddef_containingtype(f)->selector_count);
+ UPB_ASSERT((size_t)*s < upb_msgdef_selectorcount(upb_fielddef_containingtype(f)));
return true;
}
diff --git a/upb/handlers.h b/upb/handlers.h
index a4e2a04..15d06a0 100644
--- a/upb/handlers.h
+++ b/upb/handlers.h
@@ -21,6 +21,7 @@
#include "upb/def.h"
#include "upb/table.int.h"
+#include "upb/refcounted.h"
#ifdef __cplusplus
namespace upb {
diff --git a/upb/msg.c b/upb/msg.c
index 29ba2e1..41260d6 100644
--- a/upb/msg.c
+++ b/upb/msg.c
@@ -1,4 +1,6 @@
+#include <string.h>
+#include "upb/table.int.h"
#include "upb/msg.h"
#include "upb/structs.int.h"
diff --git a/upb/msg.h b/upb/msg.h
index c72e9f0..3f0aa0b 100644
--- a/upb/msg.h
+++ b/upb/msg.h
@@ -21,9 +21,8 @@
#ifndef UPB_MSG_H_
#define UPB_MSG_H_
-#include "upb/def.h"
-#include "upb/handlers.h"
-#include "upb/sink.h"
+#include <stdint.h>
+#include "upb/upb.h"
#ifdef __cplusplus
diff --git a/upb/msgfactory.c b/upb/msgfactory.c
index 593c9dc..63df49e 100644
--- a/upb/msgfactory.c
+++ b/upb/msgfactory.c
@@ -1,4 +1,5 @@
+#include "upb/handlers.h"
#include "upb/msgfactory.h"
static bool is_power_of_two(size_t val) {
diff --git a/upb/pb/decoder.int.h b/upb/pb/decoder.int.h
index 4032570..f02bdd5 100644
--- a/upb/pb/decoder.int.h
+++ b/upb/pb/decoder.int.h
@@ -9,7 +9,6 @@
#include "upb/handlers.h"
#include "upb/pb/decoder.h"
#include "upb/sink.h"
-#include "upb/structdefs.int.h"
#include "upb/table.int.h"
/* C++ names are not actually used since this type isn't exposed to users. */
diff --git a/upb/pb/glue.c b/upb/pb/glue.c
deleted file mode 100644
index fb2b769..0000000
--- a/upb/pb/glue.c
+++ /dev/null
@@ -1,54 +0,0 @@
-
-#include "upb/pb/glue.h"
-
-#include "upb/descriptor/reader.h"
-#include "upb/pb/decoder.h"
-
-upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
- upb_status *status) {
- /* Create handlers. */
- const upb_pbdecodermethod *decoder_m;
- const upb_handlers *reader_h = upb_descreader_newhandlers(&reader_h);
- upb_env env;
- upb_pbdecodermethodopts opts;
- upb_pbdecoder *decoder;
- upb_descreader *reader;
- bool ok;
- size_t i;
- upb_filedef **ret = NULL;
-
- upb_pbdecodermethodopts_init(&opts, reader_h);
- decoder_m = upb_pbdecodermethod_new(&opts, &decoder_m);
-
- upb_env_init(&env);
- upb_env_reporterrorsto(&env, status);
-
- reader = upb_descreader_create(&env, reader_h);
- decoder = upb_pbdecoder_create(&env, decoder_m, upb_descreader_input(reader));
-
- /* Push input data. */
- ok = upb_bufsrc_putbuf(buf, n, upb_pbdecoder_input(decoder));
-
- if (!ok) {
- goto cleanup;
- }
-
- ret = upb_gmalloc(sizeof (*ret) * (upb_descreader_filecount(reader) + 1));
-
- if (!ret) {
- goto cleanup;
- }
-
- for (i = 0; i < upb_descreader_filecount(reader); i++) {
- ret[i] = upb_descreader_file(reader, i);
- upb_filedef_ref(ret[i], owner);
- }
-
- ret[i] = NULL;
-
-cleanup:
- upb_env_uninit(&env);
- upb_handlers_unref(reader_h, &reader_h);
- upb_pbdecodermethod_unref(decoder_m, &decoder_m);
- return ret;
-}
diff --git a/upb/pb/glue.h b/upb/pb/glue.h
deleted file mode 100644
index 716fc0e..0000000
--- a/upb/pb/glue.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-** upb's core components like upb_decoder and upb_msg are carefully designed to
-** avoid depending on each other for maximum orthogonality. In other words,
-** you can use a upb_decoder to decode into *any* kind of structure; upb_msg is
-** just one such structure. A upb_msg can be serialized/deserialized into any
-** format, protobuf binary format is just one such format.
-**
-** However, for convenience we provide functions here for doing common
-** operations like deserializing protobuf binary format into a upb_msg. The
-** compromise is that this file drags in almost all of upb as a dependency,
-** which could be undesirable if you're trying to use a trimmed-down build of
-** upb.
-**
-** While these routines are convenient, they do not reuse any encoding/decoding
-** state. For example, if a decoder is JIT-based, it will be re-JITted every
-** time these functions are called. For this reason, if you are parsing lots
-** of data and efficiency is an issue, these may not be the best functions to
-** use (though they are useful for prototyping, before optimizing).
-*/
-
-#ifndef UPB_GLUE_H
-#define UPB_GLUE_H
-
-#include <stdbool.h>
-#include "upb/def.h"
-
-#ifdef __cplusplus
-#include <vector>
-
-extern "C" {
-#endif
-
-/* Loads a binary descriptor and returns a NULL-terminated array of unfrozen
- * filedefs. The caller owns the returned array, which must be freed with
- * upb_gfree(). */
-upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
- upb_status *status);
-
-#ifdef __cplusplus
-} /* extern "C" */
-
-namespace upb {
-
-inline bool LoadDescriptor(const char* buf, size_t n, Status* status,
- std::vector<reffed_ptr<FileDef> >* files) {
- FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status);
-
- if (parsed_files) {
- FileDef** p = parsed_files;
- while (*p) {
- files->push_back(reffed_ptr<FileDef>(*p, &parsed_files));
- ++p;
- }
- free(parsed_files);
- return true;
- } else {
- return false;
- }
-}
-
-/* Templated so it can accept both string and std::string. */
-template <typename T>
-bool LoadDescriptor(const T& desc, Status* status,
- std::vector<reffed_ptr<FileDef> >* files) {
- return LoadDescriptor(desc.c_str(), desc.size(), status, files);
-}
-
-} /* namespace upb */
-
-#endif
-
-#endif /* UPB_GLUE_H */
diff --git a/upb/structdefs.int.h b/upb/structdefs.int.h
deleted file mode 100644
index ff44e2d..0000000
--- a/upb/structdefs.int.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-** This file contains definitions of structs that should be considered private
-** and NOT stable across versions of upb.
-**
-** The only reason they are declared here and not in .c files is to allow upb
-** and the application (if desired) to embed statically-initialized instances
-** of structures like defs.
-**
-** If you include this file, all guarantees of ABI compatibility go out the
-** window! Any code that includes this file needs to recompile against the
-** exact same version of upb that they are linking against.
-**
-** You also need to recompile if you change the value of the UPB_DEBUG_REFS
-** flag.
-*/
-
-#include "upb/def.h"
-
-#ifndef UPB_STATICINIT_H_
-#define UPB_STATICINIT_H_
-
-#ifdef __cplusplus
-/* Because of how we do our typedefs, this header can't be included from C++. */
-#error This file cannot be included from C++
-#endif
-
-/* upb_refcounted *************************************************************/
-
-
-/* upb_def ********************************************************************/
-
-struct upb_def {
- upb_refcounted base;
-
- const char *fullname;
- const upb_filedef* file;
- char type; /* A upb_deftype_t (char to save space) */
-
- /* Used as a flag during the def's mutable stage. Must be false unless
- * it is currently being used by a function on the stack. This allows
- * us to easily determine which defs were passed into the function's
- * current invocation. */
- bool came_from_user;
-};
-
-#define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
- { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
-
-
-/* upb_fielddef ***************************************************************/
-
-struct upb_fielddef {
- upb_def base;
-
- union {
- int64_t sint;
- uint64_t uint;
- double dbl;
- float flt;
- void *bytes;
- } defaultval;
- union {
- const upb_msgdef *def; /* If !msg_is_symbolic. */
- char *name; /* If msg_is_symbolic. */
- } msg;
- union {
- const upb_def *def; /* If !subdef_is_symbolic. */
- char *name; /* If subdef_is_symbolic. */
- } sub; /* The msgdef or enumdef for this field, if upb_hassubdef(f). */
- bool subdef_is_symbolic;
- bool msg_is_symbolic;
- const upb_oneofdef *oneof;
- bool default_is_string;
- bool type_is_set_; /* False until type is explicitly set. */
- bool is_extension_;
- bool lazy_;
- bool packed_;
- upb_intfmt_t intfmt;
- bool tagdelim;
- upb_fieldtype_t type_;
- upb_label_t label_;
- uint32_t number_;
- uint32_t selector_base; /* Used to index into a upb::Handlers table. */
- uint32_t index_;
-};
-
-extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
-
-#define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
- packed, name, num, msgdef, subdef, selector_base, \
- index, defaultval, refs, ref2s) \
- { \
- UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
- defaultval, {msgdef}, {subdef}, NULL, false, false, \
- type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
- lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
- }
-
-
-/* upb_msgdef *****************************************************************/
-
-struct upb_msgdef {
- upb_def base;
-
- size_t selector_count;
- uint32_t submsg_field_count;
-
- /* Tables for looking up fields by number and name. */
- upb_inttable itof; /* int to field */
- upb_strtable ntof; /* name to field/oneof */
-
- /* Is this a map-entry message? */
- bool map_entry;
-
- /* Whether this message has proto2 or proto3 semantics. */
- upb_syntax_t syntax;
-
- /* TODO(haberman): proper extension ranges (there can be multiple). */
-};
-
-extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
-
-/* TODO: also support static initialization of the oneofs table. This will be
- * needed if we compile in descriptors that contain oneofs. */
-#define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
- map_entry, syntax, refs, ref2s) \
- { \
- UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
- selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
- }
-
-
-/* upb_enumdef ****************************************************************/
-
-struct upb_enumdef {
- upb_def base;
-
- upb_strtable ntoi;
- upb_inttable iton;
- int32_t defaultval;
-};
-
-extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
-
-#define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
- iton, defaultval }
-
-
-/* upb_oneofdef ***************************************************************/
-
-struct upb_oneofdef {
- upb_refcounted base;
-
- uint32_t index; /* Index within oneofs. */
- const char *name;
- upb_strtable ntof;
- upb_inttable itof;
- const upb_msgdef *parent;
-};
-
-extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
-
-#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
- { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
-
-
-/* upb_symtab *****************************************************************/
-
-struct upb_symtab {
- upb_refcounted base;
-
- upb_strtable symtab;
-};
-
-struct upb_filedef {
- upb_refcounted base;
-
- const char *name;
- const char *package;
- const char *phpprefix;
- const char *phpnamespace;
- upb_syntax_t syntax;
-
- upb_inttable defs;
- upb_inttable deps;
-};
-
-extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
-
-#endif /* UPB_STATICINIT_H_ */
diff --git a/upb/table.int.h b/upb/table.int.h
index 225235e..63dce59 100644
--- a/upb/table.int.h
+++ b/upb/table.int.h
@@ -180,69 +180,11 @@ UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) {
/* upb_tabval *****************************************************************/
-#ifdef __cplusplus
-
-/* Status initialization not supported.
- *
- * This separate definition is necessary because in C++, UINTPTR_MAX isn't
- * reliably available. */
typedef struct {
uint64_t val;
} upb_tabval;
-#else
-
-/* C -- supports static initialization, but to support static initialization of
- * both integers and points for both 32 and 64 bit targets, it takes a little
- * bit of doing. */
-
-#if UINTPTR_MAX == 0xffffffffffffffffULL
-#define UPB_PTR_IS_64BITS
-#elif UINTPTR_MAX != 0xffffffff
-#error Could not determine how many bits pointers are.
-#endif
-
-typedef union {
- /* For static initialization.
- *
- * Unfortunately this ugliness is necessary -- it is the only way that we can,
- * with -std=c89 -pedantic, statically initialize this to either a pointer or
- * an integer on 32-bit platforms. */
- struct {
-#ifdef UPB_PTR_IS_64BITS
- uintptr_t val;
-#else
- uintptr_t val1;
- uintptr_t val2;
-#endif
- } staticinit;
-
- /* The normal accessor that we use for everything at runtime. */
- uint64_t val;
-} upb_tabval;
-
-#ifdef UPB_PTR_IS_64BITS
-#define UPB_TABVALUE_INT_INIT(v) {{v}}
-#define UPB_TABVALUE_EMPTY_INIT {{-1}}
-#else
-
-/* 32-bit pointers */
-
-#ifdef UPB_BIG_ENDIAN
-#define UPB_TABVALUE_INT_INIT(v) {{0, v}}
-#define UPB_TABVALUE_EMPTY_INIT {{-1, -1}}
-#else
-#define UPB_TABVALUE_INT_INIT(v) {{v, 0}}
-#define UPB_TABVALUE_EMPTY_INIT {{-1, -1}}
-#endif
-
-#endif
-
-#define UPB_TABVALUE_PTR_INIT(v) UPB_TABVALUE_INT_INIT((uintptr_t)v)
-
-#undef UPB_PTR_IS_64BITS
-
-#endif /* __cplusplus */
+#define UPB_TABVALUE_EMPTY_INIT {-1}
/* upb_table ******************************************************************/
@@ -284,31 +226,10 @@ typedef struct {
#endif
} upb_table;
-#ifdef NDEBUG
-# define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
- {count, mask, ctype, size_lg2, entries}
-#else
-# ifdef UPB_DEBUG_REFS
-/* At the moment the only mutable tables we statically initialize are debug
- * ref tables. */
-# define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
- {count, mask, ctype, size_lg2, entries, &upb_alloc_debugrefs}
-# else
-# define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
- {count, mask, ctype, size_lg2, entries, NULL}
-# endif
-#endif
-
typedef struct {
upb_table t;
} upb_strtable;
-#define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \
- {UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries)}
-
-#define UPB_EMPTY_STRTABLE_INIT(ctype) \
- UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL)
-
typedef struct {
upb_table t; /* For entries that don't fit in the array part. */
const upb_tabval *array; /* Array part of the table. See const note above. */
diff --git a/upb/upb.h b/upb/upb.h
index 2d6db8e..1c28488 100644
--- a/upb/upb.h
+++ b/upb/upb.h
@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#ifdef __cplusplus
namespace upb {
@@ -526,6 +527,13 @@ size_t upb_arena_bytesallocated(const upb_arena *a);
void upb_arena_setnextblocksize(upb_arena *a, size_t size);
void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
+UPB_INLINE void *upb_arena_malloc(upb_arena *a, size_t size) {
+ return upb_malloc(upb_arena_alloc(a), size);
+}
+UPB_INLINE void *upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize,
+ size_t size) {
+ return upb_malloc(upb_arena_realloc(a), ptr, oldsize, size);
+}
UPB_END_EXTERN_C
@@ -733,6 +741,69 @@ template <int N> class upb::InlinedEnvironment : public upb::Environment {
#endif /* __cplusplus */
+/* The types a field can have. Note that this list is not identical to the
+ * types defined in descriptor.proto, which gives INT32 and SINT32 separate
+ * types (we distinguish the two with the "integer encoding" enum below). */
+typedef enum {
+ /* Types stored in 1 byte. */
+ UPB_TYPE_BOOL = 1,
+ /* Types stored in 4 bytes. */
+ UPB_TYPE_FLOAT = 2,
+ UPB_TYPE_INT32 = 3,
+ UPB_TYPE_UINT32 = 4,
+ UPB_TYPE_ENUM = 5, /* Enum values are int32. */
+ /* Types stored as pointers (probably 4 or 8 bytes). */
+ UPB_TYPE_STRING = 6,
+ UPB_TYPE_BYTES = 7,
+ UPB_TYPE_MESSAGE = 8,
+ /* Types stored as 8 bytes. */
+ UPB_TYPE_DOUBLE = 9,
+ UPB_TYPE_INT64 = 10,
+ UPB_TYPE_UINT64 = 11
+} upb_fieldtype_t;
+
+/* The repeated-ness of each field; this matches descriptor.proto. */
+typedef enum {
+ UPB_LABEL_OPTIONAL = 1,
+ UPB_LABEL_REQUIRED = 2,
+ UPB_LABEL_REPEATED = 3
+} upb_label_t;
+
+/* How integers should be encoded in serializations that offer multiple
+ * integer encoding methods. */
+typedef enum {
+ UPB_INTFMT_VARIABLE = 1,
+ UPB_INTFMT_FIXED = 2,
+ UPB_INTFMT_ZIGZAG = 3 /* Only for signed types (INT32/INT64). */
+} upb_intfmt_t;
+
+/* Descriptor types, as defined in descriptor.proto. */
+typedef enum {
+ UPB_DESCRIPTOR_TYPE_DOUBLE = 1,
+ UPB_DESCRIPTOR_TYPE_FLOAT = 2,
+ UPB_DESCRIPTOR_TYPE_INT64 = 3,
+ UPB_DESCRIPTOR_TYPE_UINT64 = 4,
+ UPB_DESCRIPTOR_TYPE_INT32 = 5,
+ UPB_DESCRIPTOR_TYPE_FIXED64 = 6,
+ UPB_DESCRIPTOR_TYPE_FIXED32 = 7,
+ UPB_DESCRIPTOR_TYPE_BOOL = 8,
+ UPB_DESCRIPTOR_TYPE_STRING = 9,
+ UPB_DESCRIPTOR_TYPE_GROUP = 10,
+ UPB_DESCRIPTOR_TYPE_MESSAGE = 11,
+ UPB_DESCRIPTOR_TYPE_BYTES = 12,
+ UPB_DESCRIPTOR_TYPE_UINT32 = 13,
+ UPB_DESCRIPTOR_TYPE_ENUM = 14,
+ UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
+ UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
+ UPB_DESCRIPTOR_TYPE_SINT32 = 17,
+ UPB_DESCRIPTOR_TYPE_SINT64 = 18
+} upb_descriptortype_t;
+
+typedef enum {
+ UPB_SYNTAX_PROTO2 = 2,
+ UPB_SYNTAX_PROTO3 = 3
+} upb_syntax_t;
+extern const uint8_t upb_desctype_to_fieldtype[];
#endif /* UPB_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback