Skip to content

Commit

Permalink
patch x11selection (text list)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerryAlex committed Oct 25, 2024
1 parent 8b3f47b commit 90e0179
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
9 changes: 7 additions & 2 deletions lib/girepository-1.0/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,27 @@ cd ../..

git clone https://github.com/gtk-rs/gir-files.git && cd gir-files
git checkout ${gir_version}

# fetch GIRepository-3.0.gir
cp /usr/share/gir-1.0/GIRepository-3.0.gir .

# utf8
sed -i 's/type name="utf8" c:type="gchar"/type name="gchar" c:type="gchar"/g' GLib-2.0.gir
sed -i 's/type name="utf8" c:type="char"/type name="gchar" c:type="char"/g' HarfBuzz-0.0.gir
# introspectable="0"
# introspectable
sed -i 's/field name="priority" introspectable="0"/field name="priority"/g' GLib-2.0.gir
sed -i 's/enumeration name="ThreadPriority" introspectable="0" deprecated="1"/enumeration name="ThreadPriority"/g' GLib-2.0.gir
sed -i 's/function name="image_surface_create"/function name="image_surface_create" introspectable="0"/g' cairo-1.0.gir
# Win32
sed -i 's/type name="GLib.Win32/type name="GLibWin32./g' GLibWin32-2.0.gir
sed -i 's/type name="Gio.Win32/type name="GioWin32./g' GioWin32-2.0.gir
# gconstpointer
# misc
sed -i 's/gconstpointer/gpointer/g' Pango-1.0.gir

for gir in $(ls *.gir)
do
typelib=$(echo ${gir} | sed 's/.gir/.typelib/')
gi-compile-repository ${gir} -o ../${typelib} --includedir .
done

cd ..
9 changes: 9 additions & 0 deletions src/gi-ext.zig
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ pub const ArgInfoExt = struct {
try writer.writeAll("[*]*gobject.Object");
return;
}
// PATCH: text list
if (std.mem.eql(u8, "gdk_x11_display_text_property_to_text_list", func_symbol) and std.mem.eql(u8, "list", arg_name)) {
try writer.writeAll("*?[*:null]?[*:0]u8");
return;
}
if (std.mem.eql(u8, "gdk_x11_free_text_list", func_symbol) and std.mem.eql(u8, "list", arg_name)) {
try writer.writeAll("[*:null]?[*:0]u8");
return;
}
}
}
if ((self.getDirection() != .in and !(self.isCallerAllocates() and arg_type.getTag() == .array and arg_type.getArrayType() == .c)) or option_signal_param) {
Expand Down
11 changes: 10 additions & 1 deletion test/abi/c_linux.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
--- a/c_linux.zig
+++ b/c_linux.zig
@@ -1,3 +1,7 @@
@@ -19456,5 +19456,8 @@
_: u30,
};
-pub const struct__PangoGlyphVisAttr = opaque {};
+pub const struct__PangoGlyphVisAttr = packed struct(u32) {
+ is_cluster_start: bool,
Expand All @@ -9,3 +11,10 @@
+};
pub const PangoGlyphVisAttr = struct__PangoGlyphVisAttr;
pub const struct__PangoGlyphInfo = extern struct {
@@ -28908,5 +28911,5 @@
pub extern fn gsk_text_node_has_color_glyphs(node: ?*const GskRenderNode) gboolean;
pub extern fn gsk_text_node_get_num_glyphs(node: ?*const GskRenderNode) guint;
-pub extern fn gsk_text_node_get_glyphs(node: ?*const GskRenderNode, n_glyphs: [*c]guint) ?*const PangoGlyphInfo;
+pub extern fn gsk_text_node_get_glyphs(node: ?*const GskRenderNode, n_glyphs: [*c]guint) [*]const PangoGlyphInfo;
pub extern fn gsk_text_node_get_color(node: ?*const GskRenderNode) [*c]const GdkRGBA;
pub extern fn gsk_text_node_get_offset(node: ?*const GskRenderNode) [*c]const graphene_point_t;
11 changes: 10 additions & 1 deletion test/abi/c_win.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
--- a/c_win.zig
+++ b/c_win.zig
@@ -1,3 +1,7 @@
@@ -19148,5 +19148,8 @@
_: u30,
};
-pub const struct__PangoGlyphVisAttr = opaque {};
+pub const struct__PangoGlyphVisAttr = packed struct(u32) {
+ is_cluster_start: bool,
Expand All @@ -9,3 +11,10 @@
+};
pub const PangoGlyphVisAttr = struct__PangoGlyphVisAttr;
pub const struct__PangoGlyphInfo = extern struct {
@@ -29185,5 +29188,5 @@
pub extern fn gsk_text_node_has_color_glyphs(node: ?*const GskRenderNode) gboolean;
pub extern fn gsk_text_node_get_num_glyphs(node: ?*const GskRenderNode) guint;
-pub extern fn gsk_text_node_get_glyphs(node: ?*const GskRenderNode, n_glyphs: [*c]guint) ?*const PangoGlyphInfo;
+pub extern fn gsk_text_node_get_glyphs(node: ?*const GskRenderNode, n_glyphs: [*c]guint) [*]const PangoGlyphInfo;
pub extern fn gsk_text_node_get_color(node: ?*const GskRenderNode) [*c]const GdkRGBA;
pub extern fn gsk_text_node_get_offset(node: ?*const GskRenderNode) [*c]const graphene_point_t;
8 changes: 1 addition & 7 deletions test/abi/testing.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ fn isHandle(T: std.builtin.Type) bool {
return fields[0].type == c_int;
}

pub fn expect(ok: bool) !void {
if (true) {
try std.testing.expect(ok);
} else {
comptime std.debug.assert(ok);
}
}
pub const expect = std.testing.expect;

pub fn isAbiCompatitable(comptime U: type, comptime V: type) bool {
var typeinfo_u = @typeInfo(U);
Expand Down

0 comments on commit 90e0179

Please sign in to comment.