Files
josh b6fdee8bfc Lyrebird 2.0.0 — Linux support
Consolidated release: the cross-platform Linux port (engine, generators, CLI,
REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable
WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux
live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive.
See RELEASES.md and LINUX_README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-10 21:09:11 -07:00

58 lines
1.9 KiB
Swift

// CompiledSnippet.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// LyrebirdLiveCompile — core
//
// `CompiledSnippet` owns the `dlopen` handle and the resolved entry function
// pointer for one snippet's dylib. Held by the live session for the lifetime of
// the process — dylib unload is unsafe while live `Synth` instances may still
// reference types defined in the dylib. (See plan in
// `memory/project_live_compile_phases.md` non-goals.)
import Foundation
#if os(macOS) || os(Linux)
/// Handle to one successfully compiled and loaded snippet.
///
/// Intentionally a `final class` (not a `struct`): owning the `dlopen` handle
/// via reference identity means moves / copies cannot duplicate or accidentally
/// drop ownership. There is no `deinit` that calls `dlclose` — see the file
/// header.
///
/// `@unchecked Sendable`: every stored field is `let`; the `dlopen` handle and
/// the resolved entry pointer are both thread-safe to hold and read after the
/// compile completes (the loader serialises symbol resolution). Allows
/// `LiveSession.compileAndRunAsync` to return one across a `Task.detached`
/// boundary.
public final class CompiledSnippet: @unchecked Sendable {
/// Module name passed to `swiftc -module-name`; useful for diagnostics.
public let moduleName: String
/// Path to the dylib that was `dlopen`'d.
public let dylibPath: String
/// Resolved entry function pointer. The snippet harness calls this.
public let entry: SnippetEntry
/// Raw `dlopen` handle. Kept so the OS keeps the dylib mapped.
public let handle: UnsafeMutableRawPointer
init(
moduleName: String,
dylibPath: String,
entry: SnippetEntry,
handle: UnsafeMutableRawPointer
) {
self.moduleName = moduleName
self.dylibPath = dylibPath
self.entry = entry
self.handle = handle
}
}
#endif