vala r977 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r977 - in trunk: . gobject vala
- Date: Tue, 5 Feb 2008 20:05:00 +0000 (GMT)
Author: juergbi
Date: Tue Feb 5 20:05:00 2008
New Revision: 977
URL: http://svn.gnome.org/viewvc/vala?rev=977&view=rev
Log:
2008-02-05 Juerg Billeter <j bitron ch>
* vala/parser.y, vala/valaexpression.vala,
vala/valapropertyaccessor.vala, vala/valasemanticanalyzer.vala,
gobject/valaccodegenerator.vala: add support for private property
accessors
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/vala/parser.y
trunk/vala/valaexpression.vala
trunk/vala/valapropertyaccessor.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Tue Feb 5 20:05:00 2008
@@ -601,7 +601,7 @@
function.add_parameter (cvalueparam);
}
- if (!prop.is_internal_symbol () && (acc.readable || acc.writable)) {
+ if (!prop.is_internal_symbol () && (acc.readable || acc.writable) && acc.access != SymbolAccessibility.PRIVATE) {
// accessor function should be public if the property is a public symbol and it's not a construct-only setter
header_type_member_declaration.append (function.copy ());
} else {
@@ -697,7 +697,7 @@
}
if (!is_virtual) {
- if (!prop.is_internal_symbol () && (acc.readable || acc.writable)) {
+ if (!prop.is_internal_symbol () && (acc.readable || acc.writable) && acc.access != SymbolAccessibility.PRIVATE) {
// accessor function should be public if the property is a public symbol and it's not a construct-only setter
header_type_member_declaration.append (function.copy ());
} else {
Modified: trunk/vala/parser.y
==============================================================================
--- trunk/vala/parser.y (original)
+++ trunk/vala/parser.y Tue Feb 5 20:05:00 2008
@@ -2648,7 +2648,7 @@
}
VALA_CODE_NODE (current_symbol)->attributes = $2;
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL (current_symbol), $3);
}
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) {
@@ -2706,7 +2706,7 @@
opt_access_modifier
: /* empty */
{
- $$ = 0;
+ $$ = -1;
}
| access_modifier
;
@@ -2883,7 +2883,7 @@
g_object_unref (src);
g_object_unref ($5);
g_object_unref ($6);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
VALA_CODE_NODE($$)->attributes = $2;
@@ -2908,7 +2908,7 @@
$$ = vala_code_context_create_field (context, vala_symbol_get_name (VALA_SYMBOL ($6)), $5, vala_variable_declarator_get_initializer ($6), src);
g_object_unref (src);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
@@ -3060,7 +3060,7 @@
$$ = vala_code_context_create_method (context, $6, $5, src);
g_object_unref (src);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
@@ -3133,7 +3133,7 @@
g_free ($6);
g_object_unref (src);
vala_method_set_instance ($$, FALSE);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
VALA_CODE_NODE($$)->attributes = $2;
@@ -3345,7 +3345,9 @@
VALA_CODE_NODE($$)->attributes = $2;
- vala_symbol_set_access (VALA_SYMBOL ($$), $3);
+ if ($3 != -1) {
+ vala_symbol_set_access (VALA_SYMBOL ($$), $3);
+ }
g_object_unref ($5);
g_free ($6);
@@ -3381,7 +3383,9 @@
VALA_CODE_NODE($$)->attributes = $2;
- vala_symbol_set_access (VALA_SYMBOL ($$), $3);
+ if ($3 != -1) {
+ vala_symbol_set_access (VALA_SYMBOL ($$), $3);
+ }
g_object_unref ($5);
g_free ($6);
@@ -3414,14 +3418,19 @@
;
get_accessor_declaration
- : opt_attributes GET method_body
+ : opt_attributes opt_access_modifier GET method_body
{
- ValaSourceReference *src = src(@2);
- $$ = vala_code_context_create_property_accessor (context, TRUE, FALSE, FALSE, $3, src);
+ ValaSourceReference *src = src(@3);
+ $$ = vala_code_context_create_property_accessor (context, TRUE, FALSE, FALSE, $4, src);
g_object_unref (src);
+ if ($4 != NULL) {
+ g_object_unref ($4);
+ }
- if ($3 != NULL) {
- g_object_unref ($3);
+ if ($2 != -1) {
+ vala_property_accessor_set_access ($$, $2);
+ } else {
+ vala_property_accessor_set_access ($$, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
}
}
;
@@ -3435,41 +3444,65 @@
;
set_accessor_declaration
- : opt_attributes SET method_body
+ : opt_attributes opt_access_modifier SET method_body
{
- ValaSourceReference *src = src(@2);
- $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, FALSE, $3, src);
- g_object_unref (src);
- if ($3 != NULL) {
- g_object_unref ($3);
- }
- }
- | opt_attributes SET CONSTRUCT method_body
- {
- ValaSourceReference *src = src(@2);
- $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, TRUE, $4, src);
+ ValaSourceReference *src = src(@3);
+ $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, FALSE, $4, src);
g_object_unref (src);
if ($4 != NULL) {
g_object_unref ($4);
}
+
+ if ($2 != -1) {
+ vala_property_accessor_set_access ($$, $2);
+ } else {
+ vala_property_accessor_set_access ($$, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
+ }
}
- | opt_attributes CONSTRUCT method_body
+ | opt_attributes opt_access_modifier SET CONSTRUCT method_body
{
- ValaSourceReference *src = src(@2);
- $$ = vala_code_context_create_property_accessor (context, FALSE, FALSE, TRUE, $3, src);
+ ValaSourceReference *src = src(@3);
+ $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, TRUE, $5, src);
g_object_unref (src);
- if ($3 != NULL) {
- g_object_unref ($3);
+ if ($5 != NULL) {
+ g_object_unref ($5);
+ }
+
+ if ($2 != -1) {
+ vala_property_accessor_set_access ($$, $2);
+ } else {
+ vala_property_accessor_set_access ($$, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
}
}
- | opt_attributes CONSTRUCT SET method_body
+ | opt_attributes opt_access_modifier CONSTRUCT method_body
{
- ValaSourceReference *src = src(@2);
- $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, TRUE, $4, src);
+ ValaSourceReference *src = src(@3);
+ $$ = vala_code_context_create_property_accessor (context, FALSE, FALSE, TRUE, $4, src);
g_object_unref (src);
if ($4 != NULL) {
g_object_unref ($4);
}
+
+ if ($2 != -1) {
+ vala_property_accessor_set_access ($$, $2);
+ } else {
+ vala_property_accessor_set_access ($$, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
+ }
+ }
+ | opt_attributes opt_access_modifier CONSTRUCT SET method_body
+ {
+ ValaSourceReference *src = src(@3);
+ $$ = vala_code_context_create_property_accessor (context, FALSE, TRUE, TRUE, $5, src);
+ g_object_unref (src);
+ if ($5 != NULL) {
+ g_object_unref ($5);
+ }
+
+ if ($2 != -1) {
+ vala_property_accessor_set_access ($$, $2);
+ } else {
+ vala_property_accessor_set_access ($$, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
+ }
}
;
@@ -3481,7 +3514,7 @@
ValaSourceReference *src = src_com(@6, $1);
$$ = vala_code_context_create_signal (context, $6, $5, src);
g_object_unref (src);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
VALA_CODE_NODE($$)->attributes = $2;
@@ -3580,7 +3613,7 @@
vala_struct_add_type_parameter (VALA_STRUCT (current_symbol), l->data);
}
VALA_CODE_NODE(current_symbol)->attributes = $2;
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL (current_symbol), $3);
}
if ($8 != NULL) {
@@ -3690,7 +3723,7 @@
g_object_unref (parent_symbol);
VALA_CODE_NODE (iface)->attributes = $2;
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL (iface), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
@@ -3818,7 +3851,7 @@
VALA_CODE_NODE (en)->attributes = $2;
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL (en), $3);
}
@@ -3925,7 +3958,7 @@
vala_source_file_add_node (current_source_file, VALA_CODE_NODE (cb));
g_object_unref (parent_symbol);
- if ($3 != 0) {
+ if ($3 != -1) {
vala_symbol_set_access (VALA_SYMBOL (cb), $3);
}
VALA_CODE_NODE (cb)->attributes = $2;
Modified: trunk/vala/valaexpression.vala
==============================================================================
--- trunk/vala/valaexpression.vala (original)
+++ trunk/vala/valaexpression.vala Tue Feb 5 20:05:00 2008
@@ -1,6 +1,6 @@
/* valaexpression.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter
+ * Copyright (C) 2006-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -73,6 +73,12 @@
public bool can_fail { get; set; }
/**
+ * Specifies that this expression is used as lvalue, i.e. the
+ * left hand side of an assignment.
+ */
+ public bool lvalue { get; set; }
+
+ /**
* Contains all temporary variables this expression requires for
* execution.
*
Modified: trunk/vala/valapropertyaccessor.vala
==============================================================================
--- trunk/vala/valapropertyaccessor.vala (original)
+++ trunk/vala/valapropertyaccessor.vala Tue Feb 5 20:05:00 2008
@@ -46,7 +46,12 @@
* property.
*/
public bool construction { get; set; }
-
+
+ /**
+ * Specifies the accessibility of this property accessor.
+ */
+ public SymbolAccessibility access { get; set; }
+
/**
* The accessor body.
*/
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Tue Feb 5 20:05:00 2008
@@ -1485,7 +1485,36 @@
var m = (Method) member;
access = m.access;
instance = m.instance;
- } else if (member is Property || member is Signal) {
+ } else if (member is Property) {
+ var prop = (Property) member;
+ access = prop.access;
+ if (expr.lvalue) {
+ if (prop.set_accessor == null) {
+ expr.error = true;
+ Report.error (expr.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ()));
+ return;
+ }
+ if (prop.access == SymbolAccessibility.PUBLIC) {
+ access = prop.set_accessor.access;
+ } else if (prop.access == SymbolAccessibility.PROTECTED
+ && prop.set_accessor.access != SymbolAccessibility.PUBLIC) {
+ access = prop.set_accessor.access;
+ }
+ } else {
+ if (prop.get_accessor == null) {
+ expr.error = true;
+ Report.error (expr.source_reference, "Property `%s' is write-only".printf (prop.get_full_name ()));
+ return;
+ }
+ if (prop.access == SymbolAccessibility.PUBLIC) {
+ access = prop.get_accessor.access;
+ } else if (prop.access == SymbolAccessibility.PROTECTED
+ && prop.get_accessor.access != SymbolAccessibility.PUBLIC) {
+ access = prop.get_accessor.access;
+ }
+ }
+ instance = prop.instance;
+ } else if (member is Signal) {
instance = true;
}
@@ -2632,6 +2661,8 @@
}
public override void visit_assignment (Assignment! a) {
+ a.left.lvalue = true;
+
a.left.accept (this);
if (a.left.error) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]