aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2015-06-19 15:58:31 -0700
committerGravatar Paul Yang <TeBoring@users.noreply.github.com>2015-06-19 15:58:31 -0700
commitd3d66d79760f7f233c404c10528fca22f99843b2 (patch)
tree8a0c97de2bf3c1ea686213c9384ef72d5528e3a1 /src
parent5b3a8e76356ef2dcb4a87c3fa7323bdec01cf7ce (diff)
parent8c88957ef375f3b739b6e72ea5c2fb71b12e1fc2 (diff)
Merge pull request #503 from thomasvl/add_nonnill_markup
Add nonnull/nullable/null_resettable markup to ObjC library.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_field.cc4
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_file.cc18
2 files changed, 13 insertions, 9 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc
index 0f96a4e6..cf5d8cfb 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc
@@ -331,7 +331,7 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
}
printer->Print(
variables_,
- "@property(nonatomic, readwrite, $property_storage_attribute$) $property_type$ *$name$$storage_attribute$;\n");
+ "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n");
if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
@@ -379,7 +379,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration(
variables_,
"$comments$"
"$array_comment$"
- "@property(nonatomic, readwrite, strong) $array_storage_type$ *$name$$storage_attribute$;\n"
+ "@property(nonatomic, readwrite, strong, null_resettable) $array_storage_type$ *$name$$storage_attribute$;\n"
"@property(nonatomic, readonly) NSUInteger $name$_Count;\n");
if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC.
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
index 1955c053..5a5c9e9b 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -117,10 +117,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
printer->Print(
"// @@protoc_insertion_point(imports)\n"
+ "\n"
+ "CF_EXTERN_C_BEGIN\n"
"\n");
- printer->Print("CF_EXTERN_C_BEGIN\n\n");
-
set<string> fwd_decls;
for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();
iter != message_generators_.end(); ++iter) {
@@ -134,6 +134,10 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
printer->Print("\n");
}
+ printer->Print(
+ "NS_ASSUME_NONNULL_BEGIN\n"
+ "\n");
+
// need to write out all enums first
for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin();
iter != enum_generators_.end(); ++iter) {
@@ -148,7 +152,6 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
// For extensions to chain together, the Root gets created even if there
// are no extensions.
printer->Print(
- "\n"
"#pragma mark - $root_class_name$\n"
"\n"
"@interface $root_class_name$ : GPBRootObject\n"
@@ -182,11 +185,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
(*iter)->GenerateMessageHeader(printer);
}
- printer->Print("CF_EXTERN_C_END\n");
-
printer->Print(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n");
+ "NS_ASSUME_NONNULL_END\n"
+ "\n"
+ "CF_EXTERN_C_END\n"
+ "\n"
+ "// @@protoc_insertion_point(global_scope)\n");
}
void FileGenerator::GenerateSource(io::Printer *printer) {