From: Dr. Michael Lauer Date: Fri, 16 Mar 2018 14:33:08 +0000 (+0100) Subject: posix: Bind va_list and add string.concat() (POSIX) X-Git-Tag: 0.41.90~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b20375d44196400c7ef1faefeeeaf059b02b21f;p=thirdparty%2Fvala.git posix: Bind va_list and add string.concat() (POSIX) This fixes string templates when using the POSIX profile. --- diff --git a/vapi/posix.vapi b/vapi/posix.vapi index 916ead5ff..93eb80b70 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 (); +} + [Compact] [Immutable] [CCode (cname = "char", const_cname = "const char", copy_function = "strdup", free_function = "free", cheader_filename = "stdlib.h,string.h")] @@ -258,6 +269,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 += arg; + } + } + return result; + } + public inline unowned string to_string () { return this; }