@gtkx/codegen 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/LICENSE +373 -0
- package/dist/dsl/context.d.ts +104 -0
- package/dist/dsl/context.d.ts.map +1 -0
- package/dist/dsl/context.js +140 -0
- package/dist/dsl/context.js.map +1 -0
- package/dist/dsl/emit.d.ts +28 -0
- package/dist/dsl/emit.d.ts.map +1 -0
- package/dist/dsl/emit.js +41 -0
- package/dist/dsl/emit.js.map +1 -0
- package/dist/dsl/identifier.d.ts +28 -0
- package/dist/dsl/identifier.d.ts.map +1 -0
- package/dist/dsl/identifier.js +45 -0
- package/dist/dsl/identifier.js.map +1 -0
- package/dist/dsl/imports.d.ts +58 -0
- package/dist/dsl/imports.d.ts.map +1 -0
- package/dist/dsl/imports.js +107 -0
- package/dist/dsl/imports.js.map +1 -0
- package/dist/dsl/module.d.ts +53 -0
- package/dist/dsl/module.d.ts.map +1 -0
- package/dist/dsl/module.js +76 -0
- package/dist/dsl/module.js.map +1 -0
- package/dist/ffi/pipeline.d.ts +19 -0
- package/dist/ffi/pipeline.d.ts.map +1 -0
- package/dist/ffi/pipeline.js +107 -0
- package/dist/ffi/pipeline.js.map +1 -0
- package/dist/fingerprint.d.ts +30 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +33 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/gi-store.d.ts +34 -0
- package/dist/gi-store.d.ts.map +1 -0
- package/dist/gi-store.js +154 -0
- package/dist/gi-store.js.map +1 -0
- package/dist/gir/boxed.d.ts +66 -0
- package/dist/gir/boxed.d.ts.map +1 -0
- package/dist/gir/boxed.js +49 -0
- package/dist/gir/boxed.js.map +1 -0
- package/dist/gir/callback.d.ts +15 -0
- package/dist/gir/callback.d.ts.map +1 -0
- package/dist/gir/callback.js +17 -0
- package/dist/gir/callback.js.map +1 -0
- package/dist/gir/class.d.ts +49 -0
- package/dist/gir/class.d.ts.map +1 -0
- package/dist/gir/class.js +42 -0
- package/dist/gir/class.js.map +1 -0
- package/dist/gir/enum.d.ts +39 -0
- package/dist/gir/enum.d.ts.map +1 -0
- package/dist/gir/enum.js +24 -0
- package/dist/gir/enum.js.map +1 -0
- package/dist/gir/field.d.ts +27 -0
- package/dist/gir/field.d.ts.map +1 -0
- package/dist/gir/field.js +19 -0
- package/dist/gir/field.js.map +1 -0
- package/dist/gir/function.d.ts +47 -0
- package/dist/gir/function.d.ts.map +1 -0
- package/dist/gir/function.js +28 -0
- package/dist/gir/function.js.map +1 -0
- package/dist/gir/namespace.d.ts +65 -0
- package/dist/gir/namespace.d.ts.map +1 -0
- package/dist/gir/namespace.js +60 -0
- package/dist/gir/namespace.js.map +1 -0
- package/dist/gir/parameter.d.ts +82 -0
- package/dist/gir/parameter.d.ts.map +1 -0
- package/dist/gir/parameter.js +66 -0
- package/dist/gir/parameter.js.map +1 -0
- package/dist/gir/parse.d.ts +78 -0
- package/dist/gir/parse.d.ts.map +1 -0
- package/dist/gir/parse.js +155 -0
- package/dist/gir/parse.js.map +1 -0
- package/dist/gir/primitives.d.ts +36 -0
- package/dist/gir/primitives.d.ts.map +1 -0
- package/dist/gir/primitives.js +109 -0
- package/dist/gir/primitives.js.map +1 -0
- package/dist/gir/property.d.ts +29 -0
- package/dist/gir/property.d.ts.map +1 -0
- package/dist/gir/property.js +16 -0
- package/dist/gir/property.js.map +1 -0
- package/dist/gir/qualified-name.d.ts +37 -0
- package/dist/gir/qualified-name.d.ts.map +1 -0
- package/dist/gir/qualified-name.js +39 -0
- package/dist/gir/qualified-name.js.map +1 -0
- package/dist/gir/qualify.d.ts +32 -0
- package/dist/gir/qualify.d.ts.map +1 -0
- package/dist/gir/qualify.js +60 -0
- package/dist/gir/qualify.js.map +1 -0
- package/dist/gir/repository.d.ts +82 -0
- package/dist/gir/repository.d.ts.map +1 -0
- package/dist/gir/repository.js +122 -0
- package/dist/gir/repository.js.map +1 -0
- package/dist/gir/signal.d.ts +22 -0
- package/dist/gir/signal.d.ts.map +1 -0
- package/dist/gir/signal.js +20 -0
- package/dist/gir/signal.js.map +1 -0
- package/dist/gir/size.d.ts +67 -0
- package/dist/gir/size.d.ts.map +1 -0
- package/dist/gir/size.js +87 -0
- package/dist/gir/size.js.map +1 -0
- package/dist/gir/type-ref.d.ts +79 -0
- package/dist/gir/type-ref.d.ts.map +1 -0
- package/dist/gir/type-ref.js +101 -0
- package/dist/gir/type-ref.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-store.d.ts +22 -0
- package/dist/jsx-store.d.ts.map +1 -0
- package/dist/jsx-store.js +40 -0
- package/dist/jsx-store.js.map +1 -0
- package/dist/react/compounds-meta.d.ts +18 -0
- package/dist/react/compounds-meta.d.ts.map +1 -0
- package/dist/react/compounds-meta.js +93 -0
- package/dist/react/compounds-meta.js.map +1 -0
- package/dist/react/compounds.d.ts +27 -0
- package/dist/react/compounds.d.ts.map +1 -0
- package/dist/react/compounds.js +164 -0
- package/dist/react/compounds.js.map +1 -0
- package/dist/react/internal.d.ts +14 -0
- package/dist/react/internal.d.ts.map +1 -0
- package/dist/react/internal.js +79 -0
- package/dist/react/internal.js.map +1 -0
- package/dist/react/jsx.d.ts +22 -0
- package/dist/react/jsx.d.ts.map +1 -0
- package/dist/react/jsx.js +134 -0
- package/dist/react/jsx.js.map +1 -0
- package/dist/react/pipeline.d.ts +13 -0
- package/dist/react/pipeline.d.ts.map +1 -0
- package/dist/react/pipeline.js +25 -0
- package/dist/react/pipeline.js.map +1 -0
- package/dist/react/props.d.ts +38 -0
- package/dist/react/props.d.ts.map +1 -0
- package/dist/react/props.js +231 -0
- package/dist/react/props.js.map +1 -0
- package/dist/react/slot-props.d.ts +10 -0
- package/dist/react/slot-props.d.ts.map +1 -0
- package/dist/react/slot-props.js +56 -0
- package/dist/react/slot-props.js.map +1 -0
- package/dist/react/widgets.d.ts +83 -0
- package/dist/react/widgets.d.ts.map +1 -0
- package/dist/react/widgets.js +152 -0
- package/dist/react/widgets.js.map +1 -0
- package/dist/runner.d.ts +55 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +60 -0
- package/dist/runner.js.map +1 -0
- package/dist/store-fs.d.ts +109 -0
- package/dist/store-fs.d.ts.map +1 -0
- package/dist/store-fs.js +98 -0
- package/dist/store-fs.js.map +1 -0
- package/dist/transpile.d.ts +32 -0
- package/dist/transpile.d.ts.map +1 -0
- package/dist/transpile.js +63 -0
- package/dist/transpile.js.map +1 -0
- package/dist/typecheck-store.d.ts +41 -0
- package/dist/typecheck-store.d.ts.map +1 -0
- package/dist/typecheck-store.js +102 -0
- package/dist/typecheck-store.js.map +1 -0
- package/dist/writers/alias.d.ts +13 -0
- package/dist/writers/alias.d.ts.map +1 -0
- package/dist/writers/alias.js +17 -0
- package/dist/writers/alias.js.map +1 -0
- package/dist/writers/async.d.ts +22 -0
- package/dist/writers/async.d.ts.map +1 -0
- package/dist/writers/async.js +48 -0
- package/dist/writers/async.js.map +1 -0
- package/dist/writers/boxed-constructor.d.ts +26 -0
- package/dist/writers/boxed-constructor.d.ts.map +1 -0
- package/dist/writers/boxed-constructor.js +85 -0
- package/dist/writers/boxed-constructor.js.map +1 -0
- package/dist/writers/boxed-field-accessor.d.ts +18 -0
- package/dist/writers/boxed-field-accessor.d.ts.map +1 -0
- package/dist/writers/boxed-field-accessor.js +260 -0
- package/dist/writers/boxed-field-accessor.js.map +1 -0
- package/dist/writers/boxed-layout.d.ts +27 -0
- package/dist/writers/boxed-layout.d.ts.map +1 -0
- package/dist/writers/boxed-layout.js +128 -0
- package/dist/writers/boxed-layout.js.map +1 -0
- package/dist/writers/boxed.d.ts +20 -0
- package/dist/writers/boxed.d.ts.map +1 -0
- package/dist/writers/boxed.js +71 -0
- package/dist/writers/boxed.js.map +1 -0
- package/dist/writers/callables.d.ts +124 -0
- package/dist/writers/callables.d.ts.map +1 -0
- package/dist/writers/callables.js +283 -0
- package/dist/writers/callables.js.map +1 -0
- package/dist/writers/callback.d.ts +16 -0
- package/dist/writers/callback.d.ts.map +1 -0
- package/dist/writers/callback.js +38 -0
- package/dist/writers/callback.js.map +1 -0
- package/dist/writers/class-struct-record.d.ts +31 -0
- package/dist/writers/class-struct-record.d.ts.map +1 -0
- package/dist/writers/class-struct-record.js +67 -0
- package/dist/writers/class-struct-record.js.map +1 -0
- package/dist/writers/class-struct.d.ts +22 -0
- package/dist/writers/class-struct.d.ts.map +1 -0
- package/dist/writers/class-struct.js +85 -0
- package/dist/writers/class-struct.js.map +1 -0
- package/dist/writers/class.d.ts +16 -0
- package/dist/writers/class.d.ts.map +1 -0
- package/dist/writers/class.js +307 -0
- package/dist/writers/class.js.map +1 -0
- package/dist/writers/constant.d.ts +15 -0
- package/dist/writers/constant.d.ts.map +1 -0
- package/dist/writers/constant.js +23 -0
- package/dist/writers/constant.js.map +1 -0
- package/dist/writers/constants.d.ts +15 -0
- package/dist/writers/constants.d.ts.map +1 -0
- package/dist/writers/constants.js +23 -0
- package/dist/writers/constants.js.map +1 -0
- package/dist/writers/constructor-props.d.ts +32 -0
- package/dist/writers/constructor-props.d.ts.map +1 -0
- package/dist/writers/constructor-props.js +110 -0
- package/dist/writers/constructor-props.js.map +1 -0
- package/dist/writers/enum.d.ts +21 -0
- package/dist/writers/enum.d.ts.map +1 -0
- package/dist/writers/enum.js +48 -0
- package/dist/writers/enum.js.map +1 -0
- package/dist/writers/function.d.ts +40 -0
- package/dist/writers/function.d.ts.map +1 -0
- package/dist/writers/function.js +127 -0
- package/dist/writers/function.js.map +1 -0
- package/dist/writers/gtype-binding.d.ts +19 -0
- package/dist/writers/gtype-binding.d.ts.map +1 -0
- package/dist/writers/gtype-binding.js +40 -0
- package/dist/writers/gtype-binding.js.map +1 -0
- package/dist/writers/inheritance.d.ts +48 -0
- package/dist/writers/inheritance.d.ts.map +1 -0
- package/dist/writers/inheritance.js +90 -0
- package/dist/writers/inheritance.js.map +1 -0
- package/dist/writers/interface.d.ts +16 -0
- package/dist/writers/interface.d.ts.map +1 -0
- package/dist/writers/interface.js +155 -0
- package/dist/writers/interface.js.map +1 -0
- package/dist/writers/method.d.ts +150 -0
- package/dist/writers/method.d.ts.map +1 -0
- package/dist/writers/method.js +510 -0
- package/dist/writers/method.js.map +1 -0
- package/dist/writers/param-classify.d.ts +93 -0
- package/dist/writers/param-classify.d.ts.map +1 -0
- package/dist/writers/param-classify.js +163 -0
- package/dist/writers/param-classify.js.map +1 -0
- package/dist/writers/property-accessor.d.ts +19 -0
- package/dist/writers/property-accessor.d.ts.map +1 -0
- package/dist/writers/property-accessor.js +117 -0
- package/dist/writers/property-accessor.js.map +1 -0
- package/dist/writers/registration.d.ts +27 -0
- package/dist/writers/registration.d.ts.map +1 -0
- package/dist/writers/registration.js +30 -0
- package/dist/writers/registration.js.map +1 -0
- package/dist/writers/return-wrap.d.ts +39 -0
- package/dist/writers/return-wrap.d.ts.map +1 -0
- package/dist/writers/return-wrap.js +152 -0
- package/dist/writers/return-wrap.js.map +1 -0
- package/dist/writers/runtime-override.d.ts +18 -0
- package/dist/writers/runtime-override.d.ts.map +1 -0
- package/dist/writers/runtime-override.js +44 -0
- package/dist/writers/runtime-override.js.map +1 -0
- package/dist/writers/signal.d.ts +21 -0
- package/dist/writers/signal.d.ts.map +1 -0
- package/dist/writers/signal.js +260 -0
- package/dist/writers/signal.js.map +1 -0
- package/dist/writers/ts-type.d.ts +50 -0
- package/dist/writers/ts-type.d.ts.map +1 -0
- package/dist/writers/ts-type.js +75 -0
- package/dist/writers/ts-type.js.map +1 -0
- package/dist/writers/types-ts.d.ts +27 -0
- package/dist/writers/types-ts.d.ts.map +1 -0
- package/dist/writers/types-ts.js +97 -0
- package/dist/writers/types-ts.js.map +1 -0
- package/dist/writers/value.d.ts +89 -0
- package/dist/writers/value.d.ts.map +1 -0
- package/dist/writers/value.js +402 -0
- package/dist/writers/value.js.map +1 -0
- package/package.json +55 -0
- package/src/dsl/context.ts +146 -0
- package/src/dsl/emit.ts +42 -0
- package/src/dsl/identifier.ts +52 -0
- package/src/dsl/imports.ts +109 -0
- package/src/dsl/module.ts +75 -0
- package/src/ffi/pipeline.ts +113 -0
- package/src/fingerprint.ts +50 -0
- package/src/gi-store.ts +199 -0
- package/src/gir/boxed.ts +94 -0
- package/src/gir/callback.ts +26 -0
- package/src/gir/class.ts +79 -0
- package/src/gir/enum.ts +55 -0
- package/src/gir/field.ts +40 -0
- package/src/gir/function.ts +67 -0
- package/src/gir/namespace.ts +118 -0
- package/src/gir/parameter.ts +120 -0
- package/src/gir/parse.ts +171 -0
- package/src/gir/primitives.ts +137 -0
- package/src/gir/property.ts +39 -0
- package/src/gir/qualified-name.ts +55 -0
- package/src/gir/qualify.ts +64 -0
- package/src/gir/repository.ts +149 -0
- package/src/gir/signal.ts +36 -0
- package/src/gir/size.ts +129 -0
- package/src/gir/type-ref.ts +180 -0
- package/src/index.ts +16 -0
- package/src/jsx-store.ts +53 -0
- package/src/react/compounds-meta.ts +99 -0
- package/src/react/compounds.ts +204 -0
- package/src/react/internal.ts +91 -0
- package/src/react/jsx.ts +155 -0
- package/src/react/pipeline.ts +29 -0
- package/src/react/props.ts +307 -0
- package/src/react/slot-props.ts +57 -0
- package/src/react/widgets.ts +185 -0
- package/src/runner.ts +89 -0
- package/src/store-fs.ts +157 -0
- package/src/transpile.ts +80 -0
- package/src/typecheck-store.ts +136 -0
- package/src/writers/alias.ts +19 -0
- package/src/writers/async.ts +44 -0
- package/src/writers/boxed-constructor.ts +105 -0
- package/src/writers/boxed-field-accessor.ts +306 -0
- package/src/writers/boxed-layout.ts +166 -0
- package/src/writers/boxed.ts +77 -0
- package/src/writers/callables.ts +339 -0
- package/src/writers/callback.ts +40 -0
- package/src/writers/class-struct-record.ts +75 -0
- package/src/writers/class-struct.ts +96 -0
- package/src/writers/class.ts +384 -0
- package/src/writers/constant.ts +29 -0
- package/src/writers/constructor-props.ts +130 -0
- package/src/writers/enum.ts +53 -0
- package/src/writers/function.ts +136 -0
- package/src/writers/gtype-binding.ts +48 -0
- package/src/writers/inheritance.ts +104 -0
- package/src/writers/interface.ts +168 -0
- package/src/writers/method.ts +678 -0
- package/src/writers/param-classify.ts +178 -0
- package/src/writers/property-accessor.ts +139 -0
- package/src/writers/registration.ts +42 -0
- package/src/writers/return-wrap.ts +180 -0
- package/src/writers/runtime-override.ts +59 -0
- package/src/writers/signal.ts +318 -0
- package/src/writers/ts-type.ts +115 -0
- package/src/writers/value.ts +485 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parameterFromNode, returnValueFromNode } from "./parameter.js";
|
|
2
|
+
import { attr, attrBool, childOf, childrenOf } from "./parse.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a {@link GirSignal} from a `<glib:signal>` element.
|
|
5
|
+
*/
|
|
6
|
+
export const signalFromNode = (node) => {
|
|
7
|
+
const parametersNode = childOf(node, "parameters");
|
|
8
|
+
const parameterNodes = childrenOf(parametersNode, "parameter");
|
|
9
|
+
return {
|
|
10
|
+
name: attr(node, "name") ?? "",
|
|
11
|
+
parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, false)),
|
|
12
|
+
returnValue: returnValueFromNode(childOf(node, "return-value")),
|
|
13
|
+
when: (attr(node, "when") ?? "last"),
|
|
14
|
+
detailed: attrBool(node, "detailed"),
|
|
15
|
+
action: attrBool(node, "action"),
|
|
16
|
+
noRecurse: attrBool(node, "no-recurse"),
|
|
17
|
+
noHooks: attrBool(node, "no-hooks"),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/gir/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAkB/E;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAa,EAAa,EAAE;IACvD,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC/D,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;QAC9B,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAClF,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC/D,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAe;QAClD,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QAChC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;QACvC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;KACtC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type PrimitiveCategory } from "./primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* Size and alignment of a single field as it appears in a C struct laid out
|
|
4
|
+
* according to the x86-64 ABI.
|
|
5
|
+
*/
|
|
6
|
+
export type FieldLayout = {
|
|
7
|
+
/** Width of the field in bytes. */
|
|
8
|
+
readonly size: number;
|
|
9
|
+
/** Required alignment in bytes; storage offset rounds up to a multiple of this. */
|
|
10
|
+
readonly align: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns the `{ size, align }` pair for a primitive category.
|
|
14
|
+
*
|
|
15
|
+
* Pointers and pointer-sized integers (the `pointer` and 64-bit categories)
|
|
16
|
+
* report 8/8. Smaller integers and floats report their natural width.
|
|
17
|
+
*
|
|
18
|
+
* @param category - The primitive category
|
|
19
|
+
*/
|
|
20
|
+
export declare const layoutOfPrimitive: (category: PrimitiveCategory) => FieldLayout;
|
|
21
|
+
/**
|
|
22
|
+
* Layout slot for a single field that may participate in bitfield packing.
|
|
23
|
+
*
|
|
24
|
+
* `byteOffset` is always the offset of the underlying storage word; for
|
|
25
|
+
* non-bitfield fields it is the field's offset directly, and for bitfield
|
|
26
|
+
* members it is the start of the shared storage unit. `bitOffset` and
|
|
27
|
+
* `bitWidth` are populated only for bitfield members.
|
|
28
|
+
*/
|
|
29
|
+
export type FieldSlot = {
|
|
30
|
+
/** Byte offset of the storage word the field occupies. */
|
|
31
|
+
readonly byteOffset: number;
|
|
32
|
+
/** Bit position within the storage word, for bitfield members. */
|
|
33
|
+
readonly bitOffset: number | undefined;
|
|
34
|
+
/** Width in bits, for bitfield members. */
|
|
35
|
+
readonly bitWidth: number | undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Describes a field for the purposes of layout computation.
|
|
39
|
+
*/
|
|
40
|
+
export type FieldLayoutInput = {
|
|
41
|
+
/** Natural byte size and alignment of the field's value type. */
|
|
42
|
+
readonly layout: FieldLayout;
|
|
43
|
+
/** When set, the field is a bitfield member with this many bits. */
|
|
44
|
+
readonly bits: number | undefined;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Computes per-field byte offsets for a record, grouping consecutive
|
|
48
|
+
* bitfield members of compatible storage widths into a shared storage
|
|
49
|
+
* word.
|
|
50
|
+
*
|
|
51
|
+
* Mirrors the GCC/Itanium ABI rules for C bitfield packing in a
|
|
52
|
+
* single-storage-word model: a new storage word is opened when the
|
|
53
|
+
* underlying type's size changes, when the new field is not a bitfield,
|
|
54
|
+
* or when adding the bits would exceed the word's bit count.
|
|
55
|
+
*
|
|
56
|
+
* A union (`isUnion`) overlays every member at byte offset 0; its size is the
|
|
57
|
+
* largest member rounded up to the strongest member alignment.
|
|
58
|
+
*
|
|
59
|
+
* @param fields - Ordered field layouts and bit widths
|
|
60
|
+
* @param isUnion - Whether the fields are union members (overlaid at offset 0)
|
|
61
|
+
* @returns Parallel slot array and the total record size in bytes
|
|
62
|
+
*/
|
|
63
|
+
export declare const computeFieldSlots: (fields: readonly FieldLayoutInput[], isUnion?: boolean) => {
|
|
64
|
+
readonly slots: readonly FieldSlot[];
|
|
65
|
+
readonly size: number;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/gir/size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,iBAAiB,KAAG,WAG/D,CAAC;AAQF;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,GAC1B,QAAQ,SAAS,gBAAgB,EAAE,EACnC,iBAAe,KAChB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAiD/D,CAAC"}
|
package/dist/gir/size.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PRIMITIVE_SIZE } from "./primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the `{ size, align }` pair for a primitive category.
|
|
4
|
+
*
|
|
5
|
+
* Pointers and pointer-sized integers (the `pointer` and 64-bit categories)
|
|
6
|
+
* report 8/8. Smaller integers and floats report their natural width.
|
|
7
|
+
*
|
|
8
|
+
* @param category - The primitive category
|
|
9
|
+
*/
|
|
10
|
+
export const layoutOfPrimitive = (category) => {
|
|
11
|
+
const size = PRIMITIVE_SIZE[category];
|
|
12
|
+
return { size, align: size === 0 ? 1 : size };
|
|
13
|
+
};
|
|
14
|
+
const roundUp = (value, multiple) => {
|
|
15
|
+
if (multiple <= 1)
|
|
16
|
+
return value;
|
|
17
|
+
const remainder = value % multiple;
|
|
18
|
+
return remainder === 0 ? value : value + (multiple - remainder);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Computes per-field byte offsets for a record, grouping consecutive
|
|
22
|
+
* bitfield members of compatible storage widths into a shared storage
|
|
23
|
+
* word.
|
|
24
|
+
*
|
|
25
|
+
* Mirrors the GCC/Itanium ABI rules for C bitfield packing in a
|
|
26
|
+
* single-storage-word model: a new storage word is opened when the
|
|
27
|
+
* underlying type's size changes, when the new field is not a bitfield,
|
|
28
|
+
* or when adding the bits would exceed the word's bit count.
|
|
29
|
+
*
|
|
30
|
+
* A union (`isUnion`) overlays every member at byte offset 0; its size is the
|
|
31
|
+
* largest member rounded up to the strongest member alignment.
|
|
32
|
+
*
|
|
33
|
+
* @param fields - Ordered field layouts and bit widths
|
|
34
|
+
* @param isUnion - Whether the fields are union members (overlaid at offset 0)
|
|
35
|
+
* @returns Parallel slot array and the total record size in bytes
|
|
36
|
+
*/
|
|
37
|
+
export const computeFieldSlots = (fields, isUnion = false) => {
|
|
38
|
+
if (isUnion) {
|
|
39
|
+
let maxSize = 0;
|
|
40
|
+
let maxAlign = 1;
|
|
41
|
+
const unionSlots = fields.map((field) => {
|
|
42
|
+
maxSize = Math.max(maxSize, field.layout.size);
|
|
43
|
+
maxAlign = Math.max(maxAlign, field.layout.align);
|
|
44
|
+
return { byteOffset: 0, bitOffset: field.bits === undefined ? undefined : 0, bitWidth: field.bits };
|
|
45
|
+
});
|
|
46
|
+
return { slots: unionSlots, size: roundUp(maxSize, maxAlign) };
|
|
47
|
+
}
|
|
48
|
+
const slots = [];
|
|
49
|
+
let cursor = 0;
|
|
50
|
+
let maxAlign = 1;
|
|
51
|
+
let bitfieldWordOffset;
|
|
52
|
+
let bitfieldWordSize = 0;
|
|
53
|
+
let bitfieldUsedBits = 0;
|
|
54
|
+
for (const field of fields) {
|
|
55
|
+
const align = Math.max(1, field.layout.align);
|
|
56
|
+
if (align > maxAlign)
|
|
57
|
+
maxAlign = align;
|
|
58
|
+
if (field.bits === undefined) {
|
|
59
|
+
bitfieldWordOffset = undefined;
|
|
60
|
+
bitfieldWordSize = 0;
|
|
61
|
+
bitfieldUsedBits = 0;
|
|
62
|
+
cursor = roundUp(cursor, align);
|
|
63
|
+
slots.push({ byteOffset: cursor, bitOffset: undefined, bitWidth: undefined });
|
|
64
|
+
cursor += field.layout.size;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const wordSizeBits = field.layout.size * 8;
|
|
68
|
+
const fits = bitfieldWordOffset !== undefined &&
|
|
69
|
+
bitfieldWordSize === field.layout.size &&
|
|
70
|
+
bitfieldUsedBits + field.bits <= wordSizeBits;
|
|
71
|
+
if (!fits) {
|
|
72
|
+
cursor = roundUp(cursor, align);
|
|
73
|
+
bitfieldWordOffset = cursor;
|
|
74
|
+
bitfieldWordSize = field.layout.size;
|
|
75
|
+
bitfieldUsedBits = 0;
|
|
76
|
+
cursor += field.layout.size;
|
|
77
|
+
}
|
|
78
|
+
slots.push({
|
|
79
|
+
byteOffset: bitfieldWordOffset ?? 0,
|
|
80
|
+
bitOffset: bitfieldUsedBits,
|
|
81
|
+
bitWidth: field.bits,
|
|
82
|
+
});
|
|
83
|
+
bitfieldUsedBits += field.bits;
|
|
84
|
+
}
|
|
85
|
+
return { slots, size: roundUp(cursor, maxAlign) };
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../src/gir/size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AAazE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAA2B,EAAe,EAAE;IAC1E,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE;IACxD,IAAI,QAAQ,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;AACpE,CAAC,CAAC;AA6BF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,C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|
|
2
|
+
import { type PrimitiveCategory } from "./primitives.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lazily-resolved reference to a GIR type as it appears in a `<type>` or
|
|
5
|
+
* `<array>` slot.
|
|
6
|
+
*
|
|
7
|
+
* The reference captures everything the writers need at emission time
|
|
8
|
+
* without forcing entity resolution to happen at parse time (which would
|
|
9
|
+
* impose a topological-sort order on namespace loading). Resolution into a
|
|
10
|
+
* concrete `GirClass` / `GirBoxed` / `GirEnum` / … is performed on demand
|
|
11
|
+
* by the writers via `GirRepository.resolveNamed`.
|
|
12
|
+
*/
|
|
13
|
+
export type GirTypeRef = PrimitiveTypeRef | NamedTypeRef | ArrayTypeRef | ListTypeRef | HashTableTypeRef | InlineCallbackTypeRef | VarargsTypeRef;
|
|
14
|
+
/** A GIR scalar primitive: `gint`, `gboolean`, `utf8`, `gpointer`, etc. */
|
|
15
|
+
export type PrimitiveTypeRef = {
|
|
16
|
+
readonly kind: "primitive";
|
|
17
|
+
readonly category: PrimitiveCategory;
|
|
18
|
+
readonly cType: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A named type that resolves to a class, interface, boxed, enum, alias, or
|
|
22
|
+
* fundamental in some namespace.
|
|
23
|
+
*
|
|
24
|
+
* `namespaceName` is the namespace prefix from the GIR (`"GLib"`, `"Gtk"`,
|
|
25
|
+
* …) or `undefined` for an unqualified reference. The unqualified form
|
|
26
|
+
* implies "look in the namespace the reference appears in".
|
|
27
|
+
*/
|
|
28
|
+
export type NamedTypeRef = {
|
|
29
|
+
readonly kind: "named";
|
|
30
|
+
readonly namespaceName: string | undefined;
|
|
31
|
+
readonly typeName: string;
|
|
32
|
+
readonly cType: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
/** A C array (`<array>`) with optional length, fixed-size, or zero-terminated metadata. */
|
|
35
|
+
export type ArrayTypeRef = {
|
|
36
|
+
readonly kind: "array";
|
|
37
|
+
readonly element: GirTypeRef;
|
|
38
|
+
readonly cType: string | undefined;
|
|
39
|
+
readonly lengthParameterIndex: number | undefined;
|
|
40
|
+
readonly fixedSize: number | undefined;
|
|
41
|
+
readonly zeroTerminated: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** A GLib `GList` / `GSList` / `GPtrArray` / `GArray` / `GByteArray`. */
|
|
44
|
+
export type ListTypeRef = {
|
|
45
|
+
readonly kind: "list";
|
|
46
|
+
readonly flavor: "glist" | "gslist" | "gptrarray" | "garray" | "gbytearray";
|
|
47
|
+
readonly element: GirTypeRef;
|
|
48
|
+
readonly cType: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
/** A GLib `GHashTable` with key and value element types. */
|
|
51
|
+
export type HashTableTypeRef = {
|
|
52
|
+
readonly kind: "hashtable";
|
|
53
|
+
readonly key: GirTypeRef;
|
|
54
|
+
readonly value: GirTypeRef;
|
|
55
|
+
readonly cType: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
/** An inline `<callback>` (used for vtable slots and callback parameters). */
|
|
58
|
+
type InlineCallbackTypeRef = {
|
|
59
|
+
readonly kind: "callback";
|
|
60
|
+
readonly callback: RawNode;
|
|
61
|
+
};
|
|
62
|
+
/** A `<varargs/>` parameter placeholder; not marshalable. */
|
|
63
|
+
type VarargsTypeRef = {
|
|
64
|
+
readonly kind: "varargs";
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Builds a {@link GirTypeRef} from a parent XML node whose first `<type>`,
|
|
68
|
+
* `<array>`, or `<varargs>` child describes the slot.
|
|
69
|
+
*
|
|
70
|
+
* Pass the parent (`<parameter>`, `<return-value>`, `<field>`, `<property>`,
|
|
71
|
+
* `<constant>`, `<alias>`). The helper extracts the right child and routes
|
|
72
|
+
* to {@link typeRefFromTypeNode}.
|
|
73
|
+
*
|
|
74
|
+
* @param parent - The element whose typed slot we are inspecting
|
|
75
|
+
* @returns The reference, or `undefined` if no type slot exists
|
|
76
|
+
*/
|
|
77
|
+
export declare const typeRefFromSlot: (parent: RawNode | undefined) => GirTypeRef | und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AO,CAAC;CACpC,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,8EAA8E;AAC9E,KAAK,qBAAqB,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,6DAA6D;AAC7D,KAAK,cAAc,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAUnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,OAAO,GAAG,SAAS,KAAG,UAAU,GAAG,SAU1E,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { attr, attrBool, childOf, childrenOf } from "./parse.js";
|
|
2
|
+
import { primitiveCategory } from "./primitives.js";
|
|
3
|
+
const LIST_KIND_BY_NAME = new Map([
|
|
4
|
+
["GLib.List", "glist"],
|
|
5
|
+
["GLib.SList", "gslist"],
|
|
6
|
+
["GLib.PtrArray", "gptrarray"],
|
|
7
|
+
["GLib.Array", "garray"],
|
|
8
|
+
["GLib.ByteArray", "gbytearray"],
|
|
9
|
+
]);
|
|
10
|
+
/**
|
|
11
|
+
* Builds a {@link GirTypeRef} from a parent XML node whose first `<type>`,
|
|
12
|
+
* `<array>`, or `<varargs>` child describes the slot.
|
|
13
|
+
*
|
|
14
|
+
* Pass the parent (`<parameter>`, `<return-value>`, `<field>`, `<property>`,
|
|
15
|
+
* `<constant>`, `<alias>`). The helper extracts the right child and routes
|
|
16
|
+
* to {@link typeRefFromTypeNode}.
|
|
17
|
+
*
|
|
18
|
+
* @param parent - The element whose typed slot we are inspecting
|
|
19
|
+
* @returns The reference, or `undefined` if no type slot exists
|
|
20
|
+
*/
|
|
21
|
+
export const typeRefFromSlot = (parent) => {
|
|
22
|
+
if (parent === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (childOf(parent, "varargs") !== undefined)
|
|
25
|
+
return { kind: "varargs" };
|
|
26
|
+
const arrayNode = childOf(parent, "array");
|
|
27
|
+
if (arrayNode !== undefined)
|
|
28
|
+
return arrayTypeRefFromNode(arrayNode);
|
|
29
|
+
const typeNode = childOf(parent, "type");
|
|
30
|
+
if (typeNode !== undefined)
|
|
31
|
+
return typeRefFromTypeNode(typeNode);
|
|
32
|
+
const callback = childOf(parent, "callback");
|
|
33
|
+
if (callback !== undefined)
|
|
34
|
+
return { kind: "callback", callback };
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Builds a {@link GirTypeRef} from a `<type>` element.
|
|
39
|
+
*
|
|
40
|
+
* Splits a `Namespace.TypeName` form into namespace + type, recognises GLib
|
|
41
|
+
* container types (`GLib.List`, `GLib.HashTable`, …) by name and routes
|
|
42
|
+
* them to the dedicated branches, otherwise produces a primitive or named
|
|
43
|
+
* reference for later resolution.
|
|
44
|
+
*
|
|
45
|
+
* @param typeNode - A `<type>` element
|
|
46
|
+
*/
|
|
47
|
+
const typeRefFromTypeNode = (typeNode) => {
|
|
48
|
+
const name = attr(typeNode, "name") ?? "";
|
|
49
|
+
const cType = attr(typeNode, "c:type");
|
|
50
|
+
const listFlavor = LIST_KIND_BY_NAME.get(name);
|
|
51
|
+
if (listFlavor !== undefined) {
|
|
52
|
+
const elementNode = childOf(typeNode, "type");
|
|
53
|
+
const element = elementNode === undefined ? pointerFallback() : typeRefFromTypeNode(elementNode);
|
|
54
|
+
return { kind: "list", flavor: listFlavor, element, cType };
|
|
55
|
+
}
|
|
56
|
+
if (name === "GLib.HashTable") {
|
|
57
|
+
const elementTypes = childrenOf(typeNode, "type");
|
|
58
|
+
const keyNode = elementTypes[0];
|
|
59
|
+
const valueNode = elementTypes[1];
|
|
60
|
+
return {
|
|
61
|
+
kind: "hashtable",
|
|
62
|
+
key: keyNode === undefined ? pointerFallback() : typeRefFromTypeNode(keyNode),
|
|
63
|
+
value: valueNode === undefined ? pointerFallback() : typeRefFromTypeNode(valueNode),
|
|
64
|
+
cType,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const primitive = primitiveCategory(name);
|
|
68
|
+
if (primitive !== undefined) {
|
|
69
|
+
return { kind: "primitive", category: primitive, cType };
|
|
70
|
+
}
|
|
71
|
+
const [namespaceName, typeName] = splitOptionalNamespace(name);
|
|
72
|
+
return { kind: "named", namespaceName, typeName, cType };
|
|
73
|
+
};
|
|
74
|
+
const arrayTypeRefFromNode = (arrayNode) => {
|
|
75
|
+
const elementNode = childOf(arrayNode, "type");
|
|
76
|
+
const element = elementNode === undefined ? pointerFallback() : typeRefFromTypeNode(elementNode);
|
|
77
|
+
const cType = attr(arrayNode, "c:type");
|
|
78
|
+
const arrayName = attr(arrayNode, "name");
|
|
79
|
+
const listFlavor = arrayName === undefined ? undefined : LIST_KIND_BY_NAME.get(arrayName);
|
|
80
|
+
if (listFlavor !== undefined) {
|
|
81
|
+
return { kind: "list", flavor: listFlavor, element, cType };
|
|
82
|
+
}
|
|
83
|
+
const lengthAttr = attr(arrayNode, "length");
|
|
84
|
+
const fixedSizeAttr = attr(arrayNode, "fixed-size");
|
|
85
|
+
return {
|
|
86
|
+
kind: "array",
|
|
87
|
+
element,
|
|
88
|
+
cType,
|
|
89
|
+
lengthParameterIndex: lengthAttr === undefined ? undefined : Number.parseInt(lengthAttr, 10),
|
|
90
|
+
fixedSize: fixedSizeAttr === undefined ? undefined : Number.parseInt(fixedSizeAttr, 10),
|
|
91
|
+
zeroTerminated: attrBool(arrayNode, "zero-terminated", false),
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const pointerFallback = () => ({ kind: "primitive", category: "pointer", cType: undefined });
|
|
95
|
+
const splitOptionalNamespace = (name) => {
|
|
96
|
+
const dot = name.indexOf(".");
|
|
97
|
+
if (dot === -1)
|
|
98
|
+
return [undefined, name];
|
|
99
|
+
return [name.slice(0, dot), name.slice(dot + 1)];
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=type-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-ref.js","sourceRoot":"","sources":["../../src/gir/type-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAC/E,OAAO,EAA0B,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA8E5E,MAAM,iBAAiB,GAAoF,IAAI,GAAG,CAAC;IAC/G,CAAC,WAAW,EAAE,OAAO,CAAC;IACtB,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,eAAe,EAAE,WAAW,CAAC;IAC9B,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAC1B,CAAC,CAAC;AAEZ;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAA2B,EAA0B,EAAE;IACnF,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,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GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API of `@gtkx/codegen`.
|
|
3
|
+
*
|
|
4
|
+
* The package exposes a single entry point — {@link CodegenRunner} — that
|
|
5
|
+
* orchestrates the GIR-driven code generation for the FFI and React
|
|
6
|
+
* surfaces. Internal modules (`gir/`, `dsl/`, `writers/`, `ffi/`,
|
|
7
|
+
* `react/`) are not part of the supported surface and may change in any
|
|
8
|
+
* release.
|
|
9
|
+
*/
|
|
10
|
+
export { CODEGEN_VERSION, type CodegenFingerprint, computeFingerprint, FINGERPRINT_FILENAME, } from "./fingerprint.js";
|
|
11
|
+
export { CodegenRunner } from "./runner.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACH,eAAe,EACf,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API of `@gtkx/codegen`.
|
|
3
|
+
*
|
|
4
|
+
* The package exposes a single entry point — {@link CodegenRunner} — that
|
|
5
|
+
* orchestrates the GIR-driven code generation for the FFI and React
|
|
6
|
+
* surfaces. Internal modules (`gir/`, `dsl/`, `writers/`, `ffi/`,
|
|
7
|
+
* `react/`) are not part of the supported surface and may change in any
|
|
8
|
+
* release.
|
|
9
|
+
*/
|
|
10
|
+
export { CODEGEN_VERSION, computeFingerprint, FINGERPRINT_FILENAME, } from "./fingerprint.js";
|
|
11
|
+
export { CodegenRunner } from "./runner.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACH,eAAe,EAEf,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StoreOptions } from "./store-fs.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for assembling the injected `@gtkx/react-jsx` unit.
|
|
4
|
+
*/
|
|
5
|
+
export type JsxStoreOptions = StoreOptions & {
|
|
6
|
+
/** Absolute path to the gi store, for the unit's own `node_modules/@gtkx/gi`. */
|
|
7
|
+
readonly giStoreDir: string;
|
|
8
|
+
/** Real (symlink-resolved) directory of the installed `react` runtime. */
|
|
9
|
+
readonly realReactRuntimeDir: string;
|
|
10
|
+
/** Real (symlink-resolved) directory of the installed `@gtkx/react`. */
|
|
11
|
+
readonly realReactPackageDir: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Assembles the self-contained injected `@gtkx/react-jsx` unit: the generated
|
|
15
|
+
* `jsx`/`internal`/`compounds` modules plus a `package.json` and the unit's own
|
|
16
|
+
* `node_modules` symlinks to `@gtkx/gi` and `react`.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Resolved store/link/dependency paths
|
|
19
|
+
* @param files - React pipeline output keyed by source filename
|
|
20
|
+
*/
|
|
21
|
+
export declare const writeJsxStore: (options: JsxStoreOptions, files: ReadonlyMap<string, string>) => void;
|
|
22
|
+
//# sourceMappingURL=jsx-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-store.d.ts","sourceRoot":"","sources":["../src/jsx-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,eAAe,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IACzC,iFAAiF;IACjF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,wEAAwE;IACxE,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACxC,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,eAAe,EAAE,OAAO,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,IA4B5F,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { writeStore } from "./store-fs.js";
|
|
2
|
+
const stem = (relativePath) => relativePath.replace(/\.(tsx|ts)$/, "");
|
|
3
|
+
/**
|
|
4
|
+
* Assembles the self-contained injected `@gtkx/react-jsx` unit: the generated
|
|
5
|
+
* `jsx`/`internal`/`compounds` modules plus a `package.json` and the unit's own
|
|
6
|
+
* `node_modules` symlinks to `@gtkx/gi` and `react`.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Resolved store/link/dependency paths
|
|
9
|
+
* @param files - React pipeline output keyed by source filename
|
|
10
|
+
*/
|
|
11
|
+
export const writeJsxStore = (options, files) => {
|
|
12
|
+
writeStore({
|
|
13
|
+
storeDir: options.storeDir,
|
|
14
|
+
linkDir: options.linkDir,
|
|
15
|
+
files: [...files].map(([relativePath, source]) => ({
|
|
16
|
+
stem: stem(relativePath),
|
|
17
|
+
fileName: relativePath,
|
|
18
|
+
source,
|
|
19
|
+
})),
|
|
20
|
+
manifest: {
|
|
21
|
+
name: "@gtkx/react-jsx",
|
|
22
|
+
type: "module",
|
|
23
|
+
version: options.version,
|
|
24
|
+
sideEffects: ["./internal.js"],
|
|
25
|
+
exports: {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": { types: "./jsx.d.ts", default: "./jsx.js" },
|
|
28
|
+
"./jsx": { types: "./jsx.d.ts", default: "./jsx.js" },
|
|
29
|
+
"./compounds": { types: "./compounds.d.ts", default: "./compounds.js" },
|
|
30
|
+
"./internal": { types: "./internal.d.ts", default: "./internal.js" },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
symlinks: [
|
|
34
|
+
{ segments: ["node_modules", "@gtkx", "gi"], target: options.giStoreDir },
|
|
35
|
+
{ segments: ["node_modules", "@gtkx", "react"], target: options.realReactPackageDir },
|
|
36
|
+
{ segments: ["node_modules", "react"], target: options.realReactRuntimeDir },
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=jsx-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-store.js","sourceRoot":"","sources":["../src/jsx-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAE,MAAM,eAAe,CAAC;AAc9D,MAAM,IAAI,GAAG,CAAC,YAAoB,EAAU,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAEvF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAE,KAAkC,EAAQ,EAAE;IAChG,UAAU,CAAC;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC;YACxB,QAAQ,EAAE,YAAY;YACtB,MAAM;SACT,CAAC,CAAC;QACH,QAAQ,EAAE;YACN,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,CAAC,eAAe,CAAC;YAC9B,OAAO,EAAE;gBACL,gBAAgB,EAAE,gBAAgB;gBAClC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE;gBACjD,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE;gBACrD,aAAa,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,gBAAgB,EAAE;gBACvE,YAAY,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE;aACvE;SACJ;QACD,QAAQ,EAAE;YACN,EAAE,QAAQ,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;YACzE,EAAE,QAAQ,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,EAAE;YACrF,EAAE,QAAQ,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,EAAE;SAC/E;KACJ,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the container-slot method names for a JSX element name, or an
|
|
3
|
+
* empty array if no container slots exist.
|
|
4
|
+
*
|
|
5
|
+
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
6
|
+
*/
|
|
7
|
+
export declare const containerSlotsFor: (jsxName: string) => readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* Returns the virtual-subcomponent record for a JSX element name, or an
|
|
10
|
+
* empty array if no virtual subcomponents exist.
|
|
11
|
+
*
|
|
12
|
+
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
13
|
+
*/
|
|
14
|
+
export declare const virtualSubcomponentsFor: (jsxName: string) => ReadonlyArray<{
|
|
15
|
+
readonly child: string;
|
|
16
|
+
readonly intrinsic: string;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=compounds-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compounds-meta.d.ts","sourceRoot":"","sources":["../../src/react/compounds-meta.ts"],"names":[],"mappings":"AAyBA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,SAAS,MAAM,EAAoC,CAAC;AA2DxG;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAChC,SAAS,MAAM,KAChB,aAAa,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAyC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container-slot mapping for compound widgets — JSX element name to the
|
|
3
|
+
* camelCase GTK method names that append a child onto the widget.
|
|
4
|
+
*
|
|
5
|
+
* Each method name doubles as a `ReactNode` prop on the compound and as the
|
|
6
|
+
* `<ContainerSlot id="…">` identifier the reconciler dispatches to. For
|
|
7
|
+
* example `packStart` on `AdwHeaderBar` maps to `adw_header_bar_pack_start(…)`;
|
|
8
|
+
* `<AdwHeaderBar packStart={…} />` packs the value at the start.
|
|
9
|
+
*
|
|
10
|
+
* Unlike setter slots ({@link BUILT_IN_SLOT_PROPS}), a container slot accepts
|
|
11
|
+
* multiple children and appends rather than replaces.
|
|
12
|
+
*
|
|
13
|
+
* The list is small and stable; defining it in code keeps the lookup
|
|
14
|
+
* fast and avoids one more GIR-introspection pass.
|
|
15
|
+
*/
|
|
16
|
+
const CONTAINER_SLOTS = Object.freeze({
|
|
17
|
+
AdwActionRow: ["addPrefix", "addSuffix"],
|
|
18
|
+
AdwEntryRow: ["addPrefix", "addSuffix"],
|
|
19
|
+
AdwExpanderRow: ["addPrefix", "addSuffix", "addRow", "addAction"],
|
|
20
|
+
AdwHeaderBar: ["packStart", "packEnd"],
|
|
21
|
+
AdwToolbarView: ["addTopBar", "addBottomBar"],
|
|
22
|
+
GtkActionBar: ["packStart", "packEnd"],
|
|
23
|
+
GtkHeaderBar: ["packStart", "packEnd"],
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Returns the container-slot method names for a JSX element name, or an
|
|
27
|
+
* empty array if no container slots exist.
|
|
28
|
+
*
|
|
29
|
+
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
30
|
+
*/
|
|
31
|
+
export const containerSlotsFor = (jsxName) => CONTAINER_SLOTS[jsxName] ?? [];
|
|
32
|
+
/**
|
|
33
|
+
* Virtual-child subcomponent mapping — JSX element name to the map of
|
|
34
|
+
* subcomponent property → virtual JSX intrinsic name it routes through.
|
|
35
|
+
*
|
|
36
|
+
* For example `GtkConstraintLayout.Constraint` renders the
|
|
37
|
+
* `<Constraint>` virtual intrinsic so the reconciler can attach a
|
|
38
|
+
* GtkConstraint to the layout. Unlike container slots, virtual
|
|
39
|
+
* subcomponents render an existing intrinsic element rather than
|
|
40
|
+
* invoking a setter on the parent widget.
|
|
41
|
+
*/
|
|
42
|
+
const VIRTUAL_SUBCOMPONENTS = Object.freeze({
|
|
43
|
+
GtkShortcutController: [{ child: "Shortcut", intrinsic: "Shortcut" }],
|
|
44
|
+
GtkConstraintLayout: [
|
|
45
|
+
{ child: "Constraint", intrinsic: "Constraint" },
|
|
46
|
+
{ child: "Guide", intrinsic: "ConstraintGuide" },
|
|
47
|
+
{ child: "Widget", intrinsic: "ConstraintLayoutWidget" },
|
|
48
|
+
{ child: "Vfl", intrinsic: "ConstraintVfl" },
|
|
49
|
+
],
|
|
50
|
+
GtkStack: [{ child: "Page", intrinsic: "StackPage" }],
|
|
51
|
+
AdwViewStack: [{ child: "Page", intrinsic: "StackPage" }],
|
|
52
|
+
GtkNotebook: [
|
|
53
|
+
{ child: "Page", intrinsic: "NotebookPage" },
|
|
54
|
+
{ child: "PageTab", intrinsic: "NotebookPageTab" },
|
|
55
|
+
],
|
|
56
|
+
GtkGrid: [{ child: "Child", intrinsic: "GridChild" }],
|
|
57
|
+
GtkFixed: [{ child: "Child", intrinsic: "FixedChild" }],
|
|
58
|
+
GtkOverlay: [{ child: "Child", intrinsic: "OverlayChild" }],
|
|
59
|
+
GtkColumnView: [{ child: "Column", intrinsic: "ColumnViewColumn" }],
|
|
60
|
+
GtkTextView: [
|
|
61
|
+
{ child: "Tag", intrinsic: "TextTag" },
|
|
62
|
+
{ child: "Anchor", intrinsic: "TextAnchor" },
|
|
63
|
+
{ child: "Paintable", intrinsic: "TextPaintable" },
|
|
64
|
+
],
|
|
65
|
+
GtkSourceView: [
|
|
66
|
+
{ child: "Tag", intrinsic: "TextTag" },
|
|
67
|
+
{ child: "Anchor", intrinsic: "TextAnchor" },
|
|
68
|
+
{ child: "Paintable", intrinsic: "TextPaintable" },
|
|
69
|
+
],
|
|
70
|
+
GtkMenuButton: [
|
|
71
|
+
{ child: "MenuItem", intrinsic: "MenuItem" },
|
|
72
|
+
{ child: "MenuSection", intrinsic: "MenuSection" },
|
|
73
|
+
{ child: "MenuSubmenu", intrinsic: "MenuSubmenu" },
|
|
74
|
+
],
|
|
75
|
+
GtkPopoverMenu: [
|
|
76
|
+
{ child: "Item", intrinsic: "MenuItem" },
|
|
77
|
+
{ child: "Section", intrinsic: "MenuSection" },
|
|
78
|
+
{ child: "Submenu", intrinsic: "MenuSubmenu" },
|
|
79
|
+
],
|
|
80
|
+
GtkPopoverMenuBar: [
|
|
81
|
+
{ child: "Item", intrinsic: "MenuItem" },
|
|
82
|
+
{ child: "Section", intrinsic: "MenuSection" },
|
|
83
|
+
{ child: "Submenu", intrinsic: "MenuSubmenu" },
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Returns the virtual-subcomponent record for a JSX element name, or an
|
|
88
|
+
* empty array if no virtual subcomponents exist.
|
|
89
|
+
*
|
|
90
|
+
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
91
|
+
*/
|
|
92
|
+
export const virtualSubcomponentsFor = (jsxName) => VIRTUAL_SUBCOMPONENTS[jsxName] ?? [];
|
|
93
|
+
//# sourceMappingURL=compounds-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compounds-meta.js","sourceRoot":"","sources":["../../src/react/compounds-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,eAAe,GAAgD,MAAM,CAAC,MAAM,CAAC;IAC/E,YAAY,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;IACxC,WAAW,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;IACvC,cAAc,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC;IACjE,YAAY,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;IACtC,cAAc,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;IAC7C,YAAY,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;IACtC,YAAY,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAqB,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAExG;;;;;;;;;GASG;AACH,MAAM,qBAAqB,GAEvB,MAAM,CAAC,MAAM,CAAC;IACd,qBAAqB,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IACrE,mBAAmB,EAAE;QACjB,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE;QAChD,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE;QAChD,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,wBAAwB,EAAE;QACxD,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE;KA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