public override void generate_cparameters(Method m, CCodeFile decl_space, Dictionary <int, CCodeParameter> cparam_map, CCodeFunction func, CCodeFunctionDeclarator vdeclarator = null, Dictionary <int, CCodeExpression> carg_map = null, CCodeFunctionCall vcall = null, int direction = 3) { if (m.coroutine) { decl_space.add_include("gio/gio.h"); if (direction == 1) { cparam_map[get_param_pos(-1)] = new CCodeParameter("_callback_", "GAsyncReadyCallback"); cparam_map[get_param_pos(-0.9)] = new CCodeParameter("_user_data_", "gpointer"); if (carg_map != null) { carg_map[get_param_pos(-1)] = new CCodeIdentifier("_callback_"); carg_map[get_param_pos(-0.9)] = new CCodeIdentifier("_user_data_"); } } else if (direction == 2) { cparam_map[get_param_pos(0.1)] = new CCodeParameter("_res_", "GAsyncResult*"); if (carg_map != null) { carg_map[get_param_pos(0.1)] = new CCodeIdentifier("_res_"); } } } base.generate_cparameters(m, decl_space, cparam_map, func, vdeclarator, carg_map, vcall, direction); }
public override void generate_struct_declaration(Struct st, CCodeFile decl_space) { if (add_symbol_declaration(decl_space, st, get_ccode_name(st))) { return; } if (st.is_boolean_type() || st.is_integer_type() || st.is_floating_type()) { if (st.base_struct != null) { generate_struct_declaration(st.base_struct, decl_space); decl_space.add_type_declaration(new CCodeTypeDefinition(get_ccode_name(st.base_struct), new CCodeVariableDeclarator(get_ccode_name(st)))); } else { string typename = null; if (st.is_boolean_type()) { // typedef for boolean types decl_space.add_include("stdbool.h"); typename = "bool"; } else if (st.is_integer_type()) { // typedef for integral types decl_space.add_include("stdint.h"); typename = "%sint%d_t".printf(st.signed ? "" : "u", st.width); } else if (st.is_floating_type()) { // typedef for floating types typename = (st.width == 64 ? "double" : "float"); } decl_space.add_type_declaration(new CCodeTypeDefinition(typename, new CCodeVariableDeclarator(get_ccode_name(st)))); } return; } if (get_ccode_has_type_id(st)) { decl_space.add_include("glib-object.h"); decl_space.add_type_declaration(new CCodeNewline()); var macro = "(%s_get_type ())".printf(get_ccode_lower_case_name(st, null)); decl_space.add_type_declaration(new CCodeMacroReplacement(get_ccode_type_id(st), macro)); var type_fun = new StructRegisterFunction(st, context); type_fun.init_from_type(false, true); decl_space.add_type_member_declaration(type_fun.get_declaration()); } var instance_struct = new CCodeStruct("_%s".printf(get_ccode_name(st))); instance_struct.modifiers |= (st.version.deprecated ? CCodeModifiers.DEPRECATED : 0); foreach (Field f in st.get_fields()) { if (f.binding == MemberBinding.INSTANCE) { generate_type_declaration(f.variable_type, decl_space); CCodeModifiers modifiers = (f.is_volatile ? CCodeModifiers.VOLATILE : 0) | (f.version.deprecated ? CCodeModifiers.DEPRECATED : 0); instance_struct.add_field(get_ccode_name(f.variable_type), get_ccode_name(f), modifiers, get_ccode_declarator_suffix(f.variable_type)); if (f.variable_type is ArrayType && get_ccode_array_length(f)) { // create fields to store array dimensions var array_type = (ArrayType)f.variable_type; if (!array_type.fixed_length) { var len_type = int_type.copy(); for (int dim = 1; dim <= array_type.rank; dim++) { string length_cname; if (get_ccode_array_length_name(f) != null) { length_cname = get_ccode_array_length_name(f); } else { length_cname = get_array_length_cname(get_ccode_name(f), dim); } instance_struct.add_field(get_ccode_name(len_type), length_cname); } if (array_type.rank == 1 && f.is_internal_symbol()) { instance_struct.add_field(get_ccode_name(len_type), get_array_size_cname(get_ccode_name(f))); } } } else if (f.variable_type is DelegateType) { var delegate_type = (DelegateType)f.variable_type; if (delegate_type.delegate_symbol.has_target) { // create field to store delegate target instance_struct.add_field("gpointer", get_ccode_delegate_target_name(f)); if (delegate_type.is_disposable()) { instance_struct.add_field("GDestroyNotify", get_delegate_target_destroy_notify_cname(get_ccode_name(f))); } } } } } if (st.base_struct == null) { decl_space.add_type_declaration(new CCodeTypeDefinition("struct _%s".printf(get_ccode_name(st)), new CCodeVariableDeclarator(get_ccode_name(st)))); decl_space.add_type_definition(instance_struct); } else { decl_space.add_type_declaration(new CCodeTypeDefinition(get_ccode_name(st.base_struct), new CCodeVariableDeclarator(get_ccode_name(st)))); } var function = new CCodeFunction(get_ccode_dup_function(st), get_ccode_name(st) + "*"); if (st.is_private_symbol()) { function.modifiers = CCodeModifiers.STATIC; } else if (context.hide_internal && st.is_internal_symbol()) { function.modifiers = CCodeModifiers.INTERNAL; } function.add_parameter(new CCodeParameter("self", "const " + get_ccode_name(st) + "*")); decl_space.add_function_declaration(function); function = new CCodeFunction(get_ccode_free_function(st), "void"); if (st.is_private_symbol()) { function.modifiers = CCodeModifiers.STATIC; } else if (context.hide_internal && st.is_internal_symbol()) { function.modifiers = CCodeModifiers.INTERNAL; } function.add_parameter(new CCodeParameter("self", get_ccode_name(st) + "*")); decl_space.add_function_declaration(function); if (st.is_disposable()) { function = new CCodeFunction(get_ccode_copy_function(st), "void"); if (st.is_private_symbol()) { function.modifiers = CCodeModifiers.STATIC; } else if (context.hide_internal && st.is_internal_symbol()) { function.modifiers = CCodeModifiers.INTERNAL; } function.add_parameter(new CCodeParameter("self", "const " + get_ccode_name(st) + "*")); function.add_parameter(new CCodeParameter("dest", get_ccode_name(st) + "*")); decl_space.add_function_declaration(function); function = new CCodeFunction(get_ccode_destroy_function(st), "void"); if (st.is_private_symbol()) { function.modifiers = CCodeModifiers.STATIC; } else if (context.hide_internal && st.is_internal_symbol()) { function.modifiers = CCodeModifiers.INTERNAL; } function.add_parameter(new CCodeParameter("self", get_ccode_name(st) + "*")); decl_space.add_function_declaration(function); } }