[vala] Support [CCode (delegate_target = false)] attribute for fields
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Support [CCode (delegate_target = false)] attribute for fields
- Date: Thu, 2 Apr 2009 09:00:23 -0400 (EDT)
commit cabca6bf7512088fce571d0de708c8bca6b695cd
Author: Jürg Billeter <j bitron ch>
Date: Thu Apr 2 14:58:13 2009 +0200
Support [CCode (delegate_target = false)] attribute for fields
---
gobject/valaccodeassignmentmodule.vala | 7 ++++++-
gobject/valaccodebasemodule.vala | 2 +-
vala/valafield.vala | 9 +++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gobject/valaccodeassignmentmodule.vala b/gobject/valaccodeassignmentmodule.vala
index eb2a1fd..eef4f9a 100644
--- a/gobject/valaccodeassignmentmodule.vala
+++ b/gobject/valaccodeassignmentmodule.vala
@@ -117,7 +117,12 @@ internal class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
array = (array_field == null || !array_field.no_array_length);
} else if (assignment.left.value_type is DelegateType) {
var delegate_type = (DelegateType) assignment.left.value_type;
- instance_delegate = delegate_type.delegate_symbol.has_target;
+ if (delegate_type.delegate_symbol.has_target) {
+ var delegate_field = assignment.left.symbol_reference as Field;
+ if (delegate_field == null || !delegate_field.no_delegate_target) {
+ instance_delegate = true;
+ }
+ }
}
if (unref_old || array || instance_delegate) {
diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala
index e143b04..23af714 100644
--- a/gobject/valaccodebasemodule.vala
+++ b/gobject/valaccodebasemodule.vala
@@ -3016,7 +3016,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
var rhs_array_len = head.get_array_length_cexpression (init.initializer, dim);
ccomma.append_expression (new CCodeAssignment (lhs, rhs_array_len));
}
- } else if (f.field_type is DelegateType) {
+ } else if (f.field_type is DelegateType && !f.no_delegate_target) {
if (expr.type_reference.data_type is Struct) {
lhs = new CCodeMemberAccess (typed_inst, get_delegate_target_cname (f.get_cname ()));
} else {
diff --git a/vala/valafield.vala b/vala/valafield.vala
index f43e83b..c754a33 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -70,6 +70,12 @@ public class Vala.Field : Member, Lockable {
public bool no_array_length { get; set; }
/**
+ * Specifies whether a delegate target field should implicitly be created
+ * if the field type is a delegate.
+ */
+ public bool no_delegate_target { get; set; }
+
+ /**
* Specifies whether the array is null terminated.
*/
public bool array_null_terminated { get; set; }
@@ -224,6 +230,9 @@ public class Vala.Field : Member, Lockable {
if (a.has_argument ("array_length_cexpr")) {
set_array_length_cexpr (a.get_string ("array_length_cexpr"));
}
+ if (a.has_argument ("delegate_target")) {
+ no_delegate_target = !a.get_bool ("delegate_target");
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]