1
0
Fork 0
Commit graph

53 commits

Author SHA1 Message Date
5866ed57e9 Fix gint64/guint64 marshalling for macOS glib builds 2026-08-12 02:17:23 -04:00
298e5a4b43 Bind the GIO async pattern as Swift async methods 2026-08-11 23:47:16 -04:00
18e14a5b67 Boxed-record methods and moved-to routing 2026-08-11 17:34:26 -04:00
14072c5df6 Preserve references for full-transfer object parameters 2026-08-08 00:26:45 -04:00
a172d07ab1 Bind C array in-parameters, finish cross-module shadow migration 2026-08-01 23:40:58 -04:00
b13f7976cc Preserve user-defined test targets across Package.swift regeneration 2026-07-21 20:08:39 -04:00
f305df0eff Rename swift-gtk-gen to gobject-generator with generator binary 2026-07-21 18:51:15 -04:00
d6fabd56ed Generate typed public constructors for nullable string and borrowing cases 2026-07-21 17:49:38 -04:00
4f1016f682 Emit isolated deinit on root class wrappers, fix five review findings 2026-07-21 00:24:22 -04:00
525aefa7aa Complete Phase E5 tier-6 Adw/Soup/Gst compile-gate compliance
Relaxes the generated-filename PascalCase validator's uppercase-run cap
(>3 -> >4) so legitimate acronym type names (PluginAPIFlags, AuthNTLM)
stop crashing generation.

Fixes four compounding cross-module correctness bugs the larger tier-6
GIR set exposed at scale:
- The duplicate-of-dependency drop only checked simple-name collision,
  wrongly dropping genuinely distinct C types that merely share a
  post-namespace-stripping Swift name (Gst.Object/GstObject vs
  GObject.Object/GObject, plus three tier-4/5 cases: Gdk.AppLaunchContext,
  Gdk.Gravity, Gdk.Rectangle). Now also requires matching cType.
