+2008-12-19 Jürg Billeter <j@bitron.ch>
+
+ * vala/valaparser.vala:
+ * vala/valascanner.vala:
+ * vala/valatokentype.vala:
+
+ Add `owned' type modifier and `(owned)' cast to replace `#',
+ add `unowned' type modifier to complement `weak' for non-reference
+ counted objects.
+
+ `#' will be deprecated in Vala 0.5.5
+
2008-12-18 Jürg Billeter <j@bitron.ch>
* gobject/valaccodememberaccessmodule.vala:
case TokenType.NULL:
case TokenType.OUT:
case TokenType.OVERRIDE:
+ case TokenType.OWNED:
case TokenType.PARAMS:
case TokenType.PRIVATE:
case TokenType.PROTECTED:
case TokenType.TRUE:
case TokenType.TRY:
case TokenType.TYPEOF:
+ case TokenType.UNOWNED:
case TokenType.USING:
case TokenType.VAR:
case TokenType.VIRTUAL:
return;
}
accept (TokenType.DYNAMIC);
+ accept (TokenType.OWNED);
+ accept (TokenType.UNOWNED);
accept (TokenType.WEAK);
skip_symbol_name ();
skip_type_argument_list ();
bool is_dynamic = accept (TokenType.DYNAMIC);
bool value_owned = owned_by_default;
+
if (owned_by_default) {
- value_owned = !accept (TokenType.WEAK);
+ if (accept (TokenType.UNOWNED)
+ || accept (TokenType.WEAK)) {
+ value_owned = false;
+ }
+ } else {
+ value_owned = accept (TokenType.OWNED);
}
var sym = parse_symbol_name ();
}
if (!owned_by_default) {
- value_owned = accept (TokenType.HASH);
+ if (accept (TokenType.HASH)) {
+ // TODO enable warning after releasing Vala 0.5.4
+ // Report.warning (get_last_src (), "deprecated syntax, use `owned` modifier");
+ value_owned = true;
+ }
}
type.is_dynamic = is_dynamic;
}
switch (current ()) {
case TokenType.HASH:
+ // TODO enable warning after releasing Vala 0.5.4
+ // Report.warning (get_last_src (), "deprecated syntax, use `(owned)` cast");
next ();
var op = parse_unary_expression ();
return new ReferenceTransferExpression (op, get_src (begin));
case TokenType.OPEN_PARENS:
next ();
switch (current ()) {
+ case TokenType.OWNED:
+ // (owned) foo
+ next ();
+ if (accept (TokenType.CLOSE_PARENS)) {
+ var op = parse_unary_expression ();
+ return new ReferenceTransferExpression (op, get_src (begin));
+ }
+ break;
case TokenType.VOID:
case TokenType.DYNAMIC:
- case TokenType.WEAK:
case TokenType.IDENTIFIER:
var type = parse_type ();
if (accept (TokenType.CLOSE_PARENS)) {
case TokenType.SIZEOF:
case TokenType.TYPEOF:
case TokenType.IDENTIFIER:
- if (!(type is PointerType) && !type.value_owned) {
- Report.warning (get_src (begin), "obsolete syntax, weak type modifier unused in cast expressions");
- }
var inner = parse_unary_expression ();
return new CastExpression (inner, type, get_src (begin), false);
default:
var begin = get_location ();
var access = parse_access_modifier ();
var flags = parse_member_declaration_modifiers ();
- bool is_weak = accept (TokenType.WEAK);
+ bool is_weak = accept (TokenType.UNOWNED) || accept (TokenType.WEAK);
var type = parse_type (false);
string id = parse_identifier ();
var prop = new Property (id, type, null, null, get_src_com (begin));
switch (current ()) {
case TokenType.VOID:
case TokenType.DYNAMIC:
+ case TokenType.UNOWNED:
case TokenType.WEAK:
case TokenType.IDENTIFIER:
var type = parse_type ();
OPEN_BRACKET,
OPEN_PARENS,
OVERRIDE,
+ OWNED,
PARAMS,
PERCENT,
PLUS,
TRUE,
TRY,
TYPEOF,
+ UNOWNED,
USING,
VAR,
VERBATIM_STRING_LITERAL,
case OPEN_BRACKET: return "`['";
case OPEN_PARENS: return "`('";
case OVERRIDE: return "`override'";
+ case OWNED: return "`owned'";
case PARAMS: return "`params'";
case PERCENT: return "`%'";
case PLUS: return "`+'";
case TRUE: return "`true'";
case TRY: return "`try'";
case TYPEOF: return "`typeof'";
+ case UNOWNED: return "`unowned'";
case USING: return "`using'";
case VAR: return "`var'";
case VIRTUAL: return "`virtual'";