support cname attribute for constants
authorJuerg Billeter <j@bitron.ch>
Tue, 18 Dec 2007 15:49:14 +0000 (15:49 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 18 Dec 2007 15:49:14 +0000 (15:49 +0000)
2007-12-18  Juerg Billeter  <j@bitron.ch>

* vala/parser.y, vala/valaattributeprocessor.vala,
  vala/valaconstant.vala: support cname attribute for constants

svn path=/trunk/; revision=780

ChangeLog
vala/parser.y
vala/valaattributeprocessor.vala
vala/valaconstant.vala

index c2a6a7b..870d2e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-12-18  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y, vala/valaattributeprocessor.vala,
+         vala/valaconstant.vala: support cname attribute for constants
+
+2007-12-18  Jürg Billeter  <j@bitron.ch>
+
        * vala/parser.y: support PointerType for parameters
 
 2007-12-16  Jürg Billeter  <j@bitron.ch>
index a2311c8..191c37e 100644 (file)
@@ -2798,6 +2798,7 @@ constant_declaration
                if ($3 != 0) {
                        vala_symbol_set_access (VALA_SYMBOL ($$), $3);
                }
+               VALA_CODE_NODE($$)->attributes = $2;
          }
        ;
 
index e392a6a..d6a2f07 100644 (file)
@@ -86,6 +86,10 @@ public class Vala.AttributeProcessor : CodeVisitor {
                cb.process_attributes ();
        }
 
+       public override void visit_constant (Constant! c) {
+               c.process_attributes ();
+       }
+
        public override void visit_field (Field! f) {
                f.process_attributes ();
        }
index 007341f..7c7101c 100644 (file)
@@ -104,4 +104,27 @@ public class Vala.Constant : Member, Lockable {
                        type_reference = new_type;
                }
        }
+
+       private void process_ccode_attribute (Attribute! a) {
+               if (a.has_argument ("cname")) {
+                       cname = a.get_string ("cname");
+               }
+               if (a.has_argument ("cheader_filename")) {
+                       var val = a.get_string ("cheader_filename");
+                       foreach (string filename in val.split (",")) {
+                               add_cheader_filename (filename);
+                       }
+               }
+       }
+
+       /**
+        * Process all associated attributes.
+        */
+       public void process_attributes () {
+               foreach (Attribute a in attributes) {
+                       if (a.name == "CCode") {
+                               process_ccode_attribute (a);
+                       }
+               }
+       }
 }