support static interfaces make set_type_id public add GBoxed as interface
authorJürg Billeter <j@bitron.ch>
Wed, 21 Mar 2007 17:05:04 +0000 (17:05 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 21 Mar 2007 17:05:04 +0000 (17:05 +0000)
2007-03-21  Jürg Billeter  <j@bitron.ch>

* vala/parser.y, vala/valainterface.vala: support static interfaces
* vala/valastruct.vala: make set_type_id public
* vapi/glib-2.0.vala: add GBoxed as interface

svn path=/trunk/; revision=255

vala/ChangeLog
vala/vala/parser.y
vala/vala/valainterface.vala
vala/vala/valastruct.vala
vala/vapi/glib-2.0.vala

index 484bb7b..518bae3 100644 (file)
@@ -1,5 +1,11 @@
 2007-03-21  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y, vala/valainterface.vala: support static interfaces
+       * vala/valastruct.vala: make set_type_id public
+       * vapi/glib-2.0.vala: add GBoxed as interface
+
+2007-03-21  Jürg Billeter  <j@bitron.ch>
+
        * vala/valastruct.vala: use pointer as default of type_id and
          marshaller_type_name for reference types
        * vala/valapointer.vala: implement get_type_id
index ffb33a3..1333fed 100644 (file)
@@ -2937,24 +2937,24 @@ struct_member_declaration
        ;
 
 interface_declaration
-       : comment opt_attributes opt_access_modifier INTERFACE identifier opt_name_specifier opt_type_parameter_list opt_class_base
+       : comment opt_attributes opt_access_modifier opt_modifiers INTERFACE identifier opt_name_specifier opt_type_parameter_list opt_class_base
          {
-               char *name = $5;
+               char *name = $6;
          
-               if ($6 != NULL) {
-                       ValaSourceReference *ns_src = src(@5);
-                       current_namespace = vala_namespace_new ($5, ns_src);
-                       g_free ($5);
+               if ($7 != NULL) {
+                       ValaSourceReference *ns_src = src(@6);
+                       current_namespace = vala_namespace_new ($6, ns_src);
+                       g_free ($6);
                        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 = $6;
+                       name = $7;
                }
                
-               ValaSourceReference *src = src_com(@5, $1);
+               ValaSourceReference *src = src_com(@6, $1);
                current_interface = vala_interface_new (name, src);
                g_free (name);
                g_object_unref (src);
@@ -2963,21 +2963,24 @@ interface_declaration
                if ($3 != 0) {
                        VALA_DATA_TYPE(current_interface)->access = $3;
                }
-               if ($7 != NULL) {
+               if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
+                       vala_interface_set_is_static (current_interface, TRUE);
+               }
+               if ($8 != NULL) {
                        GList *l;
-                       for (l = $7; l != NULL; l = l->next) {
+                       for (l = $8; l != NULL; l = l->next) {
                                vala_interface_add_type_parameter (current_interface, l->data);
                                g_object_unref (l->data);
                        }
-                       g_list_free ($7);
+                       g_list_free ($8);
                }
-               if ($8 != NULL) {
+               if ($9 != NULL) {
                        GList *l;
-                       for (l = $8; l != NULL; l = l->next) {
+                       for (l = $9; l != NULL; l = l->next) {
                                vala_interface_add_prerequisite (current_interface, l->data);
                                g_object_unref (l->data);
                        }
-                       g_list_free ($8);
+                       g_list_free ($9);
                }
          }
          interface_body
index c496d5d..a9abea8 100644 (file)
@@ -26,6 +26,12 @@ using GLib;
  * Represents a class declaration in the source code.
  */
 public class Vala.Interface : DataType {
+       /**
+        * Specifies whether this interface is static. Static interfaces are not
+        * available at run-time. They can be implemented by structs.
+        */
+       public bool is_static { get; set; }
+
        private List<TypeParameter> type_parameters;
        
        private List<TypeReference> prerequisites;
index 383e04d..f6e6b5e 100644 (file)
@@ -340,7 +340,7 @@ public class Vala.Struct : DataType {
                return type_id;
        }
        
-       private void set_type_id (string! name) {
+       public void set_type_id (string! name) {
                this.type_id = name;
        }
 
index 4e4cc6c..78d8d97 100644 (file)
@@ -479,7 +479,12 @@ namespace GLib {
        
        public abstract class InitiallyUnowned : Object {
        }
-       
+
+       public /* static */ interface Boxed<G> {
+               public abstract G copy ();
+               public abstract void free ();
+       }
+
        [ReferenceType (free_function = "g_free")]
        public struct Value {
                public weak Object get_object ();