Skip to content

Commit

Permalink
remove non ARC code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Khokhlov committed Mar 20, 2014
1 parent ef07a0d commit 3baebcf
Show file tree
Hide file tree
Showing 51 changed files with 18 additions and 145 deletions.
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Install Protocol Buffers for Objective C
# Install Protocol Buffers for Objective-C, only for ARC projects

1.`ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"`

Expand All @@ -10,19 +10,9 @@

5.`git clone [email protected]:alexeyxo/protobuf-objc.git`

6.`./autogen.sh`

7.`./configure`

8.`sudo make && make install`
6.`./build.sh`

#Compile ".proto" files.


###Compile ARC support.
`protoc --plugin=/usr/local/bin/protoc-gen-objc-arc person.proto --objc_out="./"`

###Compile without ARC.
`protoc --plugin=/usr/local/bin/protoc-gen-objc person.proto --objc_out="./"`

#Framework Directory
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
make clean;
./autogen;
./configure;
make && make install;
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ In some 64-bit environments, try LDFLAGS=-L/usr/local/lib64.
])])
pbc_savelibs="$LIBS"
LIBS="$LIBS -lprotoc -lprotobuf -lpthread"
CFLAGS="$CFLAGS -DOBJC_ARC"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <google/protobuf/compiler/command_line_interface.h>]],
[[google::protobuf::compiler::CommandLineInterface cli;]])],
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
MAINTAINERCLEANFILES = \
Makefile.in
DEFINES = OBJC_ARC
bin_PROGRAMS = protoc-gen-objc protoc-gen-objc-arc
bin_PROGRAMS = protoc-gen-objc
protoc_gen_objc_LDFLAGS = -lprotobuf -lprotoc
protoc_gen_objc_SOURCES = \
main.cc \
Expand All @@ -15,7 +14,4 @@ protoc_gen_objc_SOURCES = \
objc_helpers.cc \
objc_field.cc \
objc_message.cc \
google/protobuf/objectivec-descriptor.pb.cc
protoc_gen_objc_arc_LDFLAGS = ${protoc_gen_objc_LDFLAGS}
protoc_gen_objc_arc_SOURCES = ${protoc_gen_objc_SOURCES}
protoc_gen_objc_arc_CPPFLAGS = -D${DEFINES}
google/protobuf/objectivec-descriptor.pb.cc
18 changes: 3 additions & 15 deletions src/compiler/objc_enum_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,14 @@ namespace google { namespace protobuf { namespace compiler { namespace objective


void RepeatedEnumFieldGenerator::GeneratePropertyHeader(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_, "@property (readonly, strong) PBArray * $name$;\n");
#else
printer->Print(variables_, "@property (readonly, retain) PBArray * $name$;\n");
#endif

}


void RepeatedEnumFieldGenerator::GenerateExtensionSource(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_,
"@property (strong) PBAppendableArray * $list_name$;\n");
#else
printer->Print(variables_,
"@property (retain) PBAppendableArray * $list_name$;\n");
#endif
printer->Print(variables_,"@property (strong) PBAppendableArray * $list_name$;\n");
}

void RepeatedEnumFieldGenerator::GenerateSynthesizeSource(io::Printer* printer) const {
Expand Down Expand Up @@ -372,11 +364,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
printer->Print(variables_,
"if (other.$list_name$.count > 0) {\n"
" if (result.$list_name$ == nil) {\n"
#ifdef OBJC_ARC
" result.$list_name$ = [other.$list_name$ copy];\n"
#else
" result.$list_name$ = [[other.$list_name$ copyWithZone:[other.$list_name$ zone]] autorelease];\n"
#endif
" } else {\n"
" [result.$list_name$ appendArray:other.$list_name$];\n"
" }\n"
Expand Down
10 changes: 2 additions & 8 deletions src/compiler/objc_extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,16 @@ namespace google { namespace protobuf { namespace compiler { namespace objective

printer->Print(
vars,
#ifdef OBJC_ARC

" [PBConcreteExtensionField extensionWithType:$extension_type$\n"
#else
" [[PBConcreteExtensionField extensionWithType:$extension_type$\n"
#endif
" extendedClass:[$extended_type$ class]\n"
" fieldNumber:$number$\n"
" defaultValue:$default$\n"
" messageOrGroupClass:[$type$ class]\n"
" isRepeated:$is_repeated$\n"
" isPacked:$is_packed$\n"
#ifdef OBJC_ARC
" isMessageSetWireFormat:$is_wire_format$];\n");
#else
" isMessageSetWireFormat:$is_wire_format$] retain];\n");
#endif

}

void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) {
Expand Down
5 changes: 0 additions & 5 deletions src/compiler/objc_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ namespace google { namespace protobuf { namespace compiler {namespace objectivec
}

printer->Print(
#ifdef OBJC_ARC
"extensionRegistry = registry;\n");
#else
"extensionRegistry = [registry retain];\n");
#endif

printer->Outdent();
printer->Outdent();

Expand Down
41 changes: 0 additions & 41 deletions src/compiler/objc_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,13 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
field_generators_.get(descriptor_->field(i)).GenerateSynthesizeSource(printer);
}

#ifdef OBJC_ARC
printer->Print("- (void) dealloc {\n");
printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i)).GenerateDeallocSource(printer);
}
printer->Outdent();
printer->Print("}\n");

#else
printer->Print("- (void) dealloc {\n");
printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i)).GenerateDeallocSource(printer);
}
printer->Outdent();
printer->Print(
" [super dealloc];\n"
"}\n");
#endif

