bugfixes, better MusicXML support and 1.1.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 142 core
|
||||
// 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
|
||||
@@ -35,7 +35,7 @@ public final class CompiledSnippet: @unchecked Sendable {
|
||||
/// Path to the dylib that was `dlopen`'d.
|
||||
public let dylibPath: String
|
||||
|
||||
/// Resolved entry function pointer. Calling this is Phase 143's job.
|
||||
/// Resolved entry function pointer. The snippet harness calls this.
|
||||
public let entry: SnippetEntry
|
||||
|
||||
/// Raw `dlopen` handle. Kept so the OS keeps the dylib mapped.
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 144
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// One parsed `swiftc` diagnostic, with `line` already mapped from the wrapped-
|
||||
// snippet coordinate space back to the user's snippet coordinate space (via the
|
||||
// `userBodyLineOffset` from `SnippetHarness.wrap(userBody:)`).
|
||||
//
|
||||
// The editor in Phase 145 (`LyrebirdScratchView`) renders diagnostics in its
|
||||
// The editor (`LyrebirdScratchView`) renders diagnostics in its
|
||||
// margin gutter using `(line, column)` directly.
|
||||
|
||||
#if os(macOS)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 144
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// `DiagnosticParser.parse(stderr:userBodyLineOffset:)` walks the swiftc stderr
|
||||
// stream line by line, extracts diagnostics matching the standard
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 144
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// Severity classifier for a parsed swiftc diagnostic line.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 142 core
|
||||
// LyrebirdLiveCompile — core
|
||||
//
|
||||
// Errors raised by `LiveCompiler.compile(source:)`. RT path never sees these:
|
||||
// compilation is a main-thread (or background-queue) operation that runs long
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 142 core
|
||||
// LyrebirdLiveCompile — core
|
||||
//
|
||||
// `LiveCompiler.compile(source:)` shells out to `swiftc -emit-library`, then
|
||||
// `dlopen`s the resulting dylib and resolves the snippet entry symbol. No UI,
|
||||
// no `SynthesisEngine` binding (those land in phases 143–146). macOS only —
|
||||
// iOS cannot exec swiftc.
|
||||
// no `SynthesisEngine` binding (those are handled by the harness and session
|
||||
// layers). macOS only — iOS cannot exec swiftc.
|
||||
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
@@ -34,8 +34,8 @@ public enum LiveCompiler {
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - source: Full Swift source, including the `@_cdecl("lyrebird_snippet_entry")`
|
||||
/// entry. Phase 143's `SnippetHarness` will wrap user input in a preamble that
|
||||
/// provides this; Phase 142 callers (incl. tests) write the full file.
|
||||
/// entry. `SnippetHarness` wraps user input in a preamble that provides
|
||||
/// this; direct callers (incl. tests) write the full file.
|
||||
/// - extraSwiftcArgs: Extra args appended to the `swiftc` invocation. Tests use
|
||||
/// this for `-suppress-warnings` etc. Production callers leave empty.
|
||||
/// - Returns: `CompiledSnippet` holding the dlopen handle and entry pointer.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 143
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// `LiveSession` owns the `SynthesisEngine` and tracks every `Synthesizer` that
|
||||
// each snippet `play(_:)`s, so the next non-additive re-evaluation can
|
||||
@@ -23,7 +23,7 @@ import LyrebirdSynth
|
||||
/// Snippets receive a `SnippetContext` bound to this session through
|
||||
/// `compileAndRun(_:additive:)`.
|
||||
///
|
||||
/// `@unchecked Sendable` (Phase 203): a `LiveSession` is shared between its `@MainActor`
|
||||
/// `@unchecked Sendable`: a `LiveSession` is shared between its `@MainActor`
|
||||
/// owner (`LyrebirdScratchModel`) and the `nonisolated` `compileAndRunAsync` it calls, so
|
||||
/// Swift 6 requires it to be `Sendable`. The conformance is sound by construction:
|
||||
///
|
||||
@@ -70,7 +70,7 @@ public final class LiveSession: @unchecked Sendable {
|
||||
engine: SynthesisEngine,
|
||||
importPaths: [URL] = LiveSession.defaultImportPaths(),
|
||||
librarySearchPaths: [URL] = LiveSession.defaultLibrarySearchPaths(),
|
||||
libraries: [String] = ["LyrebirdDynamic", "LyrebirdLiveCompile"],
|
||||
libraries: [String] = ["LyrebirdDynamic", "LyrebirdLiveCompileDynamic"],
|
||||
rpaths: [URL] = LiveSession.defaultRpaths()
|
||||
) {
|
||||
self.engine = engine
|
||||
@@ -91,7 +91,7 @@ public final class LiveSession: @unchecked Sendable {
|
||||
/// (⌘⇧↩ semantics in the future `LyrebirdScratchView` editor).
|
||||
/// - Returns: The compiled snippet handle. Retained internally so the dylib
|
||||
/// stays mapped; callers can ignore it.
|
||||
/// `@MainActor` (Phase 203): runs the snippet entry — and thus the user body's
|
||||
/// `@MainActor`: runs the snippet entry — and thus the user body's
|
||||
/// `MainActor.assumeIsolated { … }` and any `context.play(_:)` → `engine.add` — on the
|
||||
/// main thread, synchronously (swiftc compile included). The async variant
|
||||
/// ``compileAndRunAsync(_:additive:)`` keeps the compile off-main.
|
||||
@@ -112,8 +112,8 @@ public final class LiveSession: @unchecked Sendable {
|
||||
/// engine-touching steps (`clearTracked()` and the snippet entry via `runEntry`) then run
|
||||
/// on the **main actor**.
|
||||
///
|
||||
/// Running the entry on the main actor matters (Phase 203): the snippet's
|
||||
/// `context.play(_:)` calls `engine.add(_:)`, which is `@MainActor` (Phase 201) and
|
||||
/// Running the entry on the main actor matters: the snippet's
|
||||
/// `context.play(_:)` calls `engine.add(_:)`, which is `@MainActor` and
|
||||
/// mutates `engine.nodeTreeMirror` — state observed by SwiftUI on the main thread. A
|
||||
/// `nonisolated async` method resumes on the generic executor, NOT the caller's actor, so
|
||||
/// the hop is explicit here rather than assumed.
|
||||
@@ -288,7 +288,7 @@ public final class LiveSession: @unchecked Sendable {
|
||||
///
|
||||
/// Searches, in order:
|
||||
/// 1. Walks up from `Bundle(for: LiveSession.self).bundleURL` — this resolves
|
||||
/// to the directory holding `libLyrebirdLiveCompile.dylib` at runtime,
|
||||
/// to the directory holding `libLyrebirdLiveCompileDynamic.dylib` at runtime,
|
||||
/// which is the SPM debug/release dir.
|
||||
/// 2. Walks up from `Bundle.main.executableURL` — fallback for the case
|
||||
/// where the host bundles the dylibs into an `.app`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 144
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// `LiveSession.compileAndRun(_:additive:)` throws this richer error so callers
|
||||
// see diagnostics pre-mapped to user-snippet coordinates. Other `LiveCompileError`
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 143
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// `SnippetContext` is the public API surface the user's snippet talks to. The
|
||||
// host (via `LiveSession.compileAndRun`) constructs one of these, passes the
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 142 core
|
||||
// LyrebirdLiveCompile — core
|
||||
//
|
||||
// C ABI signature of the snippet's exported entry point.
|
||||
|
||||
#if os(macOS)
|
||||
|
||||
/// Snippets export this symbol via `@_cdecl("lyrebird_snippet_entry")`. Phase
|
||||
/// 143 will pass a pointer to a `LiveSession` (or harness context) here;
|
||||
/// Phase 142 only requires that snippets can declare a function matching this
|
||||
/// signature.
|
||||
/// Snippets export this symbol via `@_cdecl("lyrebird_snippet_entry")`. The host
|
||||
/// passes a pointer to a `LiveSession` (or harness context) here; snippets need
|
||||
/// only declare a function matching this signature.
|
||||
public typealias SnippetEntry = @convention(c) (UnsafeMutableRawPointer?) -> Void
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 143
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// `SnippetHarness.wrap(userBody:)` produces the full Swift source that
|
||||
// `LiveCompiler.compile(source:)` feeds to swiftc. The preamble imports the
|
||||
@@ -18,9 +18,9 @@ public enum SnippetHarness {
|
||||
|
||||
/// Wraps `userBody` in the standard preamble.
|
||||
///
|
||||
/// The user body runs inside `MainActor.assumeIsolated { … }` (Phase 203): snippets call
|
||||
/// The user body runs inside `MainActor.assumeIsolated { … }`: snippets call
|
||||
/// `@MainActor` API — `context.play(_:)` and `SynthesizerBase` subclass construction
|
||||
/// (both `@MainActor` since Phase 201) — which would not compile from the nonisolated
|
||||
/// (both `@MainActor`) — which would not compile from the nonisolated
|
||||
/// `@_cdecl` entry under Swift 6. The `assumeIsolated` closure gives the body main-actor
|
||||
/// isolation at compile time; it is safe at runtime because `LiveSession` always invokes
|
||||
/// the entry on the main actor (`compileAndRunAsync` hops via `MainActor.run`;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdLiveCompile — Phase 143
|
||||
// LyrebirdLiveCompile
|
||||
//
|
||||
// Output of `SnippetHarness.wrap(userBody:)`. Carries the full Swift source
|
||||
// that `swiftc` will compile, plus the 1-based line number on which the user's
|
||||
// body begins. Phase 144's diagnostic parser subtracts `userBodyLineOffset - 1`
|
||||
// body begins. The diagnostic parser subtracts `userBodyLineOffset - 1`
|
||||
// from each swiftc-reported line so error rows point back at the row the user
|
||||
// typed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user