Skip to content

Commit adf74af

Browse files
committed
consolidate public headers into one place
1 parent cbd135f commit adf74af

20 files changed

+71
-197
lines changed

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

+9-11
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,35 @@ namespace api {
2626
class Firestore;
2727
class PipelineResult;
2828
} // namespace api
29-
3029
namespace core {
3130
template <typename T>
3231
class EventListener;
3332
} // namespace core
34-
3533
} // namespace firestore
3634
} // namespace firebase
37-
3835
namespace api = firebase::firestore::api;
3936
namespace core = firebase::firestore::core;
4037

4138
NS_ASSUME_NONNULL_BEGIN
4239

4340
typedef api::PipelineResult CppPipelineResult;
4441

45-
typedef void (^PipelineBlock)(CppPipelineResult *_Nullable result, NSError *_Nullable error)
42+
typedef void (^PipelineBlock)(CppPipelineResult* _Nullable result,
43+
NSError* _Nullable error)
4644
NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.");
4745

4846
NS_SWIFT_SENDABLE
4947
NS_SWIFT_NAME(CallbackWrapper)
5048
@interface FIRCallbackWrapper : NSObject
51-
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.
49+
// Note: Marking callbacks in callback-based APIs as `Sendable` can help prevent
50+
// crashes when they are invoked on a different thread than the one they were
51+
// originally defined in. If this callback is expected to be called on a
52+
// different thread, it should be marked as `Sendable` to ensure thread safety.
5653
+ (std::shared_ptr<core::EventListener<api::PipelineResult>>)
5754
wrapPipelineCallback:(std::shared_ptr<api::Firestore>)firestore
58-
completion:(void (^NS_SWIFT_SENDABLE)(CppPipelineResult *_Nullable result,
59-
NSError *_Nullable error))completion
55+
completion:(void (^NS_SWIFT_SENDABLE)(
56+
CppPipelineResult* _Nullable result,
57+
NSError* _Nullable error))completion
6058
NS_SWIFT_NAME(wrapPipelineCallback(firestore:completion:));
6159

6260
@end

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

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

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

15-
#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_
16-
#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_
15+
#ifndef FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_
16+
#define FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_
1717

1818
#include <memory>
1919

20-
#include "Firestore/core/interfaceForSwift/api/pipeline_source.h"
20+
#include "Firestore/core/src/api/pipeline_source.h"
2121

2222
namespace firebase {
2323
namespace firestore {
@@ -34,4 +34,4 @@ class FirestorePipeline {
3434
} // namespace firestore
3535
} // namespace firebase
3636

37-
#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_
37+
#endif // FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_

Firestore/core/interfaceForSwift/api/Pipeline.cc Firestore/core/src/api/pipeline.cc

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

15-
#include "Firestore/core/interfaceForSwift/api/Pipeline.h"
15+
#include "Firestore/core/src/api/pipeline.h"
1616

17-
#include <future>
17+
#include <future> // NOLINT(build/c++11)
1818
#include <memory>
1919

2020
#include "Firestore/core/include/firebase/firestore/timestamp.h"
21-
#include "Firestore/core/interfaceForSwift/api/PipelineResult.h"
2221
#include "Firestore/core/src/api/firestore.h"
2322
#include "Firestore/core/src/api/listener_registration.h"
23+
#include "Firestore/core/src/api/pipeline_result.h"
2424
#include "Firestore/core/src/api/source.h"
2525
#include "Firestore/core/src/core/event_listener.h"
2626
#include "Firestore/core/src/core/listen_options.h"

Firestore/core/interfaceForSwift/api/Pipeline.h Firestore/core/src/api/pipeline.h

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

15-
#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_
16-
#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_
15+
#ifndef FIRESTORE_CORE_SRC_API_PIPELINE_H_
16+
#define FIRESTORE_CORE_SRC_API_PIPELINE_H_
1717

1818
#include <functional>
1919
#include <memory>
2020
#include <vector>
21-
#include "PipelineResult.h"
22-
#include "Stage.h"
21+
#include "Firestore/core/src/api/pipeline_result.h"
22+
#include "Firestore/core/src/api/stage.h"
2323

2424
namespace firebase {
2525
namespace firestore {
@@ -57,4 +57,4 @@ class Pipeline {
5757
} // namespace firestore
5858
} // namespace firebase
5959

60-
#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_
60+
#endif // FIRESTORE_CORE_SRC_API_PIPELINE_H_

Firestore/core/interfaceForSwift/api/PipelineResult.cc Firestore/core/src/api/pipeline_result.cc

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

15-
#include <iostream>
16-
15+
#include "Firestore/core/src/api/pipeline_result.h"
1716
#include "Firestore/core/include/firebase/firestore/timestamp.h"
18-
#include "Firestore/core/interfaceForSwift/api/PipelineResult.h"
1917

2018
namespace firebase {
2119
namespace firestore {

Firestore/core/interfaceForSwift/api/PipelineResult.h Firestore/core/src/api/pipeline_result.h

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

15-
#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_
16-
#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_
15+
#ifndef FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_
16+
#define FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_
1717

1818
#include <memory>
1919

@@ -48,4 +48,4 @@ class PipelineResult {
4848

4949
} // namespace firestore
5050
} // namespace firebase
51-
#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_
51+
#endif // FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_

0 commit comments

Comments
 (0)