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 .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
swift-version: ["6.2.0", "6.1.3"]
vips-version: ["8.15.5", "8.16.1", "8.17.2"]
swift-version: ["6.2.1"]
vips-version: ["8.15.5", "8.16.1", "8.17.3"]
container:
image: ghcr.io/t089/swift-vips-builder:swift-${{ matrix.swift-version }}-vips-${{ matrix.vips-version }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
.swiftpm
swiftly
swiftly-*.tar.gz
.swift-version
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

10 changes: 6 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
"type": "swift",
"request": "launch",
"name": "Debug vips-tool",
"program": "${workspaceFolder:swift-vips}/.build/debug/vips-tool",
"args": [],
"cwd": "${workspaceFolder:swift-vips}",
"preLaunchTask": "swift: Build Debug vips-tool"
"preLaunchTask": "swift: Build Debug vips-tool",
"target": "vips-tool",
"configuration": "debug"
},
{
"type": "swift",
"request": "launch",
"name": "Release vips-tool",
"program": "${workspaceFolder:swift-vips}/.build/release/vips-tool",
"args": [],
"cwd": "${workspaceFolder:swift-vips}",
"preLaunchTask": "swift: Build Release vips-tool"
"preLaunchTask": "swift: Build Release vips-tool",
"target": "vips-tool",
"configuration": "release"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"*.swift": "swift",
"cvipsshim.h": "c"
}
}
12 changes: 7 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// swift-tools-version:6.1
// swift-tools-version:6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "swift-vips",
platforms: [ .macOS(.v14)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(name: "VIPS", targets: ["VIPS"]),
Expand All @@ -13,13 +14,9 @@ let package = Package(
"FoundationSupport",
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.systemLibrary(name: "Cvips",
pkgConfig: "vips"),
.target(
Expand All @@ -33,6 +30,11 @@ let package = Package(
"Cvips",
"CvipsShim",
.product(name: "Logging", package: "swift-log")
],
swiftSettings: [
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("InferIsolatedConformances"),
.enableExperimentalFeature("Lifetimes")
]),
.executableTarget(name: "vips-tool",
dependencies: ["VIPS", "Cvips"]
Expand Down
9 changes: 9 additions & 0 deletions Sources/CvipsShim/CvipsShim.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
//

#include "CvipsShim.h"
#include "glib.h"


gboolean shim_g_is_object(const void * p) {
return G_IS_OBJECT(p);
}

gint shim_g_object_get_ref_count(GObject* object) {
return g_atomic_int_get(&object->ref_count);
}

GObject* shim_g_object(const void * p) {
return G_OBJECT(p);
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/CvipsShim/include/CvipsShim.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

VipsImage* shim_vips_image_new_from_source(VipsSource *source, const char* options);

gint shim_g_object_get_ref_count(GObject* object);

gboolean shim_g_is_object(const void * p);

GObject* shim_g_object(const void * p);

GType shim_g_object_type(const void * p);
Expand Down
4 changes: 2 additions & 2 deletions Sources/VIPS/Arithmetic/arithmetic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ extension VIPSImage {
/// arrays have more than one element and the image only has a single band, the result is
/// a many-band image where each band corresponds to one array element.
public func linear(_ a: Double = 1.0, _ b: Double = 0, uchar: Bool? = nil) throws -> VIPSImage {
return try VIPSImage(self) { out in
return try VIPSImage { out in
var opt = VIPSOption()

opt.set("in", value: self.image)
Expand All @@ -242,7 +242,7 @@ extension VIPSImage {
}

public func linear(_ a: [Double], _ b: [Double], uchar: Bool? = nil) throws -> VIPSImage {
return try VIPSImage(self) { out in
return try VIPSImage { out in
var opt = VIPSOption()

opt.set("in", value: self.image)
Expand Down
4 changes: 2 additions & 2 deletions Sources/VIPS/Conversion/conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extension VIPSImage {

/// See VIPSImage.bandjoin(`in`:)
public func bandjoin(_ other: [VIPSImage]) throws -> VIPSImage {
return try VIPSImage([self] + other) { out in
return try VIPSImage { out in
var opt = VIPSOption()

opt.set("in", value: [self] + other)
Expand All @@ -27,7 +27,7 @@ extension VIPSImage {
/// - Returns: A new single-band image
/// - Throws: `VIPSError` if the operation fails
public func bandbool(_ operation: VipsOperationBoolean) throws -> VIPSImage {
return try VIPSImage(self) { out in
return try VIPSImage { out in
var opt = VIPSOption()

opt.set("in", value: self.image)
Expand Down
15 changes: 15 additions & 0 deletions Sources/VIPS/Core/GConnectFlags.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Cvips

extension GConnectFlags: @retroactive OptionSet {
public static var `default`: Self {
GConnectFlags(0)
}

public static var after: Self {
G_CONNECT_AFTER
}

public static var swapped: Self {
G_CONNECT_SWAPPED
}
}
2 changes: 1 addition & 1 deletion Sources/VIPS/Core/VIPSBlob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public final class VIPSBlob: @unchecked Sendable, Equatable, CustomDebugStringCo
return try body(buffer, Unmanaged.passUnretained(self))
}

public func withVipsBlob<R>(_ body: (UnsafeMutablePointer<VipsBlob>) throws -> R) rethrows -> R
public func withVipsBlob<R>(_ body: (UnsafeMutablePointer<VipsBlob>) throws -> R) rethrows -> R where R: ~Copyable
{
return try body(self.blob)
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/VIPS/Core/VIPSImage+Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extension VIPSImage {

let blob = outBuf.pointee

defer { vips_area_unref(shim_vips_area(blob)) }

return VIPSBlob(blob)
}

Expand Down
Loading