- Qualifying a cross-module reference as "GObject.X" broke wherever a
  raw C struct also named GObject was in scope (every C target's import),
  since Swift resolved the module name to the shadowing struct. GObject's
  Support.swift now exports collision-free GLibObject/GLibValueArray
  aliases used instead.
- Missing `override` keyword: added ancestor-method-selector detection
  (name + parameter labels, same-module only, since none of these members
  are open) so a subclass narrowing an ancestor's return type compiles.
- The pre-existing cross-module inherited-member dedup pass keyed
  ancestors by bare Swift name; its cycle guard falsely self-terminated
  once two classes shared a name, missing real inherited members (e.g.
  GstObject's own ref()/unref() were never recognized as duplicating
  GObject.Object's, producing an illegal redeclaration). Rewired to walk
  by unambiguous GIR name via new ClassPlan.girName/parentGIRName fields.

Also fixes bitfield/enum-typed global constants (wraps the raw literal
in Type(rawValue:)) and a void-returning ref function
(gst_atomic_queue_ref, unlike GstBuffer/GObject's T*-returning
convention) via new RecordPlan.copyReturnsVoid.

Adds tier-6 smoke tests (Gst/Soup/Adw version calls against the real
linked libraries) and refreshes the tier-4/5 skip baselines for the
duplicate-detection fix's legitimate coverage growth. Zero skip-baseline
drift on tiers 1-6; 220/220 unit tests and all tier smoke suites pass.
2026-07-20 21:59:10 -04:00
c20015be48 Complete Phase E4 tier-5 Gtk pointer-hiding and smoke coverage
Hides pointer storage/init behind @_spi(SGTKInternal) across boxed records
and interface Ref wrappers, marks interface Ref classes @MainActor,
threads boxed-record hasCopyFunction through GValue ops, and qualifies
re-exported dependency imports @_spi(SGTKInternal). Adds the tier-5
GtkSmoke display-free runtime smoke suite.
2026-07-20 21:58:51 -04:00
dac435ec89 Add Tier 4 Gdk/Gsk bindings and E3 review remediation
Generates Gdk and Gsk wrappers (330/417 and 140/183 callables), with runtime smoke tests linked against real libgtk-4. Also fixes a latent cross-module dropped-type reference bug, corrects the init(takingOwnership:) doc for no-free records, restores a precise filename safety check, and adds unit test coverage for four previously compile-gate-only branches.
2026-07-20 12:37:54 -04:00
ea41629a1f Tier 3 compile-gate compliance: Pango, GdkPixbuf, Graphene
Root causes fixed, all in TypeMapper.swift / TypeRegistry.swift /
Planner.swift / PlanRenderer.swift / BindingPlan.swift / IRModel.swift /
XMLParser.swift:

- Global (cross-module) inherited-member post-pass in planModules
  replaces the old in-module-only version, dropping properties/methods
  redeclared by an ancestor in a DIFFERENT module (e.g.
  Pango.Coverage.ref()/unref() vs. GObject.Object)
- transfer-ownership="none" GObject-class returns now route through
  init(retaining:) instead of adopting a borrowed pointer as owned
- Non-GObject fundamental root classes (GParamSpec) capture their GIR
  glib:ref-func/glib:unref-func instead of hardcoding g_object_ref
- Interface conformance clauses annotate each interface with @MainActor
  to satisfy isolated-conformance checking across module boundaries
- Scalar marshalOut (.direct/.numericCast) returned through a pointer
  C type with no <array> length now skips instead of misreading a raw
  buffer pointer as its pointee value
- Property/method Swift-name collisions on the same class are resolved
  by dropping the property (e.g. Pango.FontFamily.isVariable)
- MultiPackageAnalyzer only walks includes for configured packages
- No unconditional Foundation import (collided with Gio.InputStream)
- gdk_pixbuf_non_anim_new added to knownMissingCFunctions (GIR-declared,
  not exported through the public umbrella header)

Smoke tests: smoke/tier3/PixbufSmoke.swift (Pixbuf construction +
dimension round-trip against real libgdk_pixbuf) and
smoke/tier3/PangoSmoke.swift (findBaseDir against real libpango,
Latin vs. Hebrew script direction).

208 unit tests pass (+14: InheritedMemberTests + E2 sections in
PropertyGenerationTests/RendererCallableTests/others). compile-gate.sh
1, 2, and 3 all PASS. smoke-test.sh 3 passes 21/21 (18 tier-1 base +
1 GdkPixbuf + 2 Pango).
2026-07-20 01:06:38 -04:00
0504b34d7f Tier 2 compile-gate compliance: interfaces, cross-module refs, Gio 2026-07-19 00:27:08 -04:00
5abb48e889 Fix Phase D signal/callback remediation defects
Destroy-notify ABI fixed to GClosureNotify's real 2-arg signature and
wired into every connect method (was leaking every _ClosureBox, and
UB on non-x86_64 with the wrong arg count). Trampolines restore
MainActor isolation via assumeIsolated, with narrowly-scoped
nonisolated(unsafe) shadow copies to satisfy Swift 6's sending
checker. Interface-signal rendering implemented and unit-tested.
Dead code removed (SignalHandlePlan), destroyTrampoline made
non-optional, D7 deferral documented in-code. CoverageStats gained
boundCallbacks/boundSignals counters. Added SignalGenerationTests,
InterfaceSignalGenerationTests, and CallbackGenerationTests (12 new
tests, 187/187 total). Fixed the dead nonDetailedSignal smoke test to
actually mutate a property and assert the closure fired.

Callback-param planner-side binding (D4.3) stays disabled: enabling
it trips a genuine Swift compiler crash on g_qsort_with_data's
GCompareDataFunc parameter. The renderer-side box setup/release logic
is implemented and unit-tested by constructing plans directly,
bypassing the blocked planner path.

Verified: swift test (187/187), compile-gate.sh 1 --fresh (PASS),
smoke-test.sh --fresh (18/18).
2026-07-18 20:45:56 -04:00
dd2cd7a689 Phase C review remediation — C5 conformance, C6 GValue setter leak, C4 double-free/crossed-pair, C1 integer widths, renderConstructor throws, +24 unit tests +3 smoke tests 2026-07-18 16:28:33 -04:00
f85af8e6ce Generate GObject properties as computed vars (C6)
Properties render as Swift computed `var`s. Each accessor is planned
independently as either a delegation to the GIR getter=/setter= method
or the uniform GValue machinery (g_object_get_property/_set_property).

Delegation is preferred and inherits the method's nullability and
ownership (e.g. Binding.source becomes Object? because get_source is
nullable, where the GValue path produced a trap-prone non-optional
Object). It is chosen only when it yields one consistent Swift type;
otherwise both accessors fall back to GValue. GValue is also the
fallback for pure-GObject properties with no dedicated C accessor.

Enum/flags GValue getters bridge gint/guint to the Swift raw value via
numericCast; a bare cast would fail to compile on any enum-bearing tier.
Construct-only properties render read-only. Interface properties become
{ get } / { get set } requirements. GObject's fundamental G_TYPE_*
constants are emitted into its support file.

Adds 17 PropertyGenerationTests (incl. 5 delegation cases) and 2 runtime
smoke tests exercising a GValue round-trip and delegated getFlags() /
nullable getSource() off a real GBinding.
2026-07-18 14:59:12 -04:00
4dd74b0f65 Remove underscore prefix from generated filenames 2026-07-17 23:26:34 -04:00
321b42f9af Complete filename/naming remediation with PascalCase convention 2026-07-17 22:48:16 -04:00
164f8b7b9a Generate boxed-record memory management and interface requirements
Boxed records (C4): resolve each record's copy/free function from the GIR
copy-function/free-function attribute, else its own ref/copy and unref/free
method, and render init(retaining:) plus an isolated deinit. The deinit is
isolated because the package's default MainActor isolation makes accessing the
non-Sendable pointer from a nonisolated deinit a hard error. The registry uses
the same resolution so transfer=none returns copy instead of adopting a
borrowed pointer. This supersedes the earlier deferral: the hypothesised
OpaquePointer/Sendable barriers either did not hold or were solvable.

Interfaces (C5): plan each interface method through planMethod and render it as
a protocol requirement (no body); the conforming class supplies the C call.
2026-07-17 21:04:37 -04:00
8698d48e1c Generate out-params as inline tuple returns 2026-07-17 19:42:00 -04:00
144da7860e Generate class methods and constructors with runtime smoke tests 2026-07-17 15:43:30 -04:00
56de5bc976 Rearchitect generator around binding-plan layer with function generation 2026-07-17 14:43:54 -04:00
73d4b442b5 Update MonorepoConfig.from to use [packages.Name] section format, update tests 2026-07-01 20:55:16 -04:00
880c1574d5 Add monorepo generation integration tests 2026-07-01 20:50:14 -04:00
173ad4bd65 Add qualifiedTypeToSwift and reexport umbrella unit tests 2026-07-01 20:48:18 -04:00
7ce28c0ba8 Add MultiPackageAnalyzer dependency resolution tests 2026-07-01 20:44:30 -04:00
f61a63f167 Add MonorepoConfig TOML parsing tests 2026-07-01 20:43:38 -04:00
4bdc734f29 Address Task 11 review: shared test support, fix TestSkipError semantics, extract preamble 2026-07-01 19:19:47 -04:00
6ae74045fa Add GIR spec accuracy test suite validating all 269 Gtk classes against input spec 2026-07-01 19:14:25 -04:00
34554c96c3 Drop public prefix for open classes (open implies public visibility) 2026-07-01 18:50:01 -04:00
9dbd2b5a7a Force open class for classes with same-namespace subclasses 2026-07-01 18:33:05 -04:00
3a033057fb Map optional boolean return with .map { $0 != 0 } 2026-07-01 18:27:57 -04:00
2bcaafb3f5 Convert Swift Bool params to gboolean (Int32) via ? 1 : 0 2026-07-01 18:23:59 -04:00
94c98f4692 Emit override keyword for subclass methods; include static functions; stop at namespace boundary 2026-07-01 18:18:28 -04:00
681a15db51 Only emit pointer property for root or cross-namespace parent classes 2026-07-01 18:05:41 -04:00
50a42b2d83 Fix typed pointer casting: .assumingMemoryBound for C functions, remove double g_object_ref_sink in constructors 2026-07-01 17:49:00 -04:00
39f0d97269 Fix signal @convention(c) missing -> Void return type 2026-07-01 17:28:36 -04:00
27edea19af Refactor CodeGen.swift into CodeGen+Signal.swift and CodeGen+Scaffolding.swift 2026-07-01 17:27:42 -04:00
84a536d314 Fix pipe deadlock in CLI generation lint test 2026-07-01 14:46:45 -04:00
cacd83dfe4 Fix pipe deadlock in plugin and CLI integration tests 2026-07-01 14:46:26 -04:00
dd1cad2961 Add build tool plugin integration test and fix list-files paths 2026-07-01 14:40:07 -04:00
15493a9821 Add CLI generation + swift-format lint integration test 2026-07-01 14:22:22 -04:00
9915723cd8 Update docs for Config.toml and auto-extracted namespace config 2026-07-01 13:56:42 -04:00
48df5c2e43 Rewrite CLI: Config.toml support, auto-extract from GIR, --list-output-files 2026-07-01 13:49:28 -04:00
a732fcaad9 Implement record, constant, alias codegen plus all override applications 2026-07-01 13:47:14 -04:00
56ca762fac Complete override application in analyzer 2026-07-01 13:37:50 -04:00
d9f67033b6 Capture interface functions and record fields correctly in parser 2026-07-01 13:36:01 -04:00
5726b5549d Add Config.toml mapping from TOML dict + GIR namespace 2026-07-01 13:31:06 -04:00
512ebdfc22 Guard against unclosed string crash in TOMLReader 2026-07-01 13:28:40 -04:00