@gtkx/gir 0.10.5 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +27 -5
- package/dist/index.js +26 -5
- package/dist/internal/normalizer.d.ts +22 -0
- package/dist/internal/normalizer.js +398 -0
- package/dist/internal/parser.d.ts +42 -0
- package/dist/{parser.js → internal/parser.js} +67 -55
- package/dist/internal/raw-types.d.ts +223 -0
- package/dist/internal/raw-types.js +9 -0
- package/dist/intrinsics.d.ts +39 -0
- package/dist/intrinsics.js +122 -0
- package/dist/repository.d.ts +151 -0
- package/dist/repository.js +322 -0
- package/dist/types.d.ts +517 -483
- package/dist/types.js +743 -1085
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +10 -0
- package/package.json +1 -1
- package/dist/class-names.d.ts +0 -2
- package/dist/class-names.js +0 -12
- package/dist/doc-sanitizer.d.ts +0 -13
- package/dist/doc-sanitizer.js +0 -334
- package/dist/naming.d.ts +0 -6
- package/dist/naming.js +0 -69
- package/dist/parser.d.ts +0 -76
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GIR Repository - Central entry point for GIR data.
|
|
3
|
+
*
|
|
4
|
+
* Loads, normalizes, and provides query access to GIR namespaces.
|
|
5
|
+
* All type references are normalized to fully qualified names.
|
|
6
|
+
*/
|
|
7
|
+
import { type GirCallback, type GirClass, type GirConstant, type GirEnumeration, type GirFunction, type GirInterface, type GirNamespace, type GirRecord, type QualifiedName, type TypeKind } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Central repository for GIR data.
|
|
10
|
+
*
|
|
11
|
+
* Loads, normalizes, and provides query access to GIR namespaces.
|
|
12
|
+
* All type references are normalized to fully qualified names.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const repo = new GirRepository();
|
|
17
|
+
* await repo.loadFromDirectory("./girs");
|
|
18
|
+
* repo.resolve();
|
|
19
|
+
*
|
|
20
|
+
* const gtkNs = repo.getNamespace("Gtk");
|
|
21
|
+
* const buttonClass = repo.resolveClass("Gtk.Button");
|
|
22
|
+
* const chain = buttonClass.getInheritanceChain();
|
|
23
|
+
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class GirRepository {
|
|
27
|
+
private rawNamespaces;
|
|
28
|
+
private normalizedNamespaces;
|
|
29
|
+
private parser;
|
|
30
|
+
private resolved;
|
|
31
|
+
/**
|
|
32
|
+
* Loads a single GIR file from XML content.
|
|
33
|
+
*/
|
|
34
|
+
loadFromXml(xml: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Loads a GIR file from disk.
|
|
37
|
+
*/
|
|
38
|
+
loadFromFile(path: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Loads all .gir files from a directory.
|
|
41
|
+
*/
|
|
42
|
+
loadFromDirectory(dirPath: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* After loading all raw GIR files, normalize and resolve all references.
|
|
45
|
+
* This must be called after loading and before querying.
|
|
46
|
+
*/
|
|
47
|
+
resolve(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Gets all loaded namespace names.
|
|
50
|
+
*/
|
|
51
|
+
getNamespaceNames(): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Gets a normalized namespace by name.
|
|
54
|
+
*/
|
|
55
|
+
getNamespace(name: string): GirNamespace | null;
|
|
56
|
+
/**
|
|
57
|
+
* Gets all normalized namespaces.
|
|
58
|
+
*/
|
|
59
|
+
getAllNamespaces(): Map<string, GirNamespace>;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves a class by qualified name.
|
|
62
|
+
* @example repo.resolveClass("Gtk.Button" as QualifiedName)
|
|
63
|
+
*/
|
|
64
|
+
resolveClass(qualifiedName: QualifiedName): GirClass | null;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves an interface by qualified name.
|
|
67
|
+
* @example repo.resolveInterface("Gio.ListModel" as QualifiedName)
|
|
68
|
+
*/
|
|
69
|
+
resolveInterface(qualifiedName: QualifiedName): GirInterface | null;
|
|
70
|
+
/**
|
|
71
|
+
* Resolves a record (boxed type) by qualified name.
|
|
72
|
+
* @example repo.resolveRecord("Gdk.Rectangle" as QualifiedName)
|
|
73
|
+
*/
|
|
74
|
+
resolveRecord(qualifiedName: QualifiedName): GirRecord | null;
|
|
75
|
+
/**
|
|
76
|
+
* Resolves an enumeration by qualified name.
|
|
77
|
+
* @example repo.resolveEnum("Gtk.Orientation" as QualifiedName)
|
|
78
|
+
*/
|
|
79
|
+
resolveEnum(qualifiedName: QualifiedName): GirEnumeration | null;
|
|
80
|
+
/**
|
|
81
|
+
* Resolves a bitfield (flags) by qualified name.
|
|
82
|
+
* @example repo.resolveFlags("Gdk.ModifierType" as QualifiedName)
|
|
83
|
+
*/
|
|
84
|
+
resolveFlags(qualifiedName: QualifiedName): GirEnumeration | null;
|
|
85
|
+
/**
|
|
86
|
+
* Resolves a callback type by qualified name.
|
|
87
|
+
* @example repo.resolveCallback("Gio.AsyncReadyCallback" as QualifiedName)
|
|
88
|
+
*/
|
|
89
|
+
resolveCallback(qualifiedName: QualifiedName): GirCallback | null;
|
|
90
|
+
/**
|
|
91
|
+
* Resolves a constant by qualified name.
|
|
92
|
+
* @example repo.resolveConstant("Gtk.MAJOR_VERSION" as QualifiedName)
|
|
93
|
+
*/
|
|
94
|
+
resolveConstant(qualifiedName: QualifiedName): GirConstant | null;
|
|
95
|
+
/**
|
|
96
|
+
* Resolves a standalone function by qualified name.
|
|
97
|
+
* @example repo.resolveFunction("Gtk.init" as QualifiedName)
|
|
98
|
+
*/
|
|
99
|
+
resolveFunction(qualifiedName: QualifiedName): GirFunction | null;
|
|
100
|
+
/**
|
|
101
|
+
* Gets the kind of a type (class, interface, record, enum, flags, callback).
|
|
102
|
+
* Returns null for intrinsic types or unknown types.
|
|
103
|
+
*/
|
|
104
|
+
getTypeKind(qualifiedName: QualifiedName): TypeKind | null;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the full inheritance chain for a class.
|
|
107
|
+
* Returns array from most derived to base.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* getInheritanceChain("Gtk.Button" as QualifiedName)
|
|
111
|
+
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
112
|
+
*/
|
|
113
|
+
getInheritanceChain(qualifiedName: QualifiedName): QualifiedName[];
|
|
114
|
+
/**
|
|
115
|
+
* Gets all interfaces implemented by a class (including inherited).
|
|
116
|
+
*/
|
|
117
|
+
getImplementedInterfaces(qualifiedName: QualifiedName): QualifiedName[];
|
|
118
|
+
/**
|
|
119
|
+
* Gets all classes that derive from a given class.
|
|
120
|
+
*/
|
|
121
|
+
getDerivedClasses(qualifiedName: QualifiedName): QualifiedName[];
|
|
122
|
+
/**
|
|
123
|
+
* Gets all classes that implement a given interface.
|
|
124
|
+
*/
|
|
125
|
+
getImplementors(interfaceName: QualifiedName): QualifiedName[];
|
|
126
|
+
/**
|
|
127
|
+
* Checks if a type is a GObject (class with GType).
|
|
128
|
+
*/
|
|
129
|
+
isGObject(qualifiedName: QualifiedName): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Checks if a type is a boxed type (record with GType).
|
|
132
|
+
*/
|
|
133
|
+
isBoxed(qualifiedName: QualifiedName): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Checks if a type is a primitive (intrinsic).
|
|
136
|
+
*/
|
|
137
|
+
isPrimitive(typeName: string): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Finds all classes matching a predicate across all namespaces.
|
|
140
|
+
*/
|
|
141
|
+
findClasses(predicate: (cls: GirClass) => boolean): GirClass[];
|
|
142
|
+
/**
|
|
143
|
+
* Finds all interfaces matching a predicate across all namespaces.
|
|
144
|
+
*/
|
|
145
|
+
findInterfaces(predicate: (iface: GirInterface) => boolean): GirInterface[];
|
|
146
|
+
/**
|
|
147
|
+
* Finds all records matching a predicate across all namespaces.
|
|
148
|
+
*/
|
|
149
|
+
findRecords(predicate: (record: GirRecord) => boolean): GirRecord[];
|
|
150
|
+
private ensureResolved;
|
|
151
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GIR Repository - Central entry point for GIR data.
|
|
3
|
+
*
|
|
4
|
+
* Loads, normalizes, and provides query access to GIR namespaces.
|
|
5
|
+
* All type references are normalized to fully qualified names.
|
|
6
|
+
*/
|
|
7
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { normalizeNamespace } from "./internal/normalizer.js";
|
|
10
|
+
import { RawGirParser } from "./internal/parser.js";
|
|
11
|
+
import { isIntrinsicType } from "./intrinsics.js";
|
|
12
|
+
import { parseQualifiedName, } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Central repository for GIR data.
|
|
15
|
+
*
|
|
16
|
+
* Loads, normalizes, and provides query access to GIR namespaces.
|
|
17
|
+
* All type references are normalized to fully qualified names.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const repo = new GirRepository();
|
|
22
|
+
* await repo.loadFromDirectory("./girs");
|
|
23
|
+
* repo.resolve();
|
|
24
|
+
*
|
|
25
|
+
* const gtkNs = repo.getNamespace("Gtk");
|
|
26
|
+
* const buttonClass = repo.resolveClass("Gtk.Button");
|
|
27
|
+
* const chain = buttonClass.getInheritanceChain();
|
|
28
|
+
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class GirRepository {
|
|
32
|
+
rawNamespaces = new Map();
|
|
33
|
+
normalizedNamespaces = new Map();
|
|
34
|
+
parser = new RawGirParser();
|
|
35
|
+
resolved = false;
|
|
36
|
+
/**
|
|
37
|
+
* Loads a single GIR file from XML content.
|
|
38
|
+
*/
|
|
39
|
+
loadFromXml(xml) {
|
|
40
|
+
const raw = this.parser.parse(xml);
|
|
41
|
+
this.rawNamespaces.set(raw.name, raw);
|
|
42
|
+
this.resolved = false;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Loads a GIR file from disk.
|
|
46
|
+
*/
|
|
47
|
+
async loadFromFile(path) {
|
|
48
|
+
const xml = await readFile(path, "utf-8");
|
|
49
|
+
this.loadFromXml(xml);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Loads all .gir files from a directory.
|
|
53
|
+
*/
|
|
54
|
+
async loadFromDirectory(dirPath) {
|
|
55
|
+
const files = await readdir(dirPath);
|
|
56
|
+
const girFiles = files.filter((f) => f.endsWith(".gir"));
|
|
57
|
+
await Promise.all(girFiles.map((file) => this.loadFromFile(join(dirPath, file))));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* After loading all raw GIR files, normalize and resolve all references.
|
|
61
|
+
* This must be called after loading and before querying.
|
|
62
|
+
*/
|
|
63
|
+
resolve() {
|
|
64
|
+
if (this.resolved)
|
|
65
|
+
return;
|
|
66
|
+
const ctx = {
|
|
67
|
+
rawNamespaces: this.rawNamespaces,
|
|
68
|
+
};
|
|
69
|
+
for (const [name, raw] of this.rawNamespaces) {
|
|
70
|
+
const normalized = normalizeNamespace(raw, ctx);
|
|
71
|
+
this.normalizedNamespaces.set(name, normalized);
|
|
72
|
+
}
|
|
73
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
74
|
+
for (const cls of ns.classes.values()) {
|
|
75
|
+
cls._setRepository(this);
|
|
76
|
+
}
|
|
77
|
+
for (const iface of ns.interfaces.values()) {
|
|
78
|
+
iface._setRepository(this);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.resolved = true;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets all loaded namespace names.
|
|
85
|
+
*/
|
|
86
|
+
getNamespaceNames() {
|
|
87
|
+
this.ensureResolved();
|
|
88
|
+
return [...this.normalizedNamespaces.keys()];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets a normalized namespace by name.
|
|
92
|
+
*/
|
|
93
|
+
getNamespace(name) {
|
|
94
|
+
this.ensureResolved();
|
|
95
|
+
return this.normalizedNamespaces.get(name) ?? null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets all normalized namespaces.
|
|
99
|
+
*/
|
|
100
|
+
getAllNamespaces() {
|
|
101
|
+
this.ensureResolved();
|
|
102
|
+
return this.normalizedNamespaces;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolves a class by qualified name.
|
|
106
|
+
* @example repo.resolveClass("Gtk.Button" as QualifiedName)
|
|
107
|
+
*/
|
|
108
|
+
resolveClass(qualifiedName) {
|
|
109
|
+
this.ensureResolved();
|
|
110
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
111
|
+
return this.normalizedNamespaces.get(namespace)?.classes.get(name) ?? null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Resolves an interface by qualified name.
|
|
115
|
+
* @example repo.resolveInterface("Gio.ListModel" as QualifiedName)
|
|
116
|
+
*/
|
|
117
|
+
resolveInterface(qualifiedName) {
|
|
118
|
+
this.ensureResolved();
|
|
119
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
120
|
+
return this.normalizedNamespaces.get(namespace)?.interfaces.get(name) ?? null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolves a record (boxed type) by qualified name.
|
|
124
|
+
* @example repo.resolveRecord("Gdk.Rectangle" as QualifiedName)
|
|
125
|
+
*/
|
|
126
|
+
resolveRecord(qualifiedName) {
|
|
127
|
+
this.ensureResolved();
|
|
128
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
129
|
+
return this.normalizedNamespaces.get(namespace)?.records.get(name) ?? null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolves an enumeration by qualified name.
|
|
133
|
+
* @example repo.resolveEnum("Gtk.Orientation" as QualifiedName)
|
|
134
|
+
*/
|
|
135
|
+
resolveEnum(qualifiedName) {
|
|
136
|
+
this.ensureResolved();
|
|
137
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
138
|
+
return this.normalizedNamespaces.get(namespace)?.enumerations.get(name) ?? null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolves a bitfield (flags) by qualified name.
|
|
142
|
+
* @example repo.resolveFlags("Gdk.ModifierType" as QualifiedName)
|
|
143
|
+
*/
|
|
144
|
+
resolveFlags(qualifiedName) {
|
|
145
|
+
this.ensureResolved();
|
|
146
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
147
|
+
return this.normalizedNamespaces.get(namespace)?.bitfields.get(name) ?? null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Resolves a callback type by qualified name.
|
|
151
|
+
* @example repo.resolveCallback("Gio.AsyncReadyCallback" as QualifiedName)
|
|
152
|
+
*/
|
|
153
|
+
resolveCallback(qualifiedName) {
|
|
154
|
+
this.ensureResolved();
|
|
155
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
156
|
+
return this.normalizedNamespaces.get(namespace)?.callbacks.get(name) ?? null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Resolves a constant by qualified name.
|
|
160
|
+
* @example repo.resolveConstant("Gtk.MAJOR_VERSION" as QualifiedName)
|
|
161
|
+
*/
|
|
162
|
+
resolveConstant(qualifiedName) {
|
|
163
|
+
this.ensureResolved();
|
|
164
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
165
|
+
return this.normalizedNamespaces.get(namespace)?.constants.get(name) ?? null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Resolves a standalone function by qualified name.
|
|
169
|
+
* @example repo.resolveFunction("Gtk.init" as QualifiedName)
|
|
170
|
+
*/
|
|
171
|
+
resolveFunction(qualifiedName) {
|
|
172
|
+
this.ensureResolved();
|
|
173
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
174
|
+
return this.normalizedNamespaces.get(namespace)?.functions.get(name) ?? null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Gets the kind of a type (class, interface, record, enum, flags, callback).
|
|
178
|
+
* Returns null for intrinsic types or unknown types.
|
|
179
|
+
*/
|
|
180
|
+
getTypeKind(qualifiedName) {
|
|
181
|
+
this.ensureResolved();
|
|
182
|
+
if (isIntrinsicType(qualifiedName)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const { namespace, name } = parseQualifiedName(qualifiedName);
|
|
186
|
+
const ns = this.normalizedNamespaces.get(namespace);
|
|
187
|
+
if (!ns)
|
|
188
|
+
return null;
|
|
189
|
+
if (ns.classes.has(name))
|
|
190
|
+
return "class";
|
|
191
|
+
if (ns.interfaces.has(name))
|
|
192
|
+
return "interface";
|
|
193
|
+
if (ns.records.has(name))
|
|
194
|
+
return "record";
|
|
195
|
+
if (ns.enumerations.has(name))
|
|
196
|
+
return "enum";
|
|
197
|
+
if (ns.bitfields.has(name))
|
|
198
|
+
return "flags";
|
|
199
|
+
if (ns.callbacks.has(name))
|
|
200
|
+
return "callback";
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Gets the full inheritance chain for a class.
|
|
205
|
+
* Returns array from most derived to base.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* getInheritanceChain("Gtk.Button" as QualifiedName)
|
|
209
|
+
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
210
|
+
*/
|
|
211
|
+
getInheritanceChain(qualifiedName) {
|
|
212
|
+
const cls = this.resolveClass(qualifiedName);
|
|
213
|
+
return cls?.getInheritanceChain() ?? [];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Gets all interfaces implemented by a class (including inherited).
|
|
217
|
+
*/
|
|
218
|
+
getImplementedInterfaces(qualifiedName) {
|
|
219
|
+
const cls = this.resolveClass(qualifiedName);
|
|
220
|
+
return cls?.getAllImplementedInterfaces() ?? [];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Gets all classes that derive from a given class.
|
|
224
|
+
*/
|
|
225
|
+
getDerivedClasses(qualifiedName) {
|
|
226
|
+
this.ensureResolved();
|
|
227
|
+
const derived = [];
|
|
228
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
229
|
+
for (const cls of ns.classes.values()) {
|
|
230
|
+
if (cls.qualifiedName !== qualifiedName && cls.isSubclassOf(qualifiedName)) {
|
|
231
|
+
derived.push(cls.qualifiedName);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return derived;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Gets all classes that implement a given interface.
|
|
239
|
+
*/
|
|
240
|
+
getImplementors(interfaceName) {
|
|
241
|
+
this.ensureResolved();
|
|
242
|
+
const implementors = [];
|
|
243
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
244
|
+
for (const cls of ns.classes.values()) {
|
|
245
|
+
if (cls.implementsInterface(interfaceName)) {
|
|
246
|
+
implementors.push(cls.qualifiedName);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return implementors;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Checks if a type is a GObject (class with GType).
|
|
254
|
+
*/
|
|
255
|
+
isGObject(qualifiedName) {
|
|
256
|
+
const cls = this.resolveClass(qualifiedName);
|
|
257
|
+
return cls?.hasGType() ?? false;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Checks if a type is a boxed type (record with GType).
|
|
261
|
+
*/
|
|
262
|
+
isBoxed(qualifiedName) {
|
|
263
|
+
const record = this.resolveRecord(qualifiedName);
|
|
264
|
+
return record?.isBoxed() ?? false;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Checks if a type is a primitive (intrinsic).
|
|
268
|
+
*/
|
|
269
|
+
isPrimitive(typeName) {
|
|
270
|
+
return isIntrinsicType(typeName);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Finds all classes matching a predicate across all namespaces.
|
|
274
|
+
*/
|
|
275
|
+
findClasses(predicate) {
|
|
276
|
+
this.ensureResolved();
|
|
277
|
+
const results = [];
|
|
278
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
279
|
+
for (const cls of ns.classes.values()) {
|
|
280
|
+
if (predicate(cls)) {
|
|
281
|
+
results.push(cls);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return results;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Finds all interfaces matching a predicate across all namespaces.
|
|
289
|
+
*/
|
|
290
|
+
findInterfaces(predicate) {
|
|
291
|
+
this.ensureResolved();
|
|
292
|
+
const results = [];
|
|
293
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
294
|
+
for (const iface of ns.interfaces.values()) {
|
|
295
|
+
if (predicate(iface)) {
|
|
296
|
+
results.push(iface);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return results;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Finds all records matching a predicate across all namespaces.
|
|
304
|
+
*/
|
|
305
|
+
findRecords(predicate) {
|
|
306
|
+
this.ensureResolved();
|
|
307
|
+
const results = [];
|
|
308
|
+
for (const ns of this.normalizedNamespaces.values()) {
|
|
309
|
+
for (const record of ns.records.values()) {
|
|
310
|
+
if (predicate(record)) {
|
|
311
|
+
results.push(record);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return results;
|
|
316
|
+
}
|
|
317
|
+
ensureResolved() {
|
|
318
|
+
if (!this.resolved) {
|
|
319
|
+
throw new Error("GirRepository.resolve() must be called before querying. Call resolve() after loading all GIR files.");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|