]> 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 19:27:39 +0000 (20:27 +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 61f07f3f904a76cebe57f678d5130aa4fa504cf7..b2e0d9019ab7362675cb47008282c67d3f9f709d 100644 (file)
@@ -885,6 +885,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 e3553941bee72a213662c0c170574edd4790853e..dde72ee2bffbff82e2e7296cee336ac9cc69fde0 100644 (file)
@@ -2889,7 +2889,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 aade8a0911fc8946e1353aeb4c329322335017ef..8882177cc1a2c02e17e2dd8c0bf4eb22f4e21607 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")]