// logic in this method is temporarily duplicated in destroy_value
// apply changes to both methods
public virtual CCodeExpression destroy_variable (Variable variable, TargetValue target_lvalue) {
- var type = variable.variable_type;
+ var type = target_lvalue.value_type;
var cvar = get_cvalue_ (target_lvalue);
if (type is DelegateType) {
/* Returns lvalue access to the given field */
public override TargetValue get_field_cvalue (Field field, TargetValue? instance) {
- var result = new GLibValue (field.variable_type.copy ());
+ var value_type = field.variable_type.copy ();
+ if (instance != null) {
+ value_type = value_type.get_actual_type (instance.value_type, null, field);
+ }
+
+ var result = new GLibValue (value_type);
- var array_type = field.variable_type as ArrayType;
- var delegate_type = field.variable_type as DelegateType;
+ var array_type = result.value_type as ArrayType;
+ var delegate_type = result.value_type as DelegateType;
if (field.binding == MemberBinding.INSTANCE) {
CCodeExpression pub_inst = null;
if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (inst, target_cname);
- if (field.variable_type.value_owned) {
+ if (result.value_type.value_owned) {
result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (inst, target_destroy_notify_cname);
}
} else {
result.delegate_target_cvalue = new CCodeMemberAccess (inst, target_cname);
- if (field.variable_type.value_owned) {
+ if (result.value_type.value_owned) {
result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess (inst, target_destroy_notify_cname);
}
}
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target && !field.no_delegate_target) {
result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (field.get_cname ()));
- if (field.variable_type.value_owned) {
+ if (result.value_type.value_owned) {
result.delegate_target_destroy_notify_cvalue = new CCodeIdentifier (get_delegate_target_destroy_notify_cname (field.get_cname ()));
}
}