2008-05-13 Jürg Billeter <j@bitron.ch>
+ * vala/valaclass.vala:
+ * vala/valainterfacewriter.vala:
+ * vala/valamemorymanager.vala:
+ * vala/valaproperty.vala:
+ * vala/valasemanticanalyzer.vala:
+ * gobject/valaccodeassignmentbinding.vala:
+ * gobject/valaccodeclassbinding.vala:
+ * gobject/valaccodegenerator.vala:
+ * gobject/valaccodememberaccessbinding.vala:
+ * gobject/valaccodetypesymbolbinding.vala:
+ * gobject/valagidlwriter.vala:
+
+ Rename Property.type_reference to Property.property_type
+
+2008-05-13 Jürg Billeter <j@bitron.ch>
+
* vala/valadelegate.vala:
* vala/valaformalparameter.vala:
* vala/valainterfacewriter.vala:
var prop = (Property) assignment.left.symbol_reference;
if (prop.set_accessor.construction && codegen.current_type_symbol is Class && codegen.current_class.is_subtype_of (codegen.gobject_type) && codegen.in_creation_method) {
- codenode = get_construct_property_assignment (prop.get_canonical_cconstant (), prop.type_reference, (CCodeExpression) assignment.right.ccodenode);
+ codenode = get_construct_property_assignment (prop.get_canonical_cconstant (), prop.property_type, (CCodeExpression) assignment.right.ccodenode);
} else {
CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
// ensure to pass the value correctly typed (especially important for varargs)
- cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.value_type, prop.type_reference);
+ cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.value_type, prop.property_type);
if (!prop.no_accessor_method) {
- if (prop.type_reference.is_real_struct_type ()) {
+ if (prop.property_type.is_real_struct_type ()) {
cexpr = codegen.get_address_of_expression (assignment.right, cexpr);
}
}
var props = cl.get_properties ();
foreach (Property prop in props) {
// FIXME: omit real struct types for now since they cannot be expressed as gobject property yet
- if (prop.type_reference.is_real_struct_type ()) {
+ if (prop.property_type.is_real_struct_type ()) {
continue;
}
if (prop.access == SymbolAccessibility.PRIVATE) {
var props = cl.get_properties ();
foreach (Property prop in props) {
// FIXME: omit real struct types for now since they cannot be expressed as gobject property yet
- if (prop.get_accessor == null || prop.is_abstract || prop.type_reference.is_real_struct_type ()) {
+ if (prop.get_accessor == null || prop.is_abstract || prop.property_type.is_real_struct_type ()) {
continue;
}
if (prop.access == SymbolAccessibility.PRIVATE) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_get_%s".printf (prefix, prop.name)));
ccall.add_argument (new CCodeIdentifier ("self"));
var csetcall = new CCodeFunctionCall ();
- csetcall.call = get_value_setter_function (prop.type_reference);
+ csetcall.call = get_value_setter_function (prop.property_type);
csetcall.add_argument (new CCodeIdentifier ("value"));
csetcall.add_argument (ccall);
ccase.add_statement (new CCodeExpressionStatement (csetcall));
var props = cl.get_properties ();
foreach (Property prop in props) {
// FIXME: omit real struct types for now since they cannot be expressed as gobject property yet
- if (prop.set_accessor == null || prop.is_abstract || prop.type_reference.is_real_struct_type ()) {
+ if (prop.set_accessor == null || prop.is_abstract || prop.property_type.is_real_struct_type ()) {
continue;
}
if (prop.access == SymbolAccessibility.PRIVATE) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_set_%s".printf (prefix, prop.name)));
ccall.add_argument (new CCodeIdentifier ("self"));
var cgetcall = new CCodeFunctionCall ();
- if (prop.type_reference.data_type != null) {
- cgetcall.call = new CCodeIdentifier (prop.type_reference.data_type.get_get_value_function ());
+ if (prop.property_type.data_type != null) {
+ cgetcall.call = new CCodeIdentifier (prop.property_type.data_type.get_get_value_function ());
} else {
cgetcall.call = new CCodeIdentifier ("g_value_get_pointer");
}
// FIXME: omit real struct types for now since they cannot be expressed as gobject property yet
// don't register private properties
- if (prop.parent_symbol is Class && !prop.type_reference.is_real_struct_type () && prop.access != SymbolAccessibility.PRIVATE) {
+ if (prop.parent_symbol is Class && !prop.property_type.is_real_struct_type () && prop.access != SymbolAccessibility.PRIVATE) {
prop_enum.add_value (new CCodeEnumValue (prop.get_upper_case_cname ()));
}
}
var prop = (Property) acc.prop;
- bool returns_real_struct = prop.type_reference.is_real_struct_type ();
+ bool returns_real_struct = prop.property_type.is_real_struct_type ();
if (acc.readable && !returns_real_struct) {
- current_return_type = prop.type_reference;
+ current_return_type = prop.property_type;
} else {
current_return_type = new VoidType ();
}
this_type = new InterfaceInstanceType ((Interface) t);
}
var cselfparam = new CCodeFormalParameter ("self", this_type.get_cname ());
- var value_type = prop.type_reference.copy ();
+ var value_type = prop.property_type.copy ();
value_type.takes_ownership = value_type.transfers_ownership;
var cvalueparam = new CCodeFormalParameter ("value", value_type.get_cname ());
if (prop.is_abstract || prop.is_virtual) {
if (acc.readable) {
- function = new CCodeFunction ("%s_get_%s".printf (t.get_lower_case_cname (null), prop.name), prop.type_reference.get_cname ());
+ function = new CCodeFunction ("%s_get_%s".printf (t.get_lower_case_cname (null), prop.name), prop.property_type.get_cname ());
} else {
function = new CCodeFunction ("%s_set_%s".printf (t.get_lower_case_cname (null), prop.name), "void");
}
if (acc.readable) {
// declare temporary variable to save the property value
- var decl = new CCodeDeclaration (prop.type_reference.get_cname ());
+ var decl = new CCodeDeclaration (prop.property_type.get_cname ());
decl.add_declarator (new CCodeVariableDeclarator ("value"));
block.add_statement (decl);
block.add_statement (new CCodeExpressionStatement (ccall));
// HACK: decrement the refcount before returning the value to simulate a weak reference getter function
- if (prop.type_reference.data_type != null && prop.type_reference.data_type.is_reference_counting ()) {
+ if (prop.property_type.data_type != null && prop.property_type.data_type.is_reference_counting ()) {
var unref_cond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("value"), new CCodeConstant ("NULL"));
- var unref_function = new CCodeFunctionCall (get_destroy_func_expression (prop.type_reference));
+ var unref_function = new CCodeFunctionCall (get_destroy_func_expression (prop.property_type));
unref_function.add_argument (new CCodeIdentifier ("value"));
var unref_block = new CCodeBlock ();
unref_block.add_statement (new CCodeExpressionStatement (unref_function));
// return non simple structs as out parameter
function = new CCodeFunction ("%s_get_%s".printf (prefix, prop.name), "void");
} else {
- function = new CCodeFunction ("%s_get_%s".printf (prefix, prop.name), prop.type_reference.get_cname ());
+ function = new CCodeFunction ("%s_get_%s".printf (prefix, prop.name), prop.property_type.get_cname ());
}
} else {
function = new CCodeFunction ("%s_set_%s".printf (prefix, prop.name), "void");
function.add_parameter (cselfparam);
if (returns_real_struct) {
// return non simple structs as out parameter
- var coutparamname = "%s*".printf (prop.type_reference.get_cname ());
+ var coutparamname = "%s*".printf (prop.property_type.get_cname ());
var coutparam = new CCodeFormalParameter ("value", coutparamname);
function.add_parameter (coutparam);
} else {
// paramenter and insert an empty return statement afterwards.
if (current_property_accessor != null &&
current_property_accessor.readable &&
- current_property_accessor.prop.type_reference.is_real_struct_type()) {
+ current_property_accessor.prop.property_type.is_real_struct_type()) {
var cfragment = new CCodeFragment ();
cfragment.append (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("*value"), (CCodeExpression) stmt.return_expression.ccodenode)));
cfragment.append (new CCodeReturnStatement ());
var ccomma = new CCodeCommaExpression ();
// assign current value to temp variable
- var temp_decl = get_temp_variable (prop.type_reference, true, expr);
+ var temp_decl = get_temp_variable (prop.property_type, true, expr);
temp_vars.insert (0, temp_decl);
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), (CCodeExpression) expr.inner.ccodenode));
private CCodeStatement create_property_type_check_statement (Property prop, bool check_return_type, Typesymbol t, bool non_null, string var_name) {
if (check_return_type) {
- return create_type_check_statement (prop, prop.type_reference, t, non_null, var_name);
+ return create_type_check_statement (prop, prop.property_type, t, non_null, var_name);
} else {
return create_type_check_statement (prop, new VoidType (), t, non_null, var_name);
}
// Property acesses to real struct types are handeled different to other properties.
// They are returned as out parameter.
- if (base_property.type_reference.is_real_struct_type ()) {
+ if (base_property.property_type.is_real_struct_type ()) {
var ccomma = new CCodeCommaExpression ();
- var temp_var = codegen.get_temp_variable (base_property.type_reference);
+ var temp_var = codegen.get_temp_variable (base_property.property_type);
var ctemp = new CCodeIdentifier (temp_var.name);
codegen.temp_vars.add (temp_var);
ccall.add_argument (new CCodeUnaryExpression(CCodeUnaryOperator.ADDRESS_OF, ctemp));
if (codegen.current_property_accessor != null &&
codegen.current_property_accessor.writable &&
codegen.current_property_accessor.value_parameter == p &&
- codegen.current_property_accessor.prop.type_reference.is_real_struct_type ()) {
+ codegen.current_property_accessor.prop.property_type.is_real_struct_type ()) {
expr.ccodenode = new CCodeIdentifier ("(*value)");
} else {
expr.ccodenode = new CCodeIdentifier (p.name);
cspec.add_argument (prop.get_canonical_cconstant ());
cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick)));
cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
- if ((prop.type_reference.data_type is Class && ((Class) prop.type_reference.data_type).is_subtype_of (codegen.gobject_type)) || prop.type_reference.data_type is Interface) {
+ if ((prop.property_type.data_type is Class && ((Class) prop.property_type.data_type).is_subtype_of (codegen.gobject_type)) || prop.property_type.data_type is Interface) {
cspec.call = new CCodeIdentifier ("g_param_spec_object");
- cspec.add_argument (new CCodeIdentifier (prop.type_reference.data_type.get_upper_case_cname ("TYPE_")));
- } else if (prop.type_reference.data_type == codegen.string_type.data_type) {
+ cspec.add_argument (new CCodeIdentifier (prop.property_type.data_type.get_upper_case_cname ("TYPE_")));
+ } else if (prop.property_type.data_type == codegen.string_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_string");
cspec.add_argument (new CCodeConstant ("NULL"));
- } else if (prop.type_reference.data_type is Enum) {
- var e = prop.type_reference.data_type as Enum;
+ } else if (prop.property_type.data_type is Enum) {
+ var e = prop.property_type.data_type as Enum;
if (e.has_type_id) {
if (e.is_flags) {
cspec.call = new CCodeIdentifier ("g_param_spec_flags");
if (prop.default_expression != null) {
cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
} else {
- cspec.add_argument (new CCodeConstant (prop.type_reference.data_type.get_default_value ()));
+ cspec.add_argument (new CCodeConstant (prop.property_type.data_type.get_default_value ()));
}
- } else if (prop.type_reference.data_type is Struct) {
- var st = (Struct) prop.type_reference.data_type;
+ } else if (prop.property_type.data_type is Struct) {
+ var st = (Struct) prop.property_type.data_type;
if (st.get_type_id () == "G_TYPE_INT") {
cspec.call = new CCodeIdentifier ("g_param_spec_int");
cspec.add_argument (new CCodeConstant ("G_MININT"));
}
write_indent ();
- stream.printf ("<property name=\"%s\" type=\"%s\"", prop.name, get_gidl_type_name (prop.type_reference));
+ stream.printf ("<property name=\"%s\" type=\"%s\"", prop.name, get_gidl_type_name (prop.property_type));
if (prop.get_accessor != null) {
stream.printf (" readable=\"1\"");
}
if (empty_get && empty_set) {
/* automatic property accessor body generation */
- var field_type = prop.type_reference.copy ();
+ var field_type = prop.property_type.copy ();
var f = new Field ("_%s".printf (prop.name), field_type, prop.default_expression, prop.source_reference);
f.access = SymbolAccessibility.PRIVATE;
prop.field = f;
} else if (prop.is_virtual) {
write_string ("virtual ");
}
- if (!prop.type_reference.takes_ownership) {
+ if (!prop.property_type.takes_ownership) {
write_string ("weak ");
}
- write_type (prop.type_reference);
+ write_type (prop.property_type);
- if (prop.type_reference.transfers_ownership) {
+ if (prop.property_type.transfers_ownership) {
write_string ("#");
}
} else if (current_symbol is Property) {
/* property get accessor */
var prop = (Property) current_symbol;
- if (prop.type_reference.transfers_ownership) {
+ if (prop.property_type.transfers_ownership) {
visit_possibly_missing_copy_expression (stmt.return_expression);
} else {
visit_possibly_leaked_expression (stmt.return_expression);
/**
* The property type.
*/
- public DataType type_reference {
+ public DataType property_type {
get { return _data_type; }
set {
_data_type = value;
* @param source reference to source code
* @return newly created property
*/
- public Property (string _name, DataType type, PropertyAccessor? _get_accessor, PropertyAccessor? _set_accessor, SourceReference source) {
- name = _name;
- type_reference = type;
- get_accessor = _get_accessor;
- set_accessor = _set_accessor;
- source_reference = source;
+ public Property (string name, DataType property_type, PropertyAccessor? get_accessor, PropertyAccessor? set_accessor, SourceReference source_reference) {
+ this.name = name;
+ this.property_type = property_type;
+ this.get_accessor = get_accessor;
+ this.set_accessor = set_accessor;
+ this.source_reference = source_reference;
}
public override void accept (CodeVisitor visitor) {
}
public override void accept_children (CodeVisitor visitor) {
- type_reference.accept (visitor);
+ property_type.accept (visitor);
if (get_accessor != null) {
get_accessor.accept (visitor);
* property
*/
public bool equals (Property prop2) {
- if (!prop2.type_reference.equals (type_reference)) {
+ if (!prop2.property_type.equals (property_type)) {
return false;
}
}
public override void replace_type (DataType old_type, DataType new_type) {
- if (type_reference == old_type) {
- type_reference = new_type;
+ if (property_type == old_type) {
+ property_type = new_type;
}
}
}
prop.accept_children (this);
// check whether property type is at least as accessible as the property
- if (!is_type_accessible (prop, prop.type_reference)) {
+ if (!is_type_accessible (prop, prop.property_type)) {
prop.error = true;
- Report.error (prop.source_reference, "property type `%s` is less accessible than property `%s`".printf (prop.type_reference.to_string (), prop.get_full_name ()));
+ Report.error (prop.source_reference, "property type `%s` is less accessible than property `%s`".printf (prop.property_type.to_string (), prop.get_full_name ()));
return;
}
* Reference counting types can simulate to return a weak
* reference */
if ((prop.is_abstract || prop.is_virtual) &&
- prop.type_reference.data_type != null &&
- prop.type_reference.data_type.is_reference_type () &&
- !prop.type_reference.data_type.is_reference_counting () &&
- !prop.type_reference.transfers_ownership)
+ prop.property_type.data_type != null &&
+ prop.property_type.data_type.is_reference_type () &&
+ !prop.property_type.data_type.is_reference_counting () &&
+ !prop.property_type.transfers_ownership)
{
- Report.error (prop.source_reference, "%s: abstract or virtual properties using reference types not supporting reference counting, like `%s', have to mark their return value to transfer ownership.".printf (prop.get_full_name (), prop.type_reference.data_type.get_full_name ()));
+ Report.error (prop.source_reference, "%s: abstract or virtual properties using reference types not supporting reference counting, like `%s', have to mark their return value to transfer ownership.".printf (prop.get_full_name (), prop.property_type.data_type.get_full_name ()));
prop.error = true;
}
current_symbol = current_symbol.parent_symbol;
if (!prop.is_internal_symbol ()) {
- current_source_file.add_type_dependency (prop.type_reference, SourceFileDependencyType.HEADER_SHALLOW);
+ current_source_file.add_type_dependency (prop.property_type, SourceFileDependencyType.HEADER_SHALLOW);
}
- current_source_file.add_type_dependency (prop.type_reference, SourceFileDependencyType.SOURCE);
+ current_source_file.add_type_dependency (prop.property_type, SourceFileDependencyType.SOURCE);
if (prop.parent_symbol is Class) {
var cl = (Class) prop.parent_symbol;
acc.prop = (Property) current_symbol;
if (acc.readable) {
- current_return_type = acc.prop.type_reference;
+ current_return_type = acc.prop.property_type;
} else {
// void
current_return_type = new VoidType ();
}
if (acc.body != null && (acc.writable || acc.construction)) {
- var value_type = acc.prop.type_reference.copy ();
+ var value_type = acc.prop.property_type.copy ();
value_type.takes_ownership = value_type.transfers_ownership;
acc.value_parameter = new FormalParameter ("value", value_type, acc.source_reference);
acc.body.scope.add (acc.value_parameter.name, acc.value_parameter);
return c.type_reference;
} else if (sym is Property) {
var prop = (Property) sym;
- var type = prop.type_reference.copy ();
+ var type = prop.property_type.copy ();
type.takes_ownership = false;
return type;
} else if (sym is FormalParameter) {
member_type = f.field_type;
} else if (init.symbol_reference is Property) {
var prop = (Property) init.symbol_reference;
- member_type = prop.type_reference;
+ member_type = prop.property_type;
if (prop.set_accessor == null || !prop.set_accessor.writable) {
init.error = true;
Report.error (init.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ()));