Add internal initializer to autogeneration
Some checks are pending
Deploy Docs / publish (push) Waiting to run
SwiftLint / SwiftLint (push) Waiting to run

This commit is contained in:
david-swift 2025-11-04 13:09:17 +01:00
parent 90e8c78163
commit 7eb2bf7bb2
54 changed files with 102 additions and 85 deletions

View File

@ -2,7 +2,7 @@
// ActionRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// AspectFrame.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Avatar.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Banner.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Bin.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Box.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -59,7 +59,7 @@ public struct Box: AdwaitaWidget {
var prepend: () -> Body = { [] }
/// Initialize `Box`.
public init(spacing: Int) {
init(spacing: Int) {
self.spacing = spacing
}

View File

@ -2,7 +2,7 @@
// Button.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -61,7 +61,7 @@ public struct Button: AdwaitaWidget {
var clicked: (() -> Void)?
/// Initialize `Button`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ButtonContent.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Carousel.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// CenterBox.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// CheckButton.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Clamp.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// ComboRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -112,7 +112,7 @@ public struct ComboRow: AdwaitaWidget {
var prefix: () -> Body = { [] }
/// Initialize `ComboRow`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// DropDown.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -76,7 +76,7 @@ public struct DropDown: AdwaitaWidget {
var activate: (() -> Void)?
/// Initialize `DropDown`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// Entry.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -266,7 +266,7 @@ public struct Entry: AdwaitaWidget {
var removeWidget: (() -> Void)?
/// Initialize `Entry`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// EntryRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -83,7 +83,7 @@ public struct EntryRow: AdwaitaWidget {
var prefix: () -> Body = { [] }
/// Initialize `EntryRow`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ExpanderRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Fixed.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// FlowBox.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// HeaderBar.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Image.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Label.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// LevelBar.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// LinkButton.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// ListBox.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Menu.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -86,7 +86,7 @@ public struct Menu: AdwaitaWidget {
var activate: (() -> Void)?
/// Initialize `Menu`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// NavigationView.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -101,7 +101,7 @@ public struct NavigationView: AdwaitaWidget {
var replaced: (() -> Void)?
/// Initialize `NavigationView`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// Overlay.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// OverlaySplitView.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -107,7 +107,7 @@ public struct OverlaySplitView: AdwaitaWidget {
var sidebarWidthFraction: Double?
/// Initialize `OverlaySplitView`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// PasswordEntryRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -77,7 +77,7 @@ public struct PasswordEntryRow: AdwaitaWidget {
var prefix: () -> Body = { [] }
/// Initialize `PasswordEntryRow`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// Picture.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Popover.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesGroup.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -49,7 +49,7 @@ public struct PreferencesGroup: AdwaitaWidget {
var child: () -> Body = { [] }
/// Initialize `PreferencesGroup`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// PreferencesPage.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// ProgressBar.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -66,7 +66,7 @@ public struct ProgressBar: AdwaitaWidget {
var text: String?
/// Initialize `ProgressBar`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ScrolledWindow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -140,7 +140,7 @@ public struct ScrolledWindow: AdwaitaWidget {
var scrollChild: (() -> Void)?
/// Initialize `ScrolledWindow`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// SearchBar.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// SearchEntry.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Separator.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// SpinRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// Spinner.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// SplitButton.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// StatusPage.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// SwitchRow.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// ToastOverlay.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -33,7 +33,7 @@ public struct ToastOverlay: AdwaitaWidget {
var child: Body?
/// Initialize `ToastOverlay`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ToggleButton.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -72,7 +72,7 @@ public struct ToggleButton: AdwaitaWidget {
var toggled: (() -> Void)?
/// Initialize `ToggleButton`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ToggleGroup.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw
@ -78,7 +78,7 @@ public struct ToggleGroup: AdwaitaWidget {
var nToggles: Binding<UInt>?
/// Initialize `ToggleGroup`.
public init() {
init() {
}
/// The view storage.

View File

@ -2,7 +2,7 @@
// ToolbarView.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -2,7 +2,7 @@
// WindowTitle.swift
// Adwaita
//
// Created by auto-generation on 03.11.25.
// Created by auto-generation on 04.11.25.
//
import CAdw

View File

@ -22,7 +22,7 @@ extension Class {
) -> String {
let requiredProperties = properties(namespace: namespace, configurations: configs)
.filter { config.requiredProperties.contains($0.name) }
var initializer = "public init("
var initializer = "\(config.internalInitializer ? "" : "public ")init("
if config.dynamicWidget != nil {
initializer.append("_ elements: [Element], ")
}

View File

@ -27,6 +27,7 @@ struct Property: Decodable {
/// Whether the property is deprecated.
var deprecated: Bool?
/// Whether the property is itself a view.
var isView: Bool {
(self.type?.isWidget ?? false) || (self.type?.isMenu ?? false)
}

View File

@ -7,7 +7,7 @@
import Foundation
// swiftlint:disable type_body_length
// swiftlint:disable type_body_length file_length
/// The configuration for the generation.
struct GenerationConfiguration {
@ -86,7 +86,8 @@ struct GenerationConfiguration {
excludeProperties: [
"expression", "factory", "list-factory", "model", "selected-item", "header-factory", "search-match-mode"
],
cast: true
cast: true,
internalInitializer: true
),
.init(
class: "ExpanderRow",
@ -105,12 +106,14 @@ struct GenerationConfiguration {
.init(name: "prefix", add: "adw_entry_row_add_prefix")
],
excludeProperties: ["attributes", "input-hints", "input-purpose"],
cast: true
cast: true,
internalInitializer: true
),
.init(
class: "PasswordEntryRow",
excludeProperties: ["attributes", "input-hints", "input-purpose"],
cast: true
cast: true,
internalInitializer: true
),
.init(
class: "SpinRow",
@ -122,7 +125,8 @@ struct GenerationConfiguration {
.init(
class: "PreferencesGroup",
staticWidgets: [.init(name: "child", add: "adw_preferences_group_add")],
cast: true
cast: true,
internalInitializer: true
),
.init(
class: "PreferencesPage",
@ -135,7 +139,8 @@ struct GenerationConfiguration {
.init(
class: "OverlaySplitView",
bindings: [.init(property: "show-sidebar")],
excludeProperties: ["sidebar-position", "sidebar-width-unit"]
excludeProperties: ["sidebar-position", "sidebar-width-unit"],
internalInitializer: true
),
.init(
class: "HeaderBar",
@ -152,7 +157,7 @@ struct GenerationConfiguration {
.init(name: "top", add: "adw_toolbar_view_add_top_bar")
]
),
.init(class: "ToastOverlay"),
.init(class: "ToastOverlay", internalInitializer: true),
.init(
class: "SplitButton",
excludeProperties: ["direction", "popover"],
@ -160,13 +165,15 @@ struct GenerationConfiguration {
),
.init(
class: "NavigationView",
excludeProperties: ["navigation-stack", "visible-page"]
excludeProperties: ["navigation-stack", "visible-page"],
internalInitializer: true
),
.init(class: "Spinner"),
.init(
class: "ToggleGroup",
bindings: [.init(property: "active"), .init(property: "active-name"), .init(property: "n-toggles")],
excludeProperties: ["toggles"]
excludeProperties: ["toggles"],
internalInitializer: true
)
]
@ -196,7 +203,8 @@ struct GenerationConfiguration {
],
requiredProperties: ["spacing"],
excludeProperties: ["baseline-position", "orientation"],
cast: true
cast: true,
internalInitializer: true
),
.init(class: "LevelBar", excludeProperties: ["mode", "orientation"]),
.init(
@ -208,19 +216,21 @@ struct GenerationConfiguration {
),
excludeProperties: ["selection-mode", "tab-behavior"]
),
.init(class: "ProgressBar", excludeProperties: ["ellipsize", "orientation"]),
.init(class: "ProgressBar", excludeProperties: ["ellipsize", "orientation"], internalInitializer: true),
.init(
class: "Button",
excludeProperties: excludeButtons,
cast: true,
setConditions: ["label": "storage.content[\"child\"] == nil"]
setConditions: ["label": "storage.content[\"child\"] == nil"],
internalInitializer: true
),
.init(
class: "ToggleButton",
bindings: [.init(property: "active")],
excludeProperties: ["group"] + excludeButtons,
cast: true,
setConditions: ["label": "storage.content[\"child\"] == nil"]
setConditions: ["label": "storage.content[\"child\"] == nil"],
internalInitializer: true
),
.init(
class: "LinkButton",
@ -255,14 +265,16 @@ struct GenerationConfiguration {
"secondary-icon-storage-type",
"tabs"
],
cast: true
cast: true,
internalInitializer: true
),
.init(
class: "MenuButton",
name: "Menu",
bindings: [.init(property: "active")],
excludeProperties: ["direction", "popover"] + excludeButtons,
setConditions: ["label": "storage.content[\"child\"] == nil"]
setConditions: ["label": "storage.content[\"child\"] == nil"],
internalInitializer: true
),
.init(
class: "CenterBox",
@ -286,7 +298,8 @@ struct GenerationConfiguration {
)
}
"""
]
],
internalInitializer: true
),
.init(class: "Overlay", staticWidgets: [.init(name: "overlay", add: "gtk_overlay_add_overlay")]),
.init(class: "Popover", excludeProperties: ["pointing-to", "position"], cast: true),
@ -330,7 +343,8 @@ struct GenerationConfiguration {
"model",
"search-match-mode",
"selected-item"
]
],
internalInitializer: true
)
]
@ -384,4 +398,4 @@ struct GenerationConfiguration {
}
// swiftlint:enable type_body_length
// swiftlint:enable type_body_length file_length

View File

@ -36,6 +36,8 @@ struct WidgetConfiguration {
var lastProperties: [String] = []
/// Manually add setters which do not follow common practices.
var setters: [String] = []
/// Whether the initializer of the widget should not be public in Swift.
var internalInitializer = false
/// The configuration for a binding.
struct BindingConfiguration {