Skip to content

Commit 967b626

Browse files
committed
consolidate public headers into one place
1 parent 31ba446 commit 967b626

25 files changed

+94
-215
lines changed

FirebaseFirestore.podspec

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
3535
s.pod_target_xcconfig = {
3636
# Enables C++ <-> Swift interop (by default it's only C)
3737
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
38+
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}/Firestore/core/src/api"'
3839
}
3940

4041
s.resource_bundles = {

FirebaseFirestoreInternal.podspec

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
3030
# framework.
3131
s.public_header_files = [
3232
'Firestore/Source/Public/FirebaseFirestore/*.h',
33-
'Firestore/core/interfaceForSwift/api/*.h'
33+
'Firestore/core/src/api/FirebaseFirestoreCpp.h'
3434
]
3535

3636
# source_files contains most of the header and source files for the project.
@@ -54,8 +54,8 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
5454
'Firestore/Protos/nanopb/**/*.cc',
5555
'Firestore/core/include/**/*.{cc,mm}',
5656
'Firestore/core/src/**/*.{cc,mm}',
57+
'Firestore/core/src/api/*.{cc,mm}',
5758
'FirebaseAuth/Interop/**/*.h',
58-
'Firestore/core/interfaceForSwift/**/*.{cc,h}',
5959
]
6060

6161
# Internal headers that aren't necessarily globally unique. Most C++ internal
@@ -132,6 +132,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
132132
'HEADER_SEARCH_PATHS' =>
133133
'"${PODS_TARGET_SRCROOT}" ' +
134134
'"${PODS_TARGET_SRCROOT}/Firestore/Source/Public" ' +
135+
'"${PODS_TARGET_SRCROOT}/Firestore/core/src/api" ' +
135136
'"${PODS_ROOT}/nanopb" ' +
136137
'"${PODS_TARGET_SRCROOT}/Firestore/Protos/nanopb"'
137138
}

Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_macOS.xcscheme

+9-13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "54B8E4A9224BDC4100930F18"
34+
BuildableName = "Firestore_IntegrationTests_macOS.xctest"
35+
BlueprintName = "Firestore_IntegrationTests_macOS"
36+
ReferencedContainer = "container:Firestore.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3039
<Testables>
3140
<TestableReference
3241
skipped = "NO">
@@ -39,17 +48,6 @@
3948
</BuildableReference>
4049
</TestableReference>
4150
</Testables>
42-
<MacroExpansion>
43-
<BuildableReference
44-
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "54B8E4A9224BDC4100930F18"
46-
BuildableName = "Firestore_IntegrationTests_macOS.xctest"
47-
BlueprintName = "Firestore_IntegrationTests_macOS"
48-
ReferencedContainer = "container:Firestore.xcodeproj">
49-
</BuildableReference>
50-
</MacroExpansion>
51-
<AdditionalOptions>
52-
</AdditionalOptions>
5351
</TestAction>
5452
<LaunchAction
5553
buildConfiguration = "Debug"
@@ -70,8 +68,6 @@
7068
ReferencedContainer = "container:Firestore.xcodeproj">
7169
</BuildableReference>
7270
</MacroExpansion>
73-
<AdditionalOptions>
74-
</AdditionalOptions>
7571
</LaunchAction>
7672
<ProfileAction
7773
buildConfiguration = "Release"

Firestore/Source/Public/FirebaseFirestore/FirebaseFirestore.h

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#import "FIRAggregateQuery.h"
1919
#import "FIRAggregateQuerySnapshot.h"
2020
#import "FIRAggregateSource.h"
21-
#import "FIRCallbackWrapper.h"
2221
#import "FIRCollectionReference.h"
2322
#import "FIRDocumentChange.h"
2423
#import "FIRDocumentReference.h"

Firestore/core/interfaceForSwift/api/CollectionStage.h

-39
This file was deleted.

Firestore/core/interfaceForSwift/api/FirestorePipeline.h

-37
This file was deleted.

Firestore/core/interfaceForSwift/api/PipelineSource.h

-47
This file was deleted.

Firestore/Source/Public/FirebaseFirestore/FIRCallbackWrapper.h Firestore/core/src/api/FIRCallbackWrapper.h

