Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
a771c9e1
Commit
a771c9e1
authored
Apr 04, 2016
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #852 from qzix/master
Added deprecated option handling to objective-c
parents
452e2b2c
268ce281
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
11 deletions
+41
-11
objectivec_enum.cc
src/google/protobuf/compiler/objectivec/objectivec_enum.cc
+4
-2
objectivec_field.cc
src/google/protobuf/compiler/objectivec/objectivec_field.cc
+9
-8
objectivec_file.cc
src/google/protobuf/compiler/objectivec/objectivec_file.cc
+10
-0
objectivec_helpers.h
src/google/protobuf/compiler/objectivec/objectivec_helpers.h
+16
-0
objectivec_message.cc
...google/protobuf/compiler/objectivec/objectivec_message.cc
+2
-1
No files found.
src/google/protobuf/compiler/objectivec/objectivec_enum.cc
View file @
a771c9e1
...
@@ -72,8 +72,9 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
...
@@ -72,8 +72,9 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
"
\n
"
,
"
\n
"
,
"name"
,
name_
);
"name"
,
name_
);
printer
->
Print
(
"$comments$typedef GPB_ENUM($name$) {
\n
"
,
printer
->
Print
(
"$comments$typedef
$deprecated_attribute$
GPB_ENUM($name$) {
\n
"
,
"comments"
,
enum_comments
,
"comments"
,
enum_comments
,
"deprecated_attribute"
,
GetOptionalDeprecatedAttribute
(
descriptor_
),
"name"
,
name_
);
"name"
,
name_
);
printer
->
Indent
();
printer
->
Indent
();
...
@@ -99,8 +100,9 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
...
@@ -99,8 +100,9 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
}
}
printer
->
Print
(
printer
->
Print
(
"$name$ = $value$,
\n
"
,
"$name$
$deprecated_attribute$
= $value$,
\n
"
,
"name"
,
EnumValueName
(
all_values_
[
i
]),
"name"
,
EnumValueName
(
all_values_
[
i
]),
"deprecated_attribute"
,
GetOptionalDeprecatedAttribute
(
all_values_
[
i
]),
"value"
,
SimpleItoa
(
all_values_
[
i
]
->
number
()));
"value"
,
SimpleItoa
(
all_values_
[
i
]
->
number
()));
}
}
printer
->
Outdent
();
printer
->
Outdent
();
...
...
src/google/protobuf/compiler/objectivec/objectivec_field.cc
View file @
a771c9e1
...
@@ -78,6 +78,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
...
@@ -78,6 +78,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
classname
+
"_FieldNumber_"
+
capitalized_name
;
classname
+
"_FieldNumber_"
+
capitalized_name
;
(
*
variables
)[
"field_number"
]
=
SimpleItoa
(
descriptor
->
number
());
(
*
variables
)[
"field_number"
]
=
SimpleItoa
(
descriptor
->
number
());
(
*
variables
)[
"field_type"
]
=
GetCapitalizedType
(
descriptor
);
(
*
variables
)[
"field_type"
]
=
GetCapitalizedType
(
descriptor
);
(
*
variables
)[
"deprecated_attribute"
]
=
GetOptionalDeprecatedAttribute
(
descriptor
);
std
::
vector
<
string
>
field_flags
;
std
::
vector
<
string
>
field_flags
;
if
(
descriptor
->
is_repeated
())
field_flags
.
push_back
(
"GPBFieldRepeated"
);
if
(
descriptor
->
is_repeated
())
field_flags
.
push_back
(
"GPBFieldRepeated"
);
if
(
descriptor
->
is_required
())
field_flags
.
push_back
(
"GPBFieldRequired"
);
if
(
descriptor
->
is_required
())
field_flags
.
push_back
(
"GPBFieldRequired"
);
...
@@ -266,12 +267,12 @@ void SingleFieldGenerator::GeneratePropertyDeclaration(
...
@@ -266,12 +267,12 @@ void SingleFieldGenerator::GeneratePropertyDeclaration(
printer
->
Print
(
variables_
,
"$comments$"
);
printer
->
Print
(
variables_
,
"$comments$"
);
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
"@property(nonatomic, readwrite) $property_type$ $name$;
\n
"
"@property(nonatomic, readwrite) $property_type$ $name$
$deprecated_attribute$
;
\n
"
"
\n
"
);
"
\n
"
);
if
(
WantsHasProperty
())
{
if
(
WantsHasProperty
())
{
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
"@property(nonatomic, readwrite) BOOL has$capitalized_name$;
\n
"
);
"@property(nonatomic, readwrite) BOOL has$capitalized_name$
$deprecated_attribute$
;
\n
"
);
}
}
}
}
...
@@ -330,18 +331,18 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
...
@@ -330,18 +331,18 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
printer
->
Print
(
variables_
,
"$comments$"
);
printer
->
Print
(
variables_
,
"$comments$"
);
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
"@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;
\n
"
);
"@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$
$deprecated_attribute$
;
\n
"
);
if
(
WantsHasProperty
())
{
if
(
WantsHasProperty
())
{
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
"/// Test to see if @c $name$ has been set.
\n
"
"/// Test to see if @c $name$ has been set.
\n
"
"@property(nonatomic, readwrite) BOOL has$capitalized_name$;
\n
"
);
"@property(nonatomic, readwrite) BOOL has$capitalized_name$
$deprecated_attribute$
;
\n
"
);
}
}
if
(
IsInitName
(
variables_
.
find
(
"name"
)
->
second
))
{
if
(
IsInitName
(
variables_
.
find
(
"name"
)
->
second
))
{
// If property name starts with init we need to annotate it to get past ARC.
// 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
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
printer
->
Print
(
variables_
,
printer
->
Print
(
variables_
,
"- ($property_type$ *)$name$ GPB_METHOD_FAMILY_NONE;
\n
"
);
"- ($property_type$ *)$name$ GPB_METHOD_FAMILY_NONE
$deprecated_attribute$
;
\n
"
);
}
}
printer
->
Print
(
"
\n
"
);
printer
->
Print
(
"
\n
"
);
}
}
...
@@ -385,14 +386,14 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration(
...
@@ -385,14 +386,14 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration(
variables_
,
variables_
,
"$comments$"
"$comments$"
"$array_comment$"
"$array_comment$"
"@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$;
\n
"
"@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$
$deprecated_attribute$
;
\n
"
"/// The number of items in @c $name$ without causing the array to be created.
\n
"
"/// The number of items in @c $name$ without causing the array to be created.
\n
"
"@property(nonatomic, readonly) NSUInteger $name$_Count;
\n
"
);
"@property(nonatomic, readonly) NSUInteger $name$_Count
$deprecated_attribute$
;
\n
"
);
if
(
IsInitName
(
variables_
.
find
(
"name"
)
->
second
))
{
if
(
IsInitName
(
variables_
.
find
(
"name"
)
->
second
))
{
// If property name starts with init we need to annotate it to get past ARC.
// 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
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
printer
->
Print
(
variables_
,
printer
->
Print
(
variables_
,
"- ($array_property_type$ *)$name$ GPB_METHOD_FAMILY_NONE;
\n
"
);
"- ($array_property_type$ *)$name$ GPB_METHOD_FAMILY_NONE
$deprecated_attribute$
;
\n
"
);
}
}
printer
->
Print
(
"
\n
"
);
printer
->
Print
(
"
\n
"
);
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_file.cc
View file @
a771c9e1
...
@@ -115,6 +115,9 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
...
@@ -115,6 +115,9 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
printer
->
Print
(
printer
->
Print
(
"// @@protoc_insertion_point(imports)
\n
"
"// @@protoc_insertion_point(imports)
\n
"
"
\n
"
"
\n
"
"#pragma clang diagnostic push
\n
"
"#pragma clang diagnostic ignored
\"
-Wdeprecated-declarations
\"\n
"
"
\n
"
"CF_EXTERN_C_BEGIN
\n
"
"CF_EXTERN_C_BEGIN
\n
"
"
\n
"
);
"
\n
"
);
...
@@ -189,6 +192,8 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
...
@@ -189,6 +192,8 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
"
\n
"
"
\n
"
"CF_EXTERN_C_END
\n
"
"CF_EXTERN_C_END
\n
"
"
\n
"
"
\n
"
"#pragma clang diagnostic pop
\n
"
"
\n
"
"// @@protoc_insertion_point(global_scope)
\n
"
);
"// @@protoc_insertion_point(global_scope)
\n
"
);
}
}
...
@@ -216,6 +221,9 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
...
@@ -216,6 +221,9 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
}
}
printer
->
Print
(
printer
->
Print
(
"// @@protoc_insertion_point(imports)
\n
"
"// @@protoc_insertion_point(imports)
\n
"
"
\n
"
"#pragma clang diagnostic push
\n
"
"#pragma clang diagnostic ignored
\"
-Wdeprecated-declarations
\"\n
"
"
\n
"
);
"
\n
"
);
printer
->
Print
(
printer
->
Print
(
...
@@ -342,6 +350,8 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
...
@@ -342,6 +350,8 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
}
}
printer
->
Print
(
printer
->
Print
(
"
\n
"
"#pragma clang diagnostic pop
\n
"
"
\n
"
"
\n
"
"// @@protoc_insertion_point(global_scope)
\n
"
);
"// @@protoc_insertion_point(global_scope)
\n
"
);
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_helpers.h
View file @
a771c9e1
...
@@ -133,6 +133,22 @@ enum ObjectiveCType {
...
@@ -133,6 +133,22 @@ enum ObjectiveCType {
OBJECTIVECTYPE_MESSAGE
OBJECTIVECTYPE_MESSAGE
};
};
template
<
class
TDescriptor
>
string
GetOptionalDeprecatedAttribute
(
const
TDescriptor
*
descriptor
,
bool
preSpace
=
true
,
bool
postNewline
=
false
)
{
if
(
descriptor
->
options
().
deprecated
())
{
string
result
=
"DEPRECATED_ATTRIBUTE"
;
if
(
preSpace
)
{
result
.
insert
(
0
,
" "
);
}
if
(
postNewline
)
{
result
.
append
(
"
\n
"
);
}
return
result
;
}
else
{
return
""
;
}
}
string
GetCapitalizedType
(
const
FieldDescriptor
*
field
);
string
GetCapitalizedType
(
const
FieldDescriptor
*
field
);
ObjectiveCType
GetObjectiveCType
(
FieldDescriptor
::
Type
field_type
);
ObjectiveCType
GetObjectiveCType
(
FieldDescriptor
::
Type
field_type
);
...
...
src/google/protobuf/compiler/objectivec/objectivec_message.cc
View file @
a771c9e1
...
@@ -321,8 +321,9 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
...
@@ -321,8 +321,9 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
}
}
printer
->
Print
(
printer
->
Print
(
"$comments$@interface $classname$ : GPBMessage
\n\n
"
,
"$comments$
$deprecated_attribute$
@interface $classname$ : GPBMessage
\n\n
"
,
"classname"
,
class_name_
,
"classname"
,
class_name_
,
"deprecated_attribute"
,
GetOptionalDeprecatedAttribute
(
descriptor_
,
false
,
true
),
"comments"
,
message_comments
);
"comments"
,
message_comments
);
vector
<
char
>
seen_oneofs
(
descriptor_
->
oneof_decl_count
(),
0
);
vector
<
char
>
seen_oneofs
(
descriptor_
->
oneof_decl_count
(),
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment