1
0
Fork 0
Commit graph

84 commits

Author SHA1 Message Date
14072c5df6 Preserve references for full-transfer object parameters 2026-08-08 00:26:45 -04:00
2422737865 Return signal handler values across the C ABI 2026-08-02 02:15:06 -04:00
858544cdec Return signal handler values across the C ABI 2026-08-02 01:48:47 -04:00
a172d07ab1 Bind C array in-parameters, finish cross-module shadow migration 2026-08-01 23:40:58 -04:00
745a4c3401 Consolidate regression artifacts into per-tier flat structure 2026-07-21 22:03:38 -04:00
8bfeea2ed2 Rewrite README and add MIT license 2026-07-21 21:10:05 -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
57ff84bce5 Re-point plugins and re-enable lint gate (E6/E7)
E6: remove build-tool plugin (architecturally incompatible with the
monorepo-only CLI); rewrite the command plugin as a thin pass-through to
swift-gtk-gen.

E7: add swift-format as a dependency, format generated output in-process
before writeIfChanged, re-enable swift format lint --strict in
compile-gate.sh. CamelCase renderer identifiers (enum/bitfield cases,
signal trampoline names, _sgtk_* helpers, __result/__ptr temporaries,
hardcoded G_TYPE_* GValue constants) and drop generated block comments to
reach zero lint findings across all 6 tiers.
2026-07-20 23:44:49 -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
29872707f2 Rename README title to gobject-generator 2026-07-19 00:28:30 -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
b61512c4eb Skip caller-allocates out-params instead of miscompiling them
GIR caller-allocates out-params (char *outbuf, gunichar *result) require
the caller to allocate and size the buffer, unlike callee-allocates T**
out-params where the callee fills in the pointee. The out-param
marshalling declared a single Swift scalar and passed its address, which
is correct only for the callee-allocates shape; for caller-allocates, C
wrote buffer payload past the one-element slot (g_unichar_fully_decompose)
or the payload was reinterpreted as a pointer and dereferenced
(g_unichar_to_utf8, segfault). GIR carries no buffer-size field, so these
are now skipped rather than generated. The guard also reclassifies
time_val_from_iso8601/signal_query/type_query from plainRecord to the
accurate caller-allocates reason.
2026-07-17 21:16:53 -04:00
16e5449cad Expand runtime smoke tests across binding categories
Add smoke tests exercising boxed-record lifetime (copy-on-borrow,
adopt-on-full, init(retaining:), isolated deinit over thousands of alloc/free
cycles), out-param tuple returns, enum returns, bitfield arguments, and GError
bridging on both the success and throwing paths — proving each marshalling
category reaches real GLib/GObject correctly at runtime.
2026-07-17 21:04:43 -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
3b42593c72 B7: delete old CodeGen engine, make plan engine default
- Deleted CodeGen+Signal.swift entirely
- Replaced CodeGen.swift with minimal shim (scaffolding only)
- Removed returnType compat shims from IRModel.swift
- Simplified Main.swift to always use plan engine
- Removed single-GIR path (parser debugging only)
- Removed --engine=plan flag (plan engine is now default)
- Updated CLI tests and help text
- 124 tests pass, Gate 1 PASSES

Generated output: 271 types (GLib: 215 value types, GObject: 56 types incl. 30 classes)
Class wrappers with cross-module inheritance, ownership inits, and override.
Methods/functions deferred to Phase C (needs C enum bridging).
2026-07-17 01:49:34 -04:00
7f7d5b3cb8 Update skip baseline after class wrapper generation (Gate 1)
GObject: 56 bound types (30 class wrappers + 26 value types), up from 26.
GLib: 215 bound types (no classes - pure C library).
Gate 1 now PASSES with class wrappers, zero compile errors.
2026-07-17 01:41:33 -04:00
ebebd4b1b0 Add skip baseline for tier 1 (Gate 1a — first green gate)
241 types bound (GLib: 215, GObject: 26) across 1,157 skipped symbols.
Generated package compiles with zero errors via --engine=plan.
Skip reasons: unknownType (978), callbackWithoutUserData (97),
plainRecord (77), gtypeStruct (4), notIntrospectable (1).
2026-07-17 01:04:30 -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
58aef1a5d4 Add --monorepo-config CLI mode for unified multi-package generation 2026-07-01 20:35:56 -04:00
944b7cf670 Fix link name version suffix and Package.swift bracket alignment 2026-07-01 20:32:11 -04:00
5278fe90c3 Replace single-package scaffolding with monorepo Package.swift generation 2026-07-01 20:27:36 -04:00
f6adf61167 Remove dead buildNamespaceToModuleMap method 2026-07-01 20:25:31 -04:00
2956b23b58 Add re-export umbrella module generation with transitive import analysis 2026-07-01 20:22:12 -04:00
b32bc595ac Fix Task 4: remove dead nsToModule, add collision guards, fix pascalCase for aliases 2026-07-01 20:19:48 -04:00
3dde30dc70 Add qualifiedTypeToSwift and generateMonorepo for cross-namespace type references 2026-07-01 20:16:50 -04:00
cf9f762155 Fix code quality: add doc comments, document DAG assumption, clarify implicitImports 2026-07-01 20:14:19 -04:00
9eab7ffc72 Add MultiPackageAnalyzer with cross-package import resolution 2026-07-01 20:10:17 -04:00
bc67617649 Add includedPackages to Repository, populate from GIR include elements 2026-07-01 20:06:57 -04:00
4637693cdb Fix Task 1 review: remove duplicate parseObjectOverrides, add doc comments 2026-07-01 20:04:51 -04:00
1d6b70ae66 Add MonorepoConfig, PackageEntry, and IncludeEntry models 2026-07-01 20:01:08 -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