+2007-12-12 Jürg Billeter <j@bitron.ch>
+
+ * vala/parser.y, vala/scanner.l, vala/valadatatype.vala,
+ vala/valasymbolresolver.vala, vala/valavoidtype.vala: always use
+ VoidType
+
+ * tests/delegates.exp, tests/delegates.vala: test delegates with void
+ return types
+
2007-12-09 Jürg Billeter <j@bitron.ch>
* vapi/packages/gdk-2.0/, vapi/packages/gtk+-2.0/, vapi/packages/pango/:
-Delegate Test: 1 2 3
+Delegate Test: 1 2 3 4 5
using GLib;
+public static delegate void Maman.VoidCallback ();
+
public static delegate int Maman.ActionCallback ();
class Maman.Bar : Object {
+ static void do_void_action () {
+ stdout.printf (" 2");
+ }
+
static int do_action () {
- return 2;
+ return 4;
}
static int main (string[] args) {
stdout.printf ("Delegate Test: 1");
+ VoidCallback void_cb = do_void_action;
+
+ void_cb ();
+
+ stdout.printf (" 3");
+
ActionCallback cb = do_action;
stdout.printf (" %d", cb ());
- stdout.printf (" 3\n");
+ stdout.printf (" 5\n");
return 0;
}
%token USING "using"
%token VAR "var"
%token VIRTUAL "virtual"
+%token VOID "void"
%token VOLATILE "volatile"
%token WEAK "weak"
%token WHILE "while"
vala_unresolved_type_set_non_null (VALA_UNRESOLVED_TYPE ($$), TRUE);
}
}
+ | VOID
+ {
+ $$ = VALA_DATA_TYPE (vala_void_type_new ());
+ }
;
opt_argument_list
src = src_com(@6, $1);
- if (vala_unresolved_type_get_is_ref (VALA_UNRESOLVED_TYPE ($5)) || vala_unresolved_type_get_is_out (VALA_UNRESOLVED_TYPE ($5))) {
- vala_report_error (src, "`ref' and `out' may only be used for parameters.");
- }
- if (!vala_unresolved_type_get_is_weak (VALA_UNRESOLVED_TYPE ($5))) {
- vala_unresolved_type_set_transfers_ownership (VALA_UNRESOLVED_TYPE ($5), TRUE);
- }
+ if (VALA_IS_UNRESOLVED_TYPE ($5)) {
+ if (vala_unresolved_type_get_is_ref (VALA_UNRESOLVED_TYPE ($5)) || vala_unresolved_type_get_is_out (VALA_UNRESOLVED_TYPE ($5))) {
+ vala_report_error (src, "`ref' and `out' may only be used for parameters.");
+ }
+ if (!vala_unresolved_type_get_is_weak (VALA_UNRESOLVED_TYPE ($5))) {
+ vala_unresolved_type_set_transfers_ownership (VALA_UNRESOLVED_TYPE ($5), TRUE);
+ }
+ }
$$ = vala_code_context_create_method (context, $6, $5, src);
g_object_unref (src);
"using" { uploc; return USING; }
"var" { uploc; return VAR; }
"virtual" { uploc; return VIRTUAL; }
+"void" { uploc; return VOID; }
"volatile" { uploc; return VOLATILE; }
"weak" { uploc; return WEAK; }
"while" { uploc; return WHILE; }
* @param type2 a type reference
* @return true if this type reference is stricter or equal
*/
- public bool stricter (DataType! type2) {
+ public virtual bool stricter (DataType! type2) {
if (type2.transfers_ownership != transfers_ownership) {
return false;
}
type.add_type_argument (type_arg);
}
- if (unresolved_type.type_name == null || unresolved_type.type_name == "void") {
- return type;
- }
-
if (unresolved_type.namespace_name == null) {
Symbol sym = null;
Scope scope = current_scope;
public class Vala.VoidType : DataType {
public VoidType () {
}
+
+ public override bool stricter (DataType! type2) {
+ return (type2 is VoidType);
+ }
}