Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/CoreGraphicsPolyfill.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by khoi on 10/5/25.
//

#if os(Linux)
#if os(Linux) || os(WASI)
import Foundation
#elseif canImport(FoundationEssentials)
import FoundationEssentials
Expand All @@ -19,7 +19,7 @@ import WASILibc
import Glibc
#endif

#if os(Linux)
#if os(Linux) || os(WASI)
public typealias CGFloat = Foundation.CGFloat
public typealias CGPoint = Foundation.CGPoint
public typealias CGSize = Foundation.CGSize
Expand Down
2 changes: 1 addition & 1 deletion Source/Serialization/Serializations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension CGFloat: SerializableAtom {

}

#if canImport(CoreGraphics) || os(Linux)
#if canImport(CoreGraphics) || os(Linux) || os(WASI)
extension Double: SerializableAtom {

func serialize() -> String {
Expand Down
12 changes: 12 additions & 0 deletions Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@
// since the polyfill types are aliases to the native CoreGraphics types.
//

import Foundation
import XCTest

@testable import SVGView

final class PolyfillTests: XCTestCase {

#if os(WASI) || os(Linux) || os(Android)

#if os(WASI) || os(Linux)
func testGeometryTypesMatchFoundation() {
let scalar: Foundation.CGFloat = CGFloat(1)
let point: Foundation.CGPoint = CGPoint(x: scalar, y: scalar)
let size: Foundation.CGSize = CGSize(width: scalar, height: scalar)
let rect: Foundation.CGRect = CGRect(origin: point, size: size)

XCTAssertEqual(rect, Foundation.CGRect(x: 1, y: 1, width: 1, height: 1))
}
#endif

// MARK: - CGAffineTransform Tests

Expand Down