From 9374f2ea89248cb5e0bf0e6b5cc1928dc7ab4435 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Wed, 21 Mar 2007 17:05:04 +0000 Subject: [PATCH] support static interfaces make set_type_id public add GBoxed as interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2007-03-21 Jürg Billeter * 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 | 6 ++++++ vala/vala/parser.y | 31 +++++++++++++++++-------------- vala/vala/valainterface.vala | 6 ++++++ vala/vala/valastruct.vala | 2 +- vala/vapi/glib-2.0.vala | 7 ++++++- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/vala/ChangeLog b/vala/ChangeLog index 484bb7b..518bae3 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,5 +1,11 @@ 2007-03-21 Jürg Billeter + * 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 + * vala/valastruct.vala: use pointer as default of type_id and marshaller_type_name for reference types * vala/valapointer.vala: implement get_type_id diff --git a/vala/vala/parser.y b/vala/vala/parser.y index ffb33a3..1333fed 100644 --- a/vala/vala/parser.y +++ b/vala/vala/parser.y @@ -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 diff --git a/vala/vala/valainterface.vala b/vala/vala/valainterface.vala index c496d5d..a9abea8 100644 --- a/vala/vala/valainterface.vala +++ b/vala/vala/valainterface.vala @@ -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 type_parameters; private List prerequisites; diff --git a/vala/vala/valastruct.vala b/vala/vala/valastruct.vala index 383e04d..f6e6b5e 100644 --- a/vala/vala/valastruct.vala +++ b/vala/vala/valastruct.vala @@ -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; } diff --git a/vala/vapi/glib-2.0.vala b/vala/vapi/glib-2.0.vala index 4e4cc6c..78d8d97 100644 --- a/vala/vapi/glib-2.0.vala +++ b/vala/vapi/glib-2.0.vala @@ -479,7 +479,12 @@ namespace GLib { public abstract class InitiallyUnowned : Object { } - + + public /* static */ interface Boxed { + public abstract G copy (); + public abstract void free (); + } + [ReferenceType (free_function = "g_free")] public struct Value { public weak Object get_object (); -- 2.7.4