///
/// AppleAuth-Swift-Cxx-Bridge.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#include "AppleAuth-Swift-Cxx-Bridge.hpp"

// Include C++ implementation defined types
#include "AppleAuth-Swift-Cxx-Umbrella.hpp"
#include "HybridAppleAuthSpecSwift.hpp"

namespace margelo::nitro::appleauth::bridge::swift {

  // pragma MARK: std::function<void(const std::optional<AppleAuthCredential>& /* result */)>
  Func_void_std__optional_AppleAuthCredential_ create_Func_void_std__optional_AppleAuthCredential_(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = AppleAuth::Func_void_std__optional_AppleAuthCredential_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::optional<AppleAuthCredential>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
  Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = AppleAuth::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
      swiftClosure.call(error);
    };
  }
  
  // pragma MARK: std::shared_ptr<margelo::nitro::appleauth::HybridAppleAuthSpec>
  std::shared_ptr<margelo::nitro::appleauth::HybridAppleAuthSpec> create_std__shared_ptr_margelo__nitro__appleauth__HybridAppleAuthSpec_(void* _Nonnull swiftUnsafePointer) {
    AppleAuth::HybridAppleAuthSpec_cxx swiftPart = AppleAuth::HybridAppleAuthSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::appleauth::HybridAppleAuthSpecSwift>(swiftPart);
  }
  void* _Nonnull get_std__shared_ptr_margelo__nitro__appleauth__HybridAppleAuthSpec_(std__shared_ptr_margelo__nitro__appleauth__HybridAppleAuthSpec_ cppType) {
    std::shared_ptr<margelo::nitro::appleauth::HybridAppleAuthSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::appleauth::HybridAppleAuthSpecSwift>(cppType);
  #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridAppleAuthSpec\" is not implemented in Swift!");
    }
  #endif
    AppleAuth::HybridAppleAuthSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }

} // namespace margelo::nitro::appleauth::bridge::swift
