File tree Expand file tree Collapse file tree 7 files changed +120
-6
lines changed
Expand file tree Collapse file tree 7 files changed +120
-6
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #import < Foundation/Foundation.h>
18+
19+ #import " Firestore/Source/Public/FirebaseFirestore/FIRInterface.h"
20+
21+ #import " Firestore/core/src/api/used_by_objective_c.h"
22+ #include " Firestore/core/src/util/string_apple.h"
23+
24+ using firebase::firestore::util::MakeString;
25+
26+ NS_ASSUME_NONNULL_BEGIN
27+
28+ @implementation FIRInterface
29+
30+ + (void )print : (NSString *)content {
31+ CppInterfaceCalledByObjectiveC::print (MakeString (content));
32+ }
33+
34+ @end
35+
36+ NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #import < Foundation/Foundation.h>
18+
19+ NS_ASSUME_NONNULL_BEGIN
20+
21+ @interface FIRInterface : NSObject
22+
23+ #pragma mark - Create Filter
24+
25+ + (void )print : (NSString *)content ;
26+
27+ @end
28+
29+ NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change 1818 @_exported import FirebaseFirestoreCpp
1919#endif // SWIFT_PACKAGE
2020
21- public class SwiftCppWrapper {
21+ public class SwiftCallingCpp {
2222 public init ( _ value: String ) {
23- _ = UsedBySwift ( std. string ( value) )
23+ CppInterfaceCalledBySwift . print ( std. string ( value) )
2424 }
2525}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #include " used_by_objective_c.h"
18+ #include < iostream>
19+
20+ void CppInterfaceCalledByObjectiveC::print (std::string content) {
21+ std::cout << " C++ function runs with value: " << content << std::endl;
22+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #ifndef FIREBASE_USED_BY_SWIFT_H
18+ #define FIREBASE_USED_BY_SWIFT_H
19+
20+ #include < string>
21+
22+ class CppInterfaceCalledByObjectiveC {
23+ public:
24+ static void print (std::string content);
25+ };
26+
27+ #endif // FIREBASE_USED_BY_SWIFT_H
Original file line number Diff line number Diff line change 1919
2020#include < string>
2121
22- class UsedBySwift {
22+ class CppInterfaceCalledBySwift {
2323 public:
24- explicit UsedBySwift (std::string content);
24+ static void print (std::string content);
2525};
2626
2727#endif // FIREBASE_USED_BY_SWIFT_H
Original file line number Diff line number Diff line change 1717#include " ../include/used_by_swift.h"
1818#include < iostream>
1919
20- UsedBySwift::UsedBySwift (std::string content) {
21- std::cout << " ctor runs with value: " << content << std::endl;
20+ void CppInterfaceCalledBySwift::print (std::string content) {
21+ std::cout << " C++ function runs with value: " << content << std::endl;
2222}
You can’t perform that action at this time.
0 commit comments