@ts-for-gir/lib 4.0.0-beta.39 → 4.0.0-beta.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/lib",
3
- "version": "4.0.0-beta.39",
3
+ "version": "4.0.0-beta.40",
4
4
  "description": "Typescript .d.ts generator from GIR for gjs",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -48,9 +48,9 @@
48
48
  "typescript": "^5.9.3"
49
49
  },
50
50
  "dependencies": {
51
- "@gi.ts/parser": "^4.0.0-beta.39",
52
- "@ts-for-gir/reporter": "^4.0.0-beta.39",
53
- "@ts-for-gir/templates": "^4.0.0-beta.39",
51
+ "@gi.ts/parser": "^4.0.0-beta.40",
52
+ "@ts-for-gir/reporter": "^4.0.0-beta.40",
53
+ "@ts-for-gir/templates": "^4.0.0-beta.40",
54
54
  "colorette": "^2.0.20",
55
55
  "ejs": "^4.0.1",
56
56
  "glob": "^13.0.6",
package/src/gir/enum.ts CHANGED
@@ -14,6 +14,7 @@ import type { IntrospectedRecord } from "./record.ts";
14
14
 
15
15
  export class IntrospectedEnum extends IntrospectedNamespaceMember {
16
16
  members = new Map<string, GirEnumMember>();
17
+ isRegistered: boolean = false;
17
18
  flags: boolean = false;
18
19
  ns: IntrospectedNamespace;
19
20
 
@@ -24,7 +25,7 @@ export class IntrospectedEnum extends IntrospectedNamespaceMember {
24
25
  }
25
26
 
26
27
  copy({ members }: { parent?: undefined; members?: Map<string, GirEnumMember> } = {}): IntrospectedEnum {
27
- const { namespace, name, flags } = this;
28
+ const { namespace, name, isRegistered, flags } = this;
28
29
 
29
30
  const en = new IntrospectedEnum(name, namespace);
30
31
 
@@ -32,6 +33,7 @@ export class IntrospectedEnum extends IntrospectedNamespaceMember {
32
33
  en.members.set(key, member.copy());
33
34
  }
34
35
 
36
+ en.isRegistered = isRegistered;
35
37
  en.flags = flags;
36
38
 
37
39
  en._copyBaseProperties(this);
@@ -93,6 +95,7 @@ export class IntrospectedEnum extends IntrospectedNamespaceMember {
93
95
  const em = new IntrospectedEnum(sanitizeMemberName(element.$.name), ns);
94
96
 
95
97
  if (element.$["glib:type-name"]) {
98
+ em.isRegistered = true;
96
99
  em.resolve_names.push(element.$["glib:type-name"]);
97
100
 
98
101
  ns.registerResolveName(element.$["glib:type-name"], ns.namespace, em.name);
package/src/gir/error.ts CHANGED
@@ -8,6 +8,7 @@ import { IntrospectedEnum } from "./enum.ts";
8
8
  import { GirEnumMember } from "./enum-member.ts";
9
9
  import { IntrospectedStaticClassFunction } from "./introspected-classes.ts";
10
10
  import type { IntrospectedNamespace } from "./namespace.ts";
11
+ import type { IntrospectedRecord } from "./record.ts";
11
12
 
12
13
  // TODO: Move to utils
13
14
  function isEnumElement(e: unknown): e is GirEnumElement {
@@ -39,6 +40,12 @@ export class IntrospectedError extends IntrospectedEnum {
39
40
  return en._copyBaseProperties(this);
40
41
  }
41
42
 
43
+ asClass(): IntrospectedRecord {
44
+ const clazz = super.asClass();
45
+ clazz.overrideGType(this.namespace.namespace === "GLib" ? "Error" : "GLib.Error");
46
+ return clazz;
47
+ }
48
+
42
49
  static fromXML(
43
50
  element: GirEnumElement | GirBitfieldElement,
44
51
  ns: IntrospectedNamespace,
@@ -603,6 +603,10 @@ export class IntrospectedClass extends IntrospectedBaseClass {
603
603
  super({ name, namespace });
604
604
  }
605
605
 
606
+ get gtype() {
607
+ return this.name;
608
+ }
609
+
606
610
  getAllSignals(): SignalDescriptor[] {
607
611
  const allSignals = this.getBaseSignals();
608
612
 
package/src/gir/record.ts CHANGED
@@ -25,6 +25,7 @@ export class IntrospectedRecord extends IntrospectedBaseClass {
25
25
  private _structFor: ClassStructTypeIdentifier | null = null;
26
26
  private _isSimple: boolean | null = null;
27
27
  private _isSimpleWithoutPointers: string | null = null;
28
+ private _overriddenGType: string | null = null;
28
29
 
29
30
  /**
30
31
  * Returns all signals for this record (records typically don't have signals)
@@ -49,6 +50,14 @@ export class IntrospectedRecord extends IntrospectedBaseClass {
49
50
  return this._structFor;
50
51
  }
51
52
 
53
+ get gtype() {
54
+ return this._overriddenGType ?? this.name;
55
+ }
56
+
57
+ overrideGType(gtype: string) {
58
+ this._overriddenGType = gtype;
59
+ }
60
+
52
61
  getType(): TypeIdentifier {
53
62
  if (this._structFor) {
54
63
  return this._structFor;
@@ -149,6 +158,7 @@ export class IntrospectedRecord extends IntrospectedBaseClass {
149
158
  constructors,
150
159
  _isForeign,
151
160
  _structFor,
161
+ _overriddenGType,
152
162
  props,
153
163
  fields,
154
164
  callbacks,
@@ -166,6 +176,7 @@ export class IntrospectedRecord extends IntrospectedBaseClass {
166
176
 
167
177
  clazz._structFor = _structFor;
168
178
  clazz._isForeign = _isForeign;
179
+ clazz._overriddenGType = _overriddenGType;
169
180
  clazz.props = (options.props ?? props).map((p) => p.copy({ parent: clazz }));
170
181
  clazz.fields = (options.fields ?? fields).map((f) => f.copy({ parent: clazz }));
171
182
  clazz.callbacks = (options.callbacks ?? callbacks).map((c) => c.copy({ parent: clazz }));
package/src/gir-module.ts CHANGED
@@ -599,7 +599,8 @@ export class GirModule implements IGirModule {
599
599
  if (ns.enumeration) {
600
600
  // Get the requested enums
601
601
  const enumerations = ns.enumeration
602
- ?.map((enumeration) => {
602
+ ?.filter(isIntrospectable)
603
+ .map((enumeration) => {
603
604
  if (enumeration.$["glib:error-domain"]) {
604
605
  return IntrospectedError.fromXML(enumeration as GirEnumElement, this, options);
605
606
  } else {