@gtkx/gir 0.11.1 → 0.12.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.
@@ -151,6 +151,9 @@ const normalizeType = (raw, currentNamespace, ctx) => {
151
151
  elementType: normalizeType(raw.elementType, currentNamespace, ctx),
152
152
  transferOwnership: raw.transferOwnership,
153
153
  nullable: raw.nullable ?? false,
154
+ lengthParamIndex: raw.lengthParamIndex,
155
+ zeroTerminated: raw.zeroTerminated,
156
+ fixedSize: raw.fixedSize,
154
157
  });
155
158
  }
156
159
  if (isArray) {
@@ -161,6 +164,9 @@ const normalizeType = (raw, currentNamespace, ctx) => {
161
164
  elementType: null,
162
165
  transferOwnership: raw.transferOwnership,
163
166
  nullable: raw.nullable ?? false,
167
+ lengthParamIndex: raw.lengthParamIndex,
168
+ zeroTerminated: raw.zeroTerminated,
169
+ fixedSize: raw.fixedSize,
164
170
  });
165
171
  }
166
172
  return new GirType({
@@ -197,6 +203,9 @@ const normalizeClass = (raw, currentNamespace, ctx) => {
197
203
  glibTypeName: raw.glibTypeName,
198
204
  glibGetType: raw.glibGetType,
199
205
  cSymbolPrefix: raw.cSymbolPrefix,
206
+ fundamental: raw.fundamental ?? false,
207
+ refFunc: raw.refFunc,
208
+ unrefFunc: raw.unrefFunc,
200
209
  implements: implementsRefs,
201
210
  methods: raw.methods.map((m) => normalizeMethod(m, currentNamespace, ctx)),
202
211
  constructors: raw.constructors.map((c) => normalizeConstructor(c, currentNamespace, ctx)),
@@ -241,6 +250,8 @@ const normalizeRecord = (raw, currentNamespace, ctx) => {
241
250
  glibTypeName: raw.glibTypeName,
242
251
  glibGetType: raw.glibGetType,
243
252
  isGtypeStructFor: raw.isGtypeStructFor,
253
+ copyFunction: raw.copyFunction,
254
+ freeFunction: raw.freeFunction,
244
255
  fields: raw.fields.map((f) => normalizeField(f, currentNamespace, ctx)),
245
256
  methods: raw.methods.map((m) => normalizeMethod(m, currentNamespace, ctx)),
246
257
  constructors: raw.constructors.map((c) => normalizeConstructor(c, currentNamespace, ctx)),
@@ -307,6 +318,8 @@ const normalizeMethod = (raw, currentNamespace, ctx) => {
307
318
  doc: raw.doc,
308
319
  returnDoc: raw.returnDoc,
309
320
  finishFunc: raw.finishFunc,
321
+ shadows: raw.shadows,
322
+ shadowedBy: raw.shadowedBy,
310
323
  });
311
324
  };
312
325
  /**
@@ -321,6 +334,8 @@ const normalizeConstructor = (raw, currentNamespace, ctx) => {
321
334
  throws: raw.throws ?? false,
322
335
  doc: raw.doc,
323
336
  returnDoc: raw.returnDoc,
337
+ shadows: raw.shadows,
338
+ shadowedBy: raw.shadowedBy,
324
339
  });
325
340
  };
326
341
  /**
@@ -335,6 +350,8 @@ const normalizeFunction = (raw, currentNamespace, ctx) => {
335
350
  throws: raw.throws ?? false,
336
351
  doc: raw.doc,
337
352
  returnDoc: raw.returnDoc,
353
+ shadows: raw.shadows,
354
+ shadowedBy: raw.shadowedBy,
338
355
  });
339
356
  };
340
357
  /**
@@ -122,6 +122,9 @@ export class RawGirParser {
122
122
  glibTypeName: cls["@_glib:type-name"] ? String(cls["@_glib:type-name"]) : undefined,
123
123
  glibGetType: cls["@_glib:get-type"] ? String(cls["@_glib:get-type"]) : undefined,
124
124
  cSymbolPrefix: cls["@_c:symbol-prefix"] ? String(cls["@_c:symbol-prefix"]) : undefined,
125
+ fundamental: cls["@_glib:fundamental"] === "1",
126
+ refFunc: cls["@_glib:ref-func"] ? String(cls["@_glib:ref-func"]) : undefined,
127
+ unrefFunc: cls["@_glib:unref-func"] ? String(cls["@_glib:unref-func"]) : undefined,
125
128
  implements: this.parseImplements(cls.implements),
126
129
  methods: this.parseMethods(ensureArray(cls.method)),
127
130
  constructors: this.parseConstructors(ensureArray(cls.constructor)),
@@ -167,6 +170,8 @@ export class RawGirParser {
167
170
  .map((method) => {
168
171
  const returnValue = method["return-value"];
169
172
  const finishFunc = method["@_glib:finish-func"];
173
+ const shadows = method["@_shadows"];
174
+ const shadowedBy = method["@_shadowed-by"];
170
175
  return {
171
176
  name: String(method["@_name"] ?? ""),
172
177
  cIdentifier: String(method["@_c:identifier"] ?? ""),
@@ -178,6 +183,8 @@ export class RawGirParser {
178
183
  doc: extractDoc(method),
179
184
  returnDoc: returnValue ? extractDoc(returnValue) : undefined,
180
185
  finishFunc: finishFunc || undefined,
186
+ shadows: shadows || undefined,
187
+ shadowedBy: shadowedBy || undefined,
181
188
  };
182
189
  });
183
190
  }
@@ -189,6 +196,8 @@ export class RawGirParser {
189
196
  .filter((ctor) => ctor["@_introspectable"] !== "0")
190
197
  .map((ctor) => {
191
198
  const returnValue = ctor["return-value"];
199
+ const shadows = ctor["@_shadows"];
200
+ const shadowedBy = ctor["@_shadowed-by"];
192
201
  return {
193
202
  name: String(ctor["@_name"] ?? ""),
194
203
  cIdentifier: String(ctor["@_c:identifier"] ?? ""),
@@ -199,6 +208,8 @@ export class RawGirParser {
199
208
  throws: ctor["@_throws"] === "1",
200
209
  doc: extractDoc(ctor),
201
210
  returnDoc: returnValue ? extractDoc(returnValue) : undefined,
211
+ shadows: shadows || undefined,
212
+ shadowedBy: shadowedBy || undefined,
202
213
  };
203
214
  });
204
215
  }
@@ -210,6 +221,8 @@ export class RawGirParser {
210
221
  .filter((func) => func["@_introspectable"] !== "0")
211
222
  .map((func) => {
212
223
  const returnValue = func["return-value"];
224
+ const shadows = func["@_shadows"];
225
+ const shadowedBy = func["@_shadowed-by"];
213
226
  return {
214
227
  name: String(func["@_name"] ?? ""),
215
228
  cIdentifier: String(func["@_c:identifier"] ?? ""),
@@ -220,6 +233,8 @@ export class RawGirParser {
220
233
  throws: func["@_throws"] === "1",
221
234
  doc: extractDoc(func),
222
235
  returnDoc: returnValue ? extractDoc(returnValue) : undefined,
236
+ shadows: shadows || undefined,
237
+ shadowedBy: shadowedBy || undefined,
223
238
  };
224
239
  });
225
240
  }
@@ -283,10 +298,16 @@ export class RawGirParser {
283
298
  typeNode["@_fixed-size"] !== undefined ||
284
299
  typeNode["@_length"] !== undefined;
285
300
  if (isArrayNode) {
301
+ const lengthAttr = typeNode["@_length"];
302
+ const zeroTerminatedAttr = typeNode["@_zero-terminated"];
303
+ const fixedSizeAttr = typeNode["@_fixed-size"];
286
304
  return {
287
305
  name: "array",
288
306
  isArray: true,
289
307
  elementType: typeNode.type ? this.parseType(typeNode.type) : undefined,
308
+ lengthParamIndex: lengthAttr !== undefined ? Number(lengthAttr) : undefined,
309
+ zeroTerminated: zeroTerminatedAttr !== undefined ? zeroTerminatedAttr !== "0" : undefined,
310
+ fixedSize: fixedSizeAttr !== undefined ? Number(fixedSizeAttr) : undefined,
290
311
  };
291
312
  }
292
313
  return { name: "void" };
@@ -391,6 +412,8 @@ export class RawGirParser {
391
412
  isGtypeStructFor: record["@_glib:is-gtype-struct-for"]
392
413
  ? String(record["@_glib:is-gtype-struct-for"])
393
414
  : undefined,
415
+ copyFunction: record["@_copy-function"] ? String(record["@_copy-function"]) : undefined,
416
+ freeFunction: record["@_free-function"] ? String(record["@_free-function"]) : undefined,
394
417
  fields: this.parseFields(ensureArray(record.field)),
395
418
  methods: this.parseMethods(ensureArray(record.method)),
396
419
  constructors: this.parseConstructors(ensureArray(record.constructor)),
@@ -73,6 +73,9 @@ export type RawClass = {
73
73
  glibTypeName?: string;
74
74
  glibGetType?: string;
75
75
  cSymbolPrefix?: string;
76
+ fundamental?: boolean;
77
+ refFunc?: string;
78
+ unrefFunc?: string;
76
79
  implements: string[];
77
80
  methods: RawMethod[];
78
81
  constructors: RawConstructor[];
@@ -92,6 +95,8 @@ export type RawRecord = {
92
95
  glibTypeName?: string;
93
96
  glibGetType?: string;
94
97
  isGtypeStructFor?: string;
98
+ copyFunction?: string;
99
+ freeFunction?: string;
95
100
  fields: RawField[];
96
101
  methods: RawMethod[];
97
102
  constructors: RawConstructor[];
@@ -122,6 +127,8 @@ export type RawMethod = {
122
127
  returnDoc?: string;
123
128
  /** For async methods, the name of the corresponding finish function */
124
129
  finishFunc?: string;
130
+ shadows?: string;
131
+ shadowedBy?: string;
125
132
  };
126
133
  /**
127
134
  * A constructor for a class or record.
@@ -134,6 +141,8 @@ export type RawConstructor = {
134
141
  throws?: boolean;
135
142
  doc?: string;
136
143
  returnDoc?: string;
144
+ shadows?: string;
145
+ shadowedBy?: string;
137
146
  };
138
147
  /**
139
148
  * A standalone function or static method.
@@ -146,6 +155,8 @@ export type RawFunction = {
146
155
  throws?: boolean;
147
156
  doc?: string;
148
157
  returnDoc?: string;
158
+ shadows?: string;
159
+ shadowedBy?: string;
149
160
  };
150
161
  /**
151
162
  * A parameter to a function, method, or callback.
@@ -178,6 +189,9 @@ export type RawType = {
178
189
  containerType?: ContainerType;
179
190
  transferOwnership?: "none" | "full" | "container";
180
191
  nullable?: boolean;
192
+ lengthParamIndex?: number;
193
+ zeroTerminated?: boolean;
194
+ fixedSize?: number;
181
195
  };
182
196
  /**
183
197
  * A GObject property definition.
package/dist/types.d.ts CHANGED
@@ -86,6 +86,9 @@ export declare class GirClass {
86
86
  readonly glibTypeName?: string;
87
87
  readonly glibGetType?: string;
88
88
  readonly cSymbolPrefix?: string;
89
+ readonly fundamental: boolean;
90
+ readonly refFunc?: string;
91
+ readonly unrefFunc?: string;
89
92
  readonly implements: QualifiedName[];
90
93
  readonly methods: GirMethod[];
91
94
  readonly constructors: GirConstructor[];
@@ -104,6 +107,9 @@ export declare class GirClass {
104
107
  glibTypeName?: string;
105
108
  glibGetType?: string;
106
109
  cSymbolPrefix?: string;
110
+ fundamental?: boolean;
111
+ refFunc?: string;
112
+ unrefFunc?: string;
107
113
  implements: QualifiedName[];
108
114
  methods: GirMethod[];
109
115
  constructors: GirConstructor[];
@@ -148,6 +154,8 @@ export declare class GirClass {
148
154
  isAbstract(): boolean;
149
155
  /** True if this has a GType (most GObject classes do). */
150
156
  hasGType(): boolean;
157
+ /** True if this is a fundamental type with custom ref/unref functions. */
158
+ isFundamental(): boolean;
151
159
  /** Gets direct subclasses of this class. */
152
160
  getDirectSubclasses(): GirClass[];
153
161
  }
