Skip to content

Commit

Permalink
fix: Make HybridView the protocol's base instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 13, 2025
1 parent 5d5a81f commit 5971908
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function createSwiftHybridObject(spec: HybridObjectSpec): SourceFile[] {
protocolBaseClasses.push(`${baseName.HybridTSpec}_protocol`)
classBaseClasses.push(`${baseName.HybridTSpec}_base`)
}
if (spec.isHybridView) {
protocolBaseClasses.push('HybridView')
}

const hasBaseClass = classBaseClasses.length > 0
const baseMembers: string[] = []
Expand All @@ -41,11 +44,7 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr
)
if (!hasBaseClass) {
// It doesn't have a base class - implement the `HybridObject` base protocol
if (spec.isHybridView) {
classBaseClasses.push('HybridView')
} else {
classBaseClasses.push('HybridObject')
}
classBaseClasses.push('HybridObject')
baseMembers.push(`public var memorySize: Int { return 0 }`)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import NitroModules

/// See ``HybridTestViewSpec``
public protocol HybridTestViewSpec_protocol: AnyObject {
public protocol HybridTestViewSpec_protocol: AnyObject, HybridView {
// Properties
var someProp: Bool { get set }
var someCallback: (_ someParam: Double) -> Void { get set }
Expand All @@ -19,7 +19,7 @@ public protocol HybridTestViewSpec_protocol: AnyObject {
}

/// See ``HybridTestViewSpec``
public class HybridTestViewSpec_base: HybridView {
public class HybridTestViewSpec_base: HybridObject {
private weak var cxxWrapper: HybridTestViewSpec_cxx? = nil
public func getCxxWrapper() -> HybridTestViewSpec_cxx {
#if DEBUG
Expand Down

0 comments on commit 5971908

Please sign in to comment.