feat: implement Haptika PPG and Watch V1
This commit is contained in:
Generated
+201
@@ -0,0 +1,201 @@
|
||||
///
|
||||
/// HybridHaptikaHealthKitSpec_cxx.swift
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
import NitroModules
|
||||
|
||||
/**
|
||||
* A class implementation that bridges HybridHaptikaHealthKitSpec over to C++.
|
||||
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
||||
*
|
||||
* Also, some Swift types need to be bridged with special handling:
|
||||
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
||||
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
||||
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
||||
*/
|
||||
open class HybridHaptikaHealthKitSpec_cxx {
|
||||
/**
|
||||
* The Swift <> C++ bridge's namespace (`margelo::nitro::haptika::ppg::bridge::swift`)
|
||||
* from `HaptikaPPG-Swift-Cxx-Bridge.hpp`.
|
||||
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
||||
*/
|
||||
public typealias bridge = margelo.nitro.haptika.ppg.bridge.swift
|
||||
|
||||
/**
|
||||
* Holds an instance of the `HybridHaptikaHealthKitSpec` Swift protocol.
|
||||
*/
|
||||
private var __implementation: any HybridHaptikaHealthKitSpec
|
||||
|
||||
/**
|
||||
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
||||
*/
|
||||
private var __cxxPart: bridge.std__weak_ptr_HybridHaptikaHealthKitSpec_
|
||||
|
||||
/**
|
||||
* Create a new `HybridHaptikaHealthKitSpec_cxx` that wraps the given `HybridHaptikaHealthKitSpec`.
|
||||
* All properties and methods bridge to C++ types.
|
||||
*/
|
||||
public init(_ implementation: any HybridHaptikaHealthKitSpec) {
|
||||
self.__implementation = implementation
|
||||
self.__cxxPart = .init()
|
||||
/* no base class */
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual `HybridHaptikaHealthKitSpec` instance this class wraps.
|
||||
*/
|
||||
@inline(__always)
|
||||
public func getHybridHaptikaHealthKitSpec() -> any HybridHaptikaHealthKitSpec {
|
||||
return __implementation
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts this instance to a retained unsafe raw pointer.
|
||||
* This acquires one additional strong reference on the object!
|
||||
*/
|
||||
public func toUnsafe() -> UnsafeMutableRawPointer {
|
||||
return Unmanaged.passRetained(self).toOpaque()
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts an unsafe pointer to a `HybridHaptikaHealthKitSpec_cxx`.
|
||||
* The pointer has to be a retained opaque `Unmanaged<HybridHaptikaHealthKitSpec_cxx>`.
|
||||
* This removes one strong reference from the object!
|
||||
*/
|
||||
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridHaptikaHealthKitSpec_cxx {
|
||||
return Unmanaged<HybridHaptikaHealthKitSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets (or creates) the C++ part of this Hybrid Object.
|
||||
* The C++ part is a `std::shared_ptr<HybridHaptikaHealthKitSpec>`.
|
||||
*/
|
||||
public func getCxxPart() -> bridge.std__shared_ptr_HybridHaptikaHealthKitSpec_ {
|
||||
let cachedCxxPart = self.__cxxPart.lock()
|
||||
if Bool(fromCxx: cachedCxxPart) {
|
||||
return cachedCxxPart
|
||||
} else {
|
||||
let newCxxPart = bridge.create_std__shared_ptr_HybridHaptikaHealthKitSpec_(self.toUnsafe())
|
||||
__cxxPart = bridge.weakify_std__shared_ptr_HybridHaptikaHealthKitSpec_(newCxxPart)
|
||||
return newCxxPart
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the memory size of the Swift class (plus size of any other allocations)
|
||||
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
||||
*/
|
||||
@inline(__always)
|
||||
public var memorySize: Int {
|
||||
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this object with the given [other] object for reference equality.
|
||||
*/
|
||||
@inline(__always)
|
||||
public func equals(other: HybridHaptikaHealthKitSpec_cxx) -> Bool {
|
||||
return self.__implementation === other.__implementation
|
||||
}
|
||||
|
||||
/**
|
||||
* Call dispose() on the Swift class.
|
||||
* This _may_ be called manually from JS.
|
||||
*/
|
||||
@inline(__always)
|
||||
public func dispose() {
|
||||
self.__implementation.dispose()
|
||||
}
|
||||
|
||||
/**
|
||||
* Call toString() on the Swift class.
|
||||
*/
|
||||
@inline(__always)
|
||||
public func toString() -> String {
|
||||
return self.__implementation.toString()
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
|
||||
// Methods
|
||||
@inline(__always)
|
||||
public final func isAvailable() -> bridge.Result_bool_ {
|
||||
do {
|
||||
let __result = try self.__implementation.isAvailable()
|
||||
let __resultCpp = __result
|
||||
return bridge.create_Result_bool_(__resultCpp)
|
||||
} catch (let __error) {
|
||||
let __exceptionPtr = __error.toCpp()
|
||||
return bridge.create_Result_bool_(__exceptionPtr)
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
public final func requestReadAuthorization() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
||||
do {
|
||||
let __result = try self.__implementation.requestReadAuthorization()
|
||||
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
||||
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
||||
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
||||
__result
|
||||
.then({ __result in __promiseHolder.resolve(__result) })
|
||||
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
||||
return __promise
|
||||
}()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
||||
} catch (let __error) {
|
||||
let __exceptionPtr = __error.toCpp()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
public final func fetchContext(lookbackDays: Double) -> bridge.Result_std__shared_ptr_Promise_NativeHealthKitContext___ {
|
||||
do {
|
||||
let __result = try self.__implementation.fetchContext(lookbackDays: lookbackDays)
|
||||
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_NativeHealthKitContext__ in
|
||||
let __promise = bridge.create_std__shared_ptr_Promise_NativeHealthKitContext__()
|
||||
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_NativeHealthKitContext__(__promise)
|
||||
__result
|
||||
.then({ __result in __promiseHolder.resolve(__result) })
|
||||
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
||||
return __promise
|
||||
}()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_NativeHealthKitContext___(__resultCpp)
|
||||
} catch (let __error) {
|
||||
let __exceptionPtr = __error.toCpp()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_NativeHealthKitContext___(__exceptionPtr)
|
||||
}
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
public final func fetchLatestHeartbeatSeries() -> bridge.Result_std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary____ {
|
||||
do {
|
||||
let __result = try self.__implementation.fetchLatestHeartbeatSeries()
|
||||
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary___ in
|
||||
let __promise = bridge.create_std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary___()
|
||||
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary___(__promise)
|
||||
__result
|
||||
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_NativeHeartbeatSeriesSummary_ in
|
||||
if let __unwrappedValue = __result {
|
||||
return bridge.create_std__optional_NativeHeartbeatSeriesSummary_(__unwrappedValue)
|
||||
} else {
|
||||
return .init()
|
||||
}
|
||||
}()) })
|
||||
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
||||
return __promise
|
||||
}()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary____(__resultCpp)
|
||||
} catch (let __error) {
|
||||
let __exceptionPtr = __error.toCpp()
|
||||
return bridge.create_Result_std__shared_ptr_Promise_std__optional_NativeHeartbeatSeriesSummary____(__exceptionPtr)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user