[vala] dova: Support public and protected instance fields in classes
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] dova: Support public and protected instance fields in classes
- Date: Tue, 13 Jul 2010 20:30:07 +0000 (UTC)
commit 5ad2f429e21e86853b01fb3391d98c579a6a9379
Author: Jürg Billeter <j bitron ch>
Date: Tue Jul 13 22:26:05 2010 +0200
dova: Support public and protected instance fields in classes
Internally handled as properties to avoid ABI issues.
Fixes bug 623503.
vala/valaclass.vala | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 1b675da..b22b009 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -285,6 +285,32 @@ public class Vala.Class : ObjectTypeSymbol {
* @param f a field
*/
public void add_field (Field f) {
+ if (CodeContext.get ().profile == Profile.DOVA &&
+ f.binding == MemberBinding.INSTANCE &&
+ (f.access == SymbolAccessibility.PUBLIC || f.access == SymbolAccessibility.PROTECTED) &&
+ name != "string" /* temporary workaround */) {
+ // public/protected instance fields not supported, convert to automatic property
+
+ var prop = new Property (f.name, f.field_type.copy (), null, null, f.source_reference, comment);
+ prop.access = access;
+
+ var get_type = prop.property_type.copy ();
+ get_type.value_owned = true;
+
+ prop.get_accessor = new PropertyAccessor (true, false, false, get_type, null, f.source_reference);
+ prop.get_accessor.access = SymbolAccessibility.PUBLIC;
+
+ prop.set_accessor = new PropertyAccessor (false, true, false, prop.property_type.copy (), null, f.source_reference);
+ prop.set_accessor.access = SymbolAccessibility.PUBLIC;
+
+ f.name = "_%s".printf (f.name);
+ f.access = SymbolAccessibility.PRIVATE;
+ prop.field = f;
+
+ add_property (prop);
+ return;
+ }
+
fields.add (f);
if (f.access == SymbolAccessibility.PRIVATE && f.binding == MemberBinding.INSTANCE) {
has_private_fields = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]