@gtkx/codegen 1.2.1 → 1.3.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/README.md +2 -1
- package/dist/analysis/descriptor-render.d.ts +7 -1
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +36 -15
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +4 -1
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +11 -2
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-capability.d.ts +5 -2
- package/dist/analysis/param-capability.d.ts.map +1 -1
- package/dist/analysis/param-capability.js +36 -4
- package/dist/analysis/param-capability.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +1 -1
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +28 -10
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +6 -0
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +11 -2
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +3 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +10 -1
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/fingerprint.d.ts +5 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +107 -15
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -0
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +29 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/external-namespaces.d.ts +8 -0
- package/dist/gir/external-namespaces.d.ts.map +1 -0
- package/dist/gir/external-namespaces.js +4 -0
- package/dist/gir/external-namespaces.js.map +1 -0
- package/dist/gir/finish-overrides.d.ts +3 -0
- package/dist/gir/finish-overrides.d.ts.map +1 -0
- package/dist/gir/finish-overrides.js +5 -0
- package/dist/gir/finish-overrides.js.map +1 -0
- package/dist/gir/function.d.ts +5 -2
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +34 -5
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/hidden-symbols.d.ts +3 -0
- package/dist/gir/hidden-symbols.d.ts.map +1 -0
- package/dist/gir/hidden-symbols.js +39 -0
- package/dist/gir/hidden-symbols.js.map +1 -0
- package/dist/gir/library.d.ts +22 -2
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +21 -3
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/ucs4-overrides.d.ts +3 -0
- package/dist/gir/ucs4-overrides.d.ts.map +1 -0
- package/dist/gir/ucs4-overrides.js +7 -0
- package/dist/gir/ucs4-overrides.js.map +1 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +27 -8
- package/dist/jsx.js.map +1 -1
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +9 -3
- package/dist/runner.js.map +1 -1
- package/dist/store/external-package-links.d.ts +6 -0
- package/dist/store/external-package-links.d.ts.map +1 -0
- package/dist/store/external-package-links.js +158 -0
- package/dist/store/external-package-links.js.map +1 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -1
- package/dist/store/gi/callable-doc.js +4 -4
- package/dist/store/gi/callable-doc.js.map +1 -1
- package/dist/store/gi/callables.d.ts +1 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +4 -4
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +25 -15
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/constructor-props.js +1 -1
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +2 -1
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +2 -2
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +6 -13
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.js +2 -2
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/method.d.ts +7 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +126 -30
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +8 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +52 -4
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +2 -3
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +2 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +142 -16
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +5 -2
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +2 -1
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +9 -5
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/runtime-override.js +1 -1
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.js +2 -2
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +82 -12
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +7 -2
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +19 -4
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +3 -1
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx-store.d.ts +8 -1
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +9 -2
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +2 -1
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +2 -1
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +2 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +8 -3
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +8 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +27 -1
- package/dist/writer/gtk-doc.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +15 -1
- package/overrides/glib/index.ts.ejs +3 -0
- package/overrides/glib/regex.ts.ejs +66 -0
- package/overrides/gobject/index.ts.ejs +3 -0
- package/overrides/gobject/object-class.ts.ejs +27 -0
- package/overrides/gobject/param-spec-getters.ts.ejs +57 -0
- package/overrides/gobject/param-spec.ts.ejs +21 -0
- package/overrides/gobject/value.ts.ejs +6 -1
- package/overrides/graphene/structs.ts.ejs +38 -3
- package/overrides/gtk/index.ts.ejs +2 -0
- package/overrides/gtk/widget-class.ts.ejs +28 -0
- package/package.json +6 -5
- package/src/analysis/descriptor-render.ts +59 -16
- package/src/analysis/descriptor.ts +15 -3
- package/src/analysis/param-capability.ts +68 -5
- package/src/analysis/param-structure.ts +1 -1
- package/src/analysis/ts-type.ts +45 -11
- package/src/compile.ts +1 -1
- package/src/docs/api-reference.ts +20 -2
- package/src/docs/pipeline.ts +15 -1
- package/src/fingerprint.ts +144 -16
- package/src/gi.ts +44 -9
- package/src/gir/external-namespaces.ts +8 -0
- package/src/gir/finish-overrides.ts +5 -0
- package/src/gir/function.ts +52 -14
- package/src/gir/hidden-symbols.ts +39 -0
- package/src/gir/library.ts +36 -3
- package/src/gir/ucs4-overrides.ts +7 -0
- package/src/jsx.ts +33 -8
- package/src/runner.ts +17 -3
- package/src/store/external-package-links.ts +226 -0
- package/src/store/gi/callable-doc.ts +8 -4
- package/src/store/gi/callables.ts +5 -5
- package/src/store/gi/class.ts +42 -32
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/function.ts +2 -1
- package/src/store/gi/gtype-binding.ts +7 -15
- package/src/store/gi/interface.ts +2 -2
- package/src/store/gi/method.ts +189 -36
- package/src/store/gi/param-marshal.ts +67 -4
- package/src/store/gi/record-constructor.ts +8 -3
- package/src/store/gi/record-field-accessor.ts +209 -16
- package/src/store/gi/record-layout.ts +11 -1
- package/src/store/gi/record.ts +17 -13
- package/src/store/gi/runtime-override.ts +1 -1
- package/src/store/gi/signal.ts +2 -2
- package/src/store/gi/vtable.ts +118 -11
- package/src/store/gi-store.ts +33 -3
- package/src/store/jsx/jsx.ts +3 -1
- package/src/store/jsx-store.ts +23 -7
- package/src/store/resolve-store.ts +2 -1
- package/src/store/store-fs.ts +10 -2
- package/src/writer/context.ts +11 -0
- package/src/writer/gtk-doc.ts +38 -1
- package/overrides/cairo/context.ts.ejs +0 -1269
- package/overrides/cairo/font-face.ts.ejs +0 -151
- package/overrides/cairo/font-options.ts.ejs +0 -199
- package/overrides/cairo/image-surface.ts.ejs +0 -132
- package/overrides/cairo/index.ts.ejs +0 -22
- package/overrides/cairo/matrix.ts.ejs +0 -171
- package/overrides/cairo/pattern.ts.ejs +0 -476
- package/overrides/cairo/recording-surface.ts.ejs +0 -102
- package/overrides/cairo/region.ts.ejs +0 -237
- package/overrides/cairo/scaled-font.ts.ejs +0 -330
- package/overrides/cairo/surface.ts.ejs +0 -296
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { alloc, type ExternalObject, getHandle, type Handle, setHandle, t, wrapHandle, write } from "@gtkx/runtime";
|
|
2
|
-
import type { RegionOverlap, Status } from "../cairo.js";
|
|
3
|
-
import { RectangleInt, Region } from "../cairo.js";
|
|
4
|
-
|
|
5
|
-
const { bind } = t;
|
|
6
|
-
const REGION_T = t.boxed("CairoRegion", {
|
|
7
|
-
ownership: "borrowed",
|
|
8
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
9
|
-
getTypeFnName: "cairo_gobject_region_get_type",
|
|
10
|
-
});
|
|
11
|
-
const RECT_INT_ARRAY_T = t.boxed("cairo_rectangle_int_t[]", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" });
|
|
12
|
-
|
|
13
|
-
declare module "../cairo.js" {
|
|
14
|
-
interface Region {
|
|
15
|
-
copy(): Region;
|
|
16
|
-
status(): Status;
|
|
17
|
-
getExtents(): RectangleInt;
|
|
18
|
-
numRectangles(): number;
|
|
19
|
-
getRectangle(nth: number): RectangleInt;
|
|
20
|
-
isEmpty(): boolean;
|
|
21
|
-
containsPoint(x: number, y: number): boolean;
|
|
22
|
-
containsRectangle(rect: RectangleInt): RegionOverlap;
|
|
23
|
-
equal(other: Region): boolean;
|
|
24
|
-
translate(dx: number, dy: number): void;
|
|
25
|
-
intersect(other: Region): void;
|
|
26
|
-
intersectRectangle(rect: RectangleInt): void;
|
|
27
|
-
subtract(other: Region): void;
|
|
28
|
-
subtractRectangle(rect: RectangleInt): void;
|
|
29
|
-
union(other: Region): void;
|
|
30
|
-
unionRectangle(rect: RectangleInt): void;
|
|
31
|
-
xor(other: Region): void;
|
|
32
|
-
xorRectangle(rect: RectangleInt): void;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const cairoRegionCreate = bind(
|
|
37
|
-
"libcairo.so.2",
|
|
38
|
-
"cairo_region_create",
|
|
39
|
-
[],
|
|
40
|
-
t.boxed("CairoRegion", {
|
|
41
|
-
ownership: "full",
|
|
42
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
43
|
-
getTypeFnName: "cairo_gobject_region_get_type",
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
const cairoRegionCreateRectangle = bind(
|
|
47
|
-
"libcairo.so.2",
|
|
48
|
-
"cairo_region_create_rectangle",
|
|
49
|
-
[t.boxed("cairo_rectangle_int_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
50
|
-
t.boxed("CairoRegion", {
|
|
51
|
-
ownership: "full",
|
|
52
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
53
|
-
getTypeFnName: "cairo_gobject_region_get_type",
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
const cairoRegionCreateRectangles = bind(
|
|
57
|
-
"libcairo.so.2",
|
|
58
|
-
"cairo_region_create_rectangles",
|
|
59
|
-
[RECT_INT_ARRAY_T, t.int32],
|
|
60
|
-
t.boxed("CairoRegion", {
|
|
61
|
-
ownership: "full",
|
|
62
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
63
|
-
getTypeFnName: "cairo_gobject_region_get_type",
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
class RegionImpl extends Region {
|
|
68
|
-
constructor(rect: RectangleInt) {
|
|
69
|
-
super();
|
|
70
|
-
setHandle(this, cairoRegionCreateRectangle(getHandle(rect)) as ExternalObject<Handle>);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static empty(): Region {
|
|
74
|
-
return wrapHandle(cairoRegionCreate() as ExternalObject<Handle>, RegionImpl);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static copy(original: Region): Region {
|
|
78
|
-
return wrapHandle(cairoRegionCopy(getHandle(original)) as ExternalObject<Handle>, RegionImpl);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static forRectangle(rect: RectangleInt): Region {
|
|
82
|
-
return wrapHandle(cairoRegionCreateRectangle(getHandle(rect)) as ExternalObject<Handle>, RegionImpl);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
static createRectangles(rects: Array<{ x: number; y: number; width: number; height: number }>): Region {
|
|
86
|
-
if (rects.length === 0) {
|
|
87
|
-
return RegionImpl.empty();
|
|
88
|
-
}
|
|
89
|
-
const buf = alloc(rects.length * 16);
|
|
90
|
-
let offset = 0;
|
|
91
|
-
for (const rect of rects) {
|
|
92
|
-
write(buf, t.int32, offset, rect.x);
|
|
93
|
-
write(buf, t.int32, offset + 4, rect.y);
|
|
94
|
-
write(buf, t.int32, offset + 8, rect.width);
|
|
95
|
-
write(buf, t.int32, offset + 12, rect.height);
|
|
96
|
-
offset += 16;
|
|
97
|
-
}
|
|
98
|
-
const ptr = cairoRegionCreateRectangles(buf, rects.length) as ExternalObject<Handle>;
|
|
99
|
-
return wrapHandle(ptr, Region) as Region;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export { RegionImpl as Region };
|
|
104
|
-
|
|
105
|
-
const cairoRegionCopy = bind(
|
|
106
|
-
"libcairo.so.2",
|
|
107
|
-
"cairo_region_copy",
|
|
108
|
-
[REGION_T],
|
|
109
|
-
t.boxed("CairoRegion", {
|
|
110
|
-
ownership: "full",
|
|
111
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
112
|
-
getTypeFnName: "cairo_gobject_region_get_type",
|
|
113
|
-
}),
|
|
114
|
-
);
|
|
115
|
-
Region.prototype.copy = function (): Region {
|
|
116
|
-
return wrapHandle(cairoRegionCopy(getHandle(this)) as ExternalObject<Handle>, Region) as Region;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const cairoRegionStatus = bind("libcairo.so.2", "cairo_region_status", [REGION_T], t.int32);
|
|
120
|
-
Region.prototype.status = function (): Status {
|
|
121
|
-
return cairoRegionStatus(getHandle(this)) as Status;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const cairoRegionGetExtents = bind(
|
|
125
|
-
"libcairo.so.2",
|
|
126
|
-
"cairo_region_get_extents",
|
|
127
|
-
[REGION_T, t.boxed("cairo_rectangle_int_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
128
|
-
t.void,
|
|
129
|
-
);
|
|
130
|
-
Region.prototype.getExtents = function (): RectangleInt {
|
|
131
|
-
const rect = new RectangleInt();
|
|
132
|
-
cairoRegionGetExtents(getHandle(this), getHandle(rect));
|
|
133
|
-
return rect;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const cairoRegionNumRectangles = bind("libcairo.so.2", "cairo_region_num_rectangles", [REGION_T], t.int32);
|
|
137
|
-
Region.prototype.numRectangles = function (): number {
|
|
138
|
-
return cairoRegionNumRectangles(getHandle(this)) as number;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const cairoRegionGetRectangle = bind(
|
|
142
|
-
"libcairo.so.2",
|
|
143
|
-
"cairo_region_get_rectangle",
|
|
144
|
-
[REGION_T, t.int32, t.boxed("cairo_rectangle_int_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
145
|
-
t.void,
|
|
146
|
-
);
|
|
147
|
-
Region.prototype.getRectangle = function (nth: number): RectangleInt {
|
|
148
|
-
const rect = new RectangleInt();
|
|
149
|
-
cairoRegionGetRectangle(getHandle(this), nth, getHandle(rect));
|
|
150
|
-
return rect;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const cairoRegionIsEmpty = bind("libcairo.so.2", "cairo_region_is_empty", [REGION_T], t.boolean);
|
|
154
|
-
Region.prototype.isEmpty = function (): boolean {
|
|
155
|
-
return cairoRegionIsEmpty(getHandle(this)) as boolean;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const cairoRegionContainsPoint = bind(
|
|
159
|
-
"libcairo.so.2",
|
|
160
|
-
"cairo_region_contains_point",
|
|
161
|
-
[REGION_T, t.int32, t.int32],
|
|
162
|
-
t.boolean,
|
|
163
|
-
);
|
|
164
|
-
Region.prototype.containsPoint = function (x: number, y: number): boolean {
|
|
165
|
-
return cairoRegionContainsPoint(getHandle(this), x, y) as boolean;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const cairoRegionContainsRectangle = bind(
|
|
169
|
-
"libcairo.so.2",
|
|
170
|
-
"cairo_region_contains_rectangle",
|
|
171
|
-
[REGION_T, t.boxed("cairo_rectangle_int_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
172
|
-
t.int32,
|
|
173
|
-
);
|
|
174
|
-
Region.prototype.containsRectangle = function (rect: RectangleInt): RegionOverlap {
|
|
175
|
-
return cairoRegionContainsRectangle(getHandle(this), getHandle(rect)) as RegionOverlap;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const cairoRegionEqual = bind("libcairo.so.2", "cairo_region_equal", [REGION_T, REGION_T], t.boolean);
|
|
179
|
-
Region.prototype.equal = function (other: Region): boolean {
|
|
180
|
-
return cairoRegionEqual(getHandle(this), getHandle(other)) as boolean;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const cairoRegionTranslate = bind("libcairo.so.2", "cairo_region_translate", [REGION_T, t.int32, t.int32], t.void);
|
|
184
|
-
Region.prototype.translate = function (dx: number, dy: number): void {
|
|
185
|
-
cairoRegionTranslate(getHandle(this), dx, dy);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const BINARY_OP_ARGS = [REGION_T, REGION_T];
|
|
189
|
-
const cairoRegionIntersect = bind("libcairo.so.2", "cairo_region_intersect", BINARY_OP_ARGS, t.int32);
|
|
190
|
-
const cairoRegionSubtract = bind("libcairo.so.2", "cairo_region_subtract", BINARY_OP_ARGS, t.int32);
|
|
191
|
-
const cairoRegionUnion = bind("libcairo.so.2", "cairo_region_union", BINARY_OP_ARGS, t.int32);
|
|
192
|
-
const cairoRegionXor = bind("libcairo.so.2", "cairo_region_xor", BINARY_OP_ARGS, t.int32);
|
|
193
|
-
|
|
194
|
-
const RECT_OP_ARGS = [
|
|
195
|
-
REGION_T,
|
|
196
|
-
t.boxed("cairo_rectangle_int_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
197
|
-
];
|
|
198
|
-
const cairoRegionIntersectRectangle = bind("libcairo.so.2", "cairo_region_intersect_rectangle", RECT_OP_ARGS, t.int32);
|
|
199
|
-
const cairoRegionSubtractRectangle = bind("libcairo.so.2", "cairo_region_subtract_rectangle", RECT_OP_ARGS, t.int32);
|
|
200
|
-
const cairoRegionUnionRectangle = bind("libcairo.so.2", "cairo_region_union_rectangle", RECT_OP_ARGS, t.int32);
|
|
201
|
-
const cairoRegionXorRectangle = bind("libcairo.so.2", "cairo_region_xor_rectangle", RECT_OP_ARGS, t.int32);
|
|
202
|
-
|
|
203
|
-
const regionOp = (self: Region, boundFn: (...args: unknown[]) => unknown, arg: Region | RectangleInt): void => {
|
|
204
|
-
boundFn(getHandle(self), getHandle(arg));
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
Region.prototype.intersect = function (other: Region): void {
|
|
208
|
-
regionOp(this, cairoRegionIntersect, other);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
Region.prototype.intersectRectangle = function (rect: RectangleInt): void {
|
|
212
|
-
regionOp(this, cairoRegionIntersectRectangle, rect);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
Region.prototype.subtract = function (other: Region): void {
|
|
216
|
-
regionOp(this, cairoRegionSubtract, other);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
Region.prototype.subtractRectangle = function (rect: RectangleInt): void {
|
|
220
|
-
regionOp(this, cairoRegionSubtractRectangle, rect);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
Region.prototype.union = function (other: Region): void {
|
|
224
|
-
regionOp(this, cairoRegionUnion, other);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
Region.prototype.unionRectangle = function (rect: RectangleInt): void {
|
|
228
|
-
regionOp(this, cairoRegionUnionRectangle, rect);
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
Region.prototype.xor = function (other: Region): void {
|
|
232
|
-
regionOp(this, cairoRegionXor, other);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
Region.prototype.xorRectangle = function (rect: RectangleInt): void {
|
|
236
|
-
regionOp(this, cairoRegionXorRectangle, rect);
|
|
237
|
-
};
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { alloc, type ExternalObject, getHandle, type Handle, read, t, wrapHandle } from "@gtkx/runtime";
|
|
2
|
-
import type { FontOptions, FontType, Status, TextClusterFlags } from "../cairo.js";
|
|
3
|
-
import { FontFace, ScaledFont } from "../cairo.js";
|
|
4
|
-
import {
|
|
5
|
-
allocGlyphBuffer,
|
|
6
|
-
type CairoGlyph,
|
|
7
|
-
type CairoTextCluster,
|
|
8
|
-
type FontExtents,
|
|
9
|
-
readFontExtents,
|
|
10
|
-
readTextExtents,
|
|
11
|
-
type TextExtents,
|
|
12
|
-
} from "./context.js";
|
|
13
|
-
import { FontOptions as FontOptionsConstructor } from "./font-options.js";
|
|
14
|
-
import { allocMatrix, type Matrix as CairoMatrix } from "./matrix.js";
|
|
15
|
-
|
|
16
|
-
const { bind } = t;
|
|
17
|
-
const SCALED_FONT_T = t.boxed("CairoScaledFont", {
|
|
18
|
-
ownership: "borrowed",
|
|
19
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
20
|
-
getTypeFnName: "cairo_gobject_scaled_font_get_type",
|
|
21
|
-
});
|
|
22
|
-
const GLYPH_BUF_REF = t.ref(t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }));
|
|
23
|
-
const CLUSTER_BUF_REF = t.ref(
|
|
24
|
-
t.boxed("cairo_text_cluster_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
declare module "../cairo.js" {
|
|
28
|
-
interface ScaledFont {
|
|
29
|
-
status(): Status;
|
|
30
|
-
extents(): FontExtents;
|
|
31
|
-
textExtents(text: string): TextExtents;
|
|
32
|
-
glyphExtents(glyphs: Array<{ index: number; x: number; y: number }>): TextExtents;
|
|
33
|
-
getFontFace(): FontFace;
|
|
34
|
-
getFontOptions(): FontOptions;
|
|
35
|
-
getFontMatrix(): CairoMatrix;
|
|
36
|
-
getCtm(): CairoMatrix;
|
|
37
|
-
getScaleMatrix(): CairoMatrix;
|
|
38
|
-
getType(): FontType;
|
|
39
|
-
getReferenceCount(): number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
namespace ScaledFont {
|
|
43
|
-
function create(
|
|
44
|
-
fontFace: FontFace,
|
|
45
|
-
fontMatrix: CairoMatrix,
|
|
46
|
-
ctm: CairoMatrix,
|
|
47
|
-
options: FontOptions,
|
|
48
|
-
): ScaledFont;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
type ScaledFontStatic = {
|
|
53
|
-
create(fontFace: FontFace, fontMatrix: CairoMatrix, ctm: CairoMatrix, options: FontOptions): ScaledFont;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const ScaledFontWithStatics = ScaledFont as typeof ScaledFont & ScaledFontStatic;
|
|
57
|
-
|
|
58
|
-
const cairoScaledFontCreate = bind(
|
|
59
|
-
"libcairo.so.2",
|
|
60
|
-
"cairo_scaled_font_create",
|
|
61
|
-
[
|
|
62
|
-
t.boxed("CairoFontFace", {
|
|
63
|
-
ownership: "borrowed",
|
|
64
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
65
|
-
getTypeFnName: "cairo_gobject_font_face_get_type",
|
|
66
|
-
}),
|
|
67
|
-
t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
68
|
-
t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
69
|
-
t.boxed("CairoFontOptions", {
|
|
70
|
-
ownership: "borrowed",
|
|
71
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
72
|
-
getTypeFnName: "cairo_gobject_font_options_get_type",
|
|
73
|
-
}),
|
|
74
|
-
],
|
|
75
|
-
t.boxed("CairoScaledFont", {
|
|
76
|
-
ownership: "full",
|
|
77
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
78
|
-
getTypeFnName: "cairo_gobject_scaled_font_get_type",
|
|
79
|
-
}),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
ScaledFontWithStatics.create = (
|
|
83
|
-
fontFace: FontFace,
|
|
84
|
-
fontMatrix: CairoMatrix,
|
|
85
|
-
ctm: CairoMatrix,
|
|
86
|
-
options: FontOptions,
|
|
87
|
-
): ScaledFont => {
|
|
88
|
-
const ptr = cairoScaledFontCreate(
|
|
89
|
-
getHandle(fontFace),
|
|
90
|
-
getHandle(fontMatrix),
|
|
91
|
-
getHandle(ctm),
|
|
92
|
-
getHandle(options),
|
|
93
|
-
) as ExternalObject<Handle>;
|
|
94
|
-
return wrapHandle(ptr, ScaledFont) as ScaledFont;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const cairoScaledFontStatus = bind("libcairo.so.2", "cairo_scaled_font_status", [SCALED_FONT_T], t.int32);
|
|
98
|
-
ScaledFont.prototype.status = function (): Status {
|
|
99
|
-
return cairoScaledFontStatus(getHandle(this)) as Status;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const cairoScaledFontExtents = bind(
|
|
103
|
-
"libcairo.so.2",
|
|
104
|
-
"cairo_scaled_font_extents",
|
|
105
|
-
[SCALED_FONT_T, t.boxed("cairo_font_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
106
|
-
t.void,
|
|
107
|
-
);
|
|
108
|
-
ScaledFont.prototype.extents = function (): FontExtents {
|
|
109
|
-
const ext = alloc(40);
|
|
110
|
-
cairoScaledFontExtents(getHandle(this), ext);
|
|
111
|
-
return readFontExtents(ext);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const cairoScaledFontTextExtents = bind(
|
|
115
|
-
"libcairo.so.2",
|
|
116
|
-
"cairo_scaled_font_text_extents",
|
|
117
|
-
[
|
|
118
|
-
SCALED_FONT_T,
|
|
119
|
-
t.string("full"),
|
|
120
|
-
t.boxed("cairo_text_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
121
|
-
],
|
|
122
|
-
t.void,
|
|
123
|
-
);
|
|
124
|
-
ScaledFont.prototype.textExtents = function (text: string): TextExtents {
|
|
125
|
-
const ext = alloc(48);
|
|
126
|
-
cairoScaledFontTextExtents(getHandle(this), text, ext);
|
|
127
|
-
return readTextExtents(ext);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const cairoScaledFontGlyphExtents = bind(
|
|
131
|
-
"libcairo.so.2",
|
|
132
|
-
"cairo_scaled_font_glyph_extents",
|
|
133
|
-
[
|
|
134
|
-
SCALED_FONT_T,
|
|
135
|
-
t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
136
|
-
t.int32,
|
|
137
|
-
t.boxed("cairo_text_extents_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" }),
|
|
138
|
-
],
|
|
139
|
-
t.void,
|
|
140
|
-
);
|
|
141
|
-
ScaledFont.prototype.glyphExtents = function (glyphs: Array<{ index: number; x: number; y: number }>): TextExtents {
|
|
142
|
-
const buf = allocGlyphBuffer(glyphs);
|
|
143
|
-
const ext = alloc(48);
|
|
144
|
-
cairoScaledFontGlyphExtents(getHandle(this), buf, glyphs.length, ext);
|
|
145
|
-
return readTextExtents(ext);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const cairoScaledFontGetFontFace = bind(
|
|
149
|
-
"libcairo.so.2",
|
|
150
|
-
"cairo_scaled_font_get_font_face",
|
|
151
|
-
[SCALED_FONT_T],
|
|
152
|
-
t.boxed("CairoFontFace", {
|
|
153
|
-
ownership: "borrowed",
|
|
154
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
155
|
-
getTypeFnName: "cairo_gobject_font_face_get_type",
|
|
156
|
-
}),
|
|
157
|
-
);
|
|
158
|
-
ScaledFont.prototype.getFontFace = function (): FontFace {
|
|
159
|
-
return wrapHandle(cairoScaledFontGetFontFace(getHandle(this)) as ExternalObject<Handle>, FontFace) as FontFace;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const cairoScaledFontGetFontOptions = bind(
|
|
163
|
-
"libcairo.so.2",
|
|
164
|
-
"cairo_scaled_font_get_font_options",
|
|
165
|
-
[
|
|
166
|
-
SCALED_FONT_T,
|
|
167
|
-
t.boxed("CairoFontOptions", {
|
|
168
|
-
ownership: "borrowed",
|
|
169
|
-
sharedLibrary: "libcairo-gobject.so.2",
|
|
170
|
-
getTypeFnName: "cairo_gobject_font_options_get_type",
|
|
171
|
-
}),
|
|
172
|
-
],
|
|
173
|
-
t.void,
|
|
174
|
-
);
|
|
175
|
-
ScaledFont.prototype.getFontOptions = function (): FontOptions {
|
|
176
|
-
const options = FontOptionsConstructor.create();
|
|
177
|
-
cairoScaledFontGetFontOptions(getHandle(this), getHandle(options));
|
|
178
|
-
return options;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const cairoScaledFontGetFontMatrix = bind(
|
|
182
|
-
"libcairo.so.2",
|
|
183
|
-
"cairo_scaled_font_get_font_matrix",
|
|
184
|
-
[SCALED_FONT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
185
|
-
t.void,
|
|
186
|
-
);
|
|
187
|
-
const cairoScaledFontGetCtm = bind(
|
|
188
|
-
"libcairo.so.2",
|
|
189
|
-
"cairo_scaled_font_get_ctm",
|
|
190
|
-
[SCALED_FONT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
191
|
-
t.void,
|
|
192
|
-
);
|
|
193
|
-
const cairoScaledFontGetScaleMatrix = bind(
|
|
194
|
-
"libcairo.so.2",
|
|
195
|
-
"cairo_scaled_font_get_scale_matrix",
|
|
196
|
-
[SCALED_FONT_T, t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
197
|
-
t.void,
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
function readMatrixVia(self: ScaledFont, boundFn: (...args: unknown[]) => unknown): CairoMatrix {
|
|
201
|
-
const { handle, obj } = allocMatrix();
|
|
202
|
-
boundFn(getHandle(self), handle);
|
|
203
|
-
return obj;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
ScaledFont.prototype.getFontMatrix = function (): CairoMatrix {
|
|
207
|
-
return readMatrixVia(this, cairoScaledFontGetFontMatrix);
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
ScaledFont.prototype.getCtm = function (): CairoMatrix {
|
|
211
|
-
return readMatrixVia(this, cairoScaledFontGetCtm);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
ScaledFont.prototype.getScaleMatrix = function (): CairoMatrix {
|
|
215
|
-
return readMatrixVia(this, cairoScaledFontGetScaleMatrix);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const cairoScaledFontGetType = bind("libcairo.so.2", "cairo_scaled_font_get_type", [SCALED_FONT_T], t.int32);
|
|
219
|
-
ScaledFont.prototype.getType = function (): FontType {
|
|
220
|
-
return cairoScaledFontGetType(getHandle(this)) as FontType;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const cairoScaledFontGetReferenceCount = bind(
|
|
224
|
-
"libcairo.so.2",
|
|
225
|
-
"cairo_scaled_font_get_reference_count",
|
|
226
|
-
[SCALED_FONT_T],
|
|
227
|
-
t.int32,
|
|
228
|
-
);
|
|
229
|
-
ScaledFont.prototype.getReferenceCount = function (): number {
|
|
230
|
-
return cairoScaledFontGetReferenceCount(getHandle(this)) as number;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
declare module "../cairo.js" {
|
|
234
|
-
interface ScaledFont {
|
|
235
|
-
textToGlyphs(x: number, y: number, text: string): [CairoGlyph[], CairoTextCluster[], TextClusterFlags];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const cairoScaledFontTextToGlyphs = bind(
|
|
240
|
-
"libcairo.so.2",
|
|
241
|
-
"cairo_scaled_font_text_to_glyphs",
|
|
242
|
-
[
|
|
243
|
-
SCALED_FONT_T,
|
|
244
|
-
t.float64,
|
|
245
|
-
t.float64,
|
|
246
|
-
t.string("full"),
|
|
247
|
-
t.int32,
|
|
248
|
-
GLYPH_BUF_REF,
|
|
249
|
-
t.ref(t.int32),
|
|
250
|
-
CLUSTER_BUF_REF,
|
|
251
|
-
t.ref(t.int32),
|
|
252
|
-
t.ref(t.int32),
|
|
253
|
-
],
|
|
254
|
-
t.int32,
|
|
255
|
-
);
|
|
256
|
-
const cairoGlyphFree = bind(
|
|
257
|
-
"libcairo.so.2",
|
|
258
|
-
"cairo_glyph_free",
|
|
259
|
-
[t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
260
|
-
t.void,
|
|
261
|
-
);
|
|
262
|
-
const cairoTextClusterFree = bind(
|
|
263
|
-
"libcairo.so.2",
|
|
264
|
-
"cairo_text_cluster_free",
|
|
265
|
-
[t.boxed("cairo_text_cluster_t", { ownership: "borrowed", sharedLibrary: "libcairo.so.2" })],
|
|
266
|
-
t.void,
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
ScaledFont.prototype.textToGlyphs = function (
|
|
270
|
-
x: number,
|
|
271
|
-
y: number,
|
|
272
|
-
text: string,
|
|
273
|
-
): [CairoGlyph[], CairoTextCluster[], TextClusterFlags] {
|
|
274
|
-
const glyphsRef: { value: ExternalObject<Handle> | null } = { value: null };
|
|
275
|
-
const numGlyphsRef = { value: 0 };
|
|
276
|
-
const clustersRef: { value: ExternalObject<Handle> | null } = { value: null };
|
|
277
|
-
const numClustersRef = { value: 0 };
|
|
278
|
-
const clusterFlagsRef = { value: 0 };
|
|
279
|
-
|
|
280
|
-
cairoScaledFontTextToGlyphs(
|
|
281
|
-
getHandle(this),
|
|
282
|
-
x,
|
|
283
|
-
y,
|
|
284
|
-
text,
|
|
285
|
-
-1,
|
|
286
|
-
glyphsRef,
|
|
287
|
-
numGlyphsRef,
|
|
288
|
-
clustersRef,
|
|
289
|
-
numClustersRef,
|
|
290
|
-
clusterFlagsRef,
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
const numGlyphs = numGlyphsRef.value;
|
|
294
|
-
const numClusters = numClustersRef.value;
|
|
295
|
-
|
|
296
|
-
const glyphsBuf = glyphsRef.value;
|
|
297
|
-
const clustersBuf = clustersRef.value;
|
|
298
|
-
|
|
299
|
-
const glyphs: CairoGlyph[] = [];
|
|
300
|
-
if (glyphsBuf !== null) {
|
|
301
|
-
for (let i = 0; i < numGlyphs; i++) {
|
|
302
|
-
const offset = i * 24;
|
|
303
|
-
glyphs.push({
|
|
304
|
-
index: read(glyphsBuf, t.uint64, offset) as number,
|
|
305
|
-
x: read(glyphsBuf, t.float64, offset + 8) as number,
|
|
306
|
-
y: read(glyphsBuf, t.float64, offset + 16) as number,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const clusters: CairoTextCluster[] = [];
|
|
312
|
-
if (clustersBuf !== null) {
|
|
313
|
-
for (let i = 0; i < numClusters; i++) {
|
|
314
|
-
const offset = i * 8;
|
|
315
|
-
clusters.push({
|
|
316
|
-
numBytes: read(clustersBuf, t.int32, offset) as number,
|
|
317
|
-
numGlyphs: read(clustersBuf, t.int32, offset + 4) as number,
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (glyphsBuf !== null) {
|
|
323
|
-
cairoGlyphFree(glyphsBuf);
|
|
324
|
-
}
|
|
325
|
-
if (clustersBuf !== null) {
|
|
326
|
-
cairoTextClusterFree(clustersBuf);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return [glyphs, clusters, clusterFlagsRef.value as TextClusterFlags];
|
|
330
|
-
};
|