// async method is suspended while waiting for callback,
// so we never need to care about memory management of async data
- ccode.add_assignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (block_id)), "_async_data_"), new CCodeIdentifier ("data"));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (block_id)), "_async_data_"), new CCodeIdentifier ("_data_"));
}
} else if (b.parent_symbol is PropertyAccessor) {
var acc = (PropertyAccessor) b.parent_symbol;
public CCodeExpression get_variable_cexpression (string name) {
if (is_in_coroutine ()) {
- return new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_variable_cname (name));
+ return new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_variable_cname (name));
} else {
return new CCodeIdentifier (get_variable_cname (name));
}
public CCodeExpression get_result_cexpression (string cname = "result") {
if (is_in_coroutine ()) {
- return new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), cname);
+ return new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), cname);
} else {
return new CCodeIdentifier (cname);
}
CCodeExpression this_access;
if (is_in_coroutine ()) {
// use closure
- this_access = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self");
+ this_access = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "self");
} else {
this_access = new CCodeIdentifier ("self");
}
var block = ((Method) m.parent_symbol).body;
set_delegate_target (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), "_async_data_"));
} else {
- set_delegate_target (expr, new CCodeIdentifier ("data"));
+ set_delegate_target (expr, new CCodeIdentifier ("_data_"));
}
} else if (expr.inner != null) {
// expr.inner is null in the special case of referencing the method in a constant initializer
}
} 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_variable_cname (local.name)));
+ result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_cname (get_variable_cname (local.name)));
if (local.variable_type.value_owned) {
- result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
+ result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
}
} else {
result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (get_variable_cname (local.name)));
if (param.name == "this") {
if (is_in_coroutine ()) {
// use closure
- result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self");
+ result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "self");
} else {
var st = result.value_type.data_type as Struct;
if (st != null && !st.is_simple_type ()) {
// use closure
result.cvalue = get_variable_cexpression (param.name);
if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
- result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_cname (get_variable_cname (param.name)));
+ result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_cname (get_variable_cname (param.name)));
if (delegate_type.value_owned) {
- result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)));
+ result.delegate_target_destroy_notify_cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)));
}
}
} else {
// output arguments used separately
out_arg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
// pass GAsyncResult stored in closure to finish function
- out_arg_map.set (get_param_pos (0.1), new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_res_"));
+ out_arg_map.set (get_param_pos (0.1), new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_res_"));
}
}
var block = ((Method) m.parent_symbol).body;
instance = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), "_async_data_");
} else {
- instance = new CCodeIdentifier ("data");
+ instance = new CCodeIdentifier ("_data_");
}
in_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
if (expr.is_yield_expression) {
// asynchronous call
in_arg_map.set (get_param_pos (-1), new CCodeIdentifier (generate_ready_function (current_method)));
- in_arg_map.set (get_param_pos (-0.9), new CCodeIdentifier ("data"));
+ in_arg_map.set (get_param_pos (-0.9), new CCodeIdentifier ("_data_"));
}
}
// set state before calling async function to support immediate callbacks
int state = next_coroutine_state++;
- ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_state_"), new CCodeConstant (state.to_string ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_state_"), new CCodeConstant (state.to_string ()));
ccode.add_expression (async_call);
ccode.add_return (new CCodeConstant ("FALSE"));
ccode.add_label ("_state_%d".printf (state));
}
public void complete_async () {
- var state = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_state_");
+ var state = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_state_");
var zero = new CCodeConstant ("0");
var state_is_zero = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, state, zero);
ccode.open_if (state_is_zero);
- var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_async_result");
+ var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_async_result");
var idle_call = new CCodeFunctionCall (new CCodeIdentifier ("g_simple_async_result_complete_in_idle"));
idle_call.add_argument (async_result_expr);
function = new CCodeFunction (m.get_real_cname () + "_co", "gboolean");
// data struct to hold parameters, local variables, and the return value
- function.add_parameter (new CCodeParameter ("data", Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data*"));
+ function.add_parameter (new CCodeParameter ("_data_", Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data*"));
function.modifiers |= CCodeModifiers.STATIC;
cfile.add_function_declaration (function);
if (!m.is_abstract || (m.is_abstract && current_type_symbol is Class)) {
if (m.body != null) {
if (m.coroutine) {
- ccode.open_switch (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_state_"));
+ ccode.open_switch (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_state_"));
// initial coroutine state
ccode.add_case (new CCodeConstant ("0"));
push_context (new EmitContext (m));
push_function (freefunc);
- ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("data", new CCodeIdentifier ("_data")));
+ ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_data_", new CCodeIdentifier ("_data")));
foreach (Parameter param in m.get_parameters ()) {
if (param.direction != ParameterDirection.OUT) {
var freecall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
freecall.add_argument (new CCodeIdentifier (dataname));
- freecall.add_argument (new CCodeIdentifier ("data"));
+ freecall.add_argument (new CCodeIdentifier ("_data_"));
ccode.add_expression (freecall);
pop_context ();
push_function (readyfunc);
- ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("data"));
- ccode.add_assignment (new CCodeIdentifier ("data"), new CCodeIdentifier ("_user_data_"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_source_object_"), new CCodeIdentifier ("source_object"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_res_"), new CCodeIdentifier ("_res_"));
+ ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_data_"));
+ ccode.add_assignment (new CCodeIdentifier ("_data_"), new CCodeIdentifier ("_user_data_"));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_source_object_"), new CCodeIdentifier ("source_object"));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_res_"), new CCodeIdentifier ("_res_"));
var ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname () + "_co"));
- ccall.add_argument (new CCodeIdentifier ("data"));
+ ccall.add_argument (new CCodeIdentifier ("_data_"));
ccode.add_expression (ccall);
readyfunc.modifiers |= CCodeModifiers.STATIC;
if (stmt.yield_expression == null) {
int state = next_coroutine_state++;
- ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_state_"), new CCodeConstant (state.to_string ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_state_"), new CCodeConstant (state.to_string ()));
ccode.add_return (new CCodeConstant ("FALSE"));
ccode.add_label ("_state_%d".printf (state));
ccode.add_statement (new CCodeEmptyStatement ());
}
var set_error = new CCodeFunctionCall (new CCodeIdentifier ("g_simple_async_result_set_from_error"));
- set_error.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_async_result"));
+ set_error.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_async_result"));
set_error.add_argument (error_expr);
ccode.add_expression (set_error);
if (expr.is_yield_expression) {
// asynchronous call
ccall.add_argument (new CCodeIdentifier (generate_ready_function (current_method)));
- ccall.add_argument (new CCodeIdentifier ("data"));
+ ccall.add_argument (new CCodeIdentifier ("_data_"));
} else {
// begin
Expression callback = args.get (base_arg_index + 4);
if (expr.is_yield_expression) {
int state = next_coroutine_state++;
- ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_state_"), new CCodeConstant (state.to_string ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_state_"), new CCodeConstant (state.to_string ()));
ccode.add_expression (ccall);
ccode.add_return (new CCodeConstant ("FALSE"));
ccode.add_label ("_state_%d".printf (state));
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_async_initable_new_finish"));
- ccall.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_source_object_"));
+ ccall.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_source_object_"));
// pass GAsyncResult stored in closure to finish function
- ccall.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_res_"));
+ ccall.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_res_"));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression ("_inner_error_")));
} else {
// begin