summaryrefslogtreecommitdiff
path: root/codegen
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-01-14 15:13:25 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2019-01-14 16:45:38 +0100
commitfaf85dc2a1f83dfe2112ee1b5cd7ffbe39bd4c0b (patch)
treef0b1e64e40f7d00ec3f12a272610f34cff94d126 /codegen
parent8054d88bef9916c9c95cb641e7d5a0b1baf108e0 (diff)
downloadvala-faf85dc2a1f83dfe2112ee1b5cd7ffbe39bd4c0b.tar.gz
codegen: Handle "delegate_target" as proper CCode attribute
Check if the given variable actually denotes to a delegate type which accepts a target parameter.
Diffstat (limited to 'codegen')
-rw-r--r--codegen/valaccodeattribute.vala28
1 files changed, 25 insertions, 3 deletions
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index defa260f9..ea099de46 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -524,6 +524,19 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public bool delegate_target {
+ get {
+ if (_delegate_target == null) {
+ if (ccode != null) {
+ _delegate_target = ccode.get_bool ("delegate_target", get_default_delegate_target ());
+ } else {
+ _delegate_target = get_default_delegate_target ();
+ }
+ }
+ return _delegate_target;
+ }
+ }
+
public string delegate_target_name {
get {
if (_delegate_target_name == null) {
@@ -587,7 +600,6 @@ public class Vala.CCodeAttribute : AttributeCache {
public string? array_length_type { get; private set; }
public string? array_length_name { get; private set; }
public string? array_length_expr { get; private set; }
- public bool delegate_target { get; private set; }
public string sentinel { get; private set; }
private string _name;
@@ -628,6 +640,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _finish_real_name;
private bool? _finish_instance;
private string _real_name;
+ private bool? _delegate_target;
private string _delegate_target_name;
private string _delegate_target_destroy_notify_name;
private string _ctype;
@@ -641,7 +654,6 @@ public class Vala.CCodeAttribute : AttributeCache {
this.node = node;
this.sym = node as Symbol;
- delegate_target = true;
ccode = node.get_attribute ("CCode");
if (ccode != null) {
array_length_type = ccode.get_string ("array_length_type");
@@ -650,7 +662,6 @@ public class Vala.CCodeAttribute : AttributeCache {
if (ccode.has_argument ("pos")) {
_pos = ccode.get_double ("pos");
}
- delegate_target = ccode.get_bool ("delegate_target", true);
sentinel = ccode.get_string ("sentinel");
}
if (sentinel == null) {
@@ -1444,6 +1455,17 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ private bool get_default_delegate_target () {
+ if (node is Field || node is Parameter || node is LocalVariable) {
+ unowned DelegateType? delegate_type = ((Variable) node).variable_type as DelegateType;
+ return delegate_type != null && delegate_type.delegate_symbol.has_target;
+ } else if (node is Callable) {
+ unowned DelegateType? delegate_type = ((Callable) node).return_type as DelegateType;
+ return delegate_type != null && delegate_type.delegate_symbol.has_target;
+ }
+ return false;
+ }
+
private bool get_default_array_length () {
if (node is Parameter) {
unowned Parameter param = (Parameter) node;