[vala/wip/mickey/posix-profile: 2/2] posix: (POSIX profile) bind va_list and add string.concat
- From: Dr. Michael Lauer <mlauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/mickey/posix-profile: 2/2] posix: (POSIX profile) bind va_list and add string.concat
- Date: Fri, 16 Mar 2018 14:38:40 +0000 (UTC)
commit 9fd331654fbe1d274a5b0f670207067ecb73b02a
Author: Dr. Michael Lauer <mickey vanille-media de>
Date: Fri Mar 16 15:33:08 2018 +0100
posix: (POSIX profile) bind va_list and add string.concat
This fixes string templates when using the POSIX profile
vapi/posix.vapi | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/vapi/posix.vapi b/vapi/posix.vapi
index 0bfc879..0c1397b 100644
--- a/vapi/posix.vapi
+++ b/vapi/posix.vapi
@@ -131,6 +131,17 @@ public struct ssize_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> ();
+}
+
[CCode (cname = "int8_t", cheader_filename = "stdint.h", default_value = "0")]
[IntegerType (rank = 1, min = -128, max = 127)]
public struct int8 {
@@ -271,6 +282,21 @@ public class string {
[PrintfFormat]
public string printf (...);
+ public string concat (...) {
+ string result = this;
+ var l = va_list();
+ while (true) {
+ 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]