+17-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
#ifndef FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_
18+
#define FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_
19+
1720
#import <Foundation/Foundation.h>
1821

1922
#if defined(__cplusplus)
@@ -26,40 +29,43 @@ namespace api {
2629
class Firestore;
2730
class PipelineResult;
2831
} // namespace api
29-
3032
namespace core {
3133
template <typename T>
3234
class EventListener;
3335
} // namespace core
34-
3536
} // namespace firestore
3637
} // namespace firebase
37-
3838
namespace api = firebase::firestore::api;
3939
namespace core = firebase::firestore::core;
4040

4141
NS_ASSUME_NONNULL_BEGIN
4242

4343
typedef api::PipelineResult CppPipelineResult;
4444

45-
typedef void (^PipelineBlock)(CppPipelineResult *_Nullable result, NSError *_Nullable error)
45+
typedef void (^PipelineBlock)(CppPipelineResult* _Nullable result,
46+
NSError* _Nullable error)
4647
NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.");
4748

4849
NS_SWIFT_SENDABLE
4950
NS_SWIFT_NAME(CallbackWrapper)
5051
@interface FIRCallbackWrapper : NSObject
5152

52-
// Note: Marking callbacks in callback-based APIs as `Sendable` can help prevent crashes when they
53-
// are invoked on a different thread than the one they were originally defined in. If this callback
54-
// is expected to be called on a different thread, it should be marked as `Sendable` to ensure
55-
// thread safety.
53+
// Note: Marking callbacks in callback-based APIs as `Sendable` can help prevent
54+
// crashes when they are invoked on a different thread than the one they were
55+
// originally defined in. If this callback is expected to be called on a
56+
// different thread, it should be marked as `Sendable` to ensure thread safety.
5657
+ (std::shared_ptr<core::EventListener<api::PipelineResult>>)
58+
// NOLINTNEXTLINE(whitespace/parens)
5759
wrapPipelineCallback:(std::shared_ptr<api::Firestore>)firestore
58-
completion:(void (^NS_SWIFT_SENDABLE)(CppPipelineResult *_Nullable result,
59-
NSError *_Nullable error))completion
60+
// NOLINTNEXTLINE(whitespace/parens)
61+
completion:(void (^NS_SWIFT_SENDABLE)(
62+
CppPipelineResult* _Nullable result,
63+
NSError* _Nullable error))completion
6064
NS_SWIFT_NAME(wrapPipelineCallback(firestore:completion:));
6165

6266
@end
6367

6468
NS_ASSUME_NONNULL_END
65-
#endif
69+
#endif // defined(__cplusplus)
70+
71+
#endif // FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_

Firestore/Source/API/FIRCallbackWrapper.mm Firestore/core/src/api/FIRCallbackWrapper.mm

+16-12
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <utility>
2121
#include <vector>
2222

23-
#include "Firestore/core/interfaceForSwift/api/Pipeline.h"
24-
#include "Firestore/core/interfaceForSwift/api/PipelineResult.h"
23+
#include "Firestore/core/src/api/pipeline.h"
24+
#include "Firestore/core/src/api/pipeline_result.h"
2525
#include "Firestore/core/src/core/event_listener.h"
2626
#include "Firestore/core/src/util/error_apple.h"
2727
#include "Firestore/core/src/util/statusor.h"
@@ -34,18 +34,22 @@
3434

3535
@implementation FIRCallbackWrapper
3636

