return "valavoid";
} else {
unowned DataType type = (DataType) node;
- return get_ccode_lower_case_name (type.data_type, infix);
+ return get_ccode_lower_case_name (type.type_symbol, infix);
}
}
}
public static bool is_ref_function_void (DataType type) {
- unowned Class? cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null) {
return get_ccode_ref_function_void (cl);
} else {
}
public static bool is_free_function_address_of (DataType type) {
- unowned Class? cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null) {
return get_ccode_free_function_address_of (cl);
} else {
}
// add extra item to have array NULL-terminated for all reference types
- if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
+ if (expr.element_type.type_symbol != null && expr.element_type.type_symbol.is_reference_type ()) {
cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cexpr, new CCodeConstant ("1"));
}
CCodeExpression length_expr = new CCodeIdentifier ("length");
// add extra item to have array NULL-terminated for all reference types
- if (array_type.element_type.data_type != null && array_type.element_type.data_type.is_reference_type ()) {
+ if (array_type.element_type.type_symbol != null && array_type.element_type.type_symbol.is_reference_type ()) {
length_expr = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, length_expr, new CCodeConstant ("1"));
}
gnew.add_argument (length_expr);
}
} else if (node is PointerType) {
var type = (PointerType) node;
- if (type.base_type.data_type != null && type.base_type.data_type.is_reference_type ()) {
+ if (type.base_type.type_symbol != null && type.base_type.type_symbol.is_reference_type ()) {
return get_ccode_name (type.base_type);
} else {
return "%s*".printf (get_ccode_name (type.base_type));
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var ref_func = get_ccode_ref_function ((ObjectTypeSymbol) prereq.data_type);
+ string ref_func = get_ccode_ref_function ((ObjectTypeSymbol) prereq.type_symbol);
if (ref_func != null) {
return ref_func;
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- string unref_func = get_ccode_unref_function ((ObjectTypeSymbol) prereq.data_type);
+ string unref_func = get_ccode_unref_function ((ObjectTypeSymbol) prereq.type_symbol);
if (unref_func != null) {
return unref_func;
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- string ref_sink_func = get_ccode_ref_sink_function ((ObjectTypeSymbol) prereq.data_type);
+ string ref_sink_func = get_ccode_ref_sink_function ((ObjectTypeSymbol) prereq.type_symbol);
if (ref_sink_func != "") {
return ref_sink_func;
}
} else {
return "G_TYPE_POINTER";
}
- } else if (node is ArrayType && ((ArrayType) node).element_type.data_type.get_full_name () == "string") {
+ } else if (node is ArrayType && ((ArrayType) node).element_type.type_symbol.get_full_name () == "string") {
return "G_TYPE_STRV";
} else if (node is PointerType || node is DelegateType) {
return "G_TYPE_POINTER";
return "G_TYPE_NONE";
} else {
var type = (DataType) node;
- if (type.data_type != null) {
- return get_ccode_type_id (type.data_type);
+ if (type.type_symbol != null) {
+ return get_ccode_type_id (type.type_symbol);
}
}
return "";
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var type_name = get_ccode_marshaller_type_name (prereq.data_type);
+ var type_name = get_ccode_marshaller_type_name (prereq.type_symbol);
if (type_name != "") {
return type_name;
}
return "POINTER";
} else if (node is ArrayType) {
unowned ArrayType array_type = (ArrayType) node;
- if (array_type.element_type.data_type.get_full_name () == "string") {
- return "BOXED,%s".printf (get_ccode_marshaller_type_name (array_type.length_type.data_type));
+ if (array_type.element_type.type_symbol.get_full_name () == "string") {
+ return "BOXED,%s".printf (get_ccode_marshaller_type_name (array_type.length_type.type_symbol));
} else {
var ret = "POINTER";
- var length_marshaller_type_name = get_ccode_marshaller_type_name (array_type.length_type.data_type);
+ var length_marshaller_type_name = get_ccode_marshaller_type_name (array_type.length_type.type_symbol);
for (var i = 0; i < array_type.rank; i++) {
ret = "%s,%s".printf (ret, length_marshaller_type_name);
}
} else if (node is VoidType) {
return "VOID";
} else {
- return get_ccode_marshaller_type_name (((DataType) node).data_type);
+ return get_ccode_marshaller_type_name (((DataType) node).type_symbol);
}
return "";
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var type_name = get_ccode_get_value_function (prereq.data_type);
+ var type_name = get_ccode_get_value_function (prereq.type_symbol);
if (type_name != "") {
return type_name;
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var type_name = get_ccode_set_value_function (prereq.data_type);
+ var type_name = get_ccode_set_value_function (prereq.type_symbol);
if (type_name != "") {
return type_name;
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var func = get_ccode_take_value_function (prereq.data_type);
+ var func = get_ccode_take_value_function (prereq.type_symbol);
if (func != "") {
return func;
}
}
} else if (sym is Interface) {
foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
- var func = get_ccode_param_spec_function (prereq.data_type);
+ var func = get_ccode_param_spec_function (prereq.type_symbol);
if (func != "") {
return func;
}
return "g_param_spec_boxed";
}
}
- } else if (node is ArrayType && ((ArrayType)node).element_type.data_type == CodeContext.get().analyzer.string_type.data_type) {
+ } else if (node is ArrayType && ((ArrayType)node).element_type.type_symbol == CodeContext.get().analyzer.string_type.type_symbol) {
return "g_param_spec_boxed";
- } else if (node is DataType && ((DataType) node).data_type != null) {
- return get_ccode_param_spec_function (((DataType) node).data_type);
+ } else if (node is DataType && ((DataType) node).type_symbol != null) {
+ return get_ccode_param_spec_function (((DataType) node).type_symbol);
}
return "g_param_spec_pointer";
}
if (m.base_interface_type != null) {
return "%sreal_%s%s".printf (get_ccode_lower_case_prefix (m.parent_symbol),
- get_ccode_lower_case_prefix (m.base_interface_type.data_type),
+ get_ccode_lower_case_prefix (m.base_interface_type.type_symbol),
m_name);
} else {
return "%sreal_%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), m_name);
TypeSymbol t;
// FIXME: workaround to make constant arrays possible
if (type is ArrayType) {
- t = ((ArrayType) type).element_type.data_type;
+ t = ((ArrayType) type).element_type.type_symbol;
} else {
- t = type.data_type;
+ t = type.type_symbol;
}
if (!t.is_reference_type ()) {
ptr = "";
if (context.module_init_method != null) {
foreach (Parameter parameter in context.module_init_method.get_parameters ()) {
- if (parameter.variable_type.data_type.is_subtype_of (type_module_type)) {
+ if (parameter.variable_type.type_symbol.is_subtype_of (type_module_type)) {
in_plugin = true;
module_init_param_name = parameter.name;
break;
public CCodeIdentifier get_value_setter_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
- if (type_reference.data_type != null) {
- return new CCodeIdentifier (get_ccode_set_value_function (type_reference.data_type));
- } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
+ if (type_reference.type_symbol != null) {
+ return new CCodeIdentifier (get_ccode_set_value_function (type_reference.type_symbol));
+ } else if (array_type != null && array_type.element_type.type_symbol == string_type.type_symbol) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_set_boxed");
} else {
public CCodeIdentifier get_value_taker_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
- if (type_reference.data_type != null) {
- return new CCodeIdentifier (get_ccode_take_value_function (type_reference.data_type));
- } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
+ if (type_reference.type_symbol != null) {
+ return new CCodeIdentifier (get_ccode_take_value_function (type_reference.type_symbol));
+ } else if (array_type != null && array_type.element_type.type_symbol == string_type.type_symbol) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_take_boxed");
} else {
CCodeIdentifier get_value_getter_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
- if (type_reference.data_type != null) {
- return new CCodeIdentifier (get_ccode_get_value_function (type_reference.data_type));
- } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
+ if (type_reference.type_symbol != null) {
+ return new CCodeIdentifier (get_ccode_get_value_function (type_reference.type_symbol));
+ } else if (array_type != null && array_type.element_type.type_symbol == string_type.type_symbol) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_get_boxed");
} else {
generate_type_declaration (delegate_target_destroy_type, decl_space);
}
}
- } else if (type.data_type is Enum) {
- var en = (Enum) type.data_type;
+ } else if (type.type_symbol is Enum) {
+ var en = (Enum) type.type_symbol;
generate_enum_declaration (en, decl_space);
} else if (type is ValueType) {
var value_type = (ValueType) type;
get_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("old_value")));
ccode.add_expression (get_call);
}
- var equalfunc = generate_struct_equal_function ((Struct) property_type.data_type);
+ var equalfunc = generate_struct_equal_function ((Struct) property_type.type_symbol);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (equalfunc));
ccall.add_argument (new CCodeIdentifier ("value"));
if (property_type.nullable) {
public bool no_implicit_copy (DataType type) {
// note: implicit copy of array is planned to be forbidden
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
return (type is DelegateType ||
type is ArrayType ||
(cl != null && !cl.is_immutable && !is_reference_counting (cl) && !get_ccode_is_gboxed (cl)));
}
public bool is_simple_struct_creation (Variable variable, Expression expr) {
- var st = variable.variable_type.data_type as Struct;
+ unowned Struct? st = variable.variable_type.type_symbol as Struct;
var creation = expr as ObjectCreationExpression;
if (creation != null && st != null && (!st.is_simple_type () || get_ccode_name (st) == "va_list") && !variable.variable_type.nullable &&
- variable.variable_type.data_type != gvalue_type && creation.get_object_initializer ().size == 0) {
+ variable.variable_type.type_symbol != gvalue_type && creation.get_object_initializer ().size == 0) {
return true;
} else {
return false;
}
public override void visit_initializer_list (InitializerList list) {
- if (list.target_type.data_type is Struct) {
+ if (list.target_type.type_symbol is Struct) {
/* initializer is used as struct initializer */
- var st = (Struct) list.target_type.data_type;
+ unowned Struct st = (Struct) list.target_type.type_symbol;
while (st.base_struct != null) {
st = st.base_struct;
}
public virtual CCodeExpression? get_dup_func_expression (DataType type, SourceReference? source_reference, bool is_chainup = false) {
if (type is ErrorType) {
return new CCodeIdentifier ("g_error_copy");
- } else if (type.data_type != null) {
+ } else if (type.type_symbol != null) {
string dup_function;
- var cl = type.data_type as Class;
- if (is_reference_counting (type.data_type)) {
- dup_function = get_ccode_ref_function ((ObjectTypeSymbol) type.data_type);
- if (type.data_type is Interface && dup_function == null) {
- Report.error (source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
+ unowned Class? cl = type.type_symbol as Class;
+ if (is_reference_counting (type.type_symbol)) {
+ dup_function = get_ccode_ref_function ((ObjectTypeSymbol) type.type_symbol);
+ if (type.type_symbol is Interface && dup_function == null) {
+ Report.error (source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.type_symbol.get_full_name ()));
return new CCodeInvalidExpression();
}
} else if (cl != null && cl.is_immutable) {
// allow duplicates of immutable instances as for example strings
- dup_function = get_ccode_dup_function (type.data_type);
+ dup_function = get_ccode_dup_function (type.type_symbol);
if (dup_function == null) {
dup_function = "";
}
dup_function = "";
}
} else if (type is ValueType) {
- dup_function = get_ccode_dup_function (type.data_type);
+ dup_function = get_ccode_dup_function (type.type_symbol);
if (dup_function == null && type.nullable) {
dup_function = generate_struct_dup_wrapper ((ValueType) type);
} else if (dup_function == null) {
}
} else {
// duplicating non-reference counted objects may cause side-effects (and performance issues)
- Report.error (source_reference, "duplicating %s instance, use unowned variable or explicitly invoke copy method".printf (type.data_type.name));
+ Report.error (source_reference, "duplicating %s instance, use unowned variable or explicitly invoke copy method".printf (type.type_symbol.name));
return new CCodeInvalidExpression();
}
}
void make_comparable_cexpression (ref DataType left_type, ref CCodeExpression cleft, ref DataType right_type, ref CCodeExpression cright) {
- unowned Struct? left_type_as_struct = left_type.data_type as Struct;
- unowned Struct? right_type_as_struct = right_type.data_type as Struct;
- unowned ObjectTypeSymbol? left_type_as_object_type = left_type.data_type as ObjectTypeSymbol;
- unowned ObjectTypeSymbol? right_type_as_object_type = right_type.data_type as ObjectTypeSymbol;
+ unowned Struct? left_type_as_struct = left_type.type_symbol as Struct;
+ unowned Struct? right_type_as_struct = right_type.type_symbol as Struct;
+ unowned ObjectTypeSymbol? left_type_as_object_type = left_type.type_symbol as ObjectTypeSymbol;
+ unowned ObjectTypeSymbol? right_type_as_object_type = right_type.type_symbol as ObjectTypeSymbol;
if (left_type_as_object_type != null && (!(left_type_as_object_type is Class) || !((Class) left_type_as_object_type).is_compact)
&& right_type_as_object_type != null && (!(right_type_as_object_type is Class) || !((Class) right_type_as_object_type).is_compact)) {
ccall.add_argument (s2);
cexp = ccall;
} else if (f.variable_type is StructValueType) {
- var equalfunc = generate_struct_equal_function (f.variable_type.data_type as Struct);
+ var equalfunc = generate_struct_equal_function (f.variable_type.type_symbol as Struct);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (equalfunc));
ccall.add_argument (s1);
ccall.add_argument (s2);
ccode.add_declaration (get_ccode_name (value_type), new CCodeVariableDeclarator ("dup"));
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- creation_call.add_argument (new CCodeConstant (get_ccode_name (value_type.data_type)));
+ creation_call.add_argument (new CCodeConstant (get_ccode_name (value_type.type_symbol)));
creation_call.add_argument (new CCodeConstant ("1"));
ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
- var st = value_type.data_type as Struct;
+ var st = value_type.type_symbol as Struct;
if (st != null && st.is_disposable ()) {
if (!get_ccode_has_copy_function (st)) {
generate_struct_copy_function (st);
cfile.add_include ("string.h");
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeConstant (get_ccode_name (value_type.data_type)));
+ sizeof_call.add_argument (new CCodeConstant (get_ccode_name (value_type.type_symbol)));
var copy_call = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
copy_call.add_argument (new CCodeIdentifier ("dup"));
}
protected string generate_dup_func_wrapper (DataType type) {
- string destroy_func = "_vala_%s_copy".printf (get_ccode_name (type.data_type));
+ string destroy_func = "_vala_%s_copy".printf (get_ccode_name (type.type_symbol));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
push_function (function);
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
assert (cl != null && get_ccode_is_gboxed (cl));
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_copy"));
}
protected string generate_free_function_address_of_wrapper (DataType type) {
- string destroy_func = "_vala_%s_free_function_address_of".printf (get_ccode_name (type.data_type));
+ string destroy_func = "_vala_%s_free_function_address_of".printf (get_ccode_name (type.type_symbol));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
push_function (function);
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
+ assert (cl != null);
+
var free_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_free_function (cl)));
free_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("self")));
protected string generate_destroy_function_content_of_wrapper (DataType type) {
// g_array_set_clear_func has a specific GDestroyNotify where the content of an element is given
- string destroy_func = "_vala_%s_free_function_content_of".printf (get_ccode_name (type.data_type));
+ string destroy_func = "_vala_%s_free_function_content_of".printf (get_ccode_name (type.type_symbol));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
}
protected string generate_free_func_wrapper (DataType type) {
- string destroy_func = "_vala_%s_free".printf (get_ccode_name (type.data_type));
+ string destroy_func = "_vala_%s_free".printf (get_ccode_name (type.type_symbol));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
push_function (function);
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null && get_ccode_is_gboxed (cl)) {
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_free"));
free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
ccode.add_expression (free_call);
} else {
- var st = type.data_type as Struct;
+ unowned Struct? st = type.type_symbol as Struct;
if (st != null && st.is_disposable ()) {
if (!get_ccode_has_destroy_function (st)) {
generate_struct_destroy_function (st);
}
public CCodeExpression? get_destroy_func_expression (DataType type, bool is_chainup = false) {
- if (context.profile == Profile.GOBJECT && (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type || type.data_type == gqueue_type)) {
+ if (context.profile == Profile.GOBJECT && (type.type_symbol == glist_type || type.type_symbol == gslist_type || type.type_symbol == gnode_type || type.type_symbol == gqueue_type)) {
// create wrapper function to free list elements if necessary
bool elements_require_free = false;
}
return cexpr;
} else {
- return new CCodeIdentifier (get_ccode_free_function (type.data_type));
+ return new CCodeIdentifier (get_ccode_free_function (type.type_symbol));
}
} else if (type is ErrorType) {
return new CCodeIdentifier ("g_error_free");
- } else if (type.data_type != null) {
+ } else if (type.type_symbol != null) {
string unref_function;
if (type is ReferenceType) {
- if (is_reference_counting (type.data_type)) {
- unref_function = get_ccode_unref_function ((ObjectTypeSymbol) type.data_type);
- if (type.data_type is Interface && unref_function == null) {
- Report.error (type.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
+ if (is_reference_counting (type.type_symbol)) {
+ unref_function = get_ccode_unref_function ((ObjectTypeSymbol) type.type_symbol);
+ if (type.type_symbol is Interface && unref_function == null) {
+ Report.error (type.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.type_symbol.get_full_name ()));
return null;
}
} else {
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null && get_ccode_is_gboxed (cl)) {
unref_function = generate_free_func_wrapper (type);
} else {
if (is_free_function_address_of (type)) {
unref_function = generate_free_function_address_of_wrapper (type);
} else {
- unref_function = get_ccode_free_function (type.data_type);
+ unref_function = get_ccode_free_function (type.type_symbol);
}
}
}
} else {
if (type.nullable) {
- unref_function = get_ccode_free_function (type.data_type);
+ unref_function = get_ccode_free_function (type.type_symbol);
if (unref_function == null) {
- if (type.data_type is Struct && ((Struct) type.data_type).is_disposable ()) {
+ if (type.type_symbol is Struct && ((Struct) type.type_symbol).is_disposable ()) {
unref_function = generate_free_func_wrapper (type);
} else {
unref_function = "g_free";
} else if (type is EnumValueType) {
unref_function = null;
} else {
- var st = (Struct) type.data_type;
- if (st.is_disposable ()) {
+ unowned Struct? st = type.type_symbol as Struct;
+ if (st != null && st.is_disposable ()) {
if (!get_ccode_has_destroy_function (st)) {
generate_struct_destroy_function (st);
}
string? destroy_func_wrapper = null;
if (element_destroy_func_expression != null) {
- destroy_func_wrapper = "_%s_%s".printf (get_ccode_free_function (collection_type.data_type), element_destroy_func_expression.name);
+ destroy_func_wrapper = "_%s_%s".printf (get_ccode_free_function (collection_type.type_symbol), element_destroy_func_expression.name);
if (!add_wrapper (destroy_func_wrapper)) {
// wrapper already defined
return destroy_func_wrapper;
}
}
- if (collection_type.data_type == gnode_type) {
+ if (collection_type.type_symbol == gnode_type) {
destroy_func = "_g_node_free_all";
if (!add_wrapper (destroy_func)) {
// wrapper already defined
cfile.add_function_declaration (function);
cfile.add_function (function);
- } else if (collection_type.data_type == glist_type) {
+ } else if (collection_type.type_symbol == glist_type) {
destroy_func = "g_list_free_full";
- } else if (collection_type.data_type == gslist_type) {
+ } else if (collection_type.type_symbol == gslist_type) {
destroy_func = "g_slist_free_full";
- } else if (collection_type.data_type == gqueue_type) {
+ } else if (collection_type.type_symbol == gqueue_type) {
destroy_func = "g_queue_free_full";
} else {
Report.error (null, "internal error: type of collection not supported");
return ccomma;
}
- bool is_gcollection = (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type || type.data_type == gqueue_type);
+ bool is_gcollection = (type.type_symbol == glist_type || type.type_symbol == gslist_type || type.type_symbol == gnode_type || type.type_symbol == gqueue_type);
CCodeFunctionCall ccall;
var cexpr = get_destroy_func_expression (type);
if (is_gcollection && cexpr is CCodeFunctionCall) {
if (type is ValueType && !type.nullable) {
// normal value type, no null check
- var st = type.data_type as Struct;
+ unowned Struct? st = type.type_symbol as Struct;
if (st != null && st.is_simple_type ()) {
// used for va_list
ccall.add_argument (cvar);
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
}
- if (gvalue_type != null && type.data_type == gvalue_type) {
+ if (gvalue_type != null && type.type_symbol == gvalue_type) {
// g_value_unset must not be called for already unset values
var cisvalid = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_VALUE"));
cisvalid.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
ccomma.append_expression (new CCodeConstant ("NULL"));
return new CCodeConditionalExpression (cisvalid, ccomma, new CCodeConstant ("NULL"));
- } else if ((type.data_type == gmutex_type ||
- type.data_type == grecmutex_type ||
- type.data_type == grwlock_type ||
- type.data_type == gcond_type)) {
+ } else if ((type.type_symbol == gmutex_type ||
+ type.type_symbol == grecmutex_type ||
+ type.type_symbol == grwlock_type ||
+ type.type_symbol == gcond_type)) {
// g_mutex_clear must not be called for uninitialized mutex
// also, g_mutex_clear does not clear the struct
requires_clear_mutex = true;
- ccall.call = new CCodeIdentifier ("_vala_clear_" + get_ccode_name (type.data_type));
+ ccall.call = new CCodeIdentifier ("_vala_clear_" + get_ccode_name (type.type_symbol));
return ccall;
} else {
return ccall;
var ccomma = new CCodeCommaExpression ();
if (context.profile == Profile.GOBJECT) {
- if (type.data_type != null && !is_reference_counting (type.data_type) &&
- (type.data_type.is_subtype_of (gstringbuilder_type)
- || type.data_type.is_subtype_of (garray_type)
- || type.data_type.is_subtype_of (gbytearray_type)
- || type.data_type.is_subtype_of (gptrarray_type))) {
+ if (type.type_symbol != null && !is_reference_counting (type.type_symbol) &&
+ (type.type_symbol.is_subtype_of (gstringbuilder_type)
+ || type.type_symbol.is_subtype_of (garray_type)
+ || type.type_symbol.is_subtype_of (gbytearray_type)
+ || type.type_symbol.is_subtype_of (gptrarray_type))) {
ccall.add_argument (new CCodeConstant ("TRUE"));
- } else if (type.data_type == gthreadpool_type) {
+ } else if (type.type_symbol == gthreadpool_type) {
ccall.add_argument (new CCodeConstant ("FALSE"));
ccall.add_argument (new CCodeConstant ("TRUE"));
} else if (type is ArrayType) {
}
if (csizeexpr != null) {
- var st = array_type.element_type.data_type as Struct;
+ unowned Struct? st = array_type.element_type.type_symbol as Struct;
if (st != null && !array_type.element_type.nullable) {
ccall.call = new CCodeIdentifier (append_struct_array_free (st));
ccall.add_argument (csizeexpr);
var cassign = new CCodeAssignment (cvar, ccomma);
// g_free (NULL) is allowed
- bool uses_gfree = (type.data_type != null && !is_reference_counting (type.data_type) && get_ccode_free_function (type.data_type) == "g_free");
+ bool uses_gfree = (type.type_symbol != null && !is_reference_counting (type.type_symbol) && get_ccode_free_function (type.type_symbol) == "g_free");
uses_gfree = uses_gfree || type is ArrayType;
if (uses_gfree) {
return cassign;
public override void visit_delete_statement (DeleteStatement stmt) {
unowned DataType type = stmt.expression.value_type;
unowned PointerType? pointer_type = type as PointerType;
- if (pointer_type != null && pointer_type.base_type.data_type != null && pointer_type.base_type.data_type.is_reference_type ()) {
+ if (pointer_type != null && pointer_type.base_type.type_symbol != null && pointer_type.base_type.type_symbol.is_reference_type ()) {
type = pointer_type.base_type;
}
}
static bool is_compact_class_destructor_call (Expression expr) {
- unowned Class? cl = expr.value_type.data_type as Class;
+ unowned Class? cl = expr.value_type.type_symbol as Class;
if (cl != null && cl.is_compact && expr.parent_node is MemberAccess) {
unowned MethodType? mt = ((MemberAccess) expr.parent_node).value_type as MethodType;
if (mt != null && mt.method_symbol != null && mt.method_symbol.get_attribute ("DestroysInstance") != null) {
}
public override void visit_base_access (BaseAccess expr) {
- set_cvalue (expr, generate_instance_cast (get_this_cexpression (), expr.value_type.data_type));
+ set_cvalue (expr, generate_instance_cast (get_this_cexpression (), expr.value_type.type_symbol));
}
public override void visit_postfix_expression (PostfixExpression expr) {
}
static bool is_limited_generic_type (GenericType type) {
- var cl = type.type_parameter.parent_symbol as Class;
- var st = type.type_parameter.parent_symbol as Struct;
+ unowned Class? cl = type.type_parameter.parent_symbol as Class;
+ unowned Struct? st = type.type_parameter.parent_symbol as Struct;
if ((cl != null && cl.is_compact) || st != null) {
// compact classes and structs only
// have very limited generics support
return false;
}
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null && is_reference_counting (cl)
&& get_ccode_ref_function (cl) == "") {
// empty ref_function => no ref necessary
return requires_destroy (array_type.element_type);
}
- var cl = type.data_type as Class;
+ unowned Class? cl = type.type_symbol as Class;
if (cl != null && is_reference_counting (cl)
&& get_ccode_unref_function (cl) == "") {
// empty unref_function => no unref necessary
generate_struct_copy_function (st);
}
- if (gvalue_type != null && type.data_type == gvalue_type) {
+ if (gvalue_type != null && type.type_symbol == gvalue_type) {
var cisvalid = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_VALUE"));
cisvalid.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cexpr));
}
CCodeExpression cifnull;
- if (type.data_type != null) {
+ if (type.type_symbol != null) {
cifnull = new CCodeConstant ("NULL");
} else {
// the value might be non-null even when the dup function is null,
CCodeExpression instance = null;
CCodeExpression creation_expr = null;
- var st = expr.type_reference.data_type as Struct;
+ unowned Struct? st = expr.type_reference.type_symbol as Struct;
if ((st != null && (!st.is_simple_type () || get_ccode_name (st) == "va_list")) || expr.get_object_initializer ().size > 0) {
// value-type initialization or object creation expression with object initializer
if (expr.symbol_reference == null) {
// no creation method
- if (expr.type_reference.data_type is Struct) {
+ if (expr.type_reference.type_symbol is Struct) {
// memset needs string.h
cfile.add_include ("string.h");
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
creation_expr = creation_call;
}
- } else if (expr.type_reference.data_type == glist_type ||
- expr.type_reference.data_type == gslist_type) {
+ } else if (expr.type_reference.type_symbol == glist_type ||
+ expr.type_reference.type_symbol == gslist_type) {
// NULL is an empty list
set_cvalue (expr, new CCodeConstant ("NULL"));
} else if (expr.symbol_reference is Method) {
generate_method_declaration (m, cfile);
- var cl = expr.type_reference.data_type as Class;
+ unowned Class? cl = expr.type_reference.type_symbol as Class;
if (!get_ccode_has_new_function (m)) {
// use construct function directly
ccode.add_expression (creation_expr);
set_cvalue (expr, instance);
} else if (instance != null) {
- if (expr.type_reference.data_type is Struct) {
+ if (expr.type_reference.type_symbol is Struct) {
ccode.add_expression (creation_expr);
} else {
ccode.add_assignment (instance, creation_expr);
ccode.add_assignment (get_cvalue_ (temp_value), creation_expr);
expr.target_value = temp_value;
- var cl = expr.type_reference.data_type as Class;
+ unowned Class? cl = expr.type_reference.type_symbol as Class;
if (context.gobject_tracing) {
// GObject creation tracing enabled
clear_func.add_argument (get_cvalue_ (expr.target_value));
string destroy_func;
if (type_arg.is_non_null_simple_type () || type_arg.is_real_non_null_struct_type ()) {
- destroy_func = get_ccode_destroy_function (type_arg.data_type);
+ destroy_func = get_ccode_destroy_function (type_arg.type_symbol);
} else {
destroy_func = generate_destroy_function_content_of_wrapper (type_arg);
}
}
public CCodeExpression? try_cast_value_to_type (CCodeExpression ccodeexpr, DataType from, DataType to, Expression? expr = null) {
- if (from == null || gvalue_type == null || from.data_type != gvalue_type || to.data_type == gvalue_type || get_ccode_type_id (to) == "") {
+ if (from == null || gvalue_type == null || from.type_symbol != gvalue_type || to.type_symbol == gvalue_type || get_ccode_type_id (to) == "") {
return null;
}
}
}
- var cl = expr.type_reference.data_type as Class;
- var iface = expr.type_reference.data_type as Interface;
+ unowned Class? cl = expr.type_reference.type_symbol as Class;
+ unowned Interface? iface = expr.type_reference.type_symbol as Interface;
if (context.profile == Profile.GOBJECT && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
if (expr.is_silent_cast) {
expr.target_value = cast_value;
}
} else {
- set_cvalue (expr, generate_instance_cast (get_cvalue (expr.inner), expr.type_reference.data_type));
+ set_cvalue (expr, generate_instance_cast (get_cvalue (expr.inner), expr.type_reference.type_symbol));
}
} else {
if (expr.is_silent_cast) {
var value_type = expr.inner.value_type;
if (value_type is ValueType) {
- var data_type = ((ValueType) value_type).data_type;
- sizeof_from.add_argument (new CCodeConstant (get_ccode_name (data_type)));
+ sizeof_from.add_argument (new CCodeConstant (get_ccode_name (value_type.type_symbol)));
array_length_expr = new CCodeBinaryExpression (CCodeBinaryOperator.DIV, sizeof_from, sizeof_to);
} else if (value_type is PointerType && ((PointerType) value_type).base_type is ValueType) {
- var data_type = ((ValueType) (((PointerType) value_type).base_type)).data_type;
- sizeof_from.add_argument (new CCodeConstant (get_ccode_name (data_type)));
+ sizeof_from.add_argument (new CCodeConstant (get_ccode_name (((PointerType) value_type).base_type.type_symbol)));
array_length_expr = new CCodeBinaryExpression (CCodeBinaryOperator.DIV, sizeof_from, sizeof_to);
} else {
// cast from unsupported non-array to array, set invalid length
make_comparable_cexpression (ref left_type, ref cleft, ref right_type, ref cright);
if (left_type is StructValueType && right_type is StructValueType) {
- var equalfunc = generate_struct_equal_function ((Struct) left_type.data_type);
+ var equalfunc = generate_struct_equal_function ((Struct) left_type.type_symbol);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (equalfunc));
ccall.add_argument (cleft);
ccall.add_argument (cright);
cright = new CCodeConstant ("TRUE");
} else if ((left_type is IntegerType || left_type is FloatingType || left_type is BooleanType || left_type is EnumValueType) && left_type.nullable &&
(right_type is IntegerType || right_type is FloatingType || right_type is BooleanType || right_type is EnumValueType) && right_type.nullable) {
- var equalfunc = generate_numeric_equal_function ((TypeSymbol) left_type.data_type);
+ var equalfunc = generate_numeric_equal_function ((TypeSymbol) left_type.type_symbol);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (equalfunc));
ccall.add_argument (cleft);
ccall.add_argument (cright);
return new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, instance_domain, type_domain);
} else {
CCodeFunctionCall ccheck;
- if (type.data_type == null || type.data_type.external_package) {
+ if (type.type_symbol == null || type.type_symbol.external_package) {
var type_id = get_type_id_expression (type);
if (type_id == null) {
return new CCodeInvalidExpression ();
ccheck.add_argument ((CCodeExpression) ccodenode);
ccheck.add_argument (type_id);
} else {
- ccheck = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (type.data_type)));
+ ccheck = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (type.type_symbol)));
ccheck.add_argument ((CCodeExpression) ccodenode);
}
ccall.add_argument (cneedle);
cif_condition = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccall, new CCodeConstant ("0"));
} else if (array_type.element_type is StructValueType) {
- var equalfunc = generate_struct_equal_function ((Struct) array_type.element_type.data_type);
+ var equalfunc = generate_struct_equal_function ((Struct) array_type.element_type.type_symbol);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (equalfunc));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, celement));
ccall.add_argument (cneedle);
if (pointer_type != null) {
type = pointer_type.base_type;
}
- var cl = type.data_type as Class;
- var iface = type.data_type as Interface;
+ unowned Class? cl = type.type_symbol as Class;
+ unowned Interface? iface = type.type_symbol as Interface;
if ((cl != null && !cl.is_compact) || iface != null || type is GenericType || type is ErrorType) {
set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
} else {
&& type.floating_reference) {
/* floating reference, sink it.
*/
- var cl = type.data_type as ObjectTypeSymbol;
+ unowned ObjectTypeSymbol? cl = type.type_symbol as ObjectTypeSymbol;
var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : "";
if (sink_func != "") {
ccode.close ();
}
} else {
- Report.error (node.source_reference, "type `%s' does not support floating references".printf (type.data_type.name));
+ Report.error (node.source_reference, "type `%s' does not support floating references".printf (type.type_symbol.name));
}
}
bool gvalue_boxing = (context.profile == Profile.GOBJECT
&& target_type != null
- && target_type.data_type == gvalue_type
+ && target_type.type_symbol == gvalue_type
&& !(type is NullType)
&& get_ccode_type_id (type) != "G_TYPE_VALUE");
bool gvariant_boxing = (context.profile == Profile.GOBJECT
&& target_type != null
- && target_type.data_type == gvariant_type
+ && target_type.type_symbol == gvariant_type
&& !(type is NullType)
- && type.data_type != gvariant_type);
+ && type.type_symbol != gvariant_type);
if (type.value_owned
&& (target_type == null || !target_type.value_owned || boxing || unboxing || gvariant_boxing)
if (!gvalue_boxing && !gvariant_boxing && target_type.value_owned && (!type.value_owned || boxing || unboxing || array_needs_copy) && requires_copy (target_type) && !(type is NullType)) {
// need to copy value
var copy = (GLibValue) copy_value (result, node);
- if (target_type.data_type is Interface && copy == null) {
- Report.error (node.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (target_type.data_type.get_full_name ()));
+ if (target_type.type_symbol is Interface && copy == null) {
+ Report.error (node.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (target_type.type_symbol.get_full_name ()));
return result;
}
result = copy;
public virtual CCodeExpression get_implicit_cast_expression (CCodeExpression source_cexpr, DataType? expression_type, DataType? target_type, CodeNode? node) {
var cexpr = source_cexpr;
- if (expression_type.data_type != null && expression_type.data_type == target_type.data_type) {
+ if (expression_type.type_symbol != null && expression_type.type_symbol == target_type.type_symbol) {
// same type, no cast required
return cexpr;
}
generate_type_declaration (target_type, cfile);
- var cl = target_type.data_type as Class;
- var iface = target_type.data_type as Interface;
+ unowned Class? cl = target_type.type_symbol as Class;
+ unowned Interface? iface = target_type.type_symbol as Interface;
if (context.checking && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
- return generate_instance_cast (cexpr, target_type.data_type);
- } else if (target_type.data_type != null && get_ccode_name (expression_type) != get_ccode_name (target_type)) {
- var st = target_type.data_type as Struct;
- if (target_type.data_type.is_reference_type () || (st != null && st.is_simple_type ())) {
+ return generate_instance_cast (cexpr, target_type.type_symbol);
+ } else if (target_type.type_symbol != null && get_ccode_name (expression_type) != get_ccode_name (target_type)) {
+ unowned Struct? st = target_type.type_symbol as Struct;
+ if (target_type.type_symbol.is_reference_type () || (st != null && st.is_simple_type ())) {
// don't cast non-simple structs
return new CCodeCastExpression (cexpr, get_ccode_name (target_type));
} else {
}
public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression, bool on_error = false) {
- var st = type.data_type as Struct;
+ unowned Struct? st = type.type_symbol as Struct;
var array_type = type as ArrayType;
- if (type.data_type != null && !type.nullable
- && (on_error ? get_ccode_default_value_on_error (type.data_type) : get_ccode_default_value (type.data_type)) != "") {
- return new CCodeConstant (on_error ? get_ccode_default_value_on_error (type.data_type) : get_ccode_default_value (type.data_type));
+ if (type.type_symbol != null && !type.nullable
+ && (on_error ? get_ccode_default_value_on_error (type.type_symbol) : get_ccode_default_value (type.type_symbol)) != "") {
+ return new CCodeConstant (on_error ? get_ccode_default_value_on_error (type.type_symbol) : get_ccode_default_value (type.type_symbol));
} else if (initializer_expression && !type.nullable &&
(st != null || (array_type != null && array_type.fixed_length))) {
// 0-initialize struct with struct initializer { 0 }
var clist = new CCodeInitializerList ();
clist.append (new CCodeConstant ("0"));
return clist;
- } else if ((type.data_type != null && type.data_type.is_reference_type ())
+ } else if ((type.type_symbol != null && type.type_symbol.is_reference_type ())
|| type.nullable
|| type is PointerType || type is DelegateType
|| (array_type != null && !array_type.fixed_length)) {
if (array_type != null && array_type.inline_allocated) {
return false;
}
- if (type.data_type != null) {
- return type.data_type.get_attribute_bool ("CCode", "lvalue_access", true);
+ if (type.type_symbol != null) {
+ return type.type_symbol.get_attribute_bool ("CCode", "lvalue_access", true);
}
return true;
}
}
public void return_default_value (DataType return_type, bool on_error = false) {
- var st = return_type.data_type as Struct;
+ unowned Struct? st = return_type.type_symbol as Struct;
if (st != null && st.is_simple_type () && !return_type.nullable) {
// 0-initialize struct with struct initializer { 0 }
// only allowed as initializer expression in C
foreach (Parameter param in d_params) {
if (dynamic_sig != null
&& param.variable_type is ArrayType
- && ((ArrayType) param.variable_type).element_type.data_type == string_type.data_type) {
+ && ((ArrayType) param.variable_type).element_type.type_symbol == string_type.type_symbol) {
// use null-terminated string arrays for dynamic signals for compatibility reasons
param.set_attribute_bool ("CCode", "array_length", false);
param.set_attribute_bool ("CCode", "array_null_terminated", true);
if (m.closure) {
int block_id = get_block_id (current_closure_block);
destroy_notify = new CCodeIdentifier ("block%d_data_unref".printf (block_id));
- } else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && is_reference_counting (m.this_parameter.variable_type.data_type)) {
+ } else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && is_reference_counting (m.this_parameter.variable_type.type_symbol)) {
destroy_notify = get_destroy_func_expression (m.this_parameter.variable_type);
}
// expr.inner is null in the special case of referencing the method in a constant initializer
var delegate_target = (CCodeExpression) get_ccodenode (expr.inner);
delegate_type = expr.target_type as DelegateType;
- if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && is_reference_counting (expr.inner.value_type.data_type)) {
+ if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.type_symbol != null && is_reference_counting (expr.inner.value_type.type_symbol)) {
var ref_call = new CCodeFunctionCall (get_dup_func_expression (expr.inner.value_type, expr.source_reference));
ref_call.add_argument (delegate_target);
delegate_target = ref_call;
// use closure
result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "self");
} else {
- var st = result.value_type.data_type as Struct;
+ unowned Struct? st = result.value_type.type_symbol as Struct;
if (st != null && !st.is_simple_type ()) {
result.cvalue = new CCodeIdentifier ("(*self)");
} else {
}
}
} else {
- var type_as_struct = result.value_type.data_type as Struct;
+ unowned Struct? type_as_struct = result.value_type.type_symbol as Struct;
if (param.direction == ParameterDirection.OUT) {
name = "_vala_%s".printf (name);
var instance_target_type = get_data_type_for_symbol ((TypeSymbol) field.parent_symbol);
- var cl = instance_target_type.data_type as Class;
- bool is_gtypeinstance = ((instance_target_type.data_type == cl) && (cl == null || !cl.is_compact));
+ unowned Class? cl = instance_target_type.type_symbol as Class;
+ bool is_gtypeinstance = ((instance_target_type.type_symbol == cl) && (cl == null || !cl.is_compact));
CCodeExpression inst;
if (is_gtypeinstance && field.access == SymbolAccessibility.PRIVATE) {
return result;
}
- if (instance_target_type.data_type.is_reference_type () || (instance != null && instance.value_type is PointerType)) {
+ if (instance_target_type.type_symbol.is_reference_type () || (instance != null && instance.value_type is PointerType)) {
result.cvalue = new CCodeMemberAccess.pointer (inst, get_ccode_name (field));
} else {
result.cvalue = new CCodeMemberAccess (inst, get_ccode_name (field));
if (ma.inner != null && ma.inner.value_type is EnumValueType && ((EnumValueType) ma.inner.value_type).get_to_string_method() == m) {
// Enum.VALUE.to_string()
- var en = (Enum) ma.inner.value_type.data_type;
+ unowned Enum en = (Enum) ma.inner.value_type.type_symbol;
ccall.call = new CCodeIdentifier (generate_enum_to_string_function (en));
- } else if (context.profile == Profile.POSIX && ma.inner != null && ma.inner.value_type != null && ma.inner.value_type.data_type == string_type.data_type && ma.member_name == "printf") {
+ } else if (context.profile == Profile.POSIX && ma.inner != null && ma.inner.value_type != null && ma.inner.value_type.type_symbol == string_type.type_symbol && ma.member_name == "printf") {
ccall.call = new CCodeIdentifier (generate_string_printf_function ());
} else if (expr.is_constructv_chainup) {
ccall.call = new CCodeIdentifier (get_ccode_constructv_name ((CreationMethod) m));
if (current_class != m.parent_symbol) {
// chain up to base class
foreach (DataType base_type in current_class.get_base_types ()) {
- if (base_type.data_type is Class) {
+ if (base_type.type_symbol is Class) {
List<TypeParameter> type_parameters = null;
if (get_ccode_real_name (m) == "g_object_new") {
// gobject-style chainup
- type_parameters = ((Class) base_type.data_type).get_type_parameters ();
+ type_parameters = ((Class) base_type.type_symbol).get_type_parameters ();
}
add_generic_type_arguments (in_arg_map, base_type.get_type_arguments (), expr, true, type_parameters);
break;
// register base types first
foreach (var base_type in cl.get_base_types ()) {
- register_plugin_type ((ObjectTypeSymbol) base_type.data_type, registered_types);
+ register_plugin_type ((ObjectTypeSymbol) base_type.type_symbol, registered_types);
}
}
}
if (param.direction != ParameterDirection.OUT) {
- var t = param.variable_type.data_type;
+ unowned TypeSymbol? t = param.variable_type.type_symbol;
if (t != null && (t.is_reference_type () || param.variable_type.is_real_struct_type ())) {
var cname = get_ccode_name (param);
if (param.direction == ParameterDirection.REF && !param.variable_type.is_real_struct_type ()) {
generate_type_declaration (param.variable_type, decl_space);
// pass non-simple structs always by reference
- if (param.variable_type.data_type is Struct) {
- var st = (Struct) param.variable_type.data_type;
+ unowned Struct? st = param.variable_type.type_symbol as Struct;
+ if (st != null) {
if (!st.is_simple_type () && param.direction == ParameterDirection.IN) {
if (st.is_immutable && !param.variable_type.value_owned) {
ctypename = "const " + ctypename;
push_function (vfunc);
- if (context.assert && m.return_type.data_type is Struct && ((Struct) m.return_type.data_type).is_simple_type () && default_value_for_type (m.return_type, false) == null) {
+ if (context.assert && m.return_type.type_symbol is Struct && ((Struct) m.return_type.type_symbol).is_simple_type () && default_value_for_type (m.return_type, false) == null) {
// the type check will use the result variable
var vardecl = new CCodeVariableDeclarator ("result", default_value_for_type (m.return_type, true));
vardecl.init0 = true;
var frag = new CCodeFragment ();
foreach (DataType base_type in class_reference.get_base_types ()) {
- if (!(base_type.data_type is Interface)) {
+ if (!(base_type.type_symbol is Interface)) {
continue;
}
- var iface = (Interface) base_type.data_type;
+ unowned Interface iface = (Interface) base_type.type_symbol;
var iface_info_name = "%s_info".printf (get_ccode_lower_case_name (iface, null));
public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
foreach (DataType base_type in class_reference.get_base_types ()) {
- if (!(base_type.data_type is Interface)) {
+ if (!(base_type.type_symbol is Interface)) {
continue;
}
- var iface = (Interface) base_type.data_type;
+ unowned Interface iface = (Interface) base_type.type_symbol;
var iface_info_name = "%s_info".printf (get_ccode_lower_case_name (iface, null));
if (!plugin) {
Parameter cancellable_param = null;
foreach (Parameter param in m.get_parameters ()) {
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
cancellable_param = param;
break;
}
bool has_cancellable = false;
foreach (Parameter param in m.get_parameters ()) {
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
has_cancellable = true;
break;
}
push_function (func);
- if (dynamic_method.dynamic_type.data_type == dbus_proxy_type) {
+ if (dynamic_method.dynamic_type.type_symbol == dbus_proxy_type) {
generate_marshalling (method, CallType.SYNC, null, method.name, -1);
} else {
Report.error (method.source_reference, "dynamic methods are not supported for `%s'".printf (dynamic_method.dynamic_type.to_string ()));
void generate_proxy_interface_init (Interface main_iface, Interface iface) {
// also generate proxy for prerequisites
foreach (var prereq in iface.get_prerequisites ()) {
- if (prereq.data_type is Interface) {
- generate_proxy_interface_init (main_iface, (Interface) prereq.data_type);
+ if (prereq.type_symbol is Interface) {
+ generate_proxy_interface_init (main_iface, (Interface) prereq.type_symbol);
}
}
// also implement prerequisites
foreach (var prereq in iface.get_prerequisites ()) {
- if (prereq.data_type is Interface) {
- result += implement_interface (define_type, main_iface, (Interface) prereq.data_type);
+ if (prereq.type_symbol is Interface) {
+ result += implement_interface (define_type, main_iface, (Interface) prereq.type_symbol);
}
}
ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
- var st = param.variable_type.data_type as Struct;
+ unowned Struct? st = param.variable_type.type_symbol as Struct;
if (st != null && !st.is_simple_type ()) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param_name)));
} else {
expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, expr);
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
cancellable = expr;
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.BusName") {
// ignore BusName sender parameters
continue;
}
string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
- var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.type_symbol));
push_function (cquark_fun);
string quark_name = "%squark_volatile".printf (get_ccode_lower_case_prefix (edomain));
bool is_file_descriptor (DataType type) {
if (type is ObjectType) {
- if (type.data_type.get_full_name () == "GLib.UnixInputStream" ||
- type.data_type.get_full_name () == "GLib.UnixOutputStream" ||
- type.data_type.get_full_name () == "GLib.Socket" ||
- type.data_type.get_full_name () == "GLib.FileDescriptorBased") {
+ if (type.type_symbol.get_full_name () == "GLib.UnixInputStream" ||
+ type.type_symbol.get_full_name () == "GLib.UnixOutputStream" ||
+ type.type_symbol.get_full_name () == "GLib.Socket" ||
+ type.type_symbol.get_full_name () == "GLib.FileDescriptorBased") {
return true;
}
}
CCodeExpression? get_file_descriptor (DataType type, CCodeExpression expr) {
if (type is ObjectType) {
- if (type.data_type.get_full_name () == "GLib.UnixInputStream") {
+ if (type.type_symbol.get_full_name () == "GLib.UnixInputStream") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_unix_input_stream_get_fd"));
result.add_argument (expr);
return result;
- } else if (type.data_type.get_full_name () == "GLib.UnixOutputStream") {
+ } else if (type.type_symbol.get_full_name () == "GLib.UnixOutputStream") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_unix_output_stream_get_fd"));
result.add_argument (expr);
return result;
- } else if (type.data_type.get_full_name () == "GLib.Socket") {
+ } else if (type.type_symbol.get_full_name () == "GLib.Socket") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_socket_get_fd"));
result.add_argument (expr);
return result;
- } else if (type.data_type.get_full_name () == "GLib.FileDescriptorBased") {
+ } else if (type.type_symbol.get_full_name () == "GLib.FileDescriptorBased") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_file_descriptor_based_get_fd"));
result.add_argument (expr);
return result;
CCodeExpression? create_from_file_descriptor (DataType type, CCodeExpression expr) {
if (type is ObjectType) {
- if (type.data_type.get_full_name () == "GLib.UnixInputStream") {
+ if (type.type_symbol.get_full_name () == "GLib.UnixInputStream") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_unix_input_stream_new"));
result.add_argument (expr);
result.add_argument (new CCodeConstant ("TRUE"));
return new CCodeCastExpression (result, "GUnixInputStream *");
- } else if (type.data_type.get_full_name () == "GLib.UnixOutputStream") {
+ } else if (type.type_symbol.get_full_name () == "GLib.UnixOutputStream") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_unix_output_stream_new"));
result.add_argument (expr);
result.add_argument (new CCodeConstant ("TRUE"));
return new CCodeCastExpression (result, "GUnixOutputStream *");
- } else if (type.data_type.get_full_name () == "GLib.Socket") {
+ } else if (type.type_symbol.get_full_name () == "GLib.Socket") {
var result = new CCodeFunctionCall (new CCodeIdentifier ("g_socket_new_from_fd"));
result.add_argument (expr);
result.add_argument (new CCodeConstant ("NULL"));
var out_args_info = new CCodeInitializerList ();
foreach (Parameter param in m.get_parameters ()) {
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.BusName") {
continue;
}
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.BusName") {
// ignore BusName sender parameters
continue;
}
}
if (param.direction == ParameterDirection.IN && !ready) {
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
ccall.add_argument (new CCodeConstant ("NULL"));
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.BusName") {
// ignore BusName sender parameters
var sender = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_method_invocation_get_sender"));
sender.add_argument (new CCodeIdentifier ("invocation"));
continue;
}
- var st = param.variable_type.data_type as Struct;
+ unowned Struct? st = param.variable_type.type_symbol as Struct;
if (st != null && !st.is_simple_type ()) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, param_expr));
} else {
foreach (Parameter param in m.get_parameters ()) {
if ((param.direction == ParameterDirection.IN && (ready_data_expr == null || ready)) ||
(param.direction == ParameterDirection.OUT && !no_reply && (!m.coroutine || ready))) {
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.Cancellable") {
continue;
}
- if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+ if (param.variable_type is ObjectType && param.variable_type.type_symbol.get_full_name () == "GLib.BusName") {
// ignore BusName sender parameters
continue;
}
ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero ("value", default_value_for_type (prop.property_type, true)));
- var st = prop.property_type.data_type as Struct;
+ unowned Struct? st = prop.property_type.type_symbol as Struct;
if (st != null && !st.is_simple_type ()) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("value")));
} else {
var error_domain_define = new CCodeMacroReplacement (get_ccode_upper_case_name (edomain), quark_fun_name + " ()");
decl_space.add_type_definition (error_domain_define);
- var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.type_symbol));
decl_space.add_function_declaration (cquark_fun);
}
string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
- var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.type_symbol));
push_function (cquark_fun);
var cquark_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
/* catch clause specifies a specific error code */
var error_match = new CCodeFunctionCall (new CCodeIdentifier ("g_error_matches"));
error_match.add_argument (get_inner_error_cexpression ());
- error_match.add_argument (new CCodeIdentifier (get_ccode_upper_case_name (catch_type.data_type)));
+ error_match.add_argument (new CCodeIdentifier (get_ccode_upper_case_name (catch_type.type_symbol)));
error_match.add_argument (new CCodeIdentifier (get_ccode_name (catch_type.error_code)));
ccode.open_if (error_match);
/* catch clause specifies a full error domain */
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY,
new CCodeMemberAccess.pointer (get_inner_error_cexpression (), "domain"), new CCodeIdentifier
- (get_ccode_upper_case_name (clause.error_type.data_type)));
+ (get_ccode_upper_case_name (clause.error_type.type_symbol)));
ccode.open_if (ccond);
}
// Check the allowed error domains to propagate
var domain_check = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeMemberAccess.pointer
- (get_inner_error_cexpression (), "domain"), new CCodeIdentifier (get_ccode_upper_case_name (error_type.data_type)));
+ (get_inner_error_cexpression (), "domain"), new CCodeIdentifier (get_ccode_upper_case_name (error_type.type_symbol)));
if (ccond == null) {
ccond = domain_check;
} else {
unowned DelegateType? delegate_type = type as DelegateType;
unowned ArrayType? array_type = type as ArrayType;
- if (type != null && ((type.value_owned && delegate_type == null) || (constructor && !type.data_type.is_subtype_of (ginitiallyunowned_type)))) {
+ if (type != null && ((type.value_owned && delegate_type == null) || (constructor && !type.type_symbol.is_subtype_of (ginitiallyunowned_type)))) {
var any_owned = false;
foreach (var generic_arg in type.get_type_arguments ()) {
any_owned |= generic_arg.value_owned;
} else if (type is PointerType) {
write_indent ();
buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s%s\"/>\n", get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
- } else if (type.data_type != null) {
+ } else if (type.type_symbol != null) {
write_indent ();
- string type_name = gi_type_name (type.data_type);
+ string type_name = gi_type_name (type.type_symbol);
bool is_array = false;
if ((type_name == "GLib.Array") || (type_name == "GLib.PtrArray")) {
is_array = true;
}
- buffer.append_printf ("<%s name=\"%s\" c:type=\"%s%s\"", is_array ? "array" : "type", gi_type_name (type.data_type), get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
+ buffer.append_printf ("<%s name=\"%s\" c:type=\"%s%s\"", is_array ? "array" : "type", gi_type_name (type.type_symbol), get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
List<DataType> type_arguments = type.get_type_arguments ();
if (type_arguments.size == 0) {
ccall = new CCodeFunctionCall (cfunc);
ccall.add_argument (cself);
var array_type = prop.property_type as ArrayType;
- if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
+ if (array_type != null && array_type.element_type.type_symbol == string_type.type_symbol) {
// G_TYPE_STRV
ccode.open_block ();
ccode.add_declaration ("int", new CCodeVariableDeclarator ("length"));
csetcall.add_argument (new CCodeIdentifier ("value"));
csetcall.add_argument (ccall);
add_guarded_expression (prop, csetcall);
- if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
+ if (array_type != null && array_type.element_type.type_symbol == string_type.type_symbol) {
ccode.close ();
}
}
ccode.add_case (new CCodeIdentifier ("%s_PROPERTY".printf (get_ccode_upper_case_name (prop))));
ccall = new CCodeFunctionCall (cfunc);
ccall.add_argument (cself);
- if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) {
+ if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.type_symbol == string_type.type_symbol) {
ccode.open_block ();
ccode.add_declaration ("gpointer", new CCodeVariableDeclarator ("boxed"));
ccode.close ();
} else {
var cgetcall = new CCodeFunctionCall ();
- if (prop.property_type.data_type != null) {
- cgetcall.call = new CCodeIdentifier (get_ccode_get_value_function (prop.property_type.data_type));
+ if (prop.property_type.type_symbol != null) {
+ cgetcall.call = new CCodeIdentifier (get_ccode_get_value_function (prop.property_type.type_symbol));
} else {
cgetcall.call = new CCodeIdentifier ("g_value_get_pointer");
}
}
public override string get_dynamic_property_getter_cname (DynamicProperty prop) {
- if (prop.dynamic_type.data_type == null
- || !prop.dynamic_type.data_type.is_subtype_of (gobject_type)) {
+ if (prop.dynamic_type.type_symbol == null
+ || !prop.dynamic_type.type_symbol.is_subtype_of (gobject_type)) {
return base.get_dynamic_property_getter_cname (prop);
}
}
public override string get_dynamic_property_setter_cname (DynamicProperty prop) {
- if (prop.dynamic_type.data_type == null
- || !prop.dynamic_type.data_type.is_subtype_of (gobject_type)) {
+ if (prop.dynamic_type.type_symbol == null
+ || !prop.dynamic_type.type_symbol.is_subtype_of (gobject_type)) {
return base.get_dynamic_property_setter_cname (prop);
}
}
public override string get_dynamic_signal_connect_wrapper_name (DynamicSignal sig) {
- if (sig.dynamic_type.data_type == null
- || !sig.dynamic_type.data_type.is_subtype_of (gobject_type)) {
+ if (sig.dynamic_type.type_symbol == null
+ || !sig.dynamic_type.type_symbol.is_subtype_of (gobject_type)) {
return base.get_dynamic_signal_connect_wrapper_name (sig);
}
}
public override string get_dynamic_signal_connect_after_wrapper_name (DynamicSignal sig) {
- if (sig.dynamic_type.data_type == null
- || !sig.dynamic_type.data_type.is_subtype_of (gobject_type)) {
+ if (sig.dynamic_type.type_symbol == null
+ || !sig.dynamic_type.type_symbol.is_subtype_of (gobject_type)) {
return base.get_dynamic_signal_connect_wrapper_name (sig);
}
return "void";
} else if (get_ccode_type_id (t) == get_ccode_type_id (string_type)) {
return "const char*";
- } else if (t.data_type is Class || t.data_type is Interface) {
+ } else if (t.type_symbol is Class || t.type_symbol is Interface) {
return "gpointer";
} else if (t is ValueType && t.nullable) {
return "gpointer";
- } else if (t.data_type is Struct) {
- var st = (Struct) t.data_type;
+ } else if (t.type_symbol is Struct) {
+ unowned Struct st = (Struct) t.type_symbol;
if (st.is_simple_type ()) {
- return get_ccode_name (t.data_type);
+ return get_ccode_name (t.type_symbol);
} else {
return "gpointer";
}
- } else if (t.data_type is Enum) {
- var en = (Enum) t.data_type;
+ } else if (t.type_symbol is Enum) {
+ unowned Enum en = (Enum) t.type_symbol;
if (en.is_flags) {
return "guint";
} else {
CCodeFunctionCall fc;
- if (return_type.data_type != null || return_type is ArrayType) {
+ if (return_type.type_symbol != null || return_type is ArrayType) {
ccode.add_declaration (get_value_type_name_from_type_reference (return_type), new CCodeVariableDeclarator ("v_return"));
fc = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
if (p.direction != ParameterDirection.IN) {
get_value_function = "g_value_get_pointer";
} else if (p.variable_type is ArrayType) {
- if (((ArrayType) p.variable_type).element_type.data_type == string_type.data_type) {
+ if (((ArrayType) p.variable_type).element_type.type_symbol == string_type.type_symbol) {
get_value_function = "g_value_get_boxed";
} else {
get_value_function = "g_value_get_pointer";
} else if (p.variable_type is ValueType && p.variable_type.nullable) {
get_value_function = "g_value_get_pointer";
} else {
- get_value_function = get_ccode_get_value_function (p.variable_type.data_type);
+ get_value_function = get_ccode_get_value_function (p.variable_type.type_symbol);
}
var inner_fc = new CCodeFunctionCall (new CCodeIdentifier (get_value_function));
inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
i++;
if (p.variable_type is ArrayType) {
var array_type = (ArrayType) p.variable_type;
- var length_value_function = get_ccode_get_value_function (array_type.length_type.data_type);
+ var length_value_function = get_ccode_get_value_function (array_type.length_type.type_symbol);
assert (length_value_function != null && length_value_function != "");
for (var j = 0; j < array_type.rank; j++) {
inner_fc = new CCodeFunctionCall (new CCodeIdentifier (length_value_function));
}
fc.add_argument (new CCodeIdentifier ("data2"));
- if (return_type.data_type != null || return_type is ArrayType) {
+ if (return_type.type_symbol != null || return_type is ArrayType) {
ccode.add_assignment (new CCodeIdentifier ("v_return"), fc);
CCodeFunctionCall set_fc;
if (return_type is ArrayType) {
- if (((ArrayType) return_type).element_type.data_type == string_type.data_type) {
+ if (((ArrayType) return_type).element_type.type_symbol == string_type.type_symbol) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_boxed"));
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else if (return_type is ErrorType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
- } else if (return_type.data_type == string_type.data_type) {
+ } else if (return_type.type_symbol == string_type.type_symbol) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_string"));
- } else if (return_type.data_type is Class || return_type.data_type is Interface) {
+ } else if (return_type.type_symbol is Class || return_type.type_symbol is Interface) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_object"));
} else if (return_type is ValueType && return_type.nullable) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else {
- set_fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_set_value_function (return_type.data_type)));
+ set_fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_set_value_function (return_type.type_symbol)));
}
set_fc.add_argument (new CCodeIdentifier ("return_value"));
set_fc.add_argument (new CCodeIdentifier ("v_return"));
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type is ValueType && sig.return_type.nullable) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
- } else if (sig.return_type.data_type == null) {
+ } else if (sig.return_type.type_symbol == null) {
csignew.add_argument (new CCodeConstant ("G_TYPE_NONE"));
} else {
- csignew.add_argument (new CCodeConstant (get_ccode_type_id (sig.return_type.data_type)));
+ csignew.add_argument (new CCodeConstant (get_ccode_type_id (sig.return_type.type_symbol)));
}
int params_len = 0;
foreach (Parameter param in params) {
if (param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
- if (array_type.element_type.data_type == string_type.data_type) {
+ if (array_type.element_type.type_symbol == string_type.type_symbol) {
csignew.add_argument (new CCodeConstant ("G_TYPE_STRV"));
} else {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
}
- assert (get_ccode_has_type_id (array_type.length_type.data_type));
- var length_type_id = get_ccode_type_id (array_type.length_type.data_type);
+ assert (get_ccode_has_type_id (array_type.length_type.type_symbol));
+ var length_type_id = get_ccode_type_id (array_type.length_type.type_symbol);
for (var i = 0; i < array_type.rank; i++) {
csignew.add_argument (new CCodeConstant (length_type_id));
}
} else if (param.variable_type is ValueType && param.variable_type.nullable) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else {
- csignew.add_argument (new CCodeConstant (get_ccode_type_id (param.variable_type.data_type)));
+ csignew.add_argument (new CCodeConstant (get_ccode_type_id (param.variable_type.type_symbol)));
}
}
bool in_gobject_instance (Method m) {
bool result = false;
if (m.binding == MemberBinding.INSTANCE) {
- result = m.this_parameter.variable_type.data_type.is_subtype_of (gobject_type);
+ result = m.this_parameter.variable_type.type_symbol.is_subtype_of (gobject_type);
}
return result;
}
}
/* We allow Gtk child to have stricter type than class field */
- var field_class = f.variable_type.data_type as Class;
+ unowned Class? field_class = f.variable_type.type_symbol as Class;
if (field_class == null || !child_class.is_subtype_of (field_class)) {
Report.error (f.source_reference, "cannot convert from Gtk child type `%s' to `%s'".printf (child_class.get_full_name(), field_class.get_full_name()));
return;
generate_class_struct_declaration (cl.base_class, decl_space);
}
foreach (DataType base_type in cl.get_base_types ()) {
- var iface = base_type.data_type as Interface;
+ unowned Interface? iface = base_type.type_symbol as Interface;
if (iface != null) {
generate_interface_declaration (iface, decl_space);
}
}
foreach (DataType base_type in cl.get_base_types ()) {
- if (base_type.data_type is Interface) {
- add_interface_init_function (cl, (Interface) base_type.data_type);
+ if (base_type.type_symbol is Interface) {
+ add_interface_init_function (cl, (Interface) base_type.type_symbol);
}
}
cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
- if (prop.property_type.data_type is Class || prop.property_type.data_type is Interface) {
- string param_spec_name = get_ccode_param_spec_function (prop.property_type.data_type);
+ if (prop.property_type.type_symbol is Class || prop.property_type.type_symbol is Interface) {
+ string param_spec_name = get_ccode_param_spec_function (prop.property_type.type_symbol);
cspec.call = new CCodeIdentifier (param_spec_name);
if (param_spec_name == "g_param_spec_string") {
cspec.add_argument (new CCodeConstant ("NULL"));
} else if (param_spec_name == "g_param_spec_variant") {
cspec.add_argument (new CCodeConstant ("G_VARIANT_TYPE_ANY"));
cspec.add_argument (new CCodeConstant ("NULL"));
- } else if (get_ccode_type_id (prop.property_type.data_type) != "G_TYPE_POINTER") {
- cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (prop.property_type.data_type)));
+ } else if (get_ccode_type_id (prop.property_type.type_symbol) != "G_TYPE_POINTER") {
+ cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (prop.property_type.type_symbol)));
}
- } else if (prop.property_type.data_type is Enum) {
- var e = prop.property_type.data_type as Enum;
+ } else if (prop.property_type.type_symbol is Enum) {
+ unowned Enum e = (Enum) prop.property_type.type_symbol;
if (get_ccode_has_type_id (e)) {
if (e.is_flags) {
cspec.call = new CCodeIdentifier ("g_param_spec_flags");
if (prop.initializer != null) {
cspec.add_argument ((CCodeExpression) get_ccodenode (prop.initializer));
} else {
- cspec.add_argument (new CCodeConstant (get_ccode_default_value (prop.property_type.data_type)));
+ cspec.add_argument (new CCodeConstant (get_ccode_default_value (prop.property_type.type_symbol)));
}
- } else if (prop.property_type.data_type is Struct) {
- var st = (Struct) prop.property_type.data_type;
+ } else if (prop.property_type.type_symbol is Struct) {
+ unowned Struct st = (Struct) prop.property_type.type_symbol;
var type_id = get_ccode_type_id (st);
if (type_id == "G_TYPE_INT") {
cspec.call = new CCodeIdentifier ("g_param_spec_int");
cspec.call = new CCodeIdentifier ("g_param_spec_boxed");
cspec.add_argument (new CCodeIdentifier (type_id));
}
- } else if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) {
+ } else if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.type_symbol == string_type.type_symbol) {
cspec.call = new CCodeIdentifier ("g_param_spec_boxed");
cspec.add_argument (new CCodeIdentifier ("G_TYPE_STRV"));
} else {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_struct.name), new CCodeVariableDeclarator (get_ccode_type_name (iface))));
foreach (DataType prerequisite in iface.get_prerequisites ()) {
- var prereq_cl = prerequisite.data_type as Class;
- var prereq_iface = prerequisite.data_type as Interface;
+ unowned Class? prereq_cl = prerequisite.type_symbol as Class;
+ unowned Interface? prereq_iface = prerequisite.type_symbol as Interface;
if (prereq_cl != null) {
generate_class_declaration (prereq_cl, decl_space);
} else if (prereq_iface != null) {
var ma = expr.call as MemberAccess;
var mtype = expr.call.value_type as MethodType;
if (mtype == null || ma == null || ma.inner == null ||
- !(ma.inner.value_type is EnumValueType) || !get_ccode_has_type_id (ma.inner.value_type.data_type) ||
+ !(ma.inner.value_type is EnumValueType) || !get_ccode_has_type_id (ma.inner.value_type.type_symbol) ||
mtype.method_symbol != ((EnumValueType) ma.inner.value_type).get_to_string_method ()) {
base.visit_method_call (expr);
return;
var cdefault = default_value_for_type (ret_type, false);
if (cdefault != null) {
ccheck.add_argument (cdefault);
- } else if (ret_type.data_type is Struct && !((Struct) ret_type.data_type).is_simple_type ()) {
+ } else if (ret_type.type_symbol is Struct && !((Struct) ret_type.type_symbol).is_simple_type ()) {
ccheck.add_argument (new CCodeIdentifier ("result"));
} else {
return;
var value = expr.inner.target_value;
var target_type = expr.type_reference;
- if (expr.is_non_null_cast || value.value_type == null || gvariant_type == null || value.value_type.data_type != gvariant_type) {
+ if (expr.is_non_null_cast || value.value_type == null || gvariant_type == null || value.value_type.type_symbol != gvariant_type) {
base.visit_cast_expression (expr);
return;
}
ccode.add_declaration ("GVariant*", new CCodeVariableDeclarator (value_name));
var hash_table_new = new CCodeFunctionCall (new CCodeIdentifier ("g_hash_table_new_full"));
- if (key_type.data_type.is_subtype_of (string_type.data_type)) {
+ if (key_type.type_symbol.is_subtype_of (string_type.type_symbol)) {
hash_table_new.add_argument (new CCodeIdentifier ("g_str_hash"));
hash_table_new.add_argument (new CCodeIdentifier ("g_str_equal"));
- } else if (key_type.data_type == gvariant_type) {
+ } else if (key_type.type_symbol == gvariant_type) {
hash_table_new.add_argument (new CCodeIdentifier ("g_variant_hash"));
hash_table_new.add_argument (new CCodeIdentifier ("g_variant_equal"));
} else {
hash_table_new.add_argument (new CCodeIdentifier ("g_direct_equal"));
}
- if (key_type.data_type.is_subtype_of (string_type.data_type)) {
+ if (key_type.type_symbol.is_subtype_of (string_type.type_symbol)) {
hash_table_new.add_argument (new CCodeIdentifier ("g_free"));
- } else if (key_type.data_type == gvariant_type) {
+ } else if (key_type.type_symbol == gvariant_type) {
hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_variant_unref"), "GDestroyNotify"));
- } else if (key_type.data_type.get_full_name () == "GLib.HashTable") {
+ } else if (key_type.type_symbol.get_full_name () == "GLib.HashTable") {
hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify"));
} else {
hash_table_new.add_argument (new CCodeIdentifier ("NULL"));
}
- if (value_type.data_type.is_subtype_of (string_type.data_type)) {
+ if (value_type.type_symbol.is_subtype_of (string_type.type_symbol)) {
hash_table_new.add_argument (new CCodeIdentifier ("g_free"));
- } else if (value_type.data_type == gvariant_type) {
+ } else if (value_type.type_symbol == gvariant_type) {
hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_variant_unref"), "GDestroyNotify"));
- } else if (value_type.data_type.get_full_name () == "GLib.HashTable") {
+ } else if (value_type.type_symbol.get_full_name () == "GLib.HashTable") {
hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify"));
} else {
hash_table_new.add_argument (new CCodeIdentifier ("NULL"));
BasicTypeInfo basic_type;
CCodeExpression result = null;
may_fail = false;
- if (is_string_marshalled_enum (type.data_type)) {
+ if (is_string_marshalled_enum (type.type_symbol)) {
get_basic_type_info ("s", out basic_type);
result = deserialize_basic (basic_type, variant_expr, true);
result = generate_enum_value_from_string (type as EnumValueType, result, error_expr);
result = deserialize_basic (basic_type, variant_expr);
} else if (type is ArrayType) {
result = deserialize_array ((ArrayType) type, variant_expr, expr);
- } else if (type.data_type is Struct) {
- var st = (Struct) type.data_type;
+ } else if (type.type_symbol is Struct) {
+ unowned Struct st = (Struct) type.type_symbol;
result = deserialize_struct (st, variant_expr);
if (result != null && type.nullable) {
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
result = cdup;
}
} else if (type is ObjectType) {
- if (type.data_type.get_full_name () == "GLib.Variant") {
+ if (type.type_symbol.get_full_name () == "GLib.Variant") {
var variant_get = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_get_variant"));
variant_get.add_argument (variant_expr);
result = variant_get;
- } else if (type.data_type.get_full_name () == "GLib.HashTable") {
+ } else if (type.type_symbol.get_full_name () == "GLib.HashTable") {
result = deserialize_hash_table ((ObjectType) type, variant_expr);
}
}
public override CCodeExpression? serialize_expression (DataType type, CCodeExpression expr) {
BasicTypeInfo basic_type;
CCodeExpression result = null;
- if (is_string_marshalled_enum (type.data_type)) {
+ if (is_string_marshalled_enum (type.type_symbol)) {
get_basic_type_info ("s", out basic_type);
result = generate_enum_value_to_string (type as EnumValueType, expr);
result = serialize_basic (basic_type, result);
result = serialize_basic (basic_type, expr);
} else if (type is ArrayType) {
result = serialize_array ((ArrayType) type, expr);
- } else if (type.data_type is Struct) {
+ } else if (type.type_symbol is Struct) {
var st_expr = expr;
if (type.nullable) {
st_expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, st_expr);
}
- result = serialize_struct ((Struct) type.data_type, st_expr);
+ result = serialize_struct ((Struct) type.type_symbol, st_expr);
} else if (type is ObjectType) {
- if (type.data_type.get_full_name () == "GLib.Variant") {
+ if (type.type_symbol.get_full_name () == "GLib.Variant") {
var variant_new = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_new_variant"));
variant_new.add_argument (expr);
result = variant_new;
- } else if (type.data_type.get_full_name () == "GLib.HashTable") {
+ } else if (type.type_symbol.get_full_name () == "GLib.HashTable") {
result = serialize_hash_table ((ObjectType) type, expr);
}
}
public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
/* register all prerequisites */
foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
- var prereq = prereq_ref.data_type;
+ unowned TypeSymbol prereq = prereq_ref.type_symbol;
var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
func.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (interface_reference))));