|
|
@ -233,6 +233,9 @@ std::string MapValueSize(upb::FieldDefPtr map_field, absl::string_view expr) { |
|
|
|
|
|
|
|
|
|
|
|
std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, |
|
|
|
std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, |
|
|
|
const Options& options); |
|
|
|
const Options& options); |
|
|
|
|
|
|
|
std::string FieldInitializerStrong(const DefPoolPair& pools, |
|
|
|
|
|
|
|
upb::FieldDefPtr field, |
|
|
|
|
|
|
|
const Options& options); |
|
|
|
|
|
|
|
|
|
|
|
void DumpEnumValues(upb::EnumDefPtr desc, Output& output) { |
|
|
|
void DumpEnumValues(upb::EnumDefPtr desc, Output& output) { |
|
|
|
std::vector<upb::EnumValDefPtr> values; |
|
|
|
std::vector<upb::EnumValDefPtr> values; |
|
|
@ -466,7 +469,7 @@ void GenerateMapGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), |
|
|
|
msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), |
|
|
|
FieldInitializer(pools, field, options), MapKeySize(field, "key"), |
|
|
|
FieldInitializerStrong(pools, field, options), MapKeySize(field, "key"), |
|
|
|
MapValueSize(field, "*val")); |
|
|
|
MapValueSize(field, "*val")); |
|
|
|
output( |
|
|
|
output( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -478,7 +481,7 @@ void GenerateMapGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CTypeConst(field), msg_name, resolved_name, |
|
|
|
CTypeConst(field), msg_name, resolved_name, |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
// Generate private getter returning a upb_Map or NULL for immutable and
|
|
|
|
// Generate private getter returning a upb_Map or NULL for immutable and
|
|
|
|
// a upb_Map for mutable.
|
|
|
|
// a upb_Map for mutable.
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -497,7 +500,7 @@ void GenerateMapGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
msg_name, resolved_name, kMapGetterPostfix, kMutableMapGetterPostfix, |
|
|
|
msg_name, resolved_name, kMapGetterPostfix, kMutableMapGetterPostfix, |
|
|
|
FieldInitializer(pools, field, options), |
|
|
|
FieldInitializerStrong(pools, field, options), |
|
|
|
MapKeySize(field, MapKeyCType(field)), |
|
|
|
MapKeySize(field, MapKeyCType(field)), |
|
|
|
MapValueSize(field, MapValueCType(field))); |
|
|
|
MapValueSize(field, MapValueCType(field))); |
|
|
|
} |
|
|
|
} |
|
|
@ -541,7 +544,7 @@ void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
CTypeConst(field), // $0
|
|
|
|
CTypeConst(field), // $0
|
|
|
|
msg_name, // $1
|
|
|
|
msg_name, // $1
|
|
|
|
ResolveFieldName(field, field_names), // $2
|
|
|
|
ResolveFieldName(field, field_names), // $2
|
|
|
|
FieldInitializer(pools, field, options) // #3
|
|
|
|
FieldInitializerStrong(pools, field, options) // #3
|
|
|
|
); |
|
|
|
); |
|
|
|
// Generate private getter returning array or NULL for immutable and upb_Array
|
|
|
|
// Generate private getter returning array or NULL for immutable and upb_Array
|
|
|
|
// for mutable.
|
|
|
|
// for mutable.
|
|
|
@ -572,7 +575,7 @@ void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
CTypeConst(field), // $0
|
|
|
|
CTypeConst(field), // $0
|
|
|
|
msg_name, // $1
|
|
|
|
msg_name, // $1
|
|
|
|
ResolveFieldName(field, field_names), // $2
|
|
|
|
ResolveFieldName(field, field_names), // $2
|
|
|
|
FieldInitializer(pools, field, options), // $3
|
|
|
|
FieldInitializerStrong(pools, field, options), // $3
|
|
|
|
kRepeatedFieldArrayGetterPostfix, // $4
|
|
|
|
kRepeatedFieldArrayGetterPostfix, // $4
|
|
|
|
kRepeatedFieldMutableArrayGetterPostfix // $5
|
|
|
|
kRepeatedFieldMutableArrayGetterPostfix // $5
|
|
|
|
); |
|
|
|
); |
|
|
@ -595,7 +598,7 @@ void GenerateScalarGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CTypeConst(field), msg_name, field_name, FieldDefault(field), |
|
|
|
CTypeConst(field), msg_name, field_name, FieldDefault(field), |
|
|
|
FieldInitializer(pools, field, Options)); |
|
|
|
FieldInitializerStrong(pools, field, Options)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GenerateGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
void GenerateGetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
@ -640,7 +643,7 @@ void GenerateMapSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), |
|
|
|
msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), |
|
|
|
FieldInitializer(pools, field, options), MapKeySize(field, "key"), |
|
|
|
FieldInitializerStrong(pools, field, options), MapKeySize(field, "key"), |
|
|
|
MapValueSize(field, "val")); |
|
|
|
MapValueSize(field, "val")); |
|
|
|
output( |
|
|
|
output( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -663,7 +666,7 @@ void GenerateMapSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
@ -686,7 +689,7 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
output( |
|
|
|
output( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
UPB_INLINE $0* $1_resize_$2($1* msg, size_t size, upb_Arena* arena) { |
|
|
|
UPB_INLINE $0* $1_resize_$2($1* msg, size_t size, upb_Arena* arena) { |
|
|
@ -717,7 +720,7 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
MessageName(field.message_type()), msg_name, resolved_name, |
|
|
|
MessageName(field.message_type()), msg_name, resolved_name, |
|
|
|
MessageMiniTableRef(field.message_type(), options), |
|
|
|
MessageMiniTableRef(field.message_type(), options), |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
output( |
|
|
|
output( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -735,7 +738,7 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
CType(field), msg_name, resolved_name, |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -768,7 +771,7 @@ void GenerateNonRepeatedSetters(upb::FieldDefPtr field, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
msg_name, field_name, CType(field), |
|
|
|
msg_name, field_name, CType(field), |
|
|
|
FieldInitializer(pools, field, options)); |
|
|
|
FieldInitializerStrong(pools, field, options)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Message fields also have a Msg_mutable_foo() accessor that will create
|
|
|
|
// Message fields also have a Msg_mutable_foo() accessor that will create
|
|
|
@ -1007,6 +1010,31 @@ std::string FieldInitializer(upb::FieldDefPtr field, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string StrongReferenceSingle(upb::FieldDefPtr field) { |
|
|
|
|
|
|
|
if (!field.message_type()) return ""; |
|
|
|
|
|
|
|
return absl::Substitute(" UPB_PRIVATE(_upb_MiniTable_StrongReference)(&$0)", |
|
|
|
|
|
|
|
MessageInitName(field.message_type())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string StrongReference(upb::FieldDefPtr field) { |
|
|
|
|
|
|
|
if (field.IsMap() && |
|
|
|
|
|
|
|
field.message_type().FindFieldByNumber(2).IsSubMessage()) { |
|
|
|
|
|
|
|
return StrongReferenceSingle(field) + ";\n" + |
|
|
|
|
|
|
|
StrongReferenceSingle(field.message_type().FindFieldByNumber(2)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return StrongReferenceSingle(field); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string FieldInitializerStrong(const DefPoolPair& pools, |
|
|
|
|
|
|
|
upb::FieldDefPtr field, |
|
|
|
|
|
|
|
const Options& options) { |
|
|
|
|
|
|
|
std::string ret = FieldInitializer(pools, field, options); |
|
|
|
|
|
|
|
if (!options.bootstrap && field.IsSubMessage()) { |
|
|
|
|
|
|
|
ret += ";\n" + StrongReference(field); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, |
|
|
|
std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, |
|
|
|
const Options& options) { |
|
|
|
const Options& options) { |
|
|
|
return FieldInitializer(field, pools.GetField64(field), |
|
|
|
return FieldInitializer(field, pools.GetField64(field), |
|
|
|