37-
// In public Swift documentation for integrating Swift and C++, using raw pointers in C++ is
38-
// generally considered unsafe. However, during an experiment where the result was passed as a value
39-
// instead of a pointer, a double free error occurred. This issue could not be traced effectively
40-
// because the implementation resides within the Swift-C++ transition layer. In this specific use
41-
// case, the C++ OnEvent() scope is destroyed after the Swift callback has been destroyed. Due to
42-
// this ordering, using a raw pointer is a safe workaround for now.
43-
+ (PipelineSnapshotListener)wrapPipelineCallback:(std::shared_ptr<api::Firestore>)firestore
44-
completion:(void (^)(CppPipelineResult *_Nullable result,
45-
NSError *_Nullable error))completion {
37+
// In public Swift documentation for integrating Swift and C++, using raw
38+
// pointers in C++ is generally considered unsafe. However, during an experiment
39+
// where the result was passed as a value instead of a pointer, a double free
40+
// error occurred. This issue could not be traced effectively because the
41+
// implementation resides within the Swift-C++ transition layer. In this
42+
// specific use case, the C++ OnEvent() scope is destroyed after the Swift
43+
// callback has been destroyed. Due to this ordering, using a raw pointer is a
44+
// safe workaround for now.
45+
+ (PipelineSnapshotListener)
46+
wrapPipelineCallback:(std::shared_ptr<api::Firestore>)firestore
47+
completion:(void (^)(CppPipelineResult* _Nullable result,
48+
NSError* _Nullable error))completion {
4649
class Converter : public EventListener<CppPipelineResult> {
4750
public:
48-
explicit Converter(std::shared_ptr<api::Firestore> firestore, PipelineBlock completion)
51+
explicit Converter(std::shared_ptr<api::Firestore> firestore,
52+
PipelineBlock completion)
4953
: firestore_(firestore), completion_(completion) {
5054
}
5155

Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h Firestore/core/src/api/FirebaseFirestoreCpp.h

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_
18-
#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_
17+
#ifndef FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_
18+
#define FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_
1919

20-
#import "Firestore/core/interfaceForSwift/api/collection_stage.h"
21-
#import "Firestore/core/interfaceForSwift/api/firestore_pipeline.h"
22-
#import "Firestore/core/interfaceForSwift/api/pipeline.h"
23-
#import "Firestore/core/interfaceForSwift/api/pipeline_result.h"
24-
#import "Firestore/core/interfaceForSwift/api/pipeline_source.h"
25-
#import "Firestore/core/interfaceForSwift/api/stage.h"
20+
#import "Firestore/core/src/api/FIRCallbackWrapper.h"
21+
#import "Firestore/core/src/api/collection_stage.h"
22+
#import "Firestore/core/src/api/firestore_pipeline.h"
23+
#import "Firestore/core/src/api/pipeline.h"
24+
#import "Firestore/core/src/api/pipeline_result.h"
25+
#import "Firestore/core/src/api/pipeline_source.h"
26+
#import "Firestore/core/src/api/stage.h"
2627

27-
#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_
28+
#endif // FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_

Firestore/core/interfaceForSwift/api/CollectionStage.cc Firestore/core/src/api/collection_stage.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "Firestore/core/interfaceForSwift/api/CollectionStage.h"
15+
#include "Firestore/core/src/api/collection_stage.h"
1616
#include <iostream>
1717

1818
namespace firebase {

Firestore/core/interfaceForSwift/api/collection_stage.h Firestore/core/src/api/collection_stage.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_
16-
#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_
15+
#ifndef FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_
16+
#define FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_
1717

1818
#include <string>
19-
#include "Firestore/core/interfaceForSwift/api/stage.h"
19+
#include "Firestore/core/src/api/stage.h"
2020

2121
namespace firebase {
2222
namespace firestore {
@@ -36,4 +36,4 @@ class Collection : public Stage {
3636
} // namespace firestore
3737
} // namespace firebase
3838

39-
#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_
39+
#endif // FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_

Firestore/core/src/api/firestore.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include <mutex>
2222
#include <string>
2323

24-
#include "Firestore/core/interfaceForSwift/api/PipelineSource.h"
2524
#include "Firestore/core/src/api/api_fwd.h"
2625
#include "Firestore/core/src/api/load_bundle_task.h"
26+
#include "Firestore/core/src/api/pipeline_source.h"
2727
#include "Firestore/core/src/api/settings.h"
2828
#include "Firestore/core/src/core/core_fwd.h"
2929
#include "Firestore/core/src/credentials/credentials_fwd.h"

Firestore/core/interfaceForSwift/api/FirestorePipeline.cc Firestore/core/src/api/firestore_pipeline.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "Firestore/core/interfaceForSwift/api/FirestorePipeline.h"
15+
#include "Firestore/core/src/api/firestore_pipeline.h"
1616

1717
#include <memory>
1818

0 commit comments

Comments
 (0)