@gtkx/gir 0.19.0 → 0.21.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 +25 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/loader.d.ts +30 -0
- package/dist/internal/loader.d.ts.map +1 -0
- package/dist/internal/loader.js +109 -0
- package/dist/internal/loader.js.map +1 -0
- package/dist/internal/normalizer.d.ts +98 -15
- package/dist/internal/normalizer.d.ts.map +1 -1
- package/dist/internal/normalizer.js +381 -412
- package/dist/internal/normalizer.js.map +1 -1
- package/dist/internal/parser.d.ts +23 -31
- package/dist/internal/parser.d.ts.map +1 -1
- package/dist/internal/parser.js +228 -244
- package/dist/internal/parser.js.map +1 -1
- package/dist/internal/raw-types.d.ts +58 -109
- package/dist/internal/raw-types.d.ts.map +1 -1
- package/dist/internal/raw-types.js +0 -8
- package/dist/internal/raw-types.js.map +1 -1
- package/dist/intrinsics.d.ts.map +1 -1
- package/dist/intrinsics.js +7 -0
- package/dist/intrinsics.js.map +1 -1
- package/dist/model/alias.d.ts +21 -0
- package/dist/model/alias.d.ts.map +1 -0
- package/dist/model/alias.js +22 -0
- package/dist/model/alias.js.map +1 -0
- package/dist/model/callables.d.ts +102 -0
- package/dist/model/callables.d.ts.map +1 -0
- package/dist/model/callables.js +123 -0
- package/dist/model/callables.js.map +1 -0
- package/dist/model/callback.d.ts +22 -0
- package/dist/model/callback.d.ts.map +1 -0
- package/dist/model/callback.js +20 -0
- package/dist/model/callback.js.map +1 -0
- package/dist/model/class.d.ts +92 -0
- package/dist/model/class.d.ts.map +1 -0
- package/dist/model/class.js +171 -0
- package/dist/model/class.js.map +1 -0
- package/dist/model/constant.d.ts +21 -0
- package/dist/model/constant.d.ts.map +1 -0
- package/dist/model/constant.js +20 -0
- package/dist/model/constant.js.map +1 -0
- package/dist/model/enumeration.d.ts +41 -0
- package/dist/model/enumeration.d.ts.map +1 -0
- package/dist/model/enumeration.js +47 -0
- package/dist/model/enumeration.js.map +1 -0
- package/dist/model/field.d.ts +21 -0
- package/dist/model/field.d.ts.map +1 -0
- package/dist/model/field.js +20 -0
- package/dist/model/field.js.map +1 -0
- package/dist/model/interface.d.ts +44 -0
- package/dist/model/interface.d.ts.map +1 -0
- package/dist/model/interface.js +67 -0
- package/dist/model/interface.js.map +1 -0
- package/dist/model/namespace.d.ts +44 -0
- package/dist/model/namespace.d.ts.map +1 -0
- package/dist/model/namespace.js +36 -0
- package/dist/model/namespace.js.map +1 -0
- package/dist/model/parameter.d.ts +43 -0
- package/dist/model/parameter.d.ts.map +1 -0
- package/dist/model/parameter.js +54 -0
- package/dist/model/parameter.js.map +1 -0
- package/dist/model/property.d.ts +62 -0
- package/dist/model/property.d.ts.map +1 -0
- package/dist/model/property.js +69 -0
- package/dist/model/property.js.map +1 -0
- package/dist/model/record.d.ts +56 -0
- package/dist/model/record.d.ts.map +1 -0
- package/dist/model/record.js +70 -0
- package/dist/model/record.js.map +1 -0
- package/dist/model/repository-like.d.ts +19 -0
- package/dist/model/repository-like.d.ts.map +1 -0
- package/dist/model/repository-like.js +2 -0
- package/dist/model/repository-like.js.map +1 -0
- package/dist/model/signal.d.ts +22 -0
- package/dist/model/signal.d.ts.map +1 -0
- package/dist/model/signal.js +22 -0
- package/dist/model/signal.js.map +1 -0
- package/dist/model/type.d.ts +71 -0
- package/dist/model/type.d.ts.map +1 -0
- package/dist/model/type.js +112 -0
- package/dist/model/type.js.map +1 -0
- package/dist/repository.d.ts +92 -138
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +155 -219
- package/dist/repository.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +25 -39
- package/src/internal/loader.ts +127 -0
- package/src/internal/normalizer.ts +451 -475
- package/src/internal/parser.ts +242 -284
- package/src/internal/raw-types.ts +65 -116
- package/src/intrinsics.ts +7 -0
- package/src/model/alias.ts +31 -0
- package/src/model/callables.ts +172 -0
- package/src/model/callback.ts +30 -0
- package/src/model/class.ts +215 -0
- package/src/model/constant.ts +29 -0
- package/src/model/enumeration.ts +64 -0
- package/src/model/field.ts +29 -0
- package/src/model/interface.ts +89 -0
- package/src/model/namespace.ts +60 -0
- package/src/model/parameter.ts +74 -0
- package/src/model/property.ts +97 -0
- package/src/model/record.ts +97 -0
- package/src/model/repository-like.ts +20 -0
- package/src/model/signal.ts +32 -0
- package/src/model/type.ts +143 -0
- package/src/repository.ts +197 -283
- package/dist/types.d.ts +0 -655
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -879
- package/dist/types.js.map +0 -1
- package/src/types.ts +0 -1192
|
@@ -1,440 +1,409 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalizer that converts raw GIR types to normalized types.
|
|
3
|
-
*
|
|
4
|
-
* The key job is to qualify all type references with their namespace,
|
|
5
|
-
* except for intrinsic types which remain unqualified.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
1
|
import { isIntrinsicType } from "../intrinsics.js";
|
|
10
|
-
import { GirAlias
|
|
2
|
+
import { GirAlias } from "../model/alias.js";
|
|
3
|
+
import { GirConstructor, GirFunction, GirMethod } from "../model/callables.js";
|
|
4
|
+
import { GirCallback } from "../model/callback.js";
|
|
5
|
+
import { GirConstant } from "../model/constant.js";
|
|
6
|
+
import { GirEnumeration, GirEnumerationMember } from "../model/enumeration.js";
|
|
7
|
+
import { GirField } from "../model/field.js";
|
|
8
|
+
import { GirParameter } from "../model/parameter.js";
|
|
9
|
+
import { GirProperty, parseDefaultValue } from "../model/property.js";
|
|
10
|
+
import { GirRecord } from "../model/record.js";
|
|
11
|
+
import { GirSignal } from "../model/signal.js";
|
|
12
|
+
import { GirType } from "../model/type.js";
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* Converts raw parsed GIR data into model instances with fully qualified
|
|
15
|
+
* type names.
|
|
16
|
+
*
|
|
17
|
+
* Uses indexed lookups for O(1) type name resolution and strict error
|
|
18
|
+
* handling (throws on unresolvable type references).
|
|
13
19
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (const rawInterface of raw.interfaces) {
|
|
30
|
-
const normalized = normalizeInterface(rawInterface, nsName, ctx);
|
|
31
|
-
interfaces.set(normalized.name, normalized);
|
|
20
|
+
export class GirNormalizer {
|
|
21
|
+
typeIndex = new Map();
|
|
22
|
+
/**
|
|
23
|
+
* Normalizes all raw namespaces into intermediate namespace data.
|
|
24
|
+
*
|
|
25
|
+
* @param rawNamespaces - Raw namespaces keyed by name, in dependency order
|
|
26
|
+
* @returns Intermediate namespace data keyed by name, in the same order
|
|
27
|
+
*/
|
|
28
|
+
normalize(rawNamespaces) {
|
|
29
|
+
this.typeIndex = this.buildTypeIndex(rawNamespaces);
|
|
30
|
+
const result = new Map();
|
|
31
|
+
for (const [name, raw] of rawNamespaces) {
|
|
32
|
+
result.set(name, this.normalizeNamespace(raw));
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
+
buildTypeIndex(rawNamespaces) {
|
|
37
|
+
const index = new Map();
|
|
38
|
+
for (const [nsName, raw] of rawNamespaces) {
|
|
39
|
+
const names = new Set();
|
|
40
|
+
for (const c of raw.classes)
|
|
41
|
+
names.add(c.name);
|
|
42
|
+
for (const i of raw.interfaces)
|
|
43
|
+
names.add(i.name);
|
|
44
|
+
for (const r of raw.records)
|
|
45
|
+
names.add(r.name);
|
|
46
|
+
for (const e of raw.enumerations)
|
|
47
|
+
names.add(e.name);
|
|
48
|
+
for (const b of raw.bitfields)
|
|
49
|
+
names.add(b.name);
|
|
50
|
+
for (const cb of raw.callbacks)
|
|
51
|
+
names.add(cb.name);
|
|
52
|
+
for (const a of raw.aliases)
|
|
53
|
+
names.add(a.name);
|
|
54
|
+
index.set(nsName, names);
|
|
55
|
+
}
|
|
56
|
+
return index;
|
|
36
57
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
58
|
+
normalizeNamespace(raw) {
|
|
59
|
+
const nsName = raw.name;
|
|
60
|
+
const classes = new Map();
|
|
61
|
+
for (const rawClass of raw.classes) {
|
|
62
|
+
const data = this.normalizeClass(rawClass, nsName);
|
|
63
|
+
classes.set(data.name, data);
|
|
64
|
+
}
|
|
65
|
+
const interfaces = new Map();
|
|
66
|
+
for (const rawIface of raw.interfaces) {
|
|
67
|
+
const data = this.normalizeInterface(rawIface, nsName);
|
|
68
|
+
interfaces.set(data.name, data);
|
|
69
|
+
}
|
|
70
|
+
const records = new Map();
|
|
71
|
+
for (const rawRecord of raw.records) {
|
|
72
|
+
const record = this.normalizeRecord(rawRecord, nsName);
|
|
73
|
+
records.set(record.name, record);
|
|
74
|
+
}
|
|
75
|
+
const enumerations = new Map();
|
|
76
|
+
for (const rawEnum of raw.enumerations) {
|
|
77
|
+
const enumeration = this.normalizeEnumeration(rawEnum, nsName);
|
|
78
|
+
enumerations.set(enumeration.name, enumeration);
|
|
79
|
+
}
|
|
80
|
+
const bitfields = new Map();
|
|
81
|
+
for (const rawBitfield of raw.bitfields) {
|
|
82
|
+
const bitfield = this.normalizeEnumeration(rawBitfield, nsName);
|
|
83
|
+
bitfields.set(bitfield.name, bitfield);
|
|
84
|
+
}
|
|
85
|
+
const callbacks = new Map();
|
|
86
|
+
for (const rawCb of raw.callbacks) {
|
|
87
|
+
const cb = this.normalizeCallback(rawCb, nsName);
|
|
88
|
+
callbacks.set(cb.name, cb);
|
|
89
|
+
}
|
|
90
|
+
const functions = new Map();
|
|
91
|
+
for (const rawFunc of raw.functions) {
|
|
92
|
+
const func = this.normalizeFunction(rawFunc, nsName);
|
|
93
|
+
functions.set(func.name, func);
|
|
94
|
+
}
|
|
95
|
+
const constants = new Map();
|
|
96
|
+
for (const rawConst of raw.constants) {
|
|
97
|
+
const constant = this.normalizeConstant(rawConst, nsName);
|
|
98
|
+
constants.set(constant.name, constant);
|
|
99
|
+
}
|
|
100
|
+
const aliases = new Map();
|
|
101
|
+
for (const rawAlias of raw.aliases) {
|
|
102
|
+
const alias = this.normalizeAlias(rawAlias, nsName);
|
|
103
|
+
aliases.set(alias.name, alias);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
name: raw.name,
|
|
107
|
+
version: raw.version,
|
|
108
|
+
sharedLibrary: raw.sharedLibrary,
|
|
109
|
+
cPrefix: raw.cPrefix,
|
|
110
|
+
classes,
|
|
111
|
+
interfaces,
|
|
112
|
+
records,
|
|
113
|
+
enumerations,
|
|
114
|
+
bitfields,
|
|
115
|
+
callbacks,
|
|
116
|
+
functions,
|
|
117
|
+
constants,
|
|
118
|
+
aliases,
|
|
119
|
+
doc: raw.doc,
|
|
120
|
+
};
|
|
40
121
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
122
|
+
qualifyTypeName(typeName, currentNamespace) {
|
|
123
|
+
if (isIntrinsicType(typeName))
|
|
124
|
+
return typeName;
|
|
125
|
+
if (typeName.includes("."))
|
|
126
|
+
return typeName;
|
|
127
|
+
if (this.typeIndex.get(currentNamespace)?.has(typeName)) {
|
|
128
|
+
return `${currentNamespace}.${typeName}`;
|
|
129
|
+
}
|
|
130
|
+
for (const [nsName, names] of this.typeIndex) {
|
|
131
|
+
if (nsName !== currentNamespace && names.has(typeName)) {
|
|
132
|
+
return `${nsName}.${typeName}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return `${currentNamespace}.${typeName}`;
|
|
44
136
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
137
|
+
normalizeType(raw, currentNamespace) {
|
|
138
|
+
if (raw.containerType === "ghashtable") {
|
|
139
|
+
const typeParams = (raw.typeParameters ?? []).map((tp) => this.normalizeType(tp, currentNamespace));
|
|
140
|
+
return new GirType({
|
|
141
|
+
name: `GLib.HashTable`,
|
|
142
|
+
cType: raw.cType,
|
|
143
|
+
containerType: raw.containerType,
|
|
144
|
+
transferOwnership: raw.transferOwnership,
|
|
145
|
+
nullable: raw.nullable ?? false,
|
|
146
|
+
isArray: false,
|
|
147
|
+
elementType: typeParams[1] ?? null,
|
|
148
|
+
typeParameters: typeParams,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (raw.containerType === "gptrarray" || raw.containerType === "garray") {
|
|
152
|
+
const typeParams = (raw.typeParameters ?? []).map((tp) => this.normalizeType(tp, currentNamespace));
|
|
153
|
+
const typeName = raw.containerType === "gptrarray" ? "PtrArray" : "Array";
|
|
154
|
+
return new GirType({
|
|
155
|
+
name: `GLib.${typeName}`,
|
|
156
|
+
cType: raw.cType,
|
|
157
|
+
containerType: raw.containerType,
|
|
158
|
+
transferOwnership: raw.transferOwnership,
|
|
159
|
+
nullable: raw.nullable ?? false,
|
|
160
|
+
isArray: true,
|
|
161
|
+
elementType: typeParams[0] ?? null,
|
|
162
|
+
typeParameters: typeParams,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (raw.containerType === "gbytearray") {
|
|
166
|
+
const elementType = raw.elementType ? this.normalizeType(raw.elementType, currentNamespace) : null;
|
|
167
|
+
return new GirType({
|
|
168
|
+
name: `GLib.ByteArray`,
|
|
169
|
+
cType: raw.cType,
|
|
170
|
+
containerType: raw.containerType,
|
|
171
|
+
transferOwnership: raw.transferOwnership,
|
|
172
|
+
nullable: raw.nullable ?? false,
|
|
173
|
+
isArray: true,
|
|
174
|
+
elementType,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (raw.containerType === "glist" || raw.containerType === "gslist") {
|
|
178
|
+
const elementType = raw.elementType ? this.normalizeType(raw.elementType, currentNamespace) : null;
|
|
179
|
+
return new GirType({
|
|
180
|
+
name: "array",
|
|
181
|
+
cType: raw.cType,
|
|
182
|
+
containerType: raw.containerType,
|
|
183
|
+
transferOwnership: raw.transferOwnership,
|
|
184
|
+
nullable: raw.nullable ?? false,
|
|
185
|
+
isArray: true,
|
|
186
|
+
elementType,
|
|
187
|
+
typeParameters: elementType ? [elementType] : [],
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const isArray = raw.isArray === true || raw.name === "array";
|
|
191
|
+
if (isArray) {
|
|
192
|
+
return new GirType({
|
|
193
|
+
name: "array",
|
|
194
|
+
cType: raw.cType,
|
|
195
|
+
isArray: true,
|
|
196
|
+
elementType: raw.elementType ? this.normalizeType(raw.elementType, currentNamespace) : null,
|
|
197
|
+
transferOwnership: raw.transferOwnership,
|
|
198
|
+
nullable: raw.nullable ?? false,
|
|
199
|
+
sizeParamIndex: raw.sizeParamIndex,
|
|
200
|
+
zeroTerminated: raw.zeroTerminated,
|
|
201
|
+
fixedSize: raw.fixedSize,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return new GirType({
|
|
205
|
+
name: this.qualifyTypeName(raw.name, currentNamespace),
|
|
206
|
+
cType: raw.cType,
|
|
207
|
+
isArray: false,
|
|
208
|
+
elementType: null,
|
|
209
|
+
transferOwnership: raw.transferOwnership,
|
|
210
|
+
nullable: raw.nullable ?? false,
|
|
211
|
+
});
|
|
48
212
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
213
|
+
normalizeClass(raw, currentNamespace) {
|
|
214
|
+
let parent = null;
|
|
215
|
+
if (raw.parent) {
|
|
216
|
+
const qualified = this.qualifyTypeName(raw.parent, currentNamespace);
|
|
217
|
+
if (qualified.includes(".")) {
|
|
218
|
+
parent = qualified;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
name: raw.name,
|
|
223
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
224
|
+
cType: raw.cType,
|
|
225
|
+
parent,
|
|
226
|
+
abstract: raw.abstract ?? false,
|
|
227
|
+
glibTypeName: raw.glibTypeName,
|
|
228
|
+
glibGetType: raw.glibGetType,
|
|
229
|
+
cSymbolPrefix: raw.cSymbolPrefix,
|
|
230
|
+
fundamental: raw.fundamental ?? false,
|
|
231
|
+
refFunc: raw.refFunc,
|
|
232
|
+
unrefFunc: raw.unrefFunc,
|
|
233
|
+
implements: raw.implements.map((impl) => this.qualifyTypeName(impl, currentNamespace)),
|
|
234
|
+
methods: raw.methods.map((m) => this.normalizeMethod(m, currentNamespace)),
|
|
235
|
+
constructors: raw.constructors.map((c) => this.normalizeConstructor(c, currentNamespace)),
|
|
236
|
+
staticFunctions: raw.functions.map((f) => this.normalizeFunction(f, currentNamespace)),
|
|
237
|
+
properties: raw.properties.map((p) => this.normalizeProperty(p, currentNamespace)),
|
|
238
|
+
signals: raw.signals.map((s) => this.normalizeSignal(s, currentNamespace)),
|
|
239
|
+
doc: raw.doc,
|
|
240
|
+
};
|
|
52
241
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
242
|
+
normalizeInterface(raw, currentNamespace) {
|
|
243
|
+
return {
|
|
244
|
+
name: raw.name,
|
|
245
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
246
|
+
cType: raw.cType,
|
|
247
|
+
glibTypeName: raw.glibTypeName,
|
|
248
|
+
prerequisites: raw.prerequisites.map((prereq) => this.qualifyTypeName(prereq, currentNamespace)),
|
|
249
|
+
methods: raw.methods.map((m) => this.normalizeMethod(m, currentNamespace)),
|
|
250
|
+
properties: raw.properties.map((p) => this.normalizeProperty(p, currentNamespace)),
|
|
251
|
+
signals: raw.signals.map((s) => this.normalizeSignal(s, currentNamespace)),
|
|
252
|
+
doc: raw.doc,
|
|
253
|
+
};
|
|
56
254
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
255
|
+
normalizeRecord(raw, currentNamespace) {
|
|
256
|
+
return new GirRecord({
|
|
257
|
+
name: raw.name,
|
|
258
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
259
|
+
cType: raw.cType,
|
|
260
|
+
opaque: raw.opaque ?? false,
|
|
261
|
+
disguised: raw.disguised ?? false,
|
|
262
|
+
glibTypeName: raw.glibTypeName,
|
|
263
|
+
glibGetType: raw.glibGetType,
|
|
264
|
+
isGtypeStructFor: raw.isGtypeStructFor,
|
|
265
|
+
copyFunction: raw.copyFunction,
|
|
266
|
+
freeFunction: raw.freeFunction,
|
|
267
|
+
fields: raw.fields.map((f) => this.normalizeField(f, currentNamespace)),
|
|
268
|
+
methods: raw.methods.map((m) => this.normalizeMethod(m, currentNamespace)),
|
|
269
|
+
constructors: raw.constructors.map((c) => this.normalizeConstructor(c, currentNamespace)),
|
|
270
|
+
staticFunctions: raw.functions.map((f) => this.normalizeFunction(f, currentNamespace)),
|
|
271
|
+
doc: raw.doc,
|
|
272
|
+
});
|
|
60
273
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
doc: raw.doc,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Normalizes a type reference, qualifying it with its namespace if not intrinsic.
|
|
80
|
-
*/
|
|
81
|
-
const normalizeTypeName = (typeName, currentNamespace, ctx) => {
|
|
82
|
-
if (isIntrinsicType(typeName)) {
|
|
83
|
-
return typeName;
|
|
274
|
+
normalizeEnumeration(raw, currentNamespace) {
|
|
275
|
+
return new GirEnumeration({
|
|
276
|
+
name: raw.name,
|
|
277
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
278
|
+
cType: raw.cType,
|
|
279
|
+
members: raw.members.map((m) => new GirEnumerationMember({
|
|
280
|
+
name: m.name,
|
|
281
|
+
value: m.value,
|
|
282
|
+
cIdentifier: m.cIdentifier,
|
|
283
|
+
doc: m.doc,
|
|
284
|
+
})),
|
|
285
|
+
glibGetType: raw.glibGetType,
|
|
286
|
+
doc: raw.doc,
|
|
287
|
+
});
|
|
84
288
|
}
|
|
85
|
-
|
|
86
|
-
return
|
|
289
|
+
normalizeCallback(raw, currentNamespace) {
|
|
290
|
+
return new GirCallback({
|
|
291
|
+
name: raw.name,
|
|
292
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
293
|
+
cType: raw.cType,
|
|
294
|
+
returnType: this.normalizeType(raw.returnType, currentNamespace),
|
|
295
|
+
parameters: raw.parameters.map((p) => this.normalizeParameter(p, currentNamespace)),
|
|
296
|
+
doc: raw.doc,
|
|
297
|
+
});
|
|
87
298
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
299
|
+
normalizeConstant(raw, currentNamespace) {
|
|
300
|
+
return new GirConstant({
|
|
301
|
+
name: raw.name,
|
|
302
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
303
|
+
cType: raw.cType,
|
|
304
|
+
value: raw.value,
|
|
305
|
+
type: this.normalizeType(raw.type, currentNamespace),
|
|
306
|
+
doc: raw.doc,
|
|
307
|
+
});
|
|
91
308
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
309
|
+
normalizeAlias(raw, currentNamespace) {
|
|
310
|
+
return new GirAlias({
|
|
311
|
+
name: raw.name,
|
|
312
|
+
qualifiedName: `${currentNamespace}.${raw.name}`,
|
|
313
|
+
cType: raw.cType,
|
|
314
|
+
targetType: this.normalizeType(raw.targetType, currentNamespace),
|
|
315
|
+
doc: raw.doc,
|
|
316
|
+
});
|
|
96
317
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
cType: raw.cType,
|
|
113
|
-
containerType: raw.containerType,
|
|
114
|
-
transferOwnership: raw.transferOwnership,
|
|
115
|
-
nullable: raw.nullable ?? false,
|
|
116
|
-
});
|
|
117
|
-
/**
|
|
118
|
-
* Normalizes a raw type to a normalized type.
|
|
119
|
-
*/
|
|
120
|
-
const normalizeType = (raw, currentNamespace, ctx) => {
|
|
121
|
-
if (raw.containerType === "ghashtable") {
|
|
122
|
-
const typeParams = (raw.typeParameters ?? []).map((tp) => normalizeType(tp, currentNamespace, ctx));
|
|
123
|
-
return new GirType({
|
|
124
|
-
...buildContainerTypeBase(raw),
|
|
125
|
-
name: qualifiedName("GLib", "HashTable"),
|
|
126
|
-
isArray: false,
|
|
127
|
-
elementType: typeParams[1] ?? null,
|
|
128
|
-
typeParameters: typeParams,
|
|
318
|
+
normalizeMethod(raw, currentNamespace) {
|
|
319
|
+
return new GirMethod({
|
|
320
|
+
name: raw.name,
|
|
321
|
+
cIdentifier: raw.cIdentifier,
|
|
322
|
+
returnType: this.normalizeType(raw.returnType, currentNamespace),
|
|
323
|
+
parameters: raw.parameters.map((p) => this.normalizeParameter(p, currentNamespace)),
|
|
324
|
+
instanceParameter: raw.instanceParameter
|
|
325
|
+
? this.normalizeParameter(raw.instanceParameter, currentNamespace)
|
|
326
|
+
: undefined,
|
|
327
|
+
throws: raw.throws ?? false,
|
|
328
|
+
doc: raw.doc,
|
|
329
|
+
returnDoc: raw.returnDoc,
|
|
330
|
+
finishFunc: raw.finishFunc,
|
|
331
|
+
shadows: raw.shadows,
|
|
332
|
+
shadowedBy: raw.shadowedBy,
|
|
129
333
|
});
|
|
130
334
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
335
|
+
normalizeConstructor(raw, currentNamespace) {
|
|
336
|
+
return new GirConstructor({
|
|
337
|
+
name: raw.name,
|
|
338
|
+
cIdentifier: raw.cIdentifier,
|
|
339
|
+
returnType: this.normalizeType(raw.returnType, currentNamespace),
|
|
340
|
+
parameters: raw.parameters.map((p) => this.normalizeParameter(p, currentNamespace)),
|
|
341
|
+
throws: raw.throws ?? false,
|
|
342
|
+
doc: raw.doc,
|
|
343
|
+
returnDoc: raw.returnDoc,
|
|
344
|
+
shadows: raw.shadows,
|
|
345
|
+
shadowedBy: raw.shadowedBy,
|
|
140
346
|
});
|
|
141
347
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
348
|
+
normalizeFunction(raw, currentNamespace) {
|
|
349
|
+
return new GirFunction({
|
|
350
|
+
name: raw.name,
|
|
351
|
+
cIdentifier: raw.cIdentifier,
|
|
352
|
+
returnType: this.normalizeType(raw.returnType, currentNamespace),
|
|
353
|
+
parameters: raw.parameters.map((p) => this.normalizeParameter(p, currentNamespace)),
|
|
354
|
+
throws: raw.throws ?? false,
|
|
355
|
+
doc: raw.doc,
|
|
356
|
+
returnDoc: raw.returnDoc,
|
|
357
|
+
shadows: raw.shadows,
|
|
358
|
+
shadowedBy: raw.shadowedBy,
|
|
150
359
|
});
|
|
151
360
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
elementType: normalizeType(raw.elementType, currentNamespace, ctx),
|
|
159
|
-
transferOwnership: raw.transferOwnership,
|
|
361
|
+
normalizeParameter(raw, currentNamespace) {
|
|
362
|
+
return new GirParameter({
|
|
363
|
+
name: raw.name,
|
|
364
|
+
type: this.normalizeType(raw.type, currentNamespace),
|
|
365
|
+
direction: raw.direction ?? "in",
|
|
366
|
+
callerAllocates: raw.callerAllocates ?? false,
|
|
160
367
|
nullable: raw.nullable ?? false,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
368
|
+
optional: raw.optional ?? false,
|
|
369
|
+
scope: raw.scope,
|
|
370
|
+
closure: raw.closure,
|
|
371
|
+
destroy: raw.destroy,
|
|
372
|
+
transferOwnership: raw.transferOwnership,
|
|
373
|
+
doc: raw.doc,
|
|
164
374
|
});
|
|
165
375
|
}
|
|
166
|
-
|
|
167
|
-
return new
|
|
168
|
-
name:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
376
|
+
normalizeProperty(raw, currentNamespace) {
|
|
377
|
+
return new GirProperty({
|
|
378
|
+
name: raw.name,
|
|
379
|
+
type: this.normalizeType(raw.type, currentNamespace),
|
|
380
|
+
readable: raw.readable ?? true,
|
|
381
|
+
writable: raw.writable ?? false,
|
|
382
|
+
constructOnly: raw.constructOnly ?? false,
|
|
383
|
+
defaultValue: parseDefaultValue(raw.defaultValueRaw),
|
|
384
|
+
getter: raw.getter,
|
|
385
|
+
setter: raw.setter,
|
|
386
|
+
doc: raw.doc,
|
|
177
387
|
});
|
|
178
388
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Normalizes a raw class to a normalized class.
|
|
190
|
-
*/
|
|
191
|
-
const normalizeClass = (raw, currentNamespace, ctx) => {
|
|
192
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
193
|
-
let parent = null;
|
|
194
|
-
if (raw.parent) {
|
|
195
|
-
const normalizedParent = normalizeTypeName(raw.parent, currentNamespace, ctx);
|
|
196
|
-
if (typeof normalizedParent !== "string" || normalizedParent.includes(".")) {
|
|
197
|
-
parent = normalizedParent;
|
|
198
|
-
}
|
|
389
|
+
normalizeSignal(raw, currentNamespace) {
|
|
390
|
+
return new GirSignal({
|
|
391
|
+
name: raw.name,
|
|
392
|
+
when: raw.when ?? "last",
|
|
393
|
+
returnType: raw.returnType ? this.normalizeType(raw.returnType, currentNamespace) : null,
|
|
394
|
+
parameters: (raw.parameters ?? []).map((p) => this.normalizeParameter(p, currentNamespace)),
|
|
395
|
+
doc: raw.doc,
|
|
396
|
+
});
|
|
199
397
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
glibGetType: raw.glibGetType,
|
|
212
|
-
cSymbolPrefix: raw.cSymbolPrefix,
|
|
213
|
-
fundamental: raw.fundamental ?? false,
|
|
214
|
-
refFunc: raw.refFunc,
|
|
215
|
-
unrefFunc: raw.unrefFunc,
|
|
216
|
-
implements: implementsRefs,
|
|
217
|
-
methods: raw.methods.map((m) => normalizeMethod(m, currentNamespace, ctx)),
|
|
218
|
-
constructors: raw.constructors.map((c) => normalizeConstructor(c, currentNamespace, ctx)),
|
|
219
|
-
staticFunctions: raw.functions.map((f) => normalizeFunction(f, currentNamespace, ctx)),
|
|
220
|
-
properties: raw.properties.map((p) => normalizeProperty(p, currentNamespace, ctx)),
|
|
221
|
-
signals: raw.signals.map((s) => normalizeSignal(s, currentNamespace, ctx)),
|
|
222
|
-
doc: raw.doc,
|
|
223
|
-
});
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Normalizes a raw interface to a normalized interface.
|
|
227
|
-
*/
|
|
228
|
-
const normalizeInterface = (raw, currentNamespace, ctx) => {
|
|
229
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
230
|
-
const prerequisites = raw.prerequisites.map((prereq) => {
|
|
231
|
-
const normalized = normalizeTypeName(prereq, currentNamespace, ctx);
|
|
232
|
-
return normalized;
|
|
233
|
-
});
|
|
234
|
-
return new GirInterface({
|
|
235
|
-
name: raw.name,
|
|
236
|
-
qualifiedName: qn,
|
|
237
|
-
cType: raw.cType,
|
|
238
|
-
glibTypeName: raw.glibTypeName,
|
|
239
|
-
prerequisites,
|
|
240
|
-
methods: raw.methods.map((m) => normalizeMethod(m, currentNamespace, ctx)),
|
|
241
|
-
properties: raw.properties.map((p) => normalizeProperty(p, currentNamespace, ctx)),
|
|
242
|
-
signals: raw.signals.map((s) => normalizeSignal(s, currentNamespace, ctx)),
|
|
243
|
-
doc: raw.doc,
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Normalizes a raw record to a normalized record.
|
|
248
|
-
*/
|
|
249
|
-
const normalizeRecord = (raw, currentNamespace, ctx) => {
|
|
250
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
251
|
-
return new GirRecord({
|
|
252
|
-
name: raw.name,
|
|
253
|
-
qualifiedName: qn,
|
|
254
|
-
cType: raw.cType,
|
|
255
|
-
opaque: raw.opaque ?? false,
|
|
256
|
-
disguised: raw.disguised ?? false,
|
|
257
|
-
glibTypeName: raw.glibTypeName,
|
|
258
|
-
glibGetType: raw.glibGetType,
|
|
259
|
-
isGtypeStructFor: raw.isGtypeStructFor,
|
|
260
|
-
copyFunction: raw.copyFunction,
|
|
261
|
-
freeFunction: raw.freeFunction,
|
|
262
|
-
fields: raw.fields.map((f) => normalizeField(f, currentNamespace, ctx)),
|
|
263
|
-
methods: raw.methods.map((m) => normalizeMethod(m, currentNamespace, ctx)),
|
|
264
|
-
constructors: raw.constructors.map((c) => normalizeConstructor(c, currentNamespace, ctx)),
|
|
265
|
-
staticFunctions: raw.functions.map((f) => normalizeFunction(f, currentNamespace, ctx)),
|
|
266
|
-
doc: raw.doc,
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* Normalizes a raw enumeration to a normalized enumeration.
|
|
271
|
-
*/
|
|
272
|
-
const normalizeEnumeration = (raw, currentNamespace) => {
|
|
273
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
274
|
-
return new GirEnumeration({
|
|
275
|
-
name: raw.name,
|
|
276
|
-
qualifiedName: qn,
|
|
277
|
-
cType: raw.cType,
|
|
278
|
-
members: raw.members.map((m) => new GirEnumerationMember({
|
|
279
|
-
name: m.name,
|
|
280
|
-
value: m.value,
|
|
281
|
-
cIdentifier: m.cIdentifier,
|
|
282
|
-
doc: m.doc,
|
|
283
|
-
})),
|
|
284
|
-
glibGetType: raw.glibGetType,
|
|
285
|
-
doc: raw.doc,
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* Normalizes a raw callback to a normalized callback.
|
|
290
|
-
*/
|
|
291
|
-
const normalizeCallback = (raw, currentNamespace, ctx) => {
|
|
292
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
293
|
-
return new GirCallback({
|
|
294
|
-
name: raw.name,
|
|
295
|
-
qualifiedName: qn,
|
|
296
|
-
cType: raw.cType,
|
|
297
|
-
returnType: normalizeType(raw.returnType, currentNamespace, ctx),
|
|
298
|
-
parameters: raw.parameters.map((p) => normalizeParameter(p, currentNamespace, ctx)),
|
|
299
|
-
doc: raw.doc,
|
|
300
|
-
});
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* Normalizes a raw constant to a normalized constant.
|
|
304
|
-
*/
|
|
305
|
-
const normalizeConstant = (raw, currentNamespace, ctx) => {
|
|
306
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
307
|
-
return new GirConstant({
|
|
308
|
-
name: raw.name,
|
|
309
|
-
qualifiedName: qn,
|
|
310
|
-
cType: raw.cType,
|
|
311
|
-
value: raw.value,
|
|
312
|
-
type: normalizeType(raw.type, currentNamespace, ctx),
|
|
313
|
-
doc: raw.doc,
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* Normalizes a raw alias to a normalized alias.
|
|
318
|
-
*/
|
|
319
|
-
const normalizeAlias = (raw, currentNamespace, ctx) => {
|
|
320
|
-
const qn = qualifiedName(currentNamespace, raw.name);
|
|
321
|
-
return new GirAlias({
|
|
322
|
-
name: raw.name,
|
|
323
|
-
qualifiedName: qn,
|
|
324
|
-
cType: raw.cType,
|
|
325
|
-
targetType: normalizeType(raw.targetType, currentNamespace, ctx),
|
|
326
|
-
doc: raw.doc,
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* Normalizes a raw method to a normalized method.
|
|
331
|
-
*/
|
|
332
|
-
const normalizeMethod = (raw, currentNamespace, ctx) => {
|
|
333
|
-
return new GirMethod({
|
|
334
|
-
name: raw.name,
|
|
335
|
-
cIdentifier: raw.cIdentifier,
|
|
336
|
-
returnType: normalizeType(raw.returnType, currentNamespace, ctx),
|
|
337
|
-
parameters: raw.parameters.map((p) => normalizeParameter(p, currentNamespace, ctx)),
|
|
338
|
-
instanceParameter: raw.instanceParameter
|
|
339
|
-
? normalizeParameter(raw.instanceParameter, currentNamespace, ctx)
|
|
340
|
-
: undefined,
|
|
341
|
-
throws: raw.throws ?? false,
|
|
342
|
-
doc: raw.doc,
|
|
343
|
-
returnDoc: raw.returnDoc,
|
|
344
|
-
finishFunc: raw.finishFunc,
|
|
345
|
-
shadows: raw.shadows,
|
|
346
|
-
shadowedBy: raw.shadowedBy,
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* Normalizes a raw constructor to a normalized constructor.
|
|
351
|
-
*/
|
|
352
|
-
const normalizeConstructor = (raw, currentNamespace, ctx) => {
|
|
353
|
-
return new GirConstructor({
|
|
354
|
-
name: raw.name,
|
|
355
|
-
cIdentifier: raw.cIdentifier,
|
|
356
|
-
returnType: normalizeType(raw.returnType, currentNamespace, ctx),
|
|
357
|
-
parameters: raw.parameters.map((p) => normalizeParameter(p, currentNamespace, ctx)),
|
|
358
|
-
throws: raw.throws ?? false,
|
|
359
|
-
doc: raw.doc,
|
|
360
|
-
returnDoc: raw.returnDoc,
|
|
361
|
-
shadows: raw.shadows,
|
|
362
|
-
shadowedBy: raw.shadowedBy,
|
|
363
|
-
});
|
|
364
|
-
};
|
|
365
|
-
/**
|
|
366
|
-
* Normalizes a raw function to a normalized function.
|
|
367
|
-
*/
|
|
368
|
-
const normalizeFunction = (raw, currentNamespace, ctx) => {
|
|
369
|
-
return new GirFunction({
|
|
370
|
-
name: raw.name,
|
|
371
|
-
cIdentifier: raw.cIdentifier,
|
|
372
|
-
returnType: normalizeType(raw.returnType, currentNamespace, ctx),
|
|
373
|
-
parameters: raw.parameters.map((p) => normalizeParameter(p, currentNamespace, ctx)),
|
|
374
|
-
throws: raw.throws ?? false,
|
|
375
|
-
doc: raw.doc,
|
|
376
|
-
returnDoc: raw.returnDoc,
|
|
377
|
-
shadows: raw.shadows,
|
|
378
|
-
shadowedBy: raw.shadowedBy,
|
|
379
|
-
});
|
|
380
|
-
};
|
|
381
|
-
/**
|
|
382
|
-
* Normalizes a raw parameter to a normalized parameter.
|
|
383
|
-
*/
|
|
384
|
-
const normalizeParameter = (raw, currentNamespace, ctx) => {
|
|
385
|
-
return new GirParameter({
|
|
386
|
-
name: raw.name,
|
|
387
|
-
type: normalizeType(raw.type, currentNamespace, ctx),
|
|
388
|
-
direction: raw.direction ?? "in",
|
|
389
|
-
callerAllocates: raw.callerAllocates ?? false,
|
|
390
|
-
nullable: raw.nullable ?? false,
|
|
391
|
-
optional: raw.optional ?? false,
|
|
392
|
-
scope: raw.scope,
|
|
393
|
-
closure: raw.closure,
|
|
394
|
-
destroy: raw.destroy,
|
|
395
|
-
transferOwnership: raw.transferOwnership,
|
|
396
|
-
doc: raw.doc,
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
/**
|
|
400
|
-
* Normalizes a raw property to a normalized property.
|
|
401
|
-
*/
|
|
402
|
-
const normalizeProperty = (raw, currentNamespace, ctx) => {
|
|
403
|
-
return new GirProperty({
|
|
404
|
-
name: raw.name,
|
|
405
|
-
type: normalizeType(raw.type, currentNamespace, ctx),
|
|
406
|
-
readable: raw.readable ?? true,
|
|
407
|
-
writable: raw.writable ?? false,
|
|
408
|
-
constructOnly: raw.constructOnly ?? false,
|
|
409
|
-
defaultValue: parseDefaultValue(raw.defaultValueRaw),
|
|
410
|
-
getter: raw.getter,
|
|
411
|
-
setter: raw.setter,
|
|
412
|
-
doc: raw.doc,
|
|
413
|
-
});
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* Normalizes a raw signal to a normalized signal.
|
|
417
|
-
*/
|
|
418
|
-
const normalizeSignal = (raw, currentNamespace, ctx) => {
|
|
419
|
-
return new GirSignal({
|
|
420
|
-
name: raw.name,
|
|
421
|
-
when: raw.when ?? "last",
|
|
422
|
-
returnType: raw.returnType ? normalizeType(raw.returnType, currentNamespace, ctx) : null,
|
|
423
|
-
parameters: (raw.parameters ?? []).map((p) => normalizeParameter(p, currentNamespace, ctx)),
|
|
424
|
-
doc: raw.doc,
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
/**
|
|
428
|
-
* Normalizes a raw field to a normalized field.
|
|
429
|
-
*/
|
|
430
|
-
const normalizeField = (raw, currentNamespace, ctx) => {
|
|
431
|
-
return new GirField({
|
|
432
|
-
name: raw.name,
|
|
433
|
-
type: normalizeType(raw.type, currentNamespace, ctx),
|
|
434
|
-
writable: raw.writable ?? false,
|
|
435
|
-
readable: raw.readable ?? true,
|
|
436
|
-
private: raw.private ?? false,
|
|
437
|
-
doc: raw.doc,
|
|
438
|
-
});
|
|
439
|
-
};
|
|
398
|
+
normalizeField(raw, currentNamespace) {
|
|
399
|
+
return new GirField({
|
|
400
|
+
name: raw.name,
|
|
401
|
+
type: this.normalizeType(raw.type, currentNamespace),
|
|
402
|
+
writable: raw.writable ?? false,
|
|
403
|
+
readable: raw.readable ?? true,
|
|
404
|
+
private: raw.private ?? false,
|
|
405
|
+
doc: raw.doc,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
440
409
|
//# sourceMappingURL=normalizer.js.map
|