]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
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 c2a6a7bbb0dcb5155206f5d397b638a9dcbfd67e..870d2e85def93cfed78d3a5eaae0ec037fcbab64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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
index a2311c803ed4a14e08c83c2f3e799c589ae1e5e2..191c37e7deb9e4f6b988ec8b5b9f97e55a021be7 100644 (file)
@@ -2798,6 +2798,7 @@ constant_declaration
                if ($3 != 0) {
                        vala_symbol_set_access (VALA_SYMBOL ($$), $3);
                }
+               VALA_CODE_NODE($$)->attributes = $2;
          }
        ;
 
index e392a6a45d51dca8fb68d59a4b7515950144aa2c..d6a2f07f8e8501dc45687a0d99eb111d273e247b 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 007341f77943a4afe46941d573cf1639ef5d3591..7c7101c6f994584b73f9eecbcbf701a81bf597a4 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);
+                       }
+               }
+       }
 }