From: Luca Bruno Date: Tue, 28 Jun 2011 08:06:44 +0000 (+0200) Subject: codegen: Rename coroutine data variable to _data_ X-Git-Tag: 0.13.1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f03035d391316bdb3be82cc29d18ebeaeb2907e3;p=thirdparty%2Fvala.git codegen: Rename coroutine data variable to _data_ --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 65010e107..84d7b3024 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -1807,7 +1807,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { // 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; @@ -1988,7 +1988,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { 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)); } @@ -2014,7 +2014,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { 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); } @@ -3588,7 +3588,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { 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"); } diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala index 4387a327d..e3f7f29bd 100644 --- a/codegen/valaccodememberaccessmodule.vala +++ b/codegen/valaccodememberaccessmodule.vala @@ -100,7 +100,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { 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 @@ -379,9 +379,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { } } 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))); @@ -415,7 +415,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { 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 ()) { @@ -448,9 +448,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { // 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 { diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 845d928a4..ddfb4fc7e 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -115,7 +115,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { // output arguments used separately out_arg_map = new HashMap (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_")); } } @@ -172,7 +172,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { 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); @@ -578,7 +578,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { 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_")); } } @@ -676,7 +676,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { // 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)); diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index ea78b5323..edda88dec 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -125,12 +125,12 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } 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); @@ -331,7 +331,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { 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); @@ -350,7 +350,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { 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")); diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala index 80c284eb1..9128fdd94 100644 --- a/codegen/valagasyncmodule.vala +++ b/codegen/valagasyncmodule.vala @@ -97,7 +97,7 @@ public class Vala.GAsyncModule : GSignalModule { 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) { @@ -136,7 +136,7 @@ public class Vala.GAsyncModule : GSignalModule { 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 (); @@ -488,13 +488,13 @@ public class Vala.GAsyncModule : GSignalModule { 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; @@ -552,7 +552,7 @@ public class Vala.GAsyncModule : GSignalModule { 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 ()); @@ -590,7 +590,7 @@ public class Vala.GAsyncModule : GSignalModule { } 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); diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala index c8ee1938a..4f48750a5 100644 --- a/codegen/valagdbusclientmodule.vala +++ b/codegen/valagdbusclientmodule.vala @@ -319,7 +319,7 @@ public class Vala.GDBusClientModule : GDBusModule { 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); @@ -356,15 +356,15 @@ public class Vala.GDBusClientModule : GDBusModule { 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