printer->Print(
"- (id) init {\n"
Expand Down Expand Up @@ -403,11 +390,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective

printer->Print(
"+ ($classname$_Builder*) builder {\n"
#ifdef OBJC_ARC
" return [[$classname$_Builder alloc] init];\n"
#else
" return [[[$classname$_Builder alloc] init] autorelease];\n"
#endif
"}\n"
"+ ($classname$_Builder*) builderWithPrototype:($classname$*) prototype {\n"
" return [[$classname$ builder] mergeFrom:prototype];\n"
Expand Down Expand Up @@ -852,37 +835,21 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
void MessageGenerator::GenerateBuilderSource(io::Printer* printer) {
printer->Print(
"@interface $classname$_Builder()\n"
#ifdef OBJC_ARC
"@property (strong) $classname$* result;\n"
#else
"@property (retain) $classname$* result;\n"
#endif

"@end\n"
"\n"
"@implementation $classname$_Builder\n"
"@synthesize result;\n"
#ifdef OBJC_ARC
"- (void) dealloc {\n"
" self.result = nil;\n"
"}\n"
#else
"- (void) dealloc {\n"
" self.result = nil;\n"
" [super dealloc];\n"
"}\n"
#endif
,
"classname", ClassName(descriptor_));

printer->Print(
"- (id) init {\n"
" if ((self = [super init])) {\n"
#ifdef OBJC_ARC
" self.result = [[$classname$ alloc] init];\n"
#else
" self.result = [[[$classname$ alloc] init] autorelease];\n"
#endif
" }\n"
" return self;\n"
"}\n",
Expand Down Expand Up @@ -914,11 +881,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective

printer->Print(
"- ($classname$_Builder*) clear {\n"
#ifdef OBJC_ARC
" self.result = [[$classname$ alloc] init];\n"
#else
" self.result = [[[$classname$ alloc] init] autorelease];\n"
#endif
" return self;\n"
"}\n"
"- ($classname$_Builder*) clone {\n"
Expand All @@ -944,11 +907,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective

printer->Outdent();
printer->Print(
#ifdef OBJC_ARC
" $classname$* returnMe = result;\n"
#else
" $classname$* returnMe = [[result retain] autorelease];\n"
#endif
" self.result = nil;\n"
" return returnMe;\n"
"}\n",
Expand Down
31 changes: 1 addition & 30 deletions src/compiler/objc_message_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,13 @@ namespace google { namespace protobuf { namespace compiler { namespace objective


void MessageFieldGenerator::GeneratePropertyHeader(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_, "@property (readonly, strong)$storage_attribute$ $storage_type$ $name$;\n");
#else
printer->Print(variables_, "@property (readonly, retain)$storage_attribute$ $storage_type$ $name$;\n");
#endif
}


void MessageFieldGenerator::GenerateExtensionSource(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_,"@property (strong)$storage_attribute$ $storage_type$ $name$;\n");
#else
printer->Print(variables_,"@property (retain)$storage_attribute$ $storage_type$ $name$;\n");
#endif

}


Expand Down Expand Up @@ -298,22 +290,13 @@ namespace google { namespace protobuf { namespace compiler { namespace objective


void RepeatedMessageFieldGenerator::GeneratePropertyHeader(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_, "@property (readonly, strong) PBArray * $name$;\n");
#else
printer->Print(variables_, "@property (readonly, retain) PBArray * $name$;\n");
#endif

}


void RepeatedMessageFieldGenerator::GenerateExtensionSource(io::Printer* printer) const {
#ifdef OBJC_ARC
printer->Print(variables_,"@property (strong) PBAppendableArray * $list_name$;\n");
#else
printer->Print(variables_,"@property (retain) PBAppendableArray * $list_name$;\n");
#endif

}


Expand Down Expand Up @@ -355,11 +338,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
"- ($storage_type$)$name$AtIndex:(NSUInteger)index;\n"
"- ($classname$_Builder *)add$capitalized_name$:($storage_type$)value;\n"
"- ($classname$_Builder *)set$capitalized_name$Array:(NSArray *)array;\n"
#ifdef OBJC_ARC
"- ($classname$_Builder *)set$capitalized_name$Values:(const $storage_type$ __strong *)values count:(NSUInteger)count;\n"
#else
"- ($classname$_Builder *)set$capitalized_name$Values:(const $storage_type$ *)values count:(NSUInteger)count;\n"
#endif
"- ($classname$_Builder *)clear$capitalized_name$;\n");
}

Expand All @@ -382,11 +361,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
" result.$list_name$ = [PBAppendableArray arrayWithArray:array valueType:PBArrayValueTypeObject];\n"
" return self;\n"
"}\n"
#ifdef OBJC_ARC
"- ($classname$_Builder *)set$capitalized_name$Values:(const $storage_type$ __strong *)values count:(NSUInteger)count {\n"
#else
"- ($classname$_Builder *)set$capitalized_name$Values:(const $storage_type$ *)values count:(NSUInteger)count {\n"
#endif
" result.$list_name$ = [PBAppendableArray arrayWithValues:values count:count valueType:PBArrayValueTypeObject];\n"
" return self;\n"
"}\n"
Expand Down Expand Up @@ -421,11 +396,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
printer->Print(variables_,
"if (other.$list_name$.count > 0) {\n"
" if (result.$list_name$ == nil) {\n"
#ifdef OBJC_ARC
" result.$list_name$ = [other.$list_name$ copy];\n"
#else
" result.$list_name$ = [[other.$list_name$ copyWithZone:[other.$list_name$ zone]] autorelease];\n"
#endif
" } else {\n"
" [result.$list_name$ appendArray:other.$list_name$];\n"
" }\n"
Expand Down
Loading

0 comments on commit 3baebcf

Please sign in to comment.