set accessibility for constants set return type in property set accessors
authorJürg Billeter <j@bitron.ch>
Sat, 2 Sep 2006 09:05:41 +0000 (09:05 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sat, 2 Sep 2006 09:05:41 +0000 (09:05 +0000)
2006-09-02  Jürg Billeter  <j@bitron.ch>

* vala/parser.y: set accessibility for constants
* vala/valasemanticanalyzer.vala: set return type in property set
  accessors to void
* vala/valacodegenerator.vala: move public constants to header file
* vala/valaclass.vala: don't create fields for properties in VAPI files
* vala/valaconstant.vala: add access member

svn path=/trunk/; revision=116

vala/ChangeLog
vala/vala/parser.y
vala/vala/valaclass.vala
vala/vala/valacodegenerator.vala
vala/vala/valaconstant.vala
vala/vala/valasemanticanalyzer.vala

index 23a5283..a11a708 100644 (file)
@@ -1,5 +1,14 @@
 2006-09-02  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y: set accessibility for constants
+       * vala/valasemanticanalyzer.vala: set return type in property set
+         accessors to void
+       * vala/valacodegenerator.vala: move public constants to header file
+       * vala/valaclass.vala: don't create fields for properties in VAPI files
+       * vala/valaconstant.vala: add access member
+
+2006-09-02  Jürg Billeter  <j@bitron.ch>
+
        * vapi/cairo.vala: mark Matrix as reference type
 
 2006-08-24  Jürg Billeter  <j@bitron.ch>
index f19f6e9..eb0e9cc 100644 (file)
@@ -2109,6 +2109,9 @@ constant_declaration
                g_object_unref (src);
                g_object_unref ($5);
                g_object_unref ($6);
+               if ($3 != 0) {
+                       $$->access = $3;
+               }
          }
        ;
 
index 66aa0ed..4933736 100644 (file)
@@ -174,7 +174,8 @@ public class Vala.Class : DataType {
        public void add_property (Property! prop) {
                properties.append (prop);
                
-               if (prop.set_accessor != null && prop.set_accessor.body == null) {
+               if (prop.set_accessor != null && prop.set_accessor.body == null &&
+                   source_reference != null && !source_reference.file.pkg) {
                        /* automatic property accessor body generation */
                        var f = new Field ("_%s".printf (prop.name), prop.type_reference, null, prop.source_reference);
                        f.access = MemberAccessibility.PRIVATE;
index 5b3fc66..d70e001 100644 (file)
@@ -860,7 +860,12 @@ public class Vala.CodeGenerator : CodeVisitor {
                        }
                        cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
                        cdecl.modifiers = CCodeModifiers.STATIC;
-                       source_type_member_declaration.append (cdecl);
+                       
+                       if (c.access == MemberAccessibility.PUBLIC) {
+                               header_type_member_declaration.append (cdecl);
+                       } else {
+                               source_type_member_declaration.append (cdecl);
+                       }
                }
        }
        
index be3a993..08ae73d 100644 (file)
@@ -41,6 +41,14 @@ public class Vala.Constant : CodeNode {
         */
        public Expression initializer { get; set; }
        
+       /**
+        * Specifies the accessibility of this constant. Public accessibility
+        * doesn't limit access. Default accessibility limits access to this
+        * program or library. Private accessibility limits access to instances
+        * of the contained type.
+        */
+       public MemberAccessibility access;
+       
        private string cname;
 
        /**
index 242198e..0eda76d 100644 (file)
@@ -263,6 +263,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                
                if (acc.readable) {
                        current_return_type = prop.type_reference;
+               } else {
+                       // void
+                       current_return_type = new TypeReference ();
                }
        }