[vala] codegen: Add G_GNUC_FORMAT attribute for FormatArg function-pointers



commit d2175507afe8ec774676a90eb652612816c6d694
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Nov 7 21:03:56 2016 +0100

    codegen: Add G_GNUC_FORMAT attribute for FormatArg function-pointers

 ccode/valaccodefunctiondeclarator.vala |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/ccode/valaccodefunctiondeclarator.vala b/ccode/valaccodefunctiondeclarator.vala
index fc59aa8..08aea1d 100644
--- a/ccode/valaccodefunctiondeclarator.vala
+++ b/ccode/valaccodefunctiondeclarator.vala
@@ -55,16 +55,23 @@ public class Vala.CCodeFunctionDeclarator : CCodeDeclarator {
                writer.write_string (name);
                writer.write_string (") (");
                
-               bool first = true;
+               int i = 0;
+               int format_arg_index = -1;
                foreach (CCodeParameter param in parameters) {
-                       if (!first) {
+                       if (i > 0) {
                                writer.write_string (", ");
-                       } else {
-                               first = false;
                        }
                        param.write (writer);
+                       if (param.format_arg) {
+                               format_arg_index = i;
+                       }
+                       i++;
                }
                
                writer.write_string (")");
+
+               if (format_arg_index >= 0) {
+                       writer.write_string (" G_GNUC_FORMAT(%d)".printf (format_arg_index + 1));
+               }
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]