diff --git a/Package.swift b/Package.swift index 594e7c3..6e6c913 100644 --- a/Package.swift +++ b/Package.swift @@ -26,9 +26,13 @@ let package = Package( dependencies: ["COM_ABI", "WindowsRuntime_ABI"], path: "Support/Sources/InternalABI", exclude: ["CMakeLists.txt"]), + .target( + name: "ABIBindings", + path: "Support/Sources/ABIBindings", + exclude: ["CMakeLists.txt"]), .target( name: "COM", - dependencies: ["COM_ABI", "InternalABI"], + dependencies: ["ABIBindings", "COM_ABI", "InternalABI"], path: "Support/Sources/COM", exclude: ["CMakeLists.txt"]), .target( diff --git a/Support/Sources/COM/ABIBinding.swift b/Support/Sources/ABIBindings/ABIBinding.swift similarity index 87% rename from Support/Sources/COM/ABIBinding.swift rename to Support/Sources/ABIBindings/ABIBinding.swift index 0da9c5b..5d5c0cb 100644 --- a/Support/Sources/COM/ABIBinding.swift +++ b/Support/Sources/ABIBindings/ABIBinding.swift @@ -40,13 +40,6 @@ extension ABIBinding { } } -public protocol IdentityBinding: PODBinding where SwiftValue == ABIValue {} - -extension IdentityBinding { - public static func toABI(_ value: SwiftValue) -> ABIValue { value } - public static func toSwift(_ value: ABIValue) -> SwiftValue { value } -} - public enum ABIBindingError: Error { case unsupported(Any.Type) } \ No newline at end of file diff --git a/Support/Sources/COM/ProjectedTypes/BoolBinding.swift b/Support/Sources/ABIBindings/BoolBinding.swift similarity index 100% rename from Support/Sources/COM/ProjectedTypes/BoolBinding.swift rename to Support/Sources/ABIBindings/BoolBinding.swift diff --git a/Support/Sources/ABIBindings/CMakeLists.txt b/Support/Sources/ABIBindings/CMakeLists.txt new file mode 100644 index 0000000..8bf22f4 --- /dev/null +++ b/Support/Sources/ABIBindings/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB_RECURSE SOURCES *.swift) +add_library(ABIBindings STATIC ${SOURCES}) \ No newline at end of file diff --git a/Support/Sources/ABIBindings/ClosedEnumBinding.swift b/Support/Sources/ABIBindings/ClosedEnumBinding.swift new file mode 100644 index 0000000..7e4df8d --- /dev/null +++ b/Support/Sources/ABIBindings/ClosedEnumBinding.swift @@ -0,0 +1,11 @@ +/// Binding for an enumeration whose ABI representation is an integer, +/// and for which allowed values are limited to a set of defined enumerants. +public protocol ClosedEnumBinding: RawRepresentable, PODBinding + where ABIValue == RawValue, SwiftValue == Self, RawValue: FixedWidthInteger & Hashable { +} + +extension ClosedEnumBinding { + public static var abiDefaultValue: RawValue { RawValue.zero } + public static func toSwift(_ value: RawValue) -> Self { Self(rawValue: value)! } + public static func toABI(_ value: Self) -> RawValue { value.rawValue } +} diff --git a/Support/Sources/ABIBindings/IdentityBinding.swift b/Support/Sources/ABIBindings/IdentityBinding.swift new file mode 100644 index 0000000..7a74961 --- /dev/null +++ b/Support/Sources/ABIBindings/IdentityBinding.swift @@ -0,0 +1,7 @@ +/// Binds a Swift type to an identical ABI type. +public protocol IdentityBinding: PODBinding where SwiftValue == ABIValue {} + +extension IdentityBinding { + public static func toABI(_ value: SwiftValue) -> ABIValue { value } + public static func toSwift(_ value: ABIValue) -> SwiftValue { value } +} \ No newline at end of file diff --git a/Support/Sources/COM/ProjectedTypes/NumericBinding.swift b/Support/Sources/ABIBindings/NumericBinding.swift similarity index 100% rename from Support/Sources/COM/ProjectedTypes/NumericBinding.swift rename to Support/Sources/ABIBindings/NumericBinding.swift diff --git a/Support/Sources/COM/ProjectedTypes/EnumBinding.swift b/Support/Sources/ABIBindings/OpenEnumBinding.swift similarity index 50% rename from Support/Sources/COM/ProjectedTypes/EnumBinding.swift rename to Support/Sources/ABIBindings/OpenEnumBinding.swift index ab3fe15..dae0a26 100644 --- a/Support/Sources/COM/ProjectedTypes/EnumBinding.swift +++ b/Support/Sources/ABIBindings/OpenEnumBinding.swift @@ -11,15 +11,3 @@ extension OpenEnumBinding { public static func toSwift(_ value: RawValue) -> Self { Self(rawValue: value) } public static func toABI(_ value: Self) -> RawValue { value.rawValue } } - -/// Binding for an enumeration whose ABI representation is an integer, -/// and for which allowed values are limited to a set of defined enumerants. -public protocol ClosedEnumBinding: RawRepresentable, PODBinding - where ABIValue == RawValue, SwiftValue == Self, RawValue: FixedWidthInteger & Hashable { -} - -extension ClosedEnumBinding { - public static var abiDefaultValue: RawValue { RawValue.zero } - public static func toSwift(_ value: RawValue) -> Self { Self(rawValue: value)! } - public static func toABI(_ value: Self) -> RawValue { value.rawValue } -} diff --git a/Support/Sources/COM/PODBinding.swift b/Support/Sources/ABIBindings/PODBinding.swift similarity index 100% rename from Support/Sources/COM/PODBinding.swift rename to Support/Sources/ABIBindings/PODBinding.swift diff --git a/Support/Sources/COM/ProjectedTypes/WideCharBinding.swift b/Support/Sources/ABIBindings/WideCharBinding.swift similarity index 100% rename from Support/Sources/COM/ProjectedTypes/WideCharBinding.swift rename to Support/Sources/ABIBindings/WideCharBinding.swift diff --git a/Support/Sources/CMakeLists.txt b/Support/Sources/CMakeLists.txt index 5e0c9f9..59d3780 100644 --- a/Support/Sources/CMakeLists.txt +++ b/Support/Sources/CMakeLists.txt @@ -2,5 +2,6 @@ add_subdirectory(COM_ABI) add_subdirectory(WindowsRuntime_ABI) add_subdirectory(InternalABI) +add_subdirectory(ABIBindings) add_subdirectory(COM) add_subdirectory(WindowsRuntime) \ No newline at end of file diff --git a/Support/Sources/COM/ABIBindings.swift b/Support/Sources/COM/ABIBindings.swift new file mode 100644 index 0000000..e6a0f55 --- /dev/null +++ b/Support/Sources/COM/ABIBindings.swift @@ -0,0 +1 @@ +@_exported import ABIBindings \ No newline at end of file diff --git a/Support/Sources/COM/CMakeLists.txt b/Support/Sources/COM/CMakeLists.txt index af95fd7..2b963a5 100644 --- a/Support/Sources/COM/CMakeLists.txt +++ b/Support/Sources/COM/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE SOURCES *.swift) add_library(COM STATIC ${SOURCES}) -target_link_libraries(COM PRIVATE COM_ABI SWRT_InternalABI) \ No newline at end of file +target_link_libraries(COM PUBLIC ABIBindings COM_ABI SWRT_InternalABI) +target_link_libraries(COM PRIVATE SWRT_InternalABI) \ No newline at end of file diff --git a/Support/Sources/WindowsRuntime/CMakeLists.txt b/Support/Sources/WindowsRuntime/CMakeLists.txt index 599fddc..8f8213e 100644 --- a/Support/Sources/WindowsRuntime/CMakeLists.txt +++ b/Support/Sources/WindowsRuntime/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE SOURCES *.swift) add_library(WindowsRuntime STATIC ${SOURCES}) -target_link_libraries(WindowsRuntime PRIVATE COM WindowsRuntime_ABI SWRT_InternalABI) \ No newline at end of file +target_link_libraries(WindowsRuntime PUBLIC COM WindowsRuntime_ABI) +target_link_libraries(WindowsRuntime PRIVATE SWRT_InternalABI) \ No newline at end of file