@@ -202,6 +210,8 @@ export declare class GirRecord {
202
210
  readonly glibTypeName?: string;
203
211
  readonly glibGetType?: string;
204
212
  readonly isGtypeStructFor?: string;
213
+ readonly copyFunction?: string;
214
+ readonly freeFunction?: string;
205
215
  readonly fields: GirField[];
206
216
  readonly methods: GirMethod[];
207
217
  readonly constructors: GirConstructor[];
@@ -216,12 +226,16 @@ export declare class GirRecord {
216
226
  glibTypeName?: string;
217
227
  glibGetType?: string;
218
228
  isGtypeStructFor?: string;
229
+ copyFunction?: string;
230
+ freeFunction?: string;
219
231
  fields: GirField[];
220
232
  methods: GirMethod[];
221
233
  constructors: GirConstructor[];
222
234
  staticFunctions: GirFunction[];
223
235
  doc?: string;
224
236
  });
237
+ /** True if this is a fundamental type with custom copy/free functions. */
238
+ isFundamental(): boolean;
225
239
  /** True if this is a GLib boxed type (has glibTypeName). */
226
240
  isBoxed(): boolean;
227
241
  /** True if this is a GType struct (vtable for a class/interface). */
@@ -326,6 +340,8 @@ export declare class GirMethod {
326
340
  readonly returnDoc?: string;
327
341
  /** For async methods, the name of the corresponding finish function */
328
342
  readonly finishFunc?: string;
343
+ readonly shadows?: string;
344
+ readonly shadowedBy?: string;
329
345
  constructor(data: {
330
346
  name: string;
331
347
  cIdentifier: string;
@@ -335,6 +351,8 @@ export declare class GirMethod {
335
351
  doc?: string;
336
352
  returnDoc?: string;
337
353
  finishFunc?: string;
354
+ shadows?: string;
355
+ shadowedBy?: string;
338
356
  });
339
357
  /** True if this follows the async/finish pattern. */
340
358
  isAsync(): boolean;
@@ -362,6 +380,8 @@ export declare class GirConstructor {
362
380
  readonly throws: boolean;
363
381
  readonly doc?: string;
364
382
  readonly returnDoc?: string;
383
+ readonly shadows?: string;
384
+ readonly shadowedBy?: string;
365
385
  constructor(data: {
366
386
  name: string;
367
387
  cIdentifier: string;
@@ -370,6 +390,8 @@ export declare class GirConstructor {
370
390
  throws: boolean;
371
391
  doc?: string;
372
392
  returnDoc?: string;
393
+ shadows?: string;
394
+ shadowedBy?: string;
373
395
  });
374
396
  /** Gets required (non-optional, non-nullable) parameters. */
375
397
  getRequiredParameters(): GirParameter[];
@@ -385,6 +407,8 @@ export declare class GirFunction {
385
407
  readonly throws: boolean;
386
408
  readonly doc?: string;
387
409
  readonly returnDoc?: string;
410
+ readonly shadows?: string;
411
+ readonly shadowedBy?: string;
388
412
  constructor(data: {
389
413
  name: string;
390
414
  cIdentifier: string;
@@ -393,6 +417,8 @@ export declare class GirFunction {
393
417
  throws: boolean;
394
418
  doc?: string;
395
419
  returnDoc?: string;
420
+ shadows?: string;
421
+ shadowedBy?: string;
396
422
  });
397
423
  /** True if this follows the async/finish pattern. */
398
424
  isAsync(): boolean;
@@ -524,6 +550,9 @@ export declare class GirType {
524
550
  readonly containerType?: ContainerType;
525
551
  readonly transferOwnership?: "none" | "full" | "container";
526
552
  readonly nullable: boolean;
553
+ readonly lengthParamIndex?: number;
554
+ readonly zeroTerminated?: boolean;
555
+ readonly fixedSize?: number;
527
556
  constructor(data: {
528
557
  name: QualifiedName | string;
529
558
  cType?: string;
@@ -533,6 +562,9 @@ export declare class GirType {
533
562
  containerType?: ContainerType;
534
563
  transferOwnership?: "none" | "full" | "container";
535
564
  nullable: boolean;
565
+ lengthParamIndex?: number;
566
+ zeroTerminated?: boolean;
567
+ fixedSize?: number;
536
568
  });
537
569
  /** True if this is an intrinsic/primitive type. */
538
570
  isIntrinsic(): boolean;
package/dist/types.js CHANGED
@@ -66,6 +66,9 @@ export class GirClass {
66
66
  glibTypeName;
67
67
  glibGetType;
68
68
  cSymbolPrefix;
69
+ fundamental;
70
+ refFunc;
71
+ unrefFunc;
69
72
  implements;
70
73
  methods;
71
74
  constructors;
@@ -84,6 +87,9 @@ export class GirClass {
84
87
  this.glibTypeName = data.glibTypeName;
85
88
  this.glibGetType = data.glibGetType;
86
89
  this.cSymbolPrefix = data.cSymbolPrefix;
90
+ this.fundamental = data.fundamental ?? false;
91
+ this.refFunc = data.refFunc;
92
+ this.unrefFunc = data.unrefFunc;
87
93
  this.implements = data.implements;
88
94
  this.methods = data.methods;
89
95
  this.constructors = data.constructors;
@@ -215,6 +221,10 @@ export class GirClass {
215
221
  hasGType() {
216
222
  return this.glibTypeName !== undefined;
217
223
  }
224
+ /** True if this is a fundamental type with custom ref/unref functions. */
225
+ isFundamental() {
226
+ return this.fundamental && this.refFunc !== undefined && this.unrefFunc !== undefined;
227
+ }
218
228
  /** Gets direct subclasses of this class. */
219
229
  getDirectSubclasses() {
220
230
  if (!this._repo)
@@ -305,6 +315,8 @@ export class GirRecord {
305
315
  glibTypeName;
306
316
  glibGetType;
307
317
  isGtypeStructFor;
318
+ copyFunction;
319
+ freeFunction;
308
320
  fields;
309
321
  methods;
310
322
  constructors;
@@ -319,12 +331,18 @@ export class GirRecord {
319
331
  this.glibTypeName = data.glibTypeName;
320
332
  this.glibGetType = data.glibGetType;
321
333
  this.isGtypeStructFor = data.isGtypeStructFor;
334
+ this.copyFunction = data.copyFunction;
335
+ this.freeFunction = data.freeFunction;
322
336
  this.fields = data.fields;
323
337
  this.methods = data.methods;
324
338
  this.constructors = data.constructors;
325
339
  this.staticFunctions = data.staticFunctions;
326
340
  this.doc = data.doc;
327
341
  }
342
+ /** True if this is a fundamental type with custom copy/free functions. */
343
+ isFundamental() {
344
+ return this.copyFunction !== undefined && this.freeFunction !== undefined;
345
+ }
328
346
  /** True if this is a GLib boxed type (has glibTypeName). */
329
347
  isBoxed() {
330
348
  return this.glibTypeName !== undefined;
@@ -449,6 +467,8 @@ export class GirMethod {
449
467
  returnDoc;
450
468
  /** For async methods, the name of the corresponding finish function */
451
469
  finishFunc;
470
+ shadows;
471
+ shadowedBy;
452
472
  constructor(data) {
453
473
  this.name = data.name;
454
474
  this.cIdentifier = data.cIdentifier;
@@ -458,6 +478,8 @@ export class GirMethod {
458
478
  this.doc = data.doc;
459
479
  this.returnDoc = data.returnDoc;
460
480
  this.finishFunc = data.finishFunc;
481
+ this.shadows = data.shadows;
482
+ this.shadowedBy = data.shadowedBy;
461
483
  }
462
484
  /** True if this follows the async/finish pattern. */
463
485
  isAsync() {
@@ -502,6 +524,8 @@ export class GirConstructor {
502
524
  throws;
503
525
  doc;
504
526
  returnDoc;
527
+ shadows;
528
+ shadowedBy;
505
529
  constructor(data) {
506
530
  this.name = data.name;
507
531
  this.cIdentifier = data.cIdentifier;
@@ -510,6 +534,8 @@ export class GirConstructor {
510
534
  this.throws = data.throws;
511
535
  this.doc = data.doc;
512
536
  this.returnDoc = data.returnDoc;
537
+ this.shadows = data.shadows;
538
+ this.shadowedBy = data.shadowedBy;
513
539
  }
514
540
  /** Gets required (non-optional, non-nullable) parameters. */
515
541
  getRequiredParameters() {
@@ -527,6 +553,8 @@ export class GirFunction {
527
553
  throws;
528
554
  doc;
529
555
  returnDoc;
556
+ shadows;
557
+ shadowedBy;
530
558
  constructor(data) {
531
559
  this.name = data.name;
532
560
  this.cIdentifier = data.cIdentifier;
@@ -535,6 +563,8 @@ export class GirFunction {
535
563
  this.throws = data.throws;
536
564
  this.doc = data.doc;
537
565
  this.returnDoc = data.returnDoc;
566
+ this.shadows = data.shadows;
567
+ this.shadowedBy = data.shadowedBy;
538
568
  }
539
569
  /** True if this follows the async/finish pattern. */
540
570
  isAsync() {
@@ -692,6 +722,9 @@ export class GirType {
692
722
  containerType;
693
723
  transferOwnership;
694
724
  nullable;
725
+ lengthParamIndex;
726
+ zeroTerminated;
727
+ fixedSize;
695
728
  constructor(data) {
696
729
  this.name = data.name;
697
730
  this.cType = data.cType;
@@ -701,6 +734,9 @@ export class GirType {
701
734
  this.containerType = data.containerType;
702
735
  this.transferOwnership = data.transferOwnership;
703
736
  this.nullable = data.nullable;
737
+ this.lengthParamIndex = data.lengthParamIndex;
738
+ this.zeroTerminated = data.zeroTerminated;
739
+ this.fixedSize = data.fixedSize;
704
740
  }
705
741
  /** True if this is an intrinsic/primitive type. */
706
742
  isIntrinsic() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/gir",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "GObject Introspection file parser for GTKX",
5
5
  "keywords": [
6
6
  "gtkx",