[Vala] Legacy Bindings: "Inject" & operator?
- From: Dr. Michael Lauer <mickey vanille de>
- To: Al Thomas via vala-list <vala-list gnome org>
- Subject: [Vala] Legacy Bindings: "Inject" & operator?
- Date: Thu, 1 Mar 2018 08:55:01 +0100
The other day I was using Posix.ctime a lot on various time_t types.
I pondered whether it would be helpful to add a to_string() method to make
this a bit more convenient.
Ideally I would state something like
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 82785747e..31a68885f 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -908,6 +908,8 @@ public struct double {
public struct time_t {
[CCode (cname = "time")]
public time_t (out time_t result = null);
+ [CCode (cname = "ctime")]
+ public unowned string to_string();
}
This doesn’t work though, since time_t is bounds as IntegerType, hence the compiler bails out with:
/Volumes/ramdisk/time.c:29:18: warning: incompatible integer to pointer conversion passing 'time_t' (aka
'long') to parameter of type 'const time_t *'
(aka 'const long *'); take the address with & [-Wint-conversion]
_tmp1_ = ctime (now);
^~~
&
Independent of whether this patch can make it to glib-2.0.vapi or not, I wonder
whether there is a CCode attribute that could make this happen without introducing
a vala helper method.
Cheers,
Mickey.
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]