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
24fe6ba7
Commit
24fe6ba7
authored
Oct 01, 2015
by
Paul Yang
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #843 from thomasvl/objcpp_enum_fwd_decl
Support enum forward decls in Objective C++
parents
ebf3eb63
ad2d5c92
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
6 deletions
+92
-6
Makefile.am
Makefile.am
+1
-0
GPBBootstrap.h
objectivec/GPBBootstrap.h
+14
-6
project.pbxproj
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+4
-0
project.pbxproj
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+4
-0
GPBObjectiveCPlusPlusTest.mm
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm
+69
-0
No files found.
Makefile.am
View file @
24fe6ba7
...
...
@@ -456,6 +456,7 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/GPBMessageTests+Runtime.m
\
objectivec/Tests/GPBMessageTests+Serialization.m
\
objectivec/Tests/GPBMessageTests.m
\
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm
\
objectivec/Tests/GPBPerfTests.m
\
objectivec/Tests/GPBStringTests.m
\
objectivec/Tests/GPBSwiftTests.swift
\
...
...
objectivec/GPBBootstrap.h
View file @
24fe6ba7
...
...
@@ -46,12 +46,20 @@
// Used in the generated code to give sizes to enums. int32_t was chosen based
// on the fact that Protocol Buffers enums are limited to this range.
// The complexity and double definition here are so we get the nice name
// for objective C, but also define the name with a trailing underscore so
// the Swift bridge will have one where the names line up to support short
// names since they are scoped to the enum.
// https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-XID_11
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
// If the headers are imported into Objective-C++, we can run into an issue
// where the defintion of NS_ENUM (really CF_ENUM) changes based on the C++
// standard that is in effect. If it isn't C++11 or higher, the definition
// doesn't allow us to forward declare. We work around this one case by
// providing a local definition. The default case has to use NS_ENUM for the
// magic that is Swift bridging of enums.
#if (__cplusplus && __cplusplus < 201103L)
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
// GPB_ENUM_FWD_DECLARE is used for forward declaring enums, ex:
// GPB_ENUM_FWD_DECLARE(Foo_Enum)
// @property (nonatomic) Foo_Enum value;
...
...
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
View file @
24fe6ba7
...
...
@@ -58,6 +58,7 @@
F4487C831AAF6AB300531423
/* GPBMessageTests+Merge.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4487C821AAF6AB300531423
/* GPBMessageTests+Merge.m */
;
};
F45C69CC16DFD08D0081955B
/* GPBExtensionInternals.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F45C69CB16DFD08D0081955B
/* GPBExtensionInternals.m */
;
};
F45E57C71AE6DC6A000B7D99
/* text_format_map_unittest_data.txt in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F45E57C61AE6DC6A000B7D99
/* text_format_map_unittest_data.txt */
;
};
F4B51B1E1BBC610700744318
/* GPBObjectiveCPlusPlusTest.mm in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4B51B1D1BBC610700744318
/* GPBObjectiveCPlusPlusTest.mm */
;
};
F4E675971B21D0000054530B
/* Any.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E675871B21D0000054530B
/* Any.pbobjc.m */
;
};
F4E675991B21D0000054530B
/* Api.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E675891B21D0000054530B
/* Api.pbobjc.m */
;
};
F4E6759B1B21D0000054530B
/* Empty.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E6758B1B21D0000054530B
/* Empty.pbobjc.m */
;
};
...
...
@@ -193,6 +194,7 @@
F45C69CB16DFD08D0081955B
/* GPBExtensionInternals.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
GPBExtensionInternals.m
;
sourceTree
=
"<group>"
;
};
F45E57C61AE6DC6A000B7D99
/* text_format_map_unittest_data.txt */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text
;
path
=
text_format_map_unittest_data.txt
;
sourceTree
=
"<group>"
;
};
F4AC9E1D1A8BEB3500BD6E83
/* unittest_cycle.proto */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text
;
path
=
unittest_cycle.proto
;
sourceTree
=
"<group>"
;
};
F4B51B1D1BBC610700744318
/* GPBObjectiveCPlusPlusTest.mm */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.cpp.objcpp
;
path
=
GPBObjectiveCPlusPlusTest.mm
;
sourceTree
=
"<group>"
;
};
F4B6B8AF1A9CC98000892426
/* GPBUnknownField_PackagePrivate.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBUnknownField_PackagePrivate.h
;
sourceTree
=
"<group>"
;
};
F4B6B8B21A9CCBDA00892426
/* GPBUnknownFieldSet_PackagePrivate.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBUnknownFieldSet_PackagePrivate.h
;
sourceTree
=
"<group>"
;
};
F4B6B8B61A9CD1DE00892426
/* GPBExtensionInternals.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBExtensionInternals.h
;
sourceTree
=
"<group>"
;
};
...
...
@@ -415,6 +417,7 @@
F4487C821AAF6AB300531423
/* GPBMessageTests+Merge.m */
,
F4487C741AADF7F500531423
/* GPBMessageTests+Runtime.m */
,
F4487C7E1AAF62CD00531423
/* GPBMessageTests+Serialization.m */
,
F4B51B1D1BBC610700744318
/* GPBObjectiveCPlusPlusTest.mm */
,
F41C175C1833D3310064ED4D
/* GPBPerfTests.m */
,
8BA9364418DA5F4B0056FA2A
/* GPBStringTests.m */
,
8B4248BA1A8C256A00BC1EC6
/* GPBSwiftTests.swift */
,
...
...
@@ -668,6 +671,7 @@
8BBEA4AA147C727D00C4ADB7
/* GPBCodedOuputStreamTests.m in Sources */
,
F4E675B21B21D0A70054530B
/* SourceContext.pbobjc.m in Sources */
,
8BBEA4AC147C727D00C4ADB7
/* GPBMessageTests.m in Sources */
,
F4B51B1E1BBC610700744318
/* GPBObjectiveCPlusPlusTest.mm in Sources */
,
F4487C7F1AAF62CD00531423
/* GPBMessageTests+Serialization.m in Sources */
,
8B4248DC1A92933A00BC1EC6
/* GPBWellKnownTypesTest.m in Sources */
,
F4E675B01B21D0A70054530B
/* Empty.pbobjc.m in Sources */
,
...
...
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
View file @
24fe6ba7
...
...
@@ -66,6 +66,7 @@
F4487C851AAF6AC500531423
/* GPBMessageTests+Merge.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4487C841AAF6AC500531423
/* GPBMessageTests+Merge.m */
;
};
F45C69CC16DFD08D0081955B
/* GPBExtensionInternals.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F45C69CB16DFD08D0081955B
/* GPBExtensionInternals.m */
;
};
F45E57C91AE6DC98000B7D99
/* text_format_map_unittest_data.txt in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F45E57C81AE6DC98000B7D99
/* text_format_map_unittest_data.txt */
;
};
F4B51B1C1BBC5C7100744318
/* GPBObjectiveCPlusPlusTest.mm in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4B51B1B1BBC5C7100744318
/* GPBObjectiveCPlusPlusTest.mm */
;
};
F4E675C81B21D1610054530B
/* Any.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E675B71B21D1440054530B
/* Any.pbobjc.m */
;
};
F4E675C91B21D1610054530B
/* Api.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E675B91B21D1440054530B
/* Api.pbobjc.m */
;
};
F4E675CA1B21D1610054530B
/* Empty.pbobjc.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F4E675BC1B21D1440054530B
/* Empty.pbobjc.m */
;
};
...
...
@@ -214,6 +215,7 @@
F45C69CB16DFD08D0081955B
/* GPBExtensionInternals.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
GPBExtensionInternals.m
;
sourceTree
=
"<group>"
;
};
F45E57C81AE6DC98000B7D99
/* text_format_map_unittest_data.txt */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text
;
path
=
text_format_map_unittest_data.txt
;
sourceTree
=
"<group>"
;
};
F4AC9E1C1A8BEB1000BD6E83
/* unittest_cycle.proto */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text
;
path
=
unittest_cycle.proto
;
sourceTree
=
"<group>"
;
};
F4B51B1B1BBC5C7100744318
/* GPBObjectiveCPlusPlusTest.mm */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.cpp.objcpp
;
path
=
GPBObjectiveCPlusPlusTest.mm
;
sourceTree
=
"<group>"
;
};
F4B6B8B01A9CC99500892426
/* GPBUnknownField_PackagePrivate.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBUnknownField_PackagePrivate.h
;
sourceTree
=
"<group>"
;
};
F4B6B8B11A9CCBBB00892426
/* GPBUnknownFieldSet_PackagePrivate.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBUnknownFieldSet_PackagePrivate.h
;
sourceTree
=
"<group>"
;
};
F4B6B8B31A9CD1C600892426
/* GPBExtensionInternals.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GPBExtensionInternals.h
;
sourceTree
=
"<group>"
;
};
...
...
@@ -453,6 +455,7 @@
F4487C841AAF6AC500531423
/* GPBMessageTests+Merge.m */
,
F4487C761AADF84900531423
/* GPBMessageTests+Runtime.m */
,
F4487C801AAF62FC00531423
/* GPBMessageTests+Serialization.m */
,
F4B51B1B1BBC5C7100744318
/* GPBObjectiveCPlusPlusTest.mm */
,
F41C175C1833D3310064ED4D
/* GPBPerfTests.m */
,
8BA9364418DA5F4B0056FA2A
/* GPBStringTests.m */
,
8B4248B31A8BD96E00BC1EC6
/* GPBSwiftTests.swift */
,
...
...
@@ -770,6 +773,7 @@
F4E675CE1B21D1610054530B
/* Type.pbobjc.m in Sources */
,
F4353D1F1AB88243005A6198
/* GPBDescriptorTests.m in Sources */
,
F4E675CF1B21D1610054530B
/* Wrappers.pbobjc.m in Sources */
,
F4B51B1C1BBC5C7100744318
/* GPBObjectiveCPlusPlusTest.mm in Sources */
,
F4E675C81B21D1610054530B
/* Any.pbobjc.m in Sources */
,
8B4248B41A8BD96E00BC1EC6
/* GPBSwiftTests.swift in Sources */
,
5102DABC1891A073002037B6
/* GPBConcurrencyTests.m in Sources */
,
...
...
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm
0 → 100644
View file @
24fe6ba7
// Protocol Buffers - Google's data interchange format
// Copyright 2013 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBTestUtilities.h"
//
// This is just a compile test (here to make sure things never regress).
//
// Objective C++ can run into issues with how the NS_ENUM/CF_ENUM declartion
// works because of the C++ spec being used for that compilation unit. So
// the fact that these imports all work without errors/warning means things
// are still good.
//
// The "well know types" should have cross file enums needing imports.
#import "GPBProtocolBuffers.h"
// Some of the tests explicitly use cross file enums also.
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestImport.pbobjc.h"
// Sanity check the conditions of the test within the Xcode project.
#if !__cplusplus
#error This isn't compiled as Objective C++?
#elif __cplusplus >= 201103L
// If this trips, it means the Xcode default might have change (or someone
// edited the testing project) and it might be time to revisit the GPB_ENUM
// define in GPBBootstrap.h.
#warning Did the Xcode default for C++ spec change?
#endif
// Dummy XCTest.
@interface GPBObjectiveCPlusPlusTests : GPBTestCase
@end
@implementation GPBObjectiveCPlusPlusTests
- (void)testCPlusPlus {
// Nothing, This was a compile test.
XCTAssertTrue(YES);
}
@end
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