From: Jürg Billeter Date: Sat, 2 Sep 2006 09:05:41 +0000 (+0000) Subject: set accessibility for constants set return type in property set accessors X-Git-Tag: VALA_0_0_4~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bcaee210559663e42f109c9d5da224713cafb7c8;p=thirdparty%2Fvala.git set accessibility for constants set return type in property set accessors 2006-09-02 Jürg Billeter * 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 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 23a5283f0..a11a70846 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,12 @@ +2006-09-02 Jürg Billeter + + * 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 * vapi/cairo.vala: mark Matrix as reference type diff --git a/vala/vala/parser.y b/vala/vala/parser.y index f19f6e9d8..eb0e9cc1f 100644 --- a/vala/vala/parser.y +++ b/vala/vala/parser.y @@ -2109,6 +2109,9 @@ constant_declaration g_object_unref (src); g_object_unref ($5); g_object_unref ($6); + if ($3 != 0) { + $$->access = $3; + } } ; diff --git a/vala/vala/valaclass.vala b/vala/vala/valaclass.vala index 66aa0ed73..49337365a 100644 --- a/vala/vala/valaclass.vala +++ b/vala/vala/valaclass.vala @@ -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; diff --git a/vala/vala/valacodegenerator.vala b/vala/vala/valacodegenerator.vala index 5b3fc6652..d70e001dc 100644 --- a/vala/vala/valacodegenerator.vala +++ b/vala/vala/valacodegenerator.vala @@ -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); + } } } diff --git a/vala/vala/valaconstant.vala b/vala/vala/valaconstant.vala index be3a9936b..08ae73d8d 100644 --- a/vala/vala/valaconstant.vala +++ b/vala/vala/valaconstant.vala @@ -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; /** diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index 242198e11..0eda76dce 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -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 (); } }