}
decl_space.add_type_member_declaration (cdecl);
- if (delegate_type.value_owned && !delegate_type.is_called_once) {
+ if (delegate_type.is_disposable ()) {
cdecl = new CCodeDeclaration ("GDestroyNotify");
cdecl.add_declarator (new CCodeVariableDeclarator (get_delegate_target_destroy_notify_cname (get_ccode_name (f))));
if (f.is_private_symbol ()) {
data.add_field ("gint", get_array_size_cname (get_local_cname (local)));
} else if (local.variable_type is DelegateType && ((DelegateType) local.variable_type).delegate_symbol.has_target) {
data.add_field ("gpointer", get_delegate_target_cname (get_local_cname (local)));
- if (local.variable_type.value_owned) {
+ if (local.variable_type.is_disposable ()) {
data.add_field ("GDestroyNotify", get_delegate_target_destroy_notify_cname (get_local_cname (local)));
}
}
}
} else if (local.variable_type is DelegateType) {
var deleg_type = (DelegateType) local.variable_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
// create variable to store delegate target
var target_var = new LocalVariable (new PointerType (new VoidType ()), get_delegate_target_cname (get_local_cname (local)));
target_var.init = local.initializer == null;
emit_temp_var (target_var);
- if (deleg_type.value_owned) {
+ if (deleg_type.is_disposable ()) {
var target_destroy_notify_var = new LocalVariable (gdestroynotify_type, get_delegate_target_destroy_notify_cname (get_local_cname (local)));
target_destroy_notify_var.init = local.initializer == null;
emit_temp_var (target_destroy_notify_var);
var target_var = new LocalVariable (new PointerType (new VoidType ()), get_delegate_target_cname (local.name), null, node_reference.source_reference);
target_var.init = init;
emit_temp_var (target_var);
- if (deleg_type.value_owned) {
+ if (deleg_type.is_disposable ()) {
var target_destroy_notify_var = new LocalVariable (gdestroynotify_type.copy (), get_delegate_target_destroy_notify_cname (local.name), null, node_reference.source_reference);
target_destroy_notify_var.init = init;
emit_temp_var (target_destroy_notify_var);
if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
- var d = deleg_type.delegate_symbol;
- generate_delegate_declaration (d, decl_space);
+ generate_delegate_declaration (deleg_type.delegate_symbol, decl_space);
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
var cparam = new CCodeParameter (get_ccode_delegate_target_name (param), target_ctypename);
cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), cparam);
if (carg_map != null) {
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
if (is_in_coroutine ()) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_cname (get_local_cname (local)));
- if (local.variable_type.value_owned) {
+ if (local.variable_type.is_disposable ()) {
result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_destroy_notify_cname (get_local_cname (local)));
}
} else {
result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (get_local_cname (local)));
- if (local.variable_type.value_owned) {
+ if (local.variable_type.is_disposable ()) {
result.delegate_target_destroy_notify_cvalue = new CCodeIdentifier (get_delegate_target_destroy_notify_cname (get_local_cname (local)));
}
}
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
CCodeExpression delegate_target_destroy_notify;
var delegate_target = get_delegate_target_cexpression (arg, out delegate_target_destroy_notify);
assert (delegate_target != null);
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
temp_var = get_temp_variable (new PointerType (new VoidType ()), true, null, true);
emit_temp_var (temp_var);
set_delegate_target (arg, get_variable_cexpression (temp_var.name));
}
} else if (m != null && m.return_type is DelegateType && async_call != ccall) {
var deleg_type = (DelegateType) m.return_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
var temp_var = get_temp_variable (new PointerType (new VoidType ()));
var temp_ref = get_variable_cexpression (temp_var.name);
}
} else if (deleg != null && deleg.return_type is DelegateType) {
var deleg_type = (DelegateType) deleg.return_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
var temp_var = get_temp_variable (new PointerType (new VoidType ()));
var temp_ref = get_variable_cexpression (temp_var.name);
} else if (m.return_type is DelegateType) {
// return delegate target if appropriate
var deleg_type = (DelegateType) m.return_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
var cparam = new CCodeParameter (get_delegate_target_cname ("result"), "void**");
cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), cparam);
if (carg_map != null) {
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
+ if (deleg_type.delegate_symbol.has_target) {
// create variable to store delegate target
vardecl = new CCodeVariableDeclarator.zero ("_vala_%s".printf (get_ccode_delegate_target_name (param)), new CCodeConstant ("NULL"));
ccode.add_declaration ("void *", vardecl);
}
foreach (Parameter param in m.get_parameters ()) {
- bool is_unowned_delegate = param.variable_type is DelegateType && !param.variable_type.value_owned;
-
var param_type = param.variable_type.copy ();
param_type.value_owned = true;
data.add_field (get_ccode_name (param_type), get_variable_cname (param.name));
var deleg_type = (DelegateType) param.variable_type;
if (deleg_type.delegate_symbol.has_target) {
data.add_field ("gpointer", get_ccode_delegate_target_name (param));
- if (!is_unowned_delegate) {
+ if (deleg_type.is_disposable ()) {
data.add_field ("GDestroyNotify", get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)));
}
}