]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Recognize usage of off_t and don't rely on given GIR type
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 13 Mar 2024 07:46:56 +0000 (08:46 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 13 Mar 2024 13:15:32 +0000 (14:15 +0100)
tests/Makefile.am
tests/gir/off_t.gir [new file with mode: 0644]
tests/gir/off_t.vapi-expected [new file with mode: 0644]
vala/valagirparser.vala
vapi/glib-2.0.vapi

index 528b3774f2ade89fff41ea47c4ab6d2ade19c961..806443855162d45afec00a12f9aad9f9bd726615 100644 (file)
@@ -909,6 +909,7 @@ TESTS = \
        gir/method-array-return.gir \
        gir/method-class.gir \
        gir/method-nowrapper.gir \
+       gir/off_t.gir \
        gir/parameter-array-length-type.gir \
        gir/parameter-array-out.gir \
        gir/parameter-nullable-out-simple-type.gir \
diff --git a/tests/gir/off_t.gir b/tests/gir/off_t.gir
new file mode 100644 (file)
index 0000000..f295b99
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+<include name="GLib" version="2.0"/>
+<package name="test"/>
+<c:include name="test.h"/>
+<namespace name="Test" version="1.0" shared-library="test" c:prefix="Test" c:identifier-prefixes="Test" c:symbol-prefixes="test">
+<function name="function" c:identifier="test_function">
+  <return-value transfer-ownership="none">
+    <type name="gsize" c:type="off_t"/>
+  </return-value>
+  <parameters>
+    <parameter name="time" transfer-ownership="none">
+      <type name="gsize" c:type="off_t"/>
+    </parameter>
+  </parameters>
+</function>
+</namespace>
+</repository>
diff --git a/tests/gir/off_t.vapi-expected b/tests/gir/off_t.vapi-expected
new file mode 100644 (file)
index 0000000..d147585
--- /dev/null
@@ -0,0 +1,5 @@
+[CCode (cprefix = "Test", gir_namespace = "Test", gir_version = "1.0", lower_case_cprefix = "test_")]
+namespace Test {
+       [CCode (cheader_filename = "test.h")]
+       public static off_t function (off_t time);
+}
index bf4dfd3c525de51c4819048a3f08167008e8a96f..7118864d99c2786e49d30d4a84e03d2635388931 100644 (file)
@@ -2935,7 +2935,11 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (type_name == "GLib.offset") {
                                type_name = "int64";
                        } else if (type_name == "gsize") {
-                               type_name = "size_t";
+                               if (ctype != null && ctype.has_prefix ("off_t")) {
+                                       type_name = "off_t";
+                               } else {
+                                       type_name = "size_t";
+                               }
                        } else if (type_name == "gssize") {
                                type_name = "ssize_t";
                        } else if (type_name == "guintptr") {
index 8f5f57fda43f590a0f3ee9801fcb963d81d839f3..0863d7a671e0a22585f8b52ed9aa02629b957889 100644 (file)
@@ -1018,6 +1018,13 @@ public struct double {
        }
 }
 
+//FIXME [GIR (name = "off_t")]
+[GIR (name = "gsize")]
+[CCode (cheader_filename = "sys/types.h", has_type_id = false, default_value = "0")]
+[IntegerType (rank = 9)]
+public struct off_t {
+}
+
 //FIXME [GIR (name = "time_t")]
 [GIR (name = "glong")]
 [CCode (cheader_filename = "time.h", has_type_id = false, default_value = "0")]