@gtkx/gir 0.1.10 → 0.1.12
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/package.json +1 -1
- package/src/parser.ts +41 -35
package/package.json
CHANGED
package/src/parser.ts
CHANGED
|
@@ -162,53 +162,59 @@ export class GirParser {
|
|
|
162
162
|
if (!methods || !Array.isArray(methods)) {
|
|
163
163
|
return [];
|
|
164
164
|
}
|
|
165
|
-
return methods
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
(method
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
165
|
+
return methods
|
|
166
|
+
.filter((method) => method["@_introspectable"] !== "0")
|
|
167
|
+
.map((method) => ({
|
|
168
|
+
name: String(method["@_name"] ?? ""),
|
|
169
|
+
cIdentifier: String(method["@_c:identifier"] ?? ""),
|
|
170
|
+
returnType: this.parseReturnType(method["return-value"] as Record<string, unknown> | undefined),
|
|
171
|
+
parameters: this.parseParameters(
|
|
172
|
+
(method.parameters && typeof method.parameters === "object" && method.parameters !== null
|
|
173
|
+
? method.parameters
|
|
174
|
+
: {}) as Record<string, unknown>,
|
|
175
|
+
),
|
|
176
|
+
throws: method["@_throws"] === "1",
|
|
177
|
+
doc: extractDoc(method),
|
|
178
|
+
}));
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
private parseConstructors(constructors: Record<string, unknown>[]): GirConstructor[] {
|
|
180
182
|
if (!constructors || !Array.isArray(constructors)) {
|
|
181
183
|
return [];
|
|
182
184
|
}
|
|
183
|
-
return constructors
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(ctor
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
return constructors
|
|
186
|
+
.filter((ctor) => ctor["@_introspectable"] !== "0")
|
|
187
|
+
.map((ctor) => ({
|
|
188
|
+
name: String(ctor["@_name"] ?? ""),
|
|
189
|
+
cIdentifier: String(ctor["@_c:identifier"] ?? ""),
|
|
190
|
+
returnType: this.parseReturnType(ctor["return-value"] as Record<string, unknown> | undefined),
|
|
191
|
+
parameters: this.parseParameters(
|
|
192
|
+
(ctor.parameters && typeof ctor.parameters === "object" && ctor.parameters !== null
|
|
193
|
+
? ctor.parameters
|
|
194
|
+
: {}) as Record<string, unknown>,
|
|
195
|
+
),
|
|
196
|
+
doc: extractDoc(ctor),
|
|
197
|
+
}));
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
private parseFunctions(functions: Record<string, unknown>[]): GirFunction[] {
|
|
197
201
|
if (!functions || !Array.isArray(functions)) {
|
|
198
202
|
return [];
|
|
199
203
|
}
|
|
200
|
-
return functions
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
(func
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
return functions
|
|
205
|
+
.filter((func) => func["@_introspectable"] !== "0")
|
|
206
|
+
.map((func) => ({
|
|
207
|
+
name: String(func["@_name"] ?? ""),
|
|
208
|
+
cIdentifier: String(func["@_c:identifier"] ?? ""),
|
|
209
|
+
returnType: this.parseReturnType(func["return-value"] as Record<string, unknown> | undefined),
|
|
210
|
+
parameters: this.parseParameters(
|
|
211
|
+
(func.parameters && typeof func.parameters === "object" && func.parameters !== null
|
|
212
|
+
? func.parameters
|
|
213
|
+
: {}) as Record<string, unknown>,
|
|
214
|
+
),
|
|
215
|
+
throws: func["@_throws"] === "1",
|
|
216
|
+
doc: extractDoc(func),
|
|
217
|
+
}));
|
|
212
218
|
}
|
|
213
219
|
|
|
214
220
|
private parseParameters(parametersNode: Record<string, unknown>): GirParameter[] {
|