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

index d12f6df3a496482613de88bc27b28350b01d7119..61f07f3f904a76cebe57f678d5130aa4fa504cf7 100644 (file)
@@ -894,6 +894,7 @@ TESTS = \
        gir/symbol-redefined.gir \
        gir/symbol-type-csuffix.gir \
        gir/symbol-without-name.gir \
+       gir/time_t.gir \
        gir/union.gir \
        gir/union-transparent.gir \
        girwriter/class-final.test \
diff --git a/tests/gir/time_t.gir b/tests/gir/time_t.gir
new file mode 100644 (file)
index 0000000..73e48f8
--- /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="glong" c:type="time_t"/>
+  </return-value>
+  <parameters>
+    <parameter name="time" transfer-ownership="none">
+      <type name="glong" c:type="time_t"/>
+    </parameter>
+  </parameters>
+</function>
+</namespace>
+</repository>
diff --git a/tests/gir/time_t.vapi-expected b/tests/gir/time_t.vapi-expected
new file mode 100644 (file)
index 0000000..80d73ef
--- /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 time_t function (time_t time);
+}
index ed8f62ef08fa17d8b5a6b4313d392bff12492da9..e3553941bee72a213662c0c170574edd4790853e 100644 (file)
@@ -2851,6 +2851,8 @@ public class Vala.GirParser : CodeVisitor {
                                        type_name = "ssize_t";
                                } else if (ctype != null && ctype.has_prefix ("gintptr")) {
                                        type_name = "intptr";
+                               } else if (ctype != null && ctype.has_prefix ("time_t")) {
+                                       type_name = "time_t";
                                } else {
                                        type_name = "long";
                                }
index c78a108d81fc7001546d17137289eb6f7f8fe7fe..aade8a0911fc8946e1353aeb4c329322335017ef 100644 (file)
@@ -1018,6 +1018,7 @@ public struct double {
        }
 }
 
+//FIXME [GIR (name = "time_t")]
 [GIR (name = "glong")]
 [CCode (cheader_filename = "time.h", has_type_id = false, default_value = "0")]
 [IntegerType (rank = 8)]