}
} else if (m is CreationMethod && m.parent_symbol is Struct) {
ccall.add_argument (get_this_cexpression ());
- } else if (m != null && m.get_type_parameters ().size > 0 && !get_ccode_has_generic_type_parameter (m) && !get_ccode_simple_generics (m) && (ccall != finish_call || expr.is_yield_expression)) {
+ } else if (m != null && m.has_type_parameters () && !get_ccode_has_generic_type_parameter (m) && !get_ccode_simple_generics (m) && (ccall != finish_call || expr.is_yield_expression)) {
// generic method
// don't add generic arguments for .end() calls
add_generic_type_arguments (in_arg_map, ma.get_type_arguments (), expr);
if (m != null && get_ccode_has_generic_type_parameter (m)) {
// insert type argument for macros
- if (m.get_type_parameters ().size > 0) {
+ if (m.has_type_parameters ()) {
// generic method
int type_param_index = 0;
foreach (var type_arg in ma.get_type_arguments ()) {
ccode.add_assignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (current_method.body))), "self"), ref_call);
}
- if (!current_class.is_compact && current_class.get_type_parameters ().size > 0) {
+ if (!current_class.is_compact && current_class.has_type_parameters ()) {
/* type, dup func, and destroy func fields for generic types */
var suffices = new string[] {"type", "dup_func", "destroy_func"};
foreach (TypeParameter type_param in current_class.get_type_parameters ()) {
if (current_type_symbol is Class && gobject_type != null && current_class.is_subtype_of (gobject_type)
- && current_class.get_type_parameters ().size > 0
+ && current_class.has_type_parameters ()
&& !((CreationMethod) m).chain_up) {
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, new CCodeIdentifier ("__params_it"), new CCodeIdentifier ("__params"));
ccode.open_while (ccond);
}
push_line (cl.source_reference);
- if (class_has_readable_properties (cl) || cl.get_type_parameters ().size > 0) {
+ if (class_has_readable_properties (cl) || cl.has_type_parameters ()) {
add_get_property_function (cl);
}
- if (class_has_writable_properties (cl) || cl.get_type_parameters ().size > 0) {
+ if (class_has_writable_properties (cl) || cl.has_type_parameters ()) {
add_set_property_function (cl);
}
pop_line ();
/* set property handlers */
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccall.add_argument (new CCodeIdentifier ("klass"));
- if (class_has_readable_properties (cl) || cl.get_type_parameters ().size > 0) {
+ if (class_has_readable_properties (cl) || cl.has_type_parameters ()) {
ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "get_property"), new CCodeIdentifier ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null))));
}
- if (class_has_writable_properties (cl) || cl.get_type_parameters ().size > 0) {
+ if (class_has_writable_properties (cl) || cl.has_type_parameters ()) {
ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "set_property"), new CCodeIdentifier ("_vala_%s_set_property".printf (get_ccode_lower_case_name (cl, null))));
}
}
/* only add the *Private struct if it is not empty, i.e. we actually have private data */
- if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
+ if (cl.has_private_fields || cl.has_type_parameters ()) {
decl_space.add_type_definition (instance_priv_struct);
var parent_decl = new CCodeDeclaration ("gint");
}
/* add struct for private fields */
- if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
+ if (cl.has_private_fields || cl.has_type_parameters ()) {
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_adjust_private_offset"));
ccall.add_argument (new CCodeIdentifier ("klass"));
ccall.add_argument (new CCodeIdentifier ("&%s_private_offset".printf (get_ccode_name (cl))));
}
}
- if (!cl.is_compact && (cl.has_private_fields || cl.get_type_parameters ().size > 0)) {
+ if (!cl.is_compact && (cl.has_private_fields || cl.has_type_parameters ())) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_get_instance_private".printf (get_ccode_lower_case_name (cl, null))));
ccall.add_argument (new CCodeIdentifier ("self"));
func.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), ccall);
get_type_interface_init_statements (context, type_init, plugin);
}
- if (cl != null && (cl.has_private_fields || cl.get_type_parameters ().size > 0)) {
+ if (cl != null && (cl.has_private_fields || cl.has_type_parameters ())) {
if (!plugin) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_instance_private"));
ccall.add_argument (new CCodeIdentifier (type_id_name));
return type_parameters;
}
+ public bool has_type_parameters () {
+ return (type_parameters != null && type_parameters.size > 0);
+ }
+
public override int get_type_parameter_index (string name) {
int i = 0;
foreach (TypeParameter parameter in type_parameters) {
// instance type might be a subtype of the parent symbol of the member
// that subtype might not be generic, so do not report an error in that case
var object_type = instance_type as ObjectType;
- if (object_type != null && object_type.type_symbol.get_type_parameters ().size > 0 &&
- instance_type.get_type_arguments ().size == 0) {
+ if (object_type != null && object_type.type_symbol.has_type_parameters ()
+ && !instance_type.has_type_arguments ()) {
error = true;
Report.error (inner.source_reference, "missing generic type arguments");
return false;
}
List<DataType> method_type_args = null;
- if (this.get_type_parameters ().size > 0) {
+ if (this.has_type_parameters ()) {
method_type_args = new ArrayList<DataType> ();
foreach (TypeParameter type_parameter in this.get_type_parameters ()) {
var type_arg = new GenericType (type_parameter);
return -1;
}
+ public bool has_type_parameters () {
+ return (type_parameters != null && type_parameters.size > 0);
+ }
+
/**
* Adds a precondition to this method.
*
dynamic_sig.handler.target_type = new DelegateType (dynamic_sig.get_delegate (new ObjectType ((ObjectTypeSymbol) dynamic_sig.parent_symbol), this));
}
- if (m != null && m.get_type_parameters ().size > 0) {
+ if (m != null && m.has_type_parameters ()) {
var ma = (MemberAccess) call;
if (ma.get_type_arguments ().size == 0) {
// infer type arguments
return type_parameters;
}
+ public bool has_type_parameters () {
+ return (type_parameters != null && type_parameters.size > 0);
+ }
+
public override int get_type_parameter_index (string name) {
int i = 0;
foreach (TypeParameter parameter in type_parameters) {
var result = new DelegateType (signal_symbol.get_delegate (sender_type, this));
result.value_owned = true;
- if (result.delegate_symbol.get_type_parameters ().size > 0) {
+ if (result.delegate_symbol.has_type_parameters ()) {
foreach (var type_param in type_sym.get_type_parameters ()) {
var type_arg = new GenericType (type_param);
type_arg.value_owned = true;