]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
support delegate keyword and optional modifiers to declare callbacks
authorJuerg Billeter <j@bitron.ch>
Mon, 9 Jul 2007 05:08:30 +0000 (05:08 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 9 Jul 2007 05:08:30 +0000 (05:08 +0000)
2007-07-09  Juerg Billeter  <j@bitron.ch>

* vala/scanner.l, vala/parser.y: support delegate keyword and optional
  modifiers to declare callbacks

svn path=/trunk/; revision=332

ChangeLog
vala/parser.y
vala/scanner.l

index f6ca8f9ddc1f42e378153b4e3dab94166e20c81b..16dcb074dc4490a984431ffc1d19211f82273c0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-09  Jürg Billeter  <j@bitron.ch>
+
+       * vala/scanner.l, vala/parser.y: support delegate keyword and optional
+         modifiers to declare callbacks
+
 2007-07-09  Jürg Billeter  <j@bitron.ch>
 
        * vala/parser.y: support # modifier to transfer ownership in method
index 56016fe6665d4aa7316b93e62caf5c546da5c683..dd3f6c22dc239f009ec59d40014e4103e8632169 100644 (file)
@@ -162,6 +162,7 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg);
 %token CONSTRUCT "construct"
 %token CONTINUE "continue"
 %token DEFAULT "default"
+%token DELEGATE "delegate"
 %token DO "do"
 %token ELSE "else"
 %token ENUM "enum"
@@ -3328,6 +3329,50 @@ callback_declaration
                        g_list_free ($10);
                }
          }
+       | comment opt_attributes opt_access_modifier opt_modifiers DELEGATE type identifier opt_name_specifier opt_type_parameter_list OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS SEMICOLON
+         {
+               ValaSourceReference *src;
+               GList *l;
+               char *name = $7;
+         
+               if ($8 != NULL) {
+                       ValaSourceReference *ns_src = src(@7);
+                       current_namespace = vala_namespace_new ($7, ns_src);
+                       g_free ($7);
+                       g_object_unref (ns_src);
+                       current_namespace_implicit = TRUE;
+
+                       vala_source_file_add_namespace (current_source_file, current_namespace);
+                       g_object_unref (current_namespace);
+                       
+                       name = $8;
+               }
+               
+               src = src_com(@7, $1);
+               $$ = vala_callback_new (name, $6, src);
+               g_free (name);
+               g_object_unref ($6);
+               g_object_unref (src);
+               if ($3 != 0) {
+                       VALA_DATA_TYPE($$)->access = $3;
+               }
+               VALA_CODE_NODE($$)->attributes = $2;
+               
+               if ($9 != NULL) {
+                       for (l = $9; l != NULL; l = l->next) {
+                               vala_callback_add_type_parameter ($$, l->data);
+                               g_object_unref (l->data);
+                       }
+                       g_list_free ($9);
+               }
+               if ($11 != NULL) {
+                       for (l = $11; l != NULL; l = l->next) {
+                               vala_callback_add_parameter ($$, l->data);
+                               g_object_unref (l->data);
+                       }
+                       g_list_free ($11);
+               }
+         }
        ;
 
 opt_attributes
index 90754b2885dbe64fa7e7f458832a51a07d4d2c26..b1b81a7fe32bc0376e20a557f0efbd244fedefb5 100644 (file)
@@ -138,6 +138,7 @@ literal                             ({integer_literal}|{real_literal}|{character_literal}|{string_literal
 "construct"    { uploc; return CONSTRUCT; }
 "continue"     { uploc; return CONTINUE; }
 "default"      { uploc; return DEFAULT; }
+"delegate"     { uploc; return DELEGATE; }
 "do"           { uploc; return DO; }
 "else"         { uploc; return ELSE; }
 "enum"         { uploc; return ENUM; }