[vala/wip/profile-posix: 25/28] posix: Bind va_list and add string.concat() (POSIX)
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/profile-posix: 25/28] posix: Bind va_list and add string.concat() (POSIX)
- Date: Fri, 23 Mar 2018 07:31:54 +0000 (UTC)
commit 51b27de1294b80b6d1dda86b123a01c58cff29d5
Author: Dr. Michael Lauer <mickey vanille-media de>
Date: Fri Mar 16 15:33:08 2018 +0100
posix: Bind va_list and add string.concat() (POSIX)
This fixes string templates when using the POSIX profile.
vapi/posix.vapi | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/vapi/posix.vapi b/vapi/posix.vapi
index 06a07d9..b7c3a68 100644
--- a/vapi/posix.vapi
+++ b/vapi/posix.vapi
@@ -251,6 +251,17 @@ public struct time_t {
public time_t ();
}
+[SimpleType]
+[CCode (cheader_filename = "stdarg.h", cprefix = "va_", has_type_id = false, destroy_function = "va_end",
lvalue_access = false)]
+public struct va_list {
+ [CCode (cname = "va_start")]
+ public va_list ();
+ [CCode (cname = "va_copy")]
+ public va_list.copy (va_list src);
+ [CCode (generic_type_pos = 1.1, simple_generics = true)]
+ public unowned G arg<G> ();
+}
+
[Compact]
[Immutable]
[CCode (cname = "char", const_cname = "const char", copy_function = "strdup", free_function = "free",
cheader_filename = "stdlib.h,string.h")]
@@ -271,6 +282,20 @@ public class string {
[PrintfFormat]
public string printf (...);
+ public string concat (...) {
+ string result = this;
+ var l = va_list ();
+ while (true) {
+ unowned string? arg = l.arg ();
+ if (arg == null) {
+ break;
+ } else {
+ result = "%s%s".printf (result, arg);
+ }
+ }
+ return result;
+ }
+
public inline unowned string to_string () {
return this;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]