Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void EnumGenerator::GenerateSource(io::Printer* printer) {
"\n"
"$classname$ *$classname$_values_[$count$];\n"
"\n"
"ComGoogleProtobufDescriptors_EnumDescriptor"
"static ComGoogleProtobufDescriptors_EnumDescriptor"
" *$classname$_descriptor_ = nil;\n"
"\n"
"@implementation $classname$\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ void CollectForwardDeclarationsForFieldType(std::set<std::string>* declarations,
declarations->insert("@class ComGoogleProtobufDescriptors_EnumDescriptor");
declarations->insert("J2OBJC_CLASS_DECLARATION(" +
ClassName(descriptor->enum_type()) + ")");
declarations->insert(
"FOUNDATION_EXPORT "
"ComGoogleProtobufDescriptors_EnumDescriptor * _Nonnull " +
ClassName(descriptor->enum_type()) + "_descriptor_");
} else if (type == JAVATYPE_MESSAGE) {
std::string classname = ClassName(descriptor->message_type());
declarations->insert("@class " + classname);
Expand Down Expand Up @@ -279,7 +275,6 @@ void FieldGenerator::GenerateFieldData(io::Printer *printer) const {
);
GenerateFieldDataOffset(printer);
GenerateClassNameOrMapData(printer);
GenerateStaticRefs(printer);
printer->Print(variables_,
" .containingType = NULL,\n" // Used by extensions.
" .optionsData = $options_data$,\n"
Expand All @@ -295,21 +290,6 @@ void FieldGenerator::GenerateClassNameOrMapData(io::Printer *printer) const {
GenerateObjcClassRef(printer, descriptor_);
}

void FieldGenerator::GenerateStaticRefs(io::Printer *printer) const {
JavaType type = GetJavaType(descriptor_);
std::string staticref;
if (type == JAVATYPE_MESSAGE) {
staticref = "&" +
GetParameterType(descriptor_) + "_descriptor_";
} else if (type == JAVATYPE_ENUM) {
staticref = "&" +
GetParameterType(descriptor_) + "_descriptor_";
} else {
staticref = "NULL";
}
printer->Print(" .descriptorRef = $staticref$,\n", "staticref", staticref);
}

SingleFieldGenerator::SingleFieldGenerator(
const FieldDescriptor *descriptor, uint32_t *numHasBits)
: FieldGenerator(descriptor) {
Expand All @@ -333,7 +313,7 @@ void SingleFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer)
"- (nonnull $classname$_Builder *)clear$capitalized_name$;\n");

if (IsGenerateProperties(descriptor_->file())) {
printer->Print(GetStorageType(descriptor_) == GetNonNullType(descriptor_)
printer->Print(GetStorageType(descriptor_) == GetNonNullType(descriptor_)
? "@property (" : "@property (nonnull, retain, ");
printer->Print(
variables_,
Expand Down Expand Up @@ -600,10 +580,6 @@ void MapEntryFieldGenerator::GenerateFieldDataOffset(io::Printer *printer)
printer->Print(variables_, " .offset = 0,\n");
}

void MapFieldGenerator::GenerateStaticRefs(io::Printer *printer) const {
printer->Print(variables_, " .descriptorRef = NULL,\n");
}

void MapEntryFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer)
const {
}
Expand All @@ -615,10 +591,6 @@ void MapEntryFieldGenerator::GenerateMessageOrBuilderProtocol(
void MapEntryFieldGenerator::GenerateDeclaration(io::Printer* printer) const {
}

void MapEntryFieldGenerator::GenerateStaticRefs(io::Printer *printer) const {
printer->Print(variables_, " .descriptorRef = NULL,\n");
}

FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
: descriptor_(descriptor),
field_generators_(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class FieldGenerator {

virtual void GenerateFieldDataOffset(io::Printer *printer) const;
virtual void GenerateClassNameOrMapData(io::Printer *printer) const;
virtual void GenerateStaticRefs(io::Printer *printer) const;

private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
Expand Down Expand Up @@ -158,7 +157,6 @@ class MapFieldGenerator : public FieldGenerator {

protected:
virtual void GenerateClassNameOrMapData(io::Printer *printer) const;
virtual void GenerateStaticRefs(io::Printer *printer) const;

private:
const FieldDescriptor* key_field_;
Expand All @@ -181,7 +179,6 @@ class MapEntryFieldGenerator : public FieldGenerator {

protected:
virtual void GenerateFieldDataOffset(io::Printer *printer) const;
virtual void GenerateStaticRefs(io::Printer *printer) const;

private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryFieldGenerator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ void MessageGenerator::GenerateHeader(io::Printer* printer) {
"\n"
"J2OBJC_STATIC_INIT($classname$)\n"
"\n"
"J2OBJC_TYPE_LITERAL_HEADER($classname$)\n"
"\n"
"FOUNDATION_EXPORT ComGoogleProtobufDescriptors_Descriptor "
"* _Nonnull $classname$_descriptor_;\n",
"J2OBJC_TYPE_LITERAL_HEADER($classname$)\n",
"classname", ClassName(descriptor_));

for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
Expand Down Expand Up @@ -358,7 +355,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
"\n"
"J2OBJC_INITIALIZED_DEFN($classname$);\n"
"\n"
"ComGoogleProtobufDescriptors_Descriptor * _Nonnull "
"static ComGoogleProtobufDescriptors_Descriptor * _Nonnull "
"$classname$_descriptor_;\n",
"classname", ClassName(descriptor_));

Expand Down Expand Up @@ -459,7 +456,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
"classname", ClassName(descriptor_), "flags",
GetMessageFlags(descriptor_));
if (field_generators_.numMapFields() > 0) {
printer->Print("static CGPFieldData mapEntryFields[] = {\n");
printer->Print("static const CGPFieldData mapEntryFields[] = {\n");
printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i))
Expand All @@ -468,7 +465,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
printer->Outdent();
printer->Print("};\n");
}
printer->Print("static CGPFieldData fields[] = {\n");
printer->Print("static const CGPFieldData fields[] = {\n");
printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i)).GenerateFieldData(printer);
Expand All @@ -493,7 +490,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
descriptor_->real_oneof_decl_count() > 0 ? "oneofs" : "NULL");

