|
|
|
@ -7,11 +7,20 @@ |
|
|
|
|
|
|
|
|
|
#include "upb/test/fuzz_util.h" |
|
|
|
|
|
|
|
|
|
#include <stddef.h> |
|
|
|
|
|
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
#include "upb/base/descriptor_constants.h" |
|
|
|
|
#include "upb/base/status.hpp" |
|
|
|
|
#include "upb/message/message.h" |
|
|
|
|
#include "upb/mem/arena.h" |
|
|
|
|
#include "upb/mini_descriptor/decode.h" |
|
|
|
|
#include "upb/mini_table/enum.h" |
|
|
|
|
#include "upb/mini_table/extension.h" |
|
|
|
|
#include "upb/mini_table/extension_registry.h" |
|
|
|
|
#include "upb/mini_table/field.h" |
|
|
|
|
#include "upb/mini_table/message.h" |
|
|
|
|
#include "upb/mini_table/sub.h" |
|
|
|
|
|
|
|
|
|
// Must be last
|
|
|
|
|
#include "upb/port/def.inc" |
|
|
|
@ -87,16 +96,17 @@ void Builder::BuildEnums() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Builder::LinkExtension(upb_MiniTableExtension* ext) { |
|
|
|
|
upb_MiniTableField* field = &ext->field; |
|
|
|
|
upb_MiniTableField* field = |
|
|
|
|
(upb_MiniTableField*)upb_MiniTableExtension_AsField(ext); |
|
|
|
|
if (upb_MiniTableField_CType(field) == kUpb_CType_Message) { |
|
|
|
|
auto mt = NextMiniTable(); |
|
|
|
|
if (!mt) field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_Int32; |
|
|
|
|
ext->sub.submsg = mt; |
|
|
|
|
ext->UPB_PRIVATE(sub).submsg = mt; |
|
|
|
|
} |
|
|
|
|
if (upb_MiniTableField_IsClosedEnum(field)) { |
|
|
|
|
auto et = NextEnumTable(); |
|
|
|
|
if (!et) field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_Int32; |
|
|
|
|
ext->sub.subenum = et; |
|
|
|
|
ext->UPB_PRIVATE(sub).subenum = et; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -120,7 +130,8 @@ void Builder::BuildExtensions(upb_ExtensionRegistry** exts) { |
|
|
|
|
status.ptr()); |
|
|
|
|
if (!ptr) break; |
|
|
|
|
if (!LinkExtension(ext)) continue; |
|
|
|
|
if (upb_ExtensionRegistry_Lookup(*exts, ext->extendee, ext->field.number)) |
|
|
|
|
if (upb_ExtensionRegistry_Lookup(*exts, ext->UPB_PRIVATE(extendee), |
|
|
|
|
upb_MiniTableExtension_Number(ext))) |
|
|
|
|
continue; |
|
|
|
|
upb_ExtensionRegistry_AddArray( |
|
|
|
|
*exts, const_cast<const upb_MiniTableExtension**>(&ext), 1); |
|
|
|
|