@gtkx/runtime 0.0.1 → 1.0.0-rc.1
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/LICENSE +373 -0
- package/README.md +171 -3
- package/dist/arg.d.ts +12 -0
- package/dist/arg.d.ts.map +1 -0
- package/dist/arg.js +5 -0
- package/dist/arg.js.map +1 -0
- package/dist/bind.d.ts +4 -0
- package/dist/bind.d.ts.map +1 -0
- package/dist/bind.js +17 -0
- package/dist/bind.js.map +1 -0
- package/dist/callback.d.ts +13 -0
- package/dist/callback.d.ts.map +1 -0
- package/dist/callback.js +68 -0
- package/dist/callback.js.map +1 -0
- package/dist/descriptors.d.ts +155 -0
- package/dist/descriptors.d.ts.map +1 -0
- package/dist/descriptors.js +103 -0
- package/dist/descriptors.js.map +1 -0
- package/dist/error.d.ts +25 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +29 -0
- package/dist/error.js.map +1 -0
- package/dist/fn.d.ts +10 -0
- package/dist/fn.d.ts.map +1 -0
- package/dist/fn.js +79 -0
- package/dist/fn.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +5 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +5 -0
- package/dist/internal.js.map +1 -0
- package/dist/library.d.ts +7 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +13 -0
- package/dist/library.js.map +1 -0
- package/dist/lifecycle.d.ts +41 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +55 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/listeners.d.ts +36 -0
- package/dist/listeners.d.ts.map +1 -0
- package/dist/listeners.js +72 -0
- package/dist/listeners.js.map +1 -0
- package/dist/mixin.d.ts +19 -0
- package/dist/mixin.d.ts.map +1 -0
- package/dist/mixin.js +39 -0
- package/dist/mixin.js.map +1 -0
- package/dist/native-value.d.ts +12 -0
- package/dist/native-value.d.ts.map +1 -0
- package/dist/native-value.js +72 -0
- package/dist/native-value.js.map +1 -0
- package/dist/object.d.ts +31 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +63 -0
- package/dist/object.js.map +1 -0
- package/dist/promisify.d.ts +13 -0
- package/dist/promisify.d.ts.map +1 -0
- package/dist/promisify.js +36 -0
- package/dist/promisify.js.map +1 -0
- package/dist/register-class.d.ts +17 -0
- package/dist/register-class.d.ts.map +1 -0
- package/dist/register-class.js +124 -0
- package/dist/register-class.js.map +1 -0
- package/dist/registry.d.ts +67 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +167 -0
- package/dist/registry.js.map +1 -0
- package/dist/signal.d.ts +34 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +88 -0
- package/dist/signal.js.map +1 -0
- package/dist/t.d.ts +50 -0
- package/dist/t.d.ts.map +1 -0
- package/dist/t.js +48 -0
- package/dist/t.js.map +1 -0
- package/dist/tuple.d.ts +6 -0
- package/dist/tuple.d.ts.map +1 -0
- package/dist/tuple.js +23 -0
- package/dist/tuple.js.map +1 -0
- package/dist/type.d.ts +81 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +174 -0
- package/dist/type.js.map +1 -0
- package/dist/value.d.ts +20 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +227 -0
- package/dist/value.js.map +1 -0
- package/package.json +56 -13
- package/src/arg.ts +13 -0
- package/src/bind.ts +22 -0
- package/src/callback.ts +87 -0
- package/src/descriptors.ts +208 -0
- package/src/error.ts +49 -0
- package/src/fn.ts +108 -0
- package/src/index.ts +57 -0
- package/src/internal.ts +12 -0
- package/src/library.ts +15 -0
- package/src/lifecycle.ts +73 -0
- package/src/listeners.ts +84 -0
- package/src/mixin.ts +48 -0
- package/src/native-value.ts +78 -0
- package/src/object.ts +83 -0
- package/src/promisify.ts +40 -0
- package/src/register-class.ts +178 -0
- package/src/registry.ts +221 -0
- package/src/signal.ts +152 -0
- package/src/t.ts +88 -0
- package/src/tuple.ts +25 -0
- package/src/type.ts +200 -0
- package/src/value.ts +307 -0
package/dist/t.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { bind } from "./bind.js";
|
|
2
|
+
import * as helpers from "./descriptors.js";
|
|
3
|
+
import { fn } from "./fn.js";
|
|
4
|
+
type T = {
|
|
5
|
+
bind: typeof bind;
|
|
6
|
+
int8: typeof helpers.int8T;
|
|
7
|
+
uint8: typeof helpers.uint8T;
|
|
8
|
+
int16: typeof helpers.int16T;
|
|
9
|
+
uint16: typeof helpers.uint16T;
|
|
10
|
+
int32: typeof helpers.int32T;
|
|
11
|
+
uint32: typeof helpers.uint32T;
|
|
12
|
+
int64: typeof helpers.int64T;
|
|
13
|
+
uint64: typeof helpers.uint64T;
|
|
14
|
+
bigint64: typeof helpers.bigint64T;
|
|
15
|
+
biguint64: typeof helpers.biguint64T;
|
|
16
|
+
gtype: typeof helpers.gtypeT;
|
|
17
|
+
float32: typeof helpers.float32T;
|
|
18
|
+
float64: typeof helpers.float64T;
|
|
19
|
+
boolean: typeof helpers.booleanT;
|
|
20
|
+
void: typeof helpers.voidT;
|
|
21
|
+
unichar: typeof helpers.unicharT;
|
|
22
|
+
buffer: typeof helpers.bufferT;
|
|
23
|
+
string: typeof helpers.stringT;
|
|
24
|
+
object: typeof helpers.objectT;
|
|
25
|
+
boxed: typeof helpers.boxedT;
|
|
26
|
+
struct: typeof helpers.structT;
|
|
27
|
+
fundamental: typeof helpers.fundamentalT;
|
|
28
|
+
ref: typeof helpers.refT;
|
|
29
|
+
hashTable: typeof helpers.hashTableT;
|
|
30
|
+
enum: typeof helpers.enumT;
|
|
31
|
+
flags: typeof helpers.flagsT;
|
|
32
|
+
array: typeof helpers.arrayT;
|
|
33
|
+
list: typeof helpers.listT;
|
|
34
|
+
slist: typeof helpers.slistT;
|
|
35
|
+
ptrArray: typeof helpers.ptrArrayT;
|
|
36
|
+
gArray: typeof helpers.gArrayT;
|
|
37
|
+
byteArray: typeof helpers.byteArrayT;
|
|
38
|
+
sizedArray: typeof helpers.sizedArrayT;
|
|
39
|
+
fixedArray: typeof helpers.fixedArrayT;
|
|
40
|
+
callback: typeof helpers.callbackT;
|
|
41
|
+
fn: typeof fn;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Type descriptor builder: a collection of factory helpers that describe C types for
|
|
45
|
+
* FFI marshalling, plus `bind` to bind a native function and `fn` to describe a
|
|
46
|
+
* function signature.
|
|
47
|
+
*/
|
|
48
|
+
export declare const t: T;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=t.d.ts.map
|
package/dist/t.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../src/t.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,KAAK,CAAC,GAAG;IACL,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,IAAI,EAAE,OAAO,OAAO,CAAC,KAAK,CAAC;IAC3B,KAAK,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAC7B,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAC7B,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAC7B,MAAM,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACnC,SAAS,EAAE,OAAO,OAAO,CAA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S,CAAC;IACnC,EAAE,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,CAAC,EAAE,CAsCf,CAAC"}
|
package/dist/t.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { bind } from "./bind.js";
|
|
2
|
+
import * as helpers from "./descriptors.js";
|
|
3
|
+
import { fn } from "./fn.js";
|
|
4
|
+
/**
|
|
5
|
+
* Type descriptor builder: a collection of factory helpers that describe C types for
|
|
6
|
+
* FFI marshalling, plus `bind` to bind a native function and `fn` to describe a
|
|
7
|
+
* function signature.
|
|
8
|
+
*/
|
|
9
|
+
export const t = {
|
|
10
|
+
bind,
|
|
11
|
+
int8: helpers.int8T,
|
|
12
|
+
uint8: helpers.uint8T,
|
|
13
|
+
int16: helpers.int16T,
|
|
14
|
+
uint16: helpers.uint16T,
|
|
15
|
+
int32: helpers.int32T,
|
|
16
|
+
uint32: helpers.uint32T,
|
|
17
|
+
int64: helpers.int64T,
|
|
18
|
+
uint64: helpers.uint64T,
|
|
19
|
+
bigint64: helpers.bigint64T,
|
|
20
|
+
biguint64: helpers.biguint64T,
|
|
21
|
+
gtype: helpers.gtypeT,
|
|
22
|
+
float32: helpers.float32T,
|
|
23
|
+
float64: helpers.float64T,
|
|
24
|
+
boolean: helpers.booleanT,
|
|
25
|
+
void: helpers.voidT,
|
|
26
|
+
unichar: helpers.unicharT,
|
|
27
|
+
buffer: helpers.bufferT,
|
|
28
|
+
string: helpers.stringT,
|
|
29
|
+
object: helpers.objectT,
|
|
30
|
+
boxed: helpers.boxedT,
|
|
31
|
+
struct: helpers.structT,
|
|
32
|
+
fundamental: helpers.fundamentalT,
|
|
33
|
+
ref: helpers.refT,
|
|
34
|
+
hashTable: helpers.hashTableT,
|
|
35
|
+
enum: helpers.enumT,
|
|
36
|
+
flags: helpers.flagsT,
|
|
37
|
+
array: helpers.arrayT,
|
|
38
|
+
list: helpers.listT,
|
|
39
|
+
slist: helpers.slistT,
|
|
40
|
+
ptrArray: helpers.ptrArrayT,
|
|
41
|
+
gArray: helpers.gArrayT,
|
|
42
|
+
byteArray: helpers.byteArrayT,
|
|
43
|
+
sizedArray: helpers.sizedArrayT,
|
|
44
|
+
fixedArray: helpers.fixedArrayT,
|
|
45
|
+
callback: helpers.callbackT,
|
|
46
|
+
fn,
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=t.js.map
|
package/dist/t.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.js","sourceRoot":"","sources":["../src/t.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AA0C7B;;;;GAIG;AACH,MAAM,CAAC,MAAM,CAAC,GAAM;IAChB,IAAI;IACJ,IAAI,EAAE,OAAO,CAAC,KAAK;IACnB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,QAAQ,EAAE,OAAO,CAAC,SAAS;IAC3B,SAAS,EAAE,OAAO,CAAC,UAAU;IAC7B,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,OAAO,EAAE,OAAO,CAAC,QAAQ;IACzB,OAAO,EAAE,OAAO,CAAC,QAAQ;IACzB,OAAO,EAAE,OAAO,CAAC,QAAQ;IACzB,IAAI,EAAE,OAAO,CAAC,KAAK;IACnB,OAAO,EAAE,OAAO,CAAC,QAAQ;IACzB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,WAAW,EAAE,OAAO,CAAC,YAAY;IACjC,GAAG,EAAE,OAAO,CAAC,IAAI;IACjB,SAAS,EAAE,OAAO,CAAC,UAAU;IAC7B,IAAI,EAAE,OAAO,CAAC,KAAK;IACnB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,IAAI,EAAE,OAAO,CAAC,KAAK;IACnB,KAAK,EAAE,OAAO,CAAC,MAAM;IACrB,QAAQ,EAAE,OAAO,CAAC,SAAS;IAC3B,MAAM,EAAE,OAAO,CAAC,OAAO;IACvB,SAAS,EAAE,OAAO,CAAC,UAAU;IAC7B,UAAU,EAAE,OAAO,CAAC,WAAW;IAC/B,UAAU,EAAE,OAAO,CAAC,WAAW;IAC/B,QAAQ,EAAE,OAAO,CAAC,SAAS;IAC3B,EAAE;CACL,CAAC","sourcesContent":["import { bind } from \"./bind.js\";\nimport * as helpers from \"./descriptors.js\";\nimport { fn } from \"./fn.js\";\n\ntype T = {\n bind: typeof bind;\n int8: typeof helpers.int8T;\n uint8: typeof helpers.uint8T;\n int16: typeof helpers.int16T;\n uint16: typeof helpers.uint16T;\n int32: typeof helpers.int32T;\n uint32: typeof helpers.uint32T;\n int64: typeof helpers.int64T;\n uint64: typeof helpers.uint64T;\n bigint64: typeof helpers.bigint64T;\n biguint64: typeof helpers.biguint64T;\n gtype: typeof helpers.gtypeT;\n float32: typeof helpers.float32T;\n float64: typeof helpers.float64T;\n boolean: typeof helpers.booleanT;\n void: typeof helpers.voidT;\n unichar: typeof helpers.unicharT;\n buffer: typeof helpers.bufferT;\n string: typeof helpers.stringT;\n object: typeof helpers.objectT;\n boxed: typeof helpers.boxedT;\n struct: typeof helpers.structT;\n fundamental: typeof helpers.fundamentalT;\n ref: typeof helpers.refT;\n hashTable: typeof helpers.hashTableT;\n enum: typeof helpers.enumT;\n flags: typeof helpers.flagsT;\n array: typeof helpers.arrayT;\n list: typeof helpers.listT;\n slist: typeof helpers.slistT;\n ptrArray: typeof helpers.ptrArrayT;\n gArray: typeof helpers.gArrayT;\n byteArray: typeof helpers.byteArrayT;\n sizedArray: typeof helpers.sizedArrayT;\n fixedArray: typeof helpers.fixedArrayT;\n callback: typeof helpers.callbackT;\n fn: typeof fn;\n};\n\n/**\n * Type descriptor builder: a collection of factory helpers that describe C types for\n * FFI marshalling, plus `bind` to bind a native function and `fn` to describe a\n * function signature.\n */\nexport const t: T = {\n bind,\n int8: helpers.int8T,\n uint8: helpers.uint8T,\n int16: helpers.int16T,\n uint16: helpers.uint16T,\n int32: helpers.int32T,\n uint32: helpers.uint32T,\n int64: helpers.int64T,\n uint64: helpers.uint64T,\n bigint64: helpers.bigint64T,\n biguint64: helpers.biguint64T,\n gtype: helpers.gtypeT,\n float32: helpers.float32T,\n float64: helpers.float64T,\n boolean: helpers.booleanT,\n void: helpers.voidT,\n unichar: helpers.unicharT,\n buffer: helpers.bufferT,\n string: helpers.stringT,\n object: helpers.objectT,\n boxed: helpers.boxedT,\n struct: helpers.structT,\n fundamental: helpers.fundamentalT,\n ref: helpers.refT,\n hashTable: helpers.hashTableT,\n enum: helpers.enumT,\n flags: helpers.flagsT,\n array: helpers.arrayT,\n list: helpers.listT,\n slist: helpers.slistT,\n ptrArray: helpers.ptrArrayT,\n gArray: helpers.gArrayT,\n byteArray: helpers.byteArrayT,\n sizedArray: helpers.sizedArrayT,\n fixedArray: helpers.fixedArrayT,\n callback: helpers.callbackT,\n fn,\n};\n"]}
|
package/dist/tuple.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const packTupleResult: (outs: unknown[], primary: unknown, hasPrimary: boolean) => unknown;
|
|
2
|
+
export declare const splitTupleResult: (result: unknown, hasPrimary: boolean, outCount: number) => {
|
|
3
|
+
primary: unknown;
|
|
4
|
+
outValues: unknown[];
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=tuple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../src/tuple.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,SAAU,OAAO,EAAE,WAAW,OAAO,cAAc,OAAO,KAAG,OAOxF,CAAC;AAEF,eAAO,MAAM,gBAAgB,WACjB,OAAO,cACH,OAAO,YACT,MAAM,KACjB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,EAAE,CAAA;CAW1C,CAAC"}
|
package/dist/tuple.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const packTupleResult = (outs, primary, hasPrimary) => {
|
|
2
|
+
if (hasPrimary) {
|
|
3
|
+
return outs.length === 0 ? primary : [primary, ...outs];
|
|
4
|
+
}
|
|
5
|
+
if (outs.length === 0)
|
|
6
|
+
return undefined;
|
|
7
|
+
if (outs.length === 1)
|
|
8
|
+
return outs[0];
|
|
9
|
+
return outs;
|
|
10
|
+
};
|
|
11
|
+
export const splitTupleResult = (result, hasPrimary, outCount) => {
|
|
12
|
+
if (hasPrimary) {
|
|
13
|
+
if (Array.isArray(result)) {
|
|
14
|
+
return { primary: result[0], outValues: result.slice(1) };
|
|
15
|
+
}
|
|
16
|
+
return { primary: result, outValues: [] };
|
|
17
|
+
}
|
|
18
|
+
if (outCount === 1) {
|
|
19
|
+
return { primary: undefined, outValues: [result] };
|
|
20
|
+
}
|
|
21
|
+
return { primary: undefined, outValues: Array.isArray(result) ? result : [] };
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=tuple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../src/tuple.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAe,EAAE,OAAgB,EAAE,UAAmB,EAAW,EAAE;IAC/F,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,MAAe,EACf,UAAmB,EACnB,QAAgB,EAC0B,EAAE;IAC5C,IAAI,UAAU,EAAE,CAAC;QACb,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAClF,CAAC,CAAC","sourcesContent":["export const packTupleResult = (outs: unknown[], primary: unknown, hasPrimary: boolean): unknown => {\n if (hasPrimary) {\n return outs.length === 0 ? primary : [primary, ...outs];\n }\n if (outs.length === 0) return undefined;\n if (outs.length === 1) return outs[0];\n return outs;\n};\n\nexport const splitTupleResult = (\n result: unknown,\n hasPrimary: boolean,\n outCount: number,\n): { primary: unknown; outValues: unknown[] } => {\n if (hasPrimary) {\n if (Array.isArray(result)) {\n return { primary: result[0], outValues: result.slice(1) };\n }\n return { primary: result, outValues: [] };\n }\n if (outCount === 1) {\n return { primary: undefined, outValues: [result] };\n }\n return { primary: undefined, outValues: Array.isArray(result) ? result : [] };\n};\n"]}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Descriptor } from "@gtkx/native";
|
|
2
|
+
import { type BoxedDescriptor, type FundamentalDescriptor } from "./descriptors.js";
|
|
3
|
+
/** Object tagged with its GLib type through a `__type__` GType field. */
|
|
4
|
+
export type TypedClass = {
|
|
5
|
+
__type__: bigint;
|
|
6
|
+
};
|
|
7
|
+
export declare const isTypedClass: (value: unknown) => value is TypedClass;
|
|
8
|
+
/** GType tag for an invalid or uninitialized type. */
|
|
9
|
+
export declare const TYPE_INVALID: bigint;
|
|
10
|
+
/** GType tag for the absence of a value (`void`). */
|
|
11
|
+
export declare const TYPE_NONE: bigint;
|
|
12
|
+
/** GType tag for the base GInterface type. */
|
|
13
|
+
export declare const TYPE_INTERFACE: bigint;
|
|
14
|
+
/** GType tag for `gchar` (signed 8-bit integer). */
|
|
15
|
+
export declare const TYPE_CHAR: bigint;
|
|
16
|
+
/** GType tag for `guchar` (unsigned 8-bit integer). */
|
|
17
|
+
export declare const TYPE_UCHAR: bigint;
|
|
18
|
+
/** GType tag for `gboolean`. */
|
|
19
|
+
export declare const TYPE_BOOLEAN: bigint;
|
|
20
|
+
/** GType tag for `gint`. */
|
|
21
|
+
export declare const TYPE_INT: bigint;
|
|
22
|
+
/** GType tag for `guint`. */
|
|
23
|
+
export declare const TYPE_UINT: bigint;
|
|
24
|
+
/** GType tag for `glong`. */
|
|
25
|
+
export declare const TYPE_LONG: bigint;
|
|
26
|
+
/** GType tag for `gulong`. */
|
|
27
|
+
export declare const TYPE_ULONG: bigint;
|
|
28
|
+
/** GType tag for `gint64`. */
|
|
29
|
+
export declare const TYPE_INT64: bigint;
|
|
30
|
+
/** GType tag for `guint64`. */
|
|
31
|
+
export declare const TYPE_UINT64: bigint;
|
|
32
|
+
/** GType tag for the base GEnum type. */
|
|
33
|
+
export declare const TYPE_ENUM: bigint;
|
|
34
|
+
/** GType tag for the base GFlags type. */
|
|
35
|
+
export declare const TYPE_FLAGS: bigint;
|
|
36
|
+
/** GType tag for `gfloat`. */
|
|
37
|
+
export declare const TYPE_FLOAT: bigint;
|
|
38
|
+
/** GType tag for `gdouble`. */
|
|
39
|
+
export declare const TYPE_DOUBLE: bigint;
|
|
40
|
+
/** GType tag for `gchararray` (a nul-terminated C string). */
|
|
41
|
+
export declare const TYPE_STRING: bigint;
|
|
42
|
+
/** GType tag for `gpointer` (an opaque pointer). */
|
|
43
|
+
export declare const TYPE_POINTER: bigint;
|
|
44
|
+
/** GType tag for the base GBoxed type. */
|
|
45
|
+
export declare const TYPE_BOXED: bigint;
|
|
46
|
+
/** GType tag for the base GParam type. */
|
|
47
|
+
export declare const TYPE_PARAM: bigint;
|
|
48
|
+
/** GType tag for the base GObject type. */
|
|
49
|
+
export declare const TYPE_OBJECT: bigint;
|
|
50
|
+
/** GType tag for a GType value itself. */
|
|
51
|
+
export declare const TYPE_GTYPE: bigint;
|
|
52
|
+
/** GType tag for GVariant. */
|
|
53
|
+
export declare const TYPE_VARIANT: bigint;
|
|
54
|
+
/** GType tag for a Unicode character stored as `guint`. */
|
|
55
|
+
export declare const TYPE_UNICHAR: bigint;
|
|
56
|
+
export declare const getErrorType: () => bigint;
|
|
57
|
+
export declare const getStrvType: () => bigint;
|
|
58
|
+
/** Returns whether `type` is `isAType` or descends from it. */
|
|
59
|
+
export declare function typeIsA(type: bigint, isAType: bigint): boolean;
|
|
60
|
+
/** Returns the immediate parent GType of the given type. */
|
|
61
|
+
export declare function typeParent(type: bigint): bigint;
|
|
62
|
+
/** Returns the GTypes of the interfaces implemented by the given type. */
|
|
63
|
+
export declare function typeInterfaces(type: bigint): bigint[];
|
|
64
|
+
/** Returns the GType registered under the given name, or `TYPE_INVALID` if none exists. */
|
|
65
|
+
export declare function typeFromName(name: string): bigint;
|
|
66
|
+
export declare function typeFundamental(type: bigint): bigint;
|
|
67
|
+
/** Returns the registered name of a GType, or null if it has none. */
|
|
68
|
+
export declare function typeName(type: bigint): string | null;
|
|
69
|
+
/** Returns whether `value` is a typed wrapper whose GType is or descends from `gtype`. */
|
|
70
|
+
export declare function valueIsA(value: unknown, gtype: bigint): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the GType produced by a `get_type` function in a shared library, caching
|
|
73
|
+
* the result per library and function name.
|
|
74
|
+
* @param sharedLibrary Path or name of the shared library exporting the function.
|
|
75
|
+
* @param getTypeFnName Name of the `*_get_type` function to call.
|
|
76
|
+
*/
|
|
77
|
+
export declare const resolveType: (sharedLibrary: string, getTypeFnName: string) => bigint;
|
|
78
|
+
export declare const resolveBoxedType: (descriptor: BoxedDescriptor) => bigint;
|
|
79
|
+
export declare const resolveFundamentalType: (descriptor: FundamentalDescriptor) => bigint;
|
|
80
|
+
export declare function resolveDescriptorType(descriptor: Descriptor): bigint;
|
|
81
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAoC,MAAM,cAAc,CAAC;AAEjF,OAAO,EACH,KAAK,eAAe,EAGpB,KAAK,qBAAqB,EAK7B,MAAM,kBAAkB,CAAC;AAG1B,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAmBF,eAAO,MAAM,YAAY,UAAW,OAAO,KAAG,KAAK,IAAI,UACqD,CAAC;AAE7G,sDAAsD;AACtD,eAAO,MAAM,YAAY,EAAE,MAAW,CAA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
+
import { biguint64T, booleanT, refT, sizedArrayT, stringT, uint32T, } from "./descriptors.js";
|
|
4
|
+
import { LIB } from "./library.js";
|
|
5
|
+
const resolvedTypeCache = new Map();
|
|
6
|
+
const gTypeFromName = bind(LIB, "g_type_from_name", [stringT("borrowed")], biguint64T);
|
|
7
|
+
const gTypeIsA = bind(LIB, "g_type_is_a", [biguint64T, biguint64T], booleanT);
|
|
8
|
+
const gTypeParent = bind(LIB, "g_type_parent", [biguint64T], biguint64T);
|
|
9
|
+
const gTypeFundamental = bind(LIB, "g_type_fundamental", [biguint64T], biguint64T);
|
|
10
|
+
const gTypeName = bind(LIB, "g_type_name", [biguint64T], stringT("borrowed"));
|
|
11
|
+
const gTypeInterfaces = bind(LIB, "g_type_interfaces", [biguint64T, refT(uint32T)], sizedArrayT(biguint64T, 1, "full"));
|
|
12
|
+
const lazyType = (name) => {
|
|
13
|
+
let cached;
|
|
14
|
+
return () => {
|
|
15
|
+
cached ??= typeFromName(name);
|
|
16
|
+
return cached;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export const isTypedClass = (value) => typeof value === "object" && value !== null && "__type__" in value && typeof value.__type__ === "bigint";
|
|
20
|
+
/** GType tag for an invalid or uninitialized type. */
|
|
21
|
+
export const TYPE_INVALID = 0n;
|
|
22
|
+
/** GType tag for the absence of a value (`void`). */
|
|
23
|
+
export const TYPE_NONE = typeFromName("void");
|
|
24
|
+
/** GType tag for the base GInterface type. */
|
|
25
|
+
export const TYPE_INTERFACE = typeFromName("GInterface");
|
|
26
|
+
/** GType tag for `gchar` (signed 8-bit integer). */
|
|
27
|
+
export const TYPE_CHAR = typeFromName("gchar");
|
|
28
|
+
/** GType tag for `guchar` (unsigned 8-bit integer). */
|
|
29
|
+
export const TYPE_UCHAR = typeFromName("guchar");
|
|
30
|
+
/** GType tag for `gboolean`. */
|
|
31
|
+
export const TYPE_BOOLEAN = typeFromName("gboolean");
|
|
32
|
+
/** GType tag for `gint`. */
|
|
33
|
+
export const TYPE_INT = typeFromName("gint");
|
|
34
|
+
/** GType tag for `guint`. */
|
|
35
|
+
export const TYPE_UINT = typeFromName("guint");
|
|
36
|
+
/** GType tag for `glong`. */
|
|
37
|
+
export const TYPE_LONG = typeFromName("glong");
|
|
38
|
+
/** GType tag for `gulong`. */
|
|
39
|
+
export const TYPE_ULONG = typeFromName("gulong");
|
|
40
|
+
/** GType tag for `gint64`. */
|
|
41
|
+
export const TYPE_INT64 = typeFromName("gint64");
|
|
42
|
+
/** GType tag for `guint64`. */
|
|
43
|
+
export const TYPE_UINT64 = typeFromName("guint64");
|
|
44
|
+
/** GType tag for the base GEnum type. */
|
|
45
|
+
export const TYPE_ENUM = typeFromName("GEnum");
|
|
46
|
+
/** GType tag for the base GFlags type. */
|
|
47
|
+
export const TYPE_FLAGS = typeFromName("GFlags");
|
|
48
|
+
/** GType tag for `gfloat`. */
|
|
49
|
+
export const TYPE_FLOAT = typeFromName("gfloat");
|
|
50
|
+
/** GType tag for `gdouble`. */
|
|
51
|
+
export const TYPE_DOUBLE = typeFromName("gdouble");
|
|
52
|
+
/** GType tag for `gchararray` (a nul-terminated C string). */
|
|
53
|
+
export const TYPE_STRING = typeFromName("gchararray");
|
|
54
|
+
/** GType tag for `gpointer` (an opaque pointer). */
|
|
55
|
+
export const TYPE_POINTER = typeFromName("gpointer");
|
|
56
|
+
/** GType tag for the base GBoxed type. */
|
|
57
|
+
export const TYPE_BOXED = typeFromName("GBoxed");
|
|
58
|
+
/** GType tag for the base GParam type. */
|
|
59
|
+
export const TYPE_PARAM = typeFromName("GParam");
|
|
60
|
+
/** GType tag for the base GObject type. */
|
|
61
|
+
export const TYPE_OBJECT = typeFromName("GObject");
|
|
62
|
+
/** GType tag for a GType value itself. */
|
|
63
|
+
export const TYPE_GTYPE = typeFromName("GType");
|
|
64
|
+
/** GType tag for GVariant. */
|
|
65
|
+
export const TYPE_VARIANT = typeFromName("GVariant");
|
|
66
|
+
/** GType tag for a Unicode character stored as `guint`. */
|
|
67
|
+
export const TYPE_UNICHAR = typeFromName("guint");
|
|
68
|
+
export const getErrorType = lazyType("GError");
|
|
69
|
+
export const getStrvType = lazyType("GStrv");
|
|
70
|
+
/** Returns whether `type` is `isAType` or descends from it. */
|
|
71
|
+
export function typeIsA(type, isAType) {
|
|
72
|
+
return gTypeIsA(type, isAType);
|
|
73
|
+
}
|
|
74
|
+
/** Returns the immediate parent GType of the given type. */
|
|
75
|
+
export function typeParent(type) {
|
|
76
|
+
return gTypeParent(type);
|
|
77
|
+
}
|
|
78
|
+
/** Returns the GTypes of the interfaces implemented by the given type. */
|
|
79
|
+
export function typeInterfaces(type) {
|
|
80
|
+
const nInterfacesRef = { value: 0 };
|
|
81
|
+
return gTypeInterfaces(type, nInterfacesRef);
|
|
82
|
+
}
|
|
83
|
+
/** Returns the GType registered under the given name, or `TYPE_INVALID` if none exists. */
|
|
84
|
+
export function typeFromName(name) {
|
|
85
|
+
return gTypeFromName(name);
|
|
86
|
+
}
|
|
87
|
+
export function typeFundamental(type) {
|
|
88
|
+
return gTypeFundamental(type);
|
|
89
|
+
}
|
|
90
|
+
/** Returns the registered name of a GType, or null if it has none. */
|
|
91
|
+
export function typeName(type) {
|
|
92
|
+
return (gTypeName(type) ?? null);
|
|
93
|
+
}
|
|
94
|
+
/** Returns whether `value` is a typed wrapper whose GType is or descends from `gtype`. */
|
|
95
|
+
export function valueIsA(value, gtype) {
|
|
96
|
+
return isTypedClass(value) && typeIsA(value.__type__, gtype);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolves the GType produced by a `get_type` function in a shared library, caching
|
|
100
|
+
* the result per library and function name.
|
|
101
|
+
* @param sharedLibrary Path or name of the shared library exporting the function.
|
|
102
|
+
* @param getTypeFnName Name of the `*_get_type` function to call.
|
|
103
|
+
*/
|
|
104
|
+
export const resolveType = (sharedLibrary, getTypeFnName) => {
|
|
105
|
+
const key = `${sharedLibrary}:${getTypeFnName}`;
|
|
106
|
+
const cached = resolvedTypeCache.get(key);
|
|
107
|
+
if (cached !== undefined)
|
|
108
|
+
return cached;
|
|
109
|
+
const gtype = nativeResolveType(sharedLibrary, getTypeFnName);
|
|
110
|
+
resolvedTypeCache.set(key, gtype);
|
|
111
|
+
return gtype;
|
|
112
|
+
};
|
|
113
|
+
export const resolveBoxedType = (descriptor) => {
|
|
114
|
+
if (descriptor.getTypeFnName && descriptor.sharedLibrary) {
|
|
115
|
+
return resolveType(descriptor.sharedLibrary, descriptor.getTypeFnName);
|
|
116
|
+
}
|
|
117
|
+
const gtype = typeFromName(descriptor.typeName);
|
|
118
|
+
if (gtype === TYPE_INVALID) {
|
|
119
|
+
throw new Error(`Cannot resolve gtype for boxed type '${descriptor.typeName}'`);
|
|
120
|
+
}
|
|
121
|
+
return gtype;
|
|
122
|
+
};
|
|
123
|
+
export const resolveFundamentalType = (descriptor) => {
|
|
124
|
+
if (descriptor.typeName) {
|
|
125
|
+
const gtype = typeFromName(descriptor.typeName);
|
|
126
|
+
if (gtype !== TYPE_INVALID)
|
|
127
|
+
return gtype;
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`Cannot resolve gtype for fundamental type without a typeName`);
|
|
130
|
+
};
|
|
131
|
+
export function resolveDescriptorType(descriptor) {
|
|
132
|
+
if (descriptor.kind === "biguint64" && "type" in descriptor)
|
|
133
|
+
return TYPE_GTYPE;
|
|
134
|
+
switch (descriptor.kind) {
|
|
135
|
+
case "boolean":
|
|
136
|
+
return TYPE_BOOLEAN;
|
|
137
|
+
case "string":
|
|
138
|
+
return TYPE_STRING;
|
|
139
|
+
case "int8":
|
|
140
|
+
case "int16":
|
|
141
|
+
case "int32":
|
|
142
|
+
return TYPE_INT;
|
|
143
|
+
case "uint8":
|
|
144
|
+
case "uint16":
|
|
145
|
+
case "uint32":
|
|
146
|
+
return TYPE_UINT;
|
|
147
|
+
case "int64":
|
|
148
|
+
case "bigint64":
|
|
149
|
+
return TYPE_INT64;
|
|
150
|
+
case "uint64":
|
|
151
|
+
case "biguint64":
|
|
152
|
+
return TYPE_UINT64;
|
|
153
|
+
case "float32":
|
|
154
|
+
return TYPE_FLOAT;
|
|
155
|
+
case "float64":
|
|
156
|
+
return TYPE_DOUBLE;
|
|
157
|
+
case "object":
|
|
158
|
+
return TYPE_OBJECT;
|
|
159
|
+
case "enum":
|
|
160
|
+
case "flags":
|
|
161
|
+
return resolveType(descriptor.sharedLibrary, descriptor.getTypeFnName);
|
|
162
|
+
case "boxed":
|
|
163
|
+
return resolveBoxedType(descriptor);
|
|
164
|
+
case "fundamental":
|
|
165
|
+
return resolveFundamentalType(descriptor);
|
|
166
|
+
case "array":
|
|
167
|
+
if (descriptor.itemDescriptor.kind === "string" && descriptor.arrayKind === "array")
|
|
168
|
+
return getStrvType();
|
|
169
|
+
throw new Error(`Unsupported array type ${descriptor.arrayKind} of ${descriptor.itemDescriptor.kind}`);
|
|
170
|
+
default:
|
|
171
|
+
throw new Error(`Unsupported type descriptor '${descriptor.kind}'`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=type.js.map
|
package/dist/type.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAEH,UAAU,EACV,QAAQ,EAER,IAAI,EACJ,WAAW,EACX,OAAO,EACP,OAAO,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOnC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEpD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACvF,MAAM,QAAQ,GAAG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AC;QAC9C,KAAK,OAAO;YACR,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,SAAS,KAAK,OAAO;gBAAE,OAAO,WAAW,EAAE,CAAC;YAC1G,MAAM,IAAI,KAAK,CAAC,0BAA0B,UAAU,CAAC,SAAS,OAAO,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3G;YACI,MAAM,IAAI,KAAK,CAAC,gCAAgC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;IAC5E,CAAC;AACL,CAAC","sourcesContent":["import { type Descriptor, resolveType as nativeResolveType } from \"@gtkx/native\";\nimport { bind } from \"./bind.js\";\nimport {\n type BoxedDescriptor,\n biguint64T,\n booleanT,\n type FundamentalDescriptor,\n refT,\n sizedArrayT,\n stringT,\n uint32T,\n} from \"./descriptors.js\";\nimport { LIB } from \"./library.js\";\n\n/** Object tagged with its GLib type through a `__type__` GType field. */\nexport type TypedClass = {\n __type__: bigint;\n};\n\nconst resolvedTypeCache = new Map<string, bigint>();\n\nconst gTypeFromName = bind(LIB, \"g_type_from_name\", [stringT(\"borrowed\")], biguint64T);\nconst gTypeIsA = bind(LIB, \"g_type_is_a\", [biguint64T, biguint64T], booleanT);\nconst gTypeParent = bind(LIB, \"g_type_parent\", [biguint64T], biguint64T);\nconst gTypeFundamental = bind(LIB, \"g_type_fundamental\", [biguint64T], biguint64T);\nconst gTypeName = bind(LIB, \"g_type_name\", [biguint64T], stringT(\"borrowed\"));\nconst gTypeInterfaces = bind(LIB, \"g_type_interfaces\", [biguint64T, refT(uint32T)], sizedArrayT(biguint64T, 1, \"full\"));\n\nconst lazyType = (name: string): (() => bigint) => {\n let cached: bigint | undefined;\n return () => {\n cached ??= typeFromName(name);\n return cached;\n };\n};\n\nexport const isTypedClass = (value: unknown): value is TypedClass =>\n typeof value === \"object\" && value !== null && \"__type__\" in value && typeof value.__type__ === \"bigint\";\n\n/** GType tag for an invalid or uninitialized type. */\nexport const TYPE_INVALID: bigint = 0n;\n/** GType tag for the absence of a value (`void`). */\nexport const TYPE_NONE: bigint = typeFromName(\"void\");\n/** GType tag for the base GInterface type. */\nexport const TYPE_INTERFACE: bigint = typeFromName(\"GInterface\");\n/** GType tag for `gchar` (signed 8-bit integer). */\nexport const TYPE_CHAR: bigint = typeFromName(\"gchar\");\n/** GType tag for `guchar` (unsigned 8-bit integer). */\nexport const TYPE_UCHAR: bigint = typeFromName(\"guchar\");\n/** GType tag for `gboolean`. */\nexport const TYPE_BOOLEAN: bigint = typeFromName(\"gboolean\");\n/** GType tag for `gint`. */\nexport const TYPE_INT: bigint = typeFromName(\"gint\");\n/** GType tag for `guint`. */\nexport const TYPE_UINT: bigint = typeFromName(\"guint\");\n/** GType tag for `glong`. */\nexport const TYPE_LONG: bigint = typeFromName(\"glong\");\n/** GType tag for `gulong`. */\nexport const TYPE_ULONG: bigint = typeFromName(\"gulong\");\n/** GType tag for `gint64`. */\nexport const TYPE_INT64: bigint = typeFromName(\"gint64\");\n/** GType tag for `guint64`. */\nexport const TYPE_UINT64: bigint = typeFromName(\"guint64\");\n/** GType tag for the base GEnum type. */\nexport const TYPE_ENUM: bigint = typeFromName(\"GEnum\");\n/** GType tag for the base GFlags type. */\nexport const TYPE_FLAGS: bigint = typeFromName(\"GFlags\");\n/** GType tag for `gfloat`. */\nexport const TYPE_FLOAT: bigint = typeFromName(\"gfloat\");\n/** GType tag for `gdouble`. */\nexport const TYPE_DOUBLE: bigint = typeFromName(\"gdouble\");\n/** GType tag for `gchararray` (a nul-terminated C string). */\nexport const TYPE_STRING: bigint = typeFromName(\"gchararray\");\n/** GType tag for `gpointer` (an opaque pointer). */\nexport const TYPE_POINTER: bigint = typeFromName(\"gpointer\");\n/** GType tag for the base GBoxed type. */\nexport const TYPE_BOXED: bigint = typeFromName(\"GBoxed\");\n/** GType tag for the base GParam type. */\nexport const TYPE_PARAM: bigint = typeFromName(\"GParam\");\n/** GType tag for the base GObject type. */\nexport const TYPE_OBJECT: bigint = typeFromName(\"GObject\");\n/** GType tag for a GType value itself. */\nexport const TYPE_GTYPE: bigint = typeFromName(\"GType\");\n/** GType tag for GVariant. */\nexport const TYPE_VARIANT: bigint = typeFromName(\"GVariant\");\n/** GType tag for a Unicode character stored as `guint`. */\nexport const TYPE_UNICHAR: bigint = typeFromName(\"guint\");\nexport const getErrorType: () => bigint = lazyType(\"GError\");\nexport const getStrvType: () => bigint = lazyType(\"GStrv\");\n\n/** Returns whether `type` is `isAType` or descends from it. */\nexport function typeIsA(type: bigint, isAType: bigint): boolean {\n return gTypeIsA(type, isAType) as boolean;\n}\n\n/** Returns the immediate parent GType of the given type. */\nexport function typeParent(type: bigint): bigint {\n return gTypeParent(type) as bigint;\n}\n\n/** Returns the GTypes of the interfaces implemented by the given type. */\nexport function typeInterfaces(type: bigint): bigint[] {\n const nInterfacesRef = { value: 0 };\n return gTypeInterfaces(type, nInterfacesRef) as bigint[];\n}\n\n/** Returns the GType registered under the given name, or `TYPE_INVALID` if none exists. */\nexport function typeFromName(name: string): bigint {\n return gTypeFromName(name) as bigint;\n}\n\nexport function typeFundamental(type: bigint): bigint {\n return gTypeFundamental(type) as bigint;\n}\n\n/** Returns the registered name of a GType, or null if it has none. */\nexport function typeName(type: bigint): string | null {\n return (gTypeName(type) ?? null) as string | null;\n}\n\n/** Returns whether `value` is a typed wrapper whose GType is or descends from `gtype`. */\nexport function valueIsA(value: unknown, gtype: bigint): boolean {\n return isTypedClass(value) && typeIsA(value.__type__, gtype);\n}\n\n/**\n * Resolves the GType produced by a `get_type` function in a shared library, caching\n * the result per library and function name.\n * @param sharedLibrary Path or name of the shared library exporting the function.\n * @param getTypeFnName Name of the `*_get_type` function to call.\n */\nexport const resolveType = (sharedLibrary: string, getTypeFnName: string): bigint => {\n const key = `${sharedLibrary}:${getTypeFnName}`;\n const cached = resolvedTypeCache.get(key);\n if (cached !== undefined) return cached;\n const gtype = nativeResolveType(sharedLibrary, getTypeFnName);\n resolvedTypeCache.set(key, gtype);\n return gtype;\n};\n\nexport const resolveBoxedType = (descriptor: BoxedDescriptor): bigint => {\n if (descriptor.getTypeFnName && descriptor.sharedLibrary) {\n return resolveType(descriptor.sharedLibrary, descriptor.getTypeFnName);\n }\n const gtype = typeFromName(descriptor.typeName);\n if (gtype === TYPE_INVALID) {\n throw new Error(`Cannot resolve gtype for boxed type '${descriptor.typeName}'`);\n }\n return gtype;\n};\n\nexport const resolveFundamentalType = (descriptor: FundamentalDescriptor): bigint => {\n if (descriptor.typeName) {\n const gtype = typeFromName(descriptor.typeName);\n if (gtype !== TYPE_INVALID) return gtype;\n }\n throw new Error(`Cannot resolve gtype for fundamental type without a typeName`);\n};\n\nexport function resolveDescriptorType(descriptor: Descriptor): bigint {\n if (descriptor.kind === \"biguint64\" && \"type\" in descriptor) return TYPE_GTYPE;\n switch (descriptor.kind) {\n case \"boolean\":\n return TYPE_BOOLEAN;\n case \"string\":\n return TYPE_STRING;\n case \"int8\":\n case \"int16\":\n case \"int32\":\n return TYPE_INT;\n case \"uint8\":\n case \"uint16\":\n case \"uint32\":\n return TYPE_UINT;\n case \"int64\":\n case \"bigint64\":\n return TYPE_INT64;\n case \"uint64\":\n case \"biguint64\":\n return TYPE_UINT64;\n case \"float32\":\n return TYPE_FLOAT;\n case \"float64\":\n return TYPE_DOUBLE;\n case \"object\":\n return TYPE_OBJECT;\n case \"enum\":\n case \"flags\":\n return resolveType(descriptor.sharedLibrary, descriptor.getTypeFnName);\n case \"boxed\":\n return resolveBoxedType(descriptor);\n case \"fundamental\":\n return resolveFundamentalType(descriptor);\n case \"array\":\n if (descriptor.itemDescriptor.kind === \"string\" && descriptor.arrayKind === \"array\") return getStrvType();\n throw new Error(`Unsupported array type ${descriptor.arrayKind} of ${descriptor.itemDescriptor.kind}`);\n default:\n throw new Error(`Unsupported type descriptor '${descriptor.kind}'`);\n }\n}\n"]}
|
package/dist/value.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Descriptor, type ExternalObject, type Handle } from "@gtkx/native";
|
|
2
|
+
export declare function getValueType(value: ExternalObject<Handle>): bigint;
|
|
3
|
+
export declare function copyValue(dest: ExternalObject<Handle>, src: ExternalObject<Handle>): void;
|
|
4
|
+
/**
|
|
5
|
+
* Reads the boxed pointer out of a GValue and returns it wrapped in its registered
|
|
6
|
+
* class, or null when the value does not hold a boxed type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBoxedValue(value: ExternalObject<Handle>): object | null;
|
|
9
|
+
/** Stores a boxed object, or null, into a GValue that holds a boxed type. */
|
|
10
|
+
export declare function setBoxedValue(value: ExternalObject<Handle>, boxed: object | null): void;
|
|
11
|
+
export declare function toValue(descriptor: Descriptor, value: unknown): ExternalObject<Handle>;
|
|
12
|
+
export declare function fromValue(value: ExternalObject<Handle>): unknown;
|
|
13
|
+
export declare function newValueForDescriptor(descriptor: Descriptor): ExternalObject<Handle>;
|
|
14
|
+
export declare function outValueForDescriptor(descriptor: Descriptor, initial?: unknown): {
|
|
15
|
+
value: ExternalObject<Handle>;
|
|
16
|
+
read: () => unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare function outValueForBoxedDescriptor(descriptor: Descriptor, boxed: object): ExternalObject<Handle>;
|
|
19
|
+
export declare function inoutValueForBoxedDescriptor(descriptor: Descriptor, boxed: object): ExternalObject<Handle>;
|
|
20
|
+
//# sourceMappingURL=value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../src/value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,UAAU,EAAE,KAAK,cAAc,EAAW,KAAK,MAAM,EAAe,MAAM,cAAc,CAAC;AAsH9G,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,CAElE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,MAAM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