]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add support for [Print] method attribute ea8cd97480a7a560cfd8ae3f060f63638b7d9de4
authorJürg Billeter <j@bitron.ch>
Fri, 2 Jul 2010 08:02:30 +0000 (10:02 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 2 Jul 2010 08:02:30 +0000 (10:02 +0200)
This stringifies and concatenates all arguments you pass to the method.

vala/valacodewriter.vala
vala/valamethodcall.vala
vala/valatemplate.vala

index c039ae7dd92000dc47f0f8dded3dbfa67388eb67..e27b981dd5ecb641b35f553e785a2357a0dc230f 100644 (file)
@@ -936,6 +936,10 @@ public class Vala.CodeWriter : CodeVisitor {
                        write_indent ();
                        write_string ("[ScanfFormat]");
                }
+               if (m.get_attribute ("Print") != null) {
+                       write_indent ();
+                       write_string ("[Print]");
+               }
 
                emit_deprecated_attribute (m);
 
index 26843276271936b6cdc265fcf3d28248ff6d72d3..8f9940f5a4a5e6492f502be80a4b18203eff4a49 100644 (file)
@@ -342,6 +342,17 @@ public class Vala.MethodCall : Expression {
                        }
                }
 
+               // concatenate stringified arguments for methods with attribute [Print]
+               if (mtype is MethodType && ((MethodType) mtype).method_symbol.get_attribute ("Print") != null) {
+                       var template = new Template (source_reference);
+                       foreach (Expression arg in argument_list) {
+                               arg.parent_node = null;
+                               template.add_expression (arg);
+                       }
+                       argument_list.clear ();
+                       add_argument (template);
+               }
+
                // printf arguments
                if (mtype is MethodType && ((MethodType) mtype).method_symbol.printf_format) {
                        StringLiteral format_literal = null;
index 90cefe067a8c59ff18f2db9ff333857a0a2503dd..c329c5ca16dfb8db6bd461998ee5088051f823dc 100644 (file)
@@ -1,6 +1,6 @@
 /* valatemplate.vala
  *
- * Copyright (C) 2009  Jürg Billeter
+ * Copyright (C) 2009-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,8 @@
 public class Vala.Template : Expression {
        private List<Expression> expression_list = new ArrayList<Expression> ();
 
-       public Template () {
+       public Template (SourceReference? source_reference = null) {
+               this.source_reference = source_reference;
        }
 
        public override void accept (CodeVisitor visitor) {