Open
Show file tree
Hide file tree
Changes from 3 commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
Expand Up@@ -407,6 +407,11 @@ class Future : public FutureBase {
/// when you set up the callback.
typedef void (*TypedCompletionCallback)(const Future<ResultType>& result_data,
void* user_data);
#if defined(__swift__)
// TODO(apple/swift#67662) indirect block parameters are unsupported
typedef void (*TypedCompletionCallback_SwiftWorkaround)(
const Future<ResultType>* result_data, void* user_data);
#endif

/// Construct a future.
Future() {}
Expand DownExpand Up@@ -464,6 +469,16 @@ class Future : public FutureBase {
inline void OnCompletion(TypedCompletionCallback callback,
void* user_data) const;

#if defined(__swift__)
// TODO(apple/swift#67662) indirect block parameters are unsupported
inline void OnCompletion_SwiftWorkaround(
TypedCompletionCallback_SwiftWorkaround callback, void* user_data) const {
OnCompletion([callback, user_data](const Future<ResultType>& future) {
callback(&future, user_data);
});
}
#endif

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/// Register a single callback that will be called at most once, when the
/// future is completed.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#define __swift__ 50000
#include "auth/src/include/firebase/auth.h"

#if FIREBASE_PLATFORM_WINDOWS
namespace firebase {
namespace auth {
Auth::Auth(const Auth &) noexcept = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm uncomfortable having this copy constructor broadly available for all Windows developers. Could you wrap this and all of the other changes in an #if for the Swift compatibility that you can use in your build? e.g. FIREBASE_SWIFT_WINDOWS=1

Copy link
Contributor Author

@compnerd compnerd Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't work. That would mean that the distribution of firebase would not be usable as the copy-constructor would not be available when used for Swift.

Note that the header actually indicates that the copy constructor is not declared (and thus the compiler will synthesize one - except because it is a movable type, it will prefer to move it) when the interop is not enabled. This means that this is only going to add the distribution size but will be discarded by the linker as static linking is employed. As a result the copy constructor is not available for Windows developers, they would need to define __swift__ for it to be made available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm following. I'll take another look at this after our next release goes out.

}
} // namespace firebase
#endif
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,13 @@ class Auth {

~Auth();

#if defined(__swift__)
#if FIREBASE_PLATFORM_WINDOWS
// TODO(apple/swift#67288) support trivial C++ types with non-trivial dtors
Auth(const Auth&) noexcept;
#endif
#endif

/// Synchronously gets the cached current user, or returns an object where
/// is_valid() == false if there is none.
///
Expand Down