From 1ee8079ecee15e6e5fcece5e4bd1c8ccd8fde3ca Mon Sep 17 00:00:00 2001 From: Abe White Date: Fri, 13 Dec 2024 11:40:59 -0600 Subject: [PATCH 1/2] Create SwiftProjecting protocol for use by bridging code --- Sources/SkipLib/BridgeSupport.swift | 20 ++++++++++++++++++++ Sources/SkipLib/Skip/KotlinSupport.kt | 4 ---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Sources/SkipLib/BridgeSupport.swift diff --git a/Sources/SkipLib/BridgeSupport.swift b/Sources/SkipLib/BridgeSupport.swift new file mode 100644 index 0000000..15921f0 --- /dev/null +++ b/Sources/SkipLib/BridgeSupport.swift @@ -0,0 +1,20 @@ +// Copyright 2024 Skip +// +// This is free software: you can redistribute and/or modify it +// under the terms of the GNU Lesser General Public License 3.0 +// as published by the Free Software Foundation https://fsf.org + +/// Marker protocol for types that are custom bridged from the Swift side. +/// +/// - Seealso: `KotlinConverting` +public protocol SwiftCustomBridged { +} + +/// Implemented by the generated Kotlin side of a bridged type to provide its Swift projection. +/// +/// - Returns: A closure that returns a Swift projection of this object when invoked. +/// - Warning: This protocol is not designed for general use. It is designed for generated bridge code. +/// - Seealso: `SkipBridgeKt.BridgeSupport` +public protocol SwiftProjecting { + func Swift_projection(options: Int) -> () -> Any +} diff --git a/Sources/SkipLib/Skip/KotlinSupport.kt b/Sources/SkipLib/Skip/KotlinSupport.kt index 017670f..2310981 100644 --- a/Sources/SkipLib/Skip/KotlinSupport.kt +++ b/Sources/SkipLib/Skip/KotlinSupport.kt @@ -5,10 +5,6 @@ // as published by the Free Software Foundation https://fsf.org package skip.lib -/// Marker protocol for types that are custom bridged from the Swift side. -interface SwiftCustomBridged { -} - /// A type that can convert to an underlying Kotlin instance. interface KotlinConverting { /// Convert a transpiled Swift instance to its Kotlin equivalent. From 51324b6f31af0535cf2575dde2387c80f945f4a8 Mon Sep 17 00:00:00 2001 From: Abe White Date: Fri, 13 Dec 2024 14:41:00 -0600 Subject: [PATCH 2/2] Add additional comments --- Sources/SkipLib/BridgeSupport.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/SkipLib/BridgeSupport.swift b/Sources/SkipLib/BridgeSupport.swift index 15921f0..e379764 100644 --- a/Sources/SkipLib/BridgeSupport.swift +++ b/Sources/SkipLib/BridgeSupport.swift @@ -12,6 +12,9 @@ public protocol SwiftCustomBridged { /// Implemented by the generated Kotlin side of a bridged type to provide its Swift projection. /// +/// We keep this in SkipLib so that the Kotlin output of transpiled bridged modules does not have a +/// dependency on SkipBridge. We can add the SkipBridge dependency only when compiling for bridging. +/// /// - Returns: A closure that returns a Swift projection of this object when invoked. /// - Warning: This protocol is not designed for general use. It is designed for generated bridge code. /// - Seealso: `SkipBridgeKt.BridgeSupport`