@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,22 +1,23 @@
|
|
|
1
|
+
import type { ContainerType } from "../model/type.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* These types represent the structure of parsed GIR XML data before normalization.
|
|
5
|
-
* They are internal to the @gtkx/gir package and not exported publicly.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
4
|
+
* A dependency declared via `<include>` in a GIR file.
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
export type RawDependency = {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Contains all type definitions from a single GIR file, including
|
|
18
|
-
* classes, interfaces, functions, enums, records, and callbacks.
|
|
12
|
+
* Lightweight header extracted from a GIR file without full parsing.
|
|
13
|
+
* Used to build the dependency graph before committing to full XML parsing.
|
|
19
14
|
*/
|
|
15
|
+
export type RawRepositoryHeader = {
|
|
16
|
+
namespaceName: string;
|
|
17
|
+
namespaceVersion: string;
|
|
18
|
+
dependencies: RawDependency[];
|
|
19
|
+
};
|
|
20
|
+
|
|
20
21
|
export type RawNamespace = {
|
|
21
22
|
name: string;
|
|
22
23
|
version: string;
|
|
@@ -34,45 +35,6 @@ export type RawNamespace = {
|
|
|
34
35
|
doc?: string;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
/**
|
|
38
|
-
* A constant value defined in a GIR namespace.
|
|
39
|
-
*/
|
|
40
|
-
export type RawConstant = {
|
|
41
|
-
name: string;
|
|
42
|
-
cType: string;
|
|
43
|
-
value: string;
|
|
44
|
-
type: RawType;
|
|
45
|
-
doc?: string;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A callback type definition (function pointer type).
|
|
50
|
-
*/
|
|
51
|
-
export type RawCallback = {
|
|
52
|
-
name: string;
|
|
53
|
-
cType: string;
|
|
54
|
-
returnType: RawType;
|
|
55
|
-
parameters: RawParameter[];
|
|
56
|
-
doc?: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* A GObject interface definition.
|
|
61
|
-
*/
|
|
62
|
-
export type RawInterface = {
|
|
63
|
-
name: string;
|
|
64
|
-
cType: string;
|
|
65
|
-
glibTypeName?: string;
|
|
66
|
-
prerequisites: string[];
|
|
67
|
-
methods: RawMethod[];
|
|
68
|
-
properties: RawProperty[];
|
|
69
|
-
signals: RawSignal[];
|
|
70
|
-
doc?: string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* A GObject class definition.
|
|
75
|
-
*/
|
|
76
38
|
export type RawClass = {
|
|
77
39
|
name: string;
|
|
78
40
|
cType: string;
|
|
@@ -93,9 +55,17 @@ export type RawClass = {
|
|
|
93
55
|
doc?: string;
|
|
94
56
|
};
|
|
95
57
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
58
|
+
export type RawInterface = {
|
|
59
|
+
name: string;
|
|
60
|
+
cType: string;
|
|
61
|
+
glibTypeName?: string;
|
|
62
|
+
prerequisites: string[];
|
|
63
|
+
methods: RawMethod[];
|
|
64
|
+
properties: RawProperty[];
|
|
65
|
+
signals: RawSignal[];
|
|
66
|
+
doc?: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
99
69
|
export type RawRecord = {
|
|
100
70
|
name: string;
|
|
101
71
|
cType: string;
|
|
@@ -113,21 +83,44 @@ export type RawRecord = {
|
|
|
113
83
|
doc?: string;
|
|
114
84
|
};
|
|
115
85
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
export type RawEnumeration = {
|
|
87
|
+
name: string;
|
|
88
|
+
cType: string;
|
|
89
|
+
members: RawEnumerationMember[];
|
|
90
|
+
glibGetType?: string;
|
|
91
|
+
doc?: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type RawEnumerationMember = {
|
|
95
|
+
name: string;
|
|
96
|
+
value: string;
|
|
97
|
+
cIdentifier: string;
|
|
98
|
+
doc?: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type RawCallback = {
|
|
102
|
+
name: string;
|
|
103
|
+
cType: string;
|
|
104
|
+
returnType: RawType;
|
|
105
|
+
parameters: RawParameter[];
|
|
106
|
+
doc?: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type RawConstant = {
|
|
120
110
|
name: string;
|
|
111
|
+
cType: string;
|
|
112
|
+
value: string;
|
|
121
113
|
type: RawType;
|
|
122
|
-
writable?: boolean;
|
|
123
|
-
readable?: boolean;
|
|
124
|
-
private?: boolean;
|
|
125
114
|
doc?: string;
|
|
126
115
|
};
|
|
127
116
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
export type RawAlias = {
|
|
118
|
+
name: string;
|
|
119
|
+
cType: string;
|
|
120
|
+
targetType: RawType;
|
|
121
|
+
doc?: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
131
124
|
export type RawMethod = {
|
|
132
125
|
name: string;
|
|
133
126
|
cIdentifier: string;
|
|
@@ -137,15 +130,11 @@ export type RawMethod = {
|
|
|
137
130
|
throws?: boolean;
|
|
138
131
|
doc?: string;
|
|
139
132
|
returnDoc?: string;
|
|
140
|
-
/** For async methods, the name of the corresponding finish function */
|
|
141
133
|
finishFunc?: string;
|
|
142
134
|
shadows?: string;
|
|
143
135
|
shadowedBy?: string;
|
|
144
136
|
};
|
|
145
137
|
|
|
146
|
-
/**
|
|
147
|
-
* A constructor for a class or record.
|
|
148
|
-
*/
|
|
149
138
|
export type RawConstructor = {
|
|
150
139
|
name: string;
|
|
151
140
|
cIdentifier: string;
|
|
@@ -158,9 +147,6 @@ export type RawConstructor = {
|
|
|
158
147
|
shadowedBy?: string;
|
|
159
148
|
};
|
|
160
149
|
|
|
161
|
-
/**
|
|
162
|
-
* A standalone function or static method.
|
|
163
|
-
*/
|
|
164
150
|
export type RawFunction = {
|
|
165
151
|
name: string;
|
|
166
152
|
cIdentifier: string;
|
|
@@ -173,9 +159,6 @@ export type RawFunction = {
|
|
|
173
159
|
shadowedBy?: string;
|
|
174
160
|
};
|
|
175
161
|
|
|
176
|
-
/**
|
|
177
|
-
* A parameter to a function, method, or callback.
|
|
178
|
-
*/
|
|
179
162
|
export type RawParameter = {
|
|
180
163
|
name: string;
|
|
181
164
|
type: RawType;
|
|
@@ -183,19 +166,13 @@ export type RawParameter = {
|
|
|
183
166
|
callerAllocates?: boolean;
|
|
184
167
|
nullable?: boolean;
|
|
185
168
|
optional?: boolean;
|
|
186
|
-
scope?: "async" | "call" | "notified";
|
|
169
|
+
scope?: "async" | "call" | "notified" | "forever";
|
|
187
170
|
closure?: number;
|
|
188
171
|
destroy?: number;
|
|
189
172
|
transferOwnership?: "none" | "full" | "container";
|
|
190
173
|
doc?: string;
|
|
191
174
|
};
|
|
192
175
|
|
|
193
|
-
/**
|
|
194
|
-
* A type reference in GIR.
|
|
195
|
-
*
|
|
196
|
-
* Type names may be unqualified (e.g., "Widget") for local types
|
|
197
|
-
* or qualified (e.g., "GObject.Object") for cross-namespace references.
|
|
198
|
-
*/
|
|
199
176
|
export type RawType = {
|
|
200
177
|
name: string;
|
|
201
178
|
cType?: string;
|
|
@@ -210,9 +187,6 @@ export type RawType = {
|
|
|
210
187
|
fixedSize?: number;
|
|
211
188
|
};
|
|
212
189
|
|
|
213
|
-
/**
|
|
214
|
-
* A GObject property definition.
|
|
215
|
-
*/
|
|
216
190
|
export type RawProperty = {
|
|
217
191
|
name: string;
|
|
218
192
|
type: RawType;
|
|
@@ -225,9 +199,6 @@ export type RawProperty = {
|
|
|
225
199
|
doc?: string;
|
|
226
200
|
};
|
|
227
201
|
|
|
228
|
-
/**
|
|
229
|
-
* A GObject signal definition.
|
|
230
|
-
*/
|
|
231
202
|
export type RawSignal = {
|
|
232
203
|
name: string;
|
|
233
204
|
when?: "first" | "last" | "cleanup";
|
|
@@ -236,33 +207,11 @@ export type RawSignal = {
|
|
|
236
207
|
doc?: string;
|
|
237
208
|
};
|
|
238
209
|
|
|
239
|
-
|
|
240
|
-
* An enumeration or bitfield definition.
|
|
241
|
-
*/
|
|
242
|
-
export type RawEnumeration = {
|
|
243
|
-
name: string;
|
|
244
|
-
cType: string;
|
|
245
|
-
members: RawEnumerationMember[];
|
|
246
|
-
glibGetType?: string;
|
|
247
|
-
doc?: string;
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* A member of an enumeration or bitfield.
|
|
252
|
-
*/
|
|
253
|
-
export type RawEnumerationMember = {
|
|
254
|
-
name: string;
|
|
255
|
-
value: string;
|
|
256
|
-
cIdentifier: string;
|
|
257
|
-
doc?: string;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* A type alias definition.
|
|
262
|
-
*/
|
|
263
|
-
export type RawAlias = {
|
|
210
|
+
export type RawField = {
|
|
264
211
|
name: string;
|
|
265
|
-
|
|
266
|
-
|
|
212
|
+
type: RawType;
|
|
213
|
+
writable?: boolean;
|
|
214
|
+
readable?: boolean;
|
|
215
|
+
private?: boolean;
|
|
267
216
|
doc?: string;
|
|
268
217
|
};
|
package/src/intrinsics.ts
CHANGED
|
@@ -30,6 +30,7 @@ export const INTRINSIC_TYPES = new Set([
|
|
|
30
30
|
"gulong",
|
|
31
31
|
"gsize",
|
|
32
32
|
"guintptr",
|
|
33
|
+
"gunichar",
|
|
33
34
|
"gfloat",
|
|
34
35
|
"gdouble",
|
|
35
36
|
"gpointer",
|
|
@@ -47,6 +48,11 @@ export const INTRINSIC_TYPES = new Set([
|
|
|
47
48
|
"double",
|
|
48
49
|
"size_t",
|
|
49
50
|
"ssize_t",
|
|
51
|
+
"time_t",
|
|
52
|
+
"pid_t",
|
|
53
|
+
"uid_t",
|
|
54
|
+
"int32",
|
|
55
|
+
"long double",
|
|
50
56
|
]);
|
|
51
57
|
|
|
52
58
|
/**
|
|
@@ -96,6 +102,7 @@ export const NUMERIC_TYPES = new Set([
|
|
|
96
102
|
"goffset",
|
|
97
103
|
"gintptr",
|
|
98
104
|
"guintptr",
|
|
105
|
+
"gunichar",
|
|
99
106
|
"gfloat",
|
|
100
107
|
"gdouble",
|
|
101
108
|
"int",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GirType } from "./type.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type alias definition.
|
|
5
|
+
*/
|
|
6
|
+
export class GirAlias {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly qualifiedName: string;
|
|
9
|
+
readonly cType: string;
|
|
10
|
+
readonly targetType: GirType;
|
|
11
|
+
readonly doc?: string;
|
|
12
|
+
|
|
13
|
+
constructor(data: {
|
|
14
|
+
name: string;
|
|
15
|
+
qualifiedName: string;
|
|
16
|
+
cType: string;
|
|
17
|
+
targetType: GirType;
|
|
18
|
+
doc?: string;
|
|
19
|
+
}) {
|
|
20
|
+
this.name = data.name;
|
|
21
|
+
this.qualifiedName = data.qualifiedName;
|
|
22
|
+
this.cType = data.cType;
|
|
23
|
+
this.targetType = data.targetType;
|
|
24
|
+
this.doc = data.doc;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** True if this alias points to a non-intrinsic, non-array type (likely a record). */
|
|
28
|
+
isRecordAlias(): boolean {
|
|
29
|
+
return !this.targetType.isIntrinsic() && !this.targetType.isArray;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { GirParameter } from "./parameter.js";
|
|
2
|
+
import type { GirType } from "./type.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Method on a class, interface, or record.
|
|
6
|
+
*/
|
|
7
|
+
export class GirMethod {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly cIdentifier: string;
|
|
10
|
+
readonly returnType: GirType;
|
|
11
|
+
readonly parameters: GirParameter[];
|
|
12
|
+
readonly instanceParameter?: GirParameter;
|
|
13
|
+
readonly throws: boolean;
|
|
14
|
+
readonly doc?: string;
|
|
15
|
+
readonly returnDoc?: string;
|
|
16
|
+
readonly finishFunc?: string;
|
|
17
|
+
readonly shadows?: string;
|
|
18
|
+
readonly shadowedBy?: string;
|
|
19
|
+
|
|
20
|
+
constructor(data: {
|
|
21
|
+
name: string;
|
|
22
|
+
cIdentifier: string;
|
|
23
|
+
returnType: GirType;
|
|
24
|
+
parameters: GirParameter[];
|
|
25
|
+
instanceParameter?: GirParameter;
|
|
26
|
+
throws: boolean;
|
|
27
|
+
doc?: string;
|
|
28
|
+
returnDoc?: string;
|
|
29
|
+
finishFunc?: string;
|
|
30
|
+
shadows?: string;
|
|
31
|
+
shadowedBy?: string;
|
|
32
|
+
}) {
|
|
33
|
+
this.name = data.name;
|
|
34
|
+
this.cIdentifier = data.cIdentifier;
|
|
35
|
+
this.returnType = data.returnType;
|
|
36
|
+
this.parameters = data.parameters;
|
|
37
|
+
this.instanceParameter = data.instanceParameter;
|
|
38
|
+
this.throws = data.throws;
|
|
39
|
+
this.doc = data.doc;
|
|
40
|
+
this.returnDoc = data.returnDoc;
|
|
41
|
+
this.finishFunc = data.finishFunc;
|
|
42
|
+
this.shadows = data.shadows;
|
|
43
|
+
this.shadowedBy = data.shadowedBy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** True if this follows the async/finish pattern. */
|
|
47
|
+
isAsync(): boolean {
|
|
48
|
+
return this.name.endsWith("_async") || this.parameters.some((p) => p.scope === "async");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** True if this is a _finish method for an async operation. */
|
|
52
|
+
isAsyncFinish(): boolean {
|
|
53
|
+
return this.name.endsWith("_finish");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Gets the corresponding _finish method name if this is async. */
|
|
57
|
+
getFinishMethodName(): string | null {
|
|
58
|
+
if (this.name.endsWith("_async")) {
|
|
59
|
+
return this.name.replace(/_async$/, "_finish");
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Gets required (non-optional, non-nullable) input parameters. */
|
|
65
|
+
getRequiredParameters(): GirParameter[] {
|
|
66
|
+
return this.parameters.filter((p) => !p.optional && !p.nullable && p.direction === "in");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Gets optional parameters. */
|
|
70
|
+
getOptionalParameters(): GirParameter[] {
|
|
71
|
+
return this.parameters.filter((p) => p.optional || p.nullable);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** True if any parameter is an out parameter. */
|
|
75
|
+
hasOutParameters(): boolean {
|
|
76
|
+
return this.parameters.some((p) => p.direction === "out" || p.direction === "inout");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Gets out parameters only. */
|
|
80
|
+
getOutParameters(): GirParameter[] {
|
|
81
|
+
return this.parameters.filter((p) => p.direction === "out" || p.direction === "inout");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Constructor for a class or record.
|
|
87
|
+
*/
|
|
88
|
+
export class GirConstructor {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly cIdentifier: string;
|
|
91
|
+
readonly returnType: GirType;
|
|
92
|
+
readonly parameters: GirParameter[];
|
|
93
|
+
readonly throws: boolean;
|
|
94
|
+
readonly doc?: string;
|
|
95
|
+
readonly returnDoc?: string;
|
|
96
|
+
readonly shadows?: string;
|
|
97
|
+
readonly shadowedBy?: string;
|
|
98
|
+
|
|
99
|
+
constructor(data: {
|
|
100
|
+
name: string;
|
|
101
|
+
cIdentifier: string;
|
|
102
|
+
returnType: GirType;
|
|
103
|
+
parameters: GirParameter[];
|
|
104
|
+
throws: boolean;
|
|
105
|
+
doc?: string;
|
|
106
|
+
returnDoc?: string;
|
|
107
|
+
shadows?: string;
|
|
108
|
+
shadowedBy?: string;
|
|
109
|
+
}) {
|
|
110
|
+
this.name = data.name;
|
|
111
|
+
this.cIdentifier = data.cIdentifier;
|
|
112
|
+
this.returnType = data.returnType;
|
|
113
|
+
this.parameters = data.parameters;
|
|
114
|
+
this.throws = data.throws;
|
|
115
|
+
this.doc = data.doc;
|
|
116
|
+
this.returnDoc = data.returnDoc;
|
|
117
|
+
this.shadows = data.shadows;
|
|
118
|
+
this.shadowedBy = data.shadowedBy;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Gets required (non-optional, non-nullable) input parameters. */
|
|
122
|
+
getRequiredParameters(): GirParameter[] {
|
|
123
|
+
return this.parameters.filter((p) => !p.optional && !p.nullable && p.direction === "in");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Standalone function or static method.
|
|
129
|
+
*/
|
|
130
|
+
export class GirFunction {
|
|
131
|
+
readonly name: string;
|
|
132
|
+
readonly cIdentifier: string;
|
|
133
|
+
readonly returnType: GirType;
|
|
134
|
+
readonly parameters: GirParameter[];
|
|
135
|
+
readonly throws: boolean;
|
|
136
|
+
readonly doc?: string;
|
|
137
|
+
readonly returnDoc?: string;
|
|
138
|
+
readonly shadows?: string;
|
|
139
|
+
readonly shadowedBy?: string;
|
|
140
|
+
|
|
141
|
+
constructor(data: {
|
|
142
|
+
name: string;
|
|
143
|
+
cIdentifier: string;
|
|
144
|
+
returnType: GirType;
|
|
145
|
+
parameters: GirParameter[];
|
|
146
|
+
throws: boolean;
|
|
147
|
+
doc?: string;
|
|
148
|
+
returnDoc?: string;
|
|
149
|
+
shadows?: string;
|
|
150
|
+
shadowedBy?: string;
|
|
151
|
+
}) {
|
|
152
|
+
this.name = data.name;
|
|
153
|
+
this.cIdentifier = data.cIdentifier;
|
|
154
|
+
this.returnType = data.returnType;
|
|
155
|
+
this.parameters = data.parameters;
|
|
156
|
+
this.throws = data.throws;
|
|
157
|
+
this.doc = data.doc;
|
|
158
|
+
this.returnDoc = data.returnDoc;
|
|
159
|
+
this.shadows = data.shadows;
|
|
160
|
+
this.shadowedBy = data.shadowedBy;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** True if this follows the async/finish pattern. */
|
|
164
|
+
isAsync(): boolean {
|
|
165
|
+
return this.name.endsWith("_async") || this.parameters.some((p) => p.scope === "async");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Gets required (non-optional, non-nullable) input parameters. */
|
|
169
|
+
getRequiredParameters(): GirParameter[] {
|
|
170
|
+
return this.parameters.filter((p) => !p.optional && !p.nullable && p.direction === "in");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GirParameter } from "./parameter.js";
|
|
2
|
+
import type { GirType } from "./type.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Callback type definition (function pointer type).
|
|
6
|
+
*/
|
|
7
|
+
export class GirCallback {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly qualifiedName: string;
|
|
10
|
+
readonly cType: string;
|
|
11
|
+
readonly returnType: GirType;
|
|
12
|
+
readonly parameters: GirParameter[];
|
|
13
|
+
readonly doc?: string;
|
|
14
|
+
|
|
15
|
+
constructor(data: {
|
|
16
|
+
name: string;
|
|
17
|
+
qualifiedName: string;
|
|
18
|
+
cType: string;
|
|
19
|
+
returnType: GirType;
|
|
20
|
+
parameters: GirParameter[];
|
|
21
|
+
doc?: string;
|
|
22
|
+
}) {
|
|
23
|
+
this.name = data.name;
|
|
24
|
+
this.qualifiedName = data.qualifiedName;
|
|
25
|
+
this.cType = data.cType;
|
|
26
|
+
this.returnType = data.returnType;
|
|
27
|
+
this.parameters = data.parameters;
|
|
28
|
+
this.doc = data.doc;
|
|
29
|
+
}
|
|
30
|
+
}
|