From b13d944af9658b632f614b6e7eb29e3348b4fe91 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 14 Jan 2025 11:26:39 +0100 Subject: [PATCH 1/5] fix: Default-implement `memorySize` via Swift `extension` --- docs/docs/hybrid-objects.md | 7 ------- docs/docs/nitrogen.md | 7 ------- docs/docs/using-nitro-in-your-app.md | 7 ------- docs/docs/view-components.md | 15 ++++++--------- .../src/syntax/swift/SwiftHybridObject.ts | 1 - .../ios/core/HybridObject.swift | 5 +++++ 6 files changed, 11 insertions(+), 31 deletions(-) diff --git a/docs/docs/hybrid-objects.md b/docs/docs/hybrid-objects.md index a99fa2e31..45ee34723 100644 --- a/docs/docs/hybrid-objects.md +++ b/docs/docs/hybrid-objects.md @@ -112,10 +112,6 @@ Hybrid Objects can be implemented in C++, Swift or Kotlin: ```swift title="HybridMath.swift" class HybridMath : HybridMathSpec { - public override var memorySize: Int { - return 0 - } - public var pi: Double { return Double.pi } @@ -128,9 +124,6 @@ Hybrid Objects can be implemented in C++, Swift or Kotlin: ```kotlin title="HybridMath.kt" class HybridMath : HybridMathSpec() { - override val memorySize: Long - get() = 0L - override var pi: Double get() = Double.PI diff --git a/docs/docs/nitrogen.md b/docs/docs/nitrogen.md index e8471439e..07fe2e271 100644 --- a/docs/docs/nitrogen.md +++ b/docs/docs/nitrogen.md @@ -206,10 +206,6 @@ To implement `Math` now, you just need to implement the spec: ```swift title="HybridMath.swift" class HybridMath : HybridMathSpec { - public override var memorySize: Int { - return 0 - } - public func add(a: Double, b: Double) throws -> Double { return a + b } @@ -219,9 +215,6 @@ To implement `Math` now, you just need to implement the spec: ```kotlin title="HybridMath.kt" class HybridMath : HybridMathSpec() { - override val memorySize: Long - get() = 0L - override fun add(a: Double, b: Double): Double { return a + b } diff --git a/docs/docs/using-nitro-in-your-app.md b/docs/docs/using-nitro-in-your-app.md index e7eae3a3f..a8e6e1c70 100644 --- a/docs/docs/using-nitro-in-your-app.md +++ b/docs/docs/using-nitro-in-your-app.md @@ -211,10 +211,6 @@ After installing Nitro, you can start creating your [Hybrid Objects](hybrid-obje ```swift title="HybridMath.swift" class HybridMath : HybridMathSpec { - public override var memorySize: Int { - return 0 - } - public var pi: Double { return Double.pi } @@ -227,9 +223,6 @@ After installing Nitro, you can start creating your [Hybrid Objects](hybrid-obje ```kotlin title="HybridMath.kt" class HybridMath : HybridMathSpec() { - override val memorySize: Long - get() = 0L - override var pi: Double get() = Double.PI diff --git a/docs/docs/view-components.md b/docs/docs/view-components.md index 3dbfb83d5..265022f9e 100644 --- a/docs/docs/view-components.md +++ b/docs/docs/view-components.md @@ -93,7 +93,8 @@ It is up to the developer on how to handle this most efficiently, but here's an ```swift class NitroImageView : UIView { - static var globalViewsMap: NSMapTable = NSMapTable(keyOptions: .strongMemory, valueOptions: .weakMemory) + static var globalViewsMap: NSMapTable + = NSMapTable(keyOptions: .strongMemory, valueOptions: .weakMemory) @objc var nitroId: NSNumber = -1 { didSet { @@ -163,15 +164,10 @@ Now implement `NitroImageViewManager` in Swift and Kotlin, and assume it has to ```swift class HybridNitroImageViewManager: HybridNitroImageViewManagerSpec { - public override var memorySize: Int { - return 0 - } private var nitroId: Double? = nil private var view: NitroImageView? { get { - guard let viewId = self.nitroId else { - return nil - } + guard let viewId = self.nitroId else { return nil } return NitroImageView.globalViewsMap.object(forKey: NSNumber(value: viewId)) } } @@ -196,10 +192,9 @@ Now implement `NitroImageViewManager` in Swift and Kotlin, and assume it has to ```kotlin class HybridNitroImageViewManager: HybridNitroImageViewManagerSpec() { private var nitroId: Double? = null - private var view: WeakReference? = null get() { - return nitroId.let { + return nitroId?.let { return NitroImageView.globalViewsMap[it]?.get() } } @@ -208,10 +203,12 @@ Now implement `NitroImageViewManager` in Swift and Kotlin, and assume it has to get() = view.image set(newValue) = view.image = newValue + override var opacity: Double { get() = view.opacity set(newValue) = view.opacity = newValue + fun setNitroId(nitroId: Double?) { this.nitroId = nitroId } diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts index a99ce5f30..14aa1f899 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts @@ -42,7 +42,6 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr if (!hasBaseClass) { // It doesn't have a base class - implement the `HybridObject` base protocol classBaseClasses.push('HybridObject') - baseMembers.push(`public var memorySize: Int { return 0 }`) } const protocolCode = ` diff --git a/packages/react-native-nitro-modules/ios/core/HybridObject.swift b/packages/react-native-nitro-modules/ios/core/HybridObject.swift index d8af0371b..803a738bd 100644 --- a/packages/react-native-nitro-modules/ios/core/HybridObject.swift +++ b/packages/react-native-nitro-modules/ios/core/HybridObject.swift @@ -29,6 +29,11 @@ public protocol HybridObject: AnyObject { var memorySize: Int { get } } +extension HybridObject { + // By default, this returns `0`. + var memorySize: Int { return 0 } +} + @available(*, deprecated, message: "HybridObjectSpec has been renamed to HybridObject. Update Nitrogen and re-generate your specs.") public typealias HybridObjectSpec = HybridObject From 22ed17e4663bef231ab46c4a869691f5d142bd9c Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 14 Jan 2025 11:27:40 +0100 Subject: [PATCH 2/5] run nitrogen --- .../android/c++/JFunc_void_std__string.hpp | 20 +++++++++---------- .../nitro/image/Func_void_std__string.kt | 14 ++++++------- .../ios/swift/Func_void_std__string.swift | 10 +++++----- .../ios/swift/HybridImageFactorySpec.swift | 1 - .../generated/ios/swift/HybridImageSpec.swift | 1 - 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp index 5bf6f155e..4ee177e98 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp @@ -18,7 +18,7 @@ namespace margelo::nitro::image { using namespace facebook; /** - * Represents the Java/Kotlin callback `(valueFromJs: String) -> Unit`. + * Represents the Java/Kotlin callback `(path: String) -> Unit`. * This can be passed around between C++ and Java/Kotlin. */ struct JFunc_void_std__string: public jni::JavaClass { @@ -29,9 +29,9 @@ namespace margelo::nitro::image { /** * Invokes the function this `JFunc_void_std__string` instance holds through JNI. */ - void invoke(const std::string& valueFromJs) const { - static const auto method = getClass()->getMethod /* valueFromJs */)>("invoke"); - method(self(), jni::make_jstring(valueFromJs)); + void invoke(const std::string& path) const { + static const auto method = getClass()->getMethod /* path */)>("invoke"); + method(self(), jni::make_jstring(path)); } }; @@ -40,7 +40,7 @@ namespace margelo::nitro::image { */ struct JFunc_void_std__string_cxx final: public jni::HybridClass { public: - static jni::local_ref fromCpp(const std::function& func) { + static jni::local_ref fromCpp(const std::function& func) { return JFunc_void_std__string_cxx::newObjectCxxArgs(func); } @@ -48,13 +48,13 @@ namespace margelo::nitro::image { /** * Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds. */ - void invoke_cxx(jni::alias_ref valueFromJs) { - _func(valueFromJs->toStdString()); + void invoke_cxx(jni::alias_ref path) { + _func(path->toStdString()); } public: [[nodiscard]] - inline const std::function& getFunction() const { + inline const std::function& getFunction() const { return _func; } @@ -65,11 +65,11 @@ namespace margelo::nitro::image { } private: - explicit JFunc_void_std__string_cxx(const std::function& func): _func(func) { } + explicit JFunc_void_std__string_cxx(const std::function& func): _func(func) { } private: friend HybridBase; - std::function _func; + std::function _func; }; } // namespace margelo::nitro::image diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt index f1e304121..9cb9eb6c8 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt @@ -14,7 +14,7 @@ import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative /** - * Represents the JavaScript callback `(valueFromJs: string) => void`. + * Represents the JavaScript callback `(path: string) => void`. * This can be either implemented in C++ (in which case it might be a callback coming from JS), * or in Kotlin/Java (in which case it is a native callback). */ @@ -28,11 +28,11 @@ fun interface Func_void_std__string: (String) -> Unit { */ @DoNotStrip @Keep - override fun invoke(valueFromJs: String): Unit + override fun invoke(path: String): Unit } /** - * Represents the JavaScript callback `(valueFromJs: string) => void`. + * Represents the JavaScript callback `(path: string) => void`. * This is implemented in C++, via a `std::function<...>`. * The callback might be coming from JS. */ @@ -55,11 +55,11 @@ class Func_void_std__string_cxx: Func_void_std__string { } @FastNative - external override fun invoke(valueFromJs: String): Unit + external override fun invoke(path: String): Unit } /** - * Represents the JavaScript callback `(valueFromJs: string) => void`. + * Represents the JavaScript callback `(path: string) => void`. * This is implemented in Java/Kotlin, via a `(String) -> Unit`. * The callback is always coming from native. */ @@ -69,7 +69,7 @@ class Func_void_std__string_cxx: Func_void_std__string { class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string { @DoNotStrip @Keep - override fun invoke(valueFromJs: String): Unit { - return this.function(valueFromJs) + override fun invoke(path: String): Unit { + return this.function(path) } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift index 9cc6f2d7d..6e1adb0c0 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift @@ -8,21 +8,21 @@ import NitroModules /** - * Wraps a Swift `(_ valueFromJs: String) -> Void` as a class. + * Wraps a Swift `(_ path: String) -> Void` as a class. * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. */ public final class Func_void_std__string { public typealias bridge = margelo.nitro.image.bridge.swift - private let closure: (_ valueFromJs: String) -> Void + private let closure: (_ path: String) -> Void - public init(_ closure: @escaping (_ valueFromJs: String) -> Void) { + public init(_ closure: @escaping (_ path: String) -> Void) { self.closure = closure } @inline(__always) - public func call(valueFromJs: std.string) -> Void { - self.closure(String(valueFromJs)) + public func call(path: std.string) -> Void { + self.closure(String(path)) } /** diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift index 527ba5217..c8b27cf50 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift @@ -37,7 +37,6 @@ public class HybridImageFactorySpec_base: HybridObject { return cxxWrapper } } - public var memorySize: Int { return 0 } } /** diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift index bade63586..25221f06f 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift @@ -37,7 +37,6 @@ public class HybridImageSpec_base: HybridObject { return cxxWrapper } } - public var memorySize: Int { return 0 } } /** From 9117b4b45c74a80aa4e0a673a4c437ed462065e4 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 14 Jan 2025 11:27:54 +0100 Subject: [PATCH 3/5] whoops --- .../android/c++/JFunc_void_std__string.hpp | 20 +++++++++---------- .../nitro/image/Func_void_std__string.kt | 14 ++++++------- .../ios/swift/Func_void_std__string.swift | 10 +++++----- .../generated/ios/swift/HybridBaseSpec.swift | 1 - .../HybridTestObjectSwiftKotlinSpec.swift | 1 - 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp index 4ee177e98..5bf6f155e 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp @@ -18,7 +18,7 @@ namespace margelo::nitro::image { using namespace facebook; /** - * Represents the Java/Kotlin callback `(path: String) -> Unit`. + * Represents the Java/Kotlin callback `(valueFromJs: String) -> Unit`. * This can be passed around between C++ and Java/Kotlin. */ struct JFunc_void_std__string: public jni::JavaClass { @@ -29,9 +29,9 @@ namespace margelo::nitro::image { /** * Invokes the function this `JFunc_void_std__string` instance holds through JNI. */ - void invoke(const std::string& path) const { - static const auto method = getClass()->getMethod /* path */)>("invoke"); - method(self(), jni::make_jstring(path)); + void invoke(const std::string& valueFromJs) const { + static const auto method = getClass()->getMethod /* valueFromJs */)>("invoke"); + method(self(), jni::make_jstring(valueFromJs)); } }; @@ -40,7 +40,7 @@ namespace margelo::nitro::image { */ struct JFunc_void_std__string_cxx final: public jni::HybridClass { public: - static jni::local_ref fromCpp(const std::function& func) { + static jni::local_ref fromCpp(const std::function& func) { return JFunc_void_std__string_cxx::newObjectCxxArgs(func); } @@ -48,13 +48,13 @@ namespace margelo::nitro::image { /** * Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds. */ - void invoke_cxx(jni::alias_ref path) { - _func(path->toStdString()); + void invoke_cxx(jni::alias_ref valueFromJs) { + _func(valueFromJs->toStdString()); } public: [[nodiscard]] - inline const std::function& getFunction() const { + inline const std::function& getFunction() const { return _func; } @@ -65,11 +65,11 @@ namespace margelo::nitro::image { } private: - explicit JFunc_void_std__string_cxx(const std::function& func): _func(func) { } + explicit JFunc_void_std__string_cxx(const std::function& func): _func(func) { } private: friend HybridBase; - std::function _func; + std::function _func; }; } // namespace margelo::nitro::image diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt index 9cb9eb6c8..f1e304121 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt @@ -14,7 +14,7 @@ import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative /** - * Represents the JavaScript callback `(path: string) => void`. + * Represents the JavaScript callback `(valueFromJs: string) => void`. * This can be either implemented in C++ (in which case it might be a callback coming from JS), * or in Kotlin/Java (in which case it is a native callback). */ @@ -28,11 +28,11 @@ fun interface Func_void_std__string: (String) -> Unit { */ @DoNotStrip @Keep - override fun invoke(path: String): Unit + override fun invoke(valueFromJs: String): Unit } /** - * Represents the JavaScript callback `(path: string) => void`. + * Represents the JavaScript callback `(valueFromJs: string) => void`. * This is implemented in C++, via a `std::function<...>`. * The callback might be coming from JS. */ @@ -55,11 +55,11 @@ class Func_void_std__string_cxx: Func_void_std__string { } @FastNative - external override fun invoke(path: String): Unit + external override fun invoke(valueFromJs: String): Unit } /** - * Represents the JavaScript callback `(path: string) => void`. + * Represents the JavaScript callback `(valueFromJs: string) => void`. * This is implemented in Java/Kotlin, via a `(String) -> Unit`. * The callback is always coming from native. */ @@ -69,7 +69,7 @@ class Func_void_std__string_cxx: Func_void_std__string { class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string { @DoNotStrip @Keep - override fun invoke(path: String): Unit { - return this.function(path) + override fun invoke(valueFromJs: String): Unit { + return this.function(valueFromJs) } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift index 6e1adb0c0..9cc6f2d7d 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/Func_void_std__string.swift @@ -8,21 +8,21 @@ import NitroModules /** - * Wraps a Swift `(_ path: String) -> Void` as a class. + * Wraps a Swift `(_ valueFromJs: String) -> Void` as a class. * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. */ public final class Func_void_std__string { public typealias bridge = margelo.nitro.image.bridge.swift - private let closure: (_ path: String) -> Void + private let closure: (_ valueFromJs: String) -> Void - public init(_ closure: @escaping (_ path: String) -> Void) { + public init(_ closure: @escaping (_ valueFromJs: String) -> Void) { self.closure = closure } @inline(__always) - public func call(path: std.string) -> Void { - self.closure(String(path)) + public func call(valueFromJs: std.string) -> Void { + self.closure(String(valueFromJs)) } /** diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift index 17b99bc3a..424e8f105 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift @@ -34,7 +34,6 @@ public class HybridBaseSpec_base: HybridObject { return cxxWrapper } } - public var memorySize: Int { return 0 } } /** diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift index ab0e04cda..d3db989ae 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift @@ -95,7 +95,6 @@ public class HybridTestObjectSwiftKotlinSpec_base: HybridObject { return cxxWrapper } } - public var memorySize: Int { return 0 } } /** From c358245b9412a44dc9105e7099e585a3909ee6d8 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 14 Jan 2025 11:31:11 +0100 Subject: [PATCH 4/5] fix: Make `protocol` extend `HybridObject` directly instead of `_base` class --- packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts | 8 ++------ .../nitrogen/generated/ios/swift/HybridBaseSpec.swift | 4 ++-- .../nitrogen/generated/ios/swift/HybridChildSpec.swift | 2 +- .../generated/ios/swift/HybridImageFactorySpec.swift | 4 ++-- .../nitrogen/generated/ios/swift/HybridImageSpec.swift | 4 ++-- .../ios/swift/HybridTestObjectSwiftKotlinSpec.swift | 4 ++-- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts index 14aa1f899..dd9fcfda0 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts @@ -11,7 +11,7 @@ export function createSwiftHybridObject(spec: HybridObjectSpec): SourceFile[] { const properties = spec.properties.map((p) => p.getCode('swift')).join('\n') const methods = spec.methods.map((p) => p.getCode('swift')).join('\n') - const protocolBaseClasses = ['AnyObject'] + const protocolBaseClasses = ['HybridObject'] const classBaseClasses: string[] = [] for (const base of spec.baseTypes) { const baseName = getHybridObjectName(base.name) @@ -39,10 +39,6 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr } }`.trim() ) - if (!hasBaseClass) { - // It doesn't have a base class - implement the `HybridObject` base protocol - classBaseClasses.push('HybridObject') - } const protocolCode = ` ${createFileMetadataString(`${protocolName}.swift`)} @@ -60,7 +56,7 @@ public protocol ${protocolName}_protocol: ${protocolBaseClasses.join(', ')} { } /// See \`\`${protocolName}\`\` -public class ${protocolName}_base: ${classBaseClasses.join(', ')} { +public class ${protocolName}_base${classBaseClasses.length > 0 ? `: ${classBaseClasses.join(',')}` : ''} { ${baseMembers.length > 0 ? indent(baseMembers.join('\n'), ' ') : `/* inherited */`} } diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift index 424e8f105..3abb26513 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridBaseSpec.swift @@ -9,7 +9,7 @@ import Foundation import NitroModules /// See ``HybridBaseSpec`` -public protocol HybridBaseSpec_protocol: AnyObject { +public protocol HybridBaseSpec_protocol: HybridObject { // Properties var baseValue: Double { get } @@ -18,7 +18,7 @@ public protocol HybridBaseSpec_protocol: AnyObject { } /// See ``HybridBaseSpec`` -public class HybridBaseSpec_base: HybridObject { +public class HybridBaseSpec_base { private weak var cxxWrapper: HybridBaseSpec_cxx? = nil public func getCxxWrapper() -> HybridBaseSpec_cxx { #if DEBUG diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridChildSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridChildSpec.swift index 2d8b46a96..6082c70bb 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridChildSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridChildSpec.swift @@ -9,7 +9,7 @@ import Foundation import NitroModules /// See ``HybridChildSpec`` -public protocol HybridChildSpec_protocol: AnyObject, HybridBaseSpec_protocol { +public protocol HybridChildSpec_protocol: HybridObject, HybridBaseSpec_protocol { // Properties var childValue: Double { get } diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift index c8b27cf50..add46a8fc 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageFactorySpec.swift @@ -9,7 +9,7 @@ import Foundation import NitroModules /// See ``HybridImageFactorySpec`` -public protocol HybridImageFactorySpec_protocol: AnyObject { +public protocol HybridImageFactorySpec_protocol: HybridObject { // Properties @@ -21,7 +21,7 @@ public protocol HybridImageFactorySpec_protocol: AnyObject { } /// See ``HybridImageFactorySpec`` -public class HybridImageFactorySpec_base: HybridObject { +public class HybridImageFactorySpec_base { private weak var cxxWrapper: HybridImageFactorySpec_cxx? = nil public func getCxxWrapper() -> HybridImageFactorySpec_cxx { #if DEBUG diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift index 25221f06f..4e742e3b9 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridImageSpec.swift @@ -9,7 +9,7 @@ import Foundation import NitroModules /// See ``HybridImageSpec`` -public protocol HybridImageSpec_protocol: AnyObject { +public protocol HybridImageSpec_protocol: HybridObject { // Properties var size: ImageSize { get } var pixelFormat: PixelFormat { get } @@ -21,7 +21,7 @@ public protocol HybridImageSpec_protocol: AnyObject { } /// See ``HybridImageSpec`` -public class HybridImageSpec_base: HybridObject { +public class HybridImageSpec_base { private weak var cxxWrapper: HybridImageSpec_cxx? = nil public func getCxxWrapper() -> HybridImageSpec_cxx { #if DEBUG diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift index d3db989ae..edd7b6bd2 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift @@ -9,7 +9,7 @@ import Foundation import NitroModules /// See ``HybridTestObjectSwiftKotlinSpec`` -public protocol HybridTestObjectSwiftKotlinSpec_protocol: AnyObject { +public protocol HybridTestObjectSwiftKotlinSpec_protocol: HybridObject { // Properties var thisObject: (any HybridTestObjectSwiftKotlinSpec) { get } var optionalHybrid: (any HybridTestObjectSwiftKotlinSpec)? { get set } @@ -79,7 +79,7 @@ public protocol HybridTestObjectSwiftKotlinSpec_protocol: AnyObject { } /// See ``HybridTestObjectSwiftKotlinSpec`` -public class HybridTestObjectSwiftKotlinSpec_base: HybridObject { +public class HybridTestObjectSwiftKotlinSpec_base { private weak var cxxWrapper: HybridTestObjectSwiftKotlinSpec_cxx? = nil public func getCxxWrapper() -> HybridTestObjectSwiftKotlinSpec_cxx { #if DEBUG From 9db7e2c1b8a078f1e2068da5581788bed8e16e05 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 14 Jan 2025 11:38:53 +0100 Subject: [PATCH 5/5] fix: Make `extension` public and remove `override` --- packages/react-native-nitro-image/ios/HybridImage.swift | 2 +- packages/react-native-nitro-modules/ios/core/HybridObject.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native-nitro-image/ios/HybridImage.swift b/packages/react-native-nitro-image/ios/HybridImage.swift index 4307de5b7..58b5a9210 100644 --- a/packages/react-native-nitro-image/ios/HybridImage.swift +++ b/packages/react-native-nitro-image/ios/HybridImage.swift @@ -25,7 +25,7 @@ class HybridImage : HybridImageSpec { * Get the memory size of the Swift class, and the `UIImage` we allocated so JS * can efficiently garbage collect it when needed. */ - public override var memorySize: Int { + public var memorySize: Int { return uiImage.memorySize } diff --git a/packages/react-native-nitro-modules/ios/core/HybridObject.swift b/packages/react-native-nitro-modules/ios/core/HybridObject.swift index 803a738bd..385300365 100644 --- a/packages/react-native-nitro-modules/ios/core/HybridObject.swift +++ b/packages/react-native-nitro-modules/ios/core/HybridObject.swift @@ -29,7 +29,7 @@ public protocol HybridObject: AnyObject { var memorySize: Int { get } } -extension HybridObject { +public extension HybridObject { // By default, this returns `0`. var memorySize: Int { return 0 } }