]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
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 23a5283f065eb526e282fbe435a5376b69d91b19..a11a70846c50a65ff10f808d0cea17fdbdbd4d4e 100644 (file)
@@ -1,3 +1,12 @@
+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
index f19f6e9d8adb7f783c06b6b50168bbebc9f66151..eb0e9cc1f581ce2b01310b651c1abf7bb9799897 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 66aa0ed73762fbdc65b7b29f87a2e8de18a683d4..49337365a75035d1e730ec270ae727f90eaab2be 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 5b3fc665272d76339d8654f3e2e7fe707c353357..d70e001dc77320e856a4f7e5a7e0aff706a40fe4 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 be3a9936b6d29365336241746e8587e06ef2d731..08ae73d8daa5c31aef2dd3616609ae3e62380e1e 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 242198e11b46b3af92ca39d92ba68b348fe0b07e..0eda76dce79fe2fb58e5eff7f8ab24038cd3fb59 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 ();
                }
        }