if (descriptor_->extension_count() > 0) {
printer->Print("static CGPFieldData extensionFields[] = {\n");
printer->Print("static const CGPFieldData extensionFields[] = {\n");
printer->Indent();
for (int i = 0; i < descriptor_->extension_count(); i++) {
ExtensionGenerator(descriptor_->extension(i)).GenerateFieldData(printer);
Expand Down
8 changes: 6 additions & 2 deletions protobuf/runtime/src/com/google/protobuf/Descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ J2OBJC_EMPTY_STATIC_INIT(ComGoogleProtobufDescriptors_EnumDescriptor)

J2OBJC_TYPE_LITERAL_HEADER(ComGoogleProtobufDescriptors_EnumDescriptor)

@interface ComGoogleProtobufDescriptors_EnumValueDescriptor : NSObject
@interface ComGoogleProtobufDescriptors_UnknownEnumValueDescriptor : NSObject

- (jint)getNumber;

- (NSString *)getName;

@end

@interface ComGoogleProtobufDescriptors_EnumValueDescriptor
: ComGoogleProtobufDescriptors_UnknownEnumValueDescriptor
@end

J2OBJC_EMPTY_STATIC_INIT(ComGoogleProtobufDescriptors_EnumValueDescriptor)

J2OBJC_TYPE_LITERAL_HEADER(ComGoogleProtobufDescriptors_EnumValueDescriptor)
Expand All @@ -142,4 +146,4 @@ J2OBJC_EMPTY_STATIC_INIT(ComGoogleProtobufDescriptors_OneofDescriptor)

J2OBJC_TYPE_LITERAL_HEADER(ComGoogleProtobufDescriptors_OneofDescriptor)

#endif // __ComGoogleProtobufDescriptors_H__
#endif // __ComGoogleProtobufDescriptors_H__
Loading