2007-04-04 Jürg Billeter <j@bitron.ch>
+ * vala/scanner.l: improve cast support
+ * vala/valasemanticanalyzer.vala: fix ownership handling of local arrays
+ * vala/valacodegenerator.vala: skip code generation for static
+ interfaces, downgrade generic management support message to warning
+ * vala/valacallback.vala: support callbacks as property type
+
+2007-04-04 Jürg Billeter <j@bitron.ch>
+
* vala/scanner.l: support casts to generic types
* vala/valasymbolresolver.vala, vala/valatypereference.vala: support
arrays of generic types
"{" { uploc; return OPEN_BRACE; }
"}" { uploc; return CLOSE_BRACE; }
-"("{space}{ident}("."{ident})?("<"({ident}".")?{ident}">")?("["{space}"]")*{space}")"{space}("("|{ident}|{literal}) { yyless (1); uploc; return OPEN_CAST_PARENS; }
+"("({space}"weak")?{space}{ident}("."{ident})?("<"({ident}".")?{ident}(","({ident}".")?{ident})*">")?("["{space}"]")*{space}")"{space}("("|{ident}|{literal}) { yyless (1); uploc; return OPEN_CAST_PARENS; }
"(" { uploc; return OPEN_PARENS; }
")" { uploc; return CLOSE_PARENS; }
"[]" { uploc; return BRACKET_PAIR; }
/* valacallback.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
public override bool is_reference_type () {
return false;
}
+
+ public override string get_type_id () {
+ return "G_TYPE_POINTER";
+ }
+
+ public override string get_marshaller_type_name () {
+ return "POINTER";
+ }
+
+ public override string get_get_value_function () {
+ return "g_value_get_pointer";
+ }
+
+ public override string get_set_value_function () {
+ return "g_value_set_pointer";
+ }
}
current_symbol = iface.symbol;
current_type_symbol = iface.symbol;
+ if (iface.is_static) {
+ return;
+ }
+
type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
header_type_declaration.append (new CCodeNewline ());
}
public override void visit_end_interface (Interface! iface) {
- add_interface_base_init_function (iface);
+ if (!iface.is_static) {
+ add_interface_base_init_function (iface);
- var type_fun = new InterfaceRegisterFunction (iface);
- type_fun.init_from_type ();
- header_type_member_declaration.append (type_fun.get_declaration ());
- source_type_member_definition.append (type_fun.get_definition ());
+ var type_fun = new InterfaceRegisterFunction (iface);
+ type_fun.init_from_type ();
+ header_type_member_declaration.append (type_fun.get_declaration ());
+ source_type_member_definition.append (type_fun.get_definition ());
+ }
current_type_symbol = null;
}
current_symbol = current_symbol.parent_symbol;
current_return_type = null;
+ if (current_type_symbol != null && current_type_symbol.node is Interface) {
+ var iface = (Interface) current_type_symbol.node;
+ if (iface.is_static) {
+ return;
+ }
+ }
+
if (current_symbol.parent_symbol != null &&
current_symbol.parent_symbol.node is Method) {
/* lambda expressions produce nested methods */
if (expr.static_type.data_type == null &&
expr.static_type.type_parameter != null) {
- expr.error = true;
- Report.error (expr.source_reference, "Missing generics support for memory management");
- return null;
+ Report.warning (expr.source_reference, "Missing generics support for memory management");
+ return (CCodeExpression) expr.ccodenode;
}
string ref_function;
if (decl.initializer.static_type.transfers_ownership) {
/* rhs transfers ownership of the expression */
if (!decl.type_reference.takes_ownership) {
- /* lhs doesn't own the value
- * promote lhs type */
-
- decl.type_reference.takes_ownership = true;
+ /* lhs doesn't own the value */
+ decl.error = true;
+ Report.error (decl.source_reference, "Invalid assignment from owned expression to unowned variable");
+ return;
}
}
}
}
public override void visit_cast_expression (CastExpression! expr) {
- if (expr.type_reference.data_type == null) {
+ if (expr.type_reference.data_type == null && expr.type_reference.type_parameter == null) {
/* if type resolving didn't succeed, skip this check */
return;
}
// FIXME: check whether cast is allowed
-
- current_source_file.add_symbol_dependency (expr.type_reference.data_type.symbol, SourceFileDependencyType.SOURCE);
+
+ if (expr.type_reference.data_type != null) {
+ current_source_file.add_symbol_dependency (expr.type_reference.data_type.symbol, SourceFileDependencyType.SOURCE);
+ }
expr.static_type = expr.type_reference;
}
var element_type = (TypeReference) args.data;
if (!element_type.takes_ownership) {
- /* lhs doesn't own the value
- * promote lhs type if it is a local variable
- * error if it's not a local variable */
- if (!(ea.container.symbol_reference.node is VariableDeclarator)) {
- a.error = true;
- Report.error (a.source_reference, "Invalid assignment from owned expression to unowned variable");
- return;
- }
-
- element_type.takes_ownership = true;
+ /* lhs doesn't own the value */
+ a.error = true;
+ Report.error (a.source_reference, "Invalid assignment from owned expression to unowned variable");
+ return;
}
} else if (a.left.static_type.takes_ownership) {
/* lhs wants to own the value