summaryrefslogtreecommitdiff
path: root/vala/valapropertyaccessor.vala
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2014-09-14 11:19:00 +0200
committerLuca Bruno <lucabru@src.gnome.org>2014-09-14 11:43:07 +0200
commit20cb52c5ac94dc2fc1a36930f341938e91025706 (patch)
treea896af4b4efd5415bd76b90575d541a3d849b06c /vala/valapropertyaccessor.vala
parent37e0fd3508c7487620406489a490d37642c2c2e4 (diff)
downloadvala-20cb52c5ac94dc2fc1a36930f341938e91025706.tar.gz
girwriter: Write accessor methods for interface properties
Fixes bug 733115
Diffstat (limited to 'vala/valapropertyaccessor.vala')
-rw-r--r--vala/valapropertyaccessor.vala29
1 files changed, 28 insertions, 1 deletions
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index 466fe6c18..057e44207 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -114,6 +114,30 @@ public class Vala.PropertyAccessor : Subroutine {
}
}
+ /**
+ * Get the method representing this property accessor
+ * @return null if the accessor is neither readable nor writable
+ */
+ public Method? get_method () {
+ Method? m = null;
+ if (readable) {
+ m = new Method ("get_"+prop.name, value_type, source_reference, comment);
+ } else if (writable) {
+ m = new Method ("set_"+prop.name, new VoidType(), source_reference, comment);
+ m.add_parameter (value_parameter.copy ());
+ }
+
+ if (m != null) {
+ m.owner = prop.owner;
+ m.access = access;
+ m.binding = prop.binding;
+ m.is_abstract = prop.is_abstract;
+ m.is_virtual = prop.is_virtual;
+ }
+
+ return m;
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -130,6 +154,10 @@ public class Vala.PropertyAccessor : Subroutine {
context.analyzer.current_symbol = this;
+ if (writable || construction) {
+ value_parameter = new Parameter ("value", value_type, source_reference);
+ }
+
if (prop.source_type == SourceFileType.SOURCE) {
if (body == null && !prop.interface_only && !prop.is_abstract) {
/* no accessor body specified, insert default body */
@@ -157,7 +185,6 @@ public class Vala.PropertyAccessor : Subroutine {
if (body != null) {
if (writable || construction) {
- value_parameter = new Parameter ("value", value_type, source_reference);
body.scope.add (value_parameter.name, value_parameter);
}