vala r1041 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1041 - in trunk: . vala
- Date: Sat, 23 Feb 2008 17:58:19 +0000 (GMT)
Author: juergbi
Date: Sat Feb 23 17:58:19 2008
New Revision: 1041
URL: http://svn.gnome.org/viewvc/vala?rev=1041&view=rev
Log:
2008-02-23 Juerg Billeter <j bitron ch>
* vala/parser.y, vala/valaclass.vala, vala/valainterface.vala:
support inner enums, support inner types in interfaces,
fixes bug 518258
Modified:
trunk/ChangeLog
trunk/vala/parser.y
trunk/vala/valaclass.vala
trunk/vala/valainterface.vala
Modified: trunk/vala/parser.y
==============================================================================
--- trunk/vala/parser.y (original)
+++ trunk/vala/parser.y Sat Feb 23 17:58:19 2008
@@ -2728,6 +2728,8 @@
if (VALA_IS_CLASS (parent_symbol)) {
vala_class_add_class (VALA_CLASS (parent_symbol), VALA_CLASS (current_symbol));
+ } else if (VALA_IS_INTERFACE (parent_symbol)) {
+ vala_interface_add_class (VALA_INTERFACE (parent_symbol), VALA_CLASS (current_symbol));
} else if (VALA_IS_NAMESPACE (parent_symbol)) {
vala_namespace_add_class (VALA_NAMESPACE (parent_symbol), VALA_CLASS (current_symbol));
vala_source_file_add_node (current_source_file, VALA_CODE_NODE (current_symbol));
@@ -2961,6 +2963,7 @@
}
| class_declaration
| struct_declaration
+ | enum_declaration
;
constant_declaration
@@ -3720,6 +3723,8 @@
if (VALA_IS_CLASS (parent_symbol)) {
vala_class_add_struct (VALA_CLASS (parent_symbol), VALA_STRUCT (current_symbol));
+ } else if (VALA_IS_INTERFACE (parent_symbol)) {
+ vala_interface_add_struct (VALA_INTERFACE (parent_symbol), VALA_STRUCT (current_symbol));
} else if (VALA_IS_NAMESPACE (parent_symbol)) {
vala_namespace_add_struct (VALA_NAMESPACE (parent_symbol), VALA_STRUCT (current_symbol));
vala_source_file_add_node (current_source_file, VALA_CODE_NODE (current_symbol));
@@ -3925,6 +3930,9 @@
g_object_unref ($1);
}
}
+ | class_declaration
+ | struct_declaration
+ | enum_declaration
;
enum_declaration
@@ -3965,8 +3973,16 @@
g_free (name);
g_object_unref (src);
- vala_namespace_add_enum (VALA_NAMESPACE (parent_symbol), en);
- vala_source_file_add_node (current_source_file, VALA_CODE_NODE (en));
+ if (VALA_IS_CLASS (parent_symbol)) {
+ vala_class_add_enum (VALA_CLASS (parent_symbol), en);
+ } else if (VALA_IS_INTERFACE (parent_symbol)) {
+ vala_interface_add_enum (VALA_INTERFACE (parent_symbol), en);
+ } else if (VALA_IS_NAMESPACE (parent_symbol)) {
+ vala_namespace_add_enum (VALA_NAMESPACE (parent_symbol), en);
+ vala_source_file_add_node (current_source_file, VALA_CODE_NODE (en));
+ } else {
+ g_assert_not_reached ();
+ }
g_object_unref (parent_symbol);
VALA_CODE_NODE (en)->attributes = $2;
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Sat Feb 23 17:58:19 2008
@@ -82,6 +82,7 @@
// inner types
private Gee.List<Class> classes = new ArrayList<Class> ();
private Gee.List<Struct> structs = new ArrayList<Struct> ();
+ private Gee.List<Enum> enums = new ArrayList<Enum> ();
/**
* Specifies the default construction method.
@@ -314,6 +315,16 @@
scope.add (st.name, st);
}
+ /**
+ * Adds the specified enum as an inner enum.
+ *
+ * @param en an enum
+ */
+ public void add_enum (Enum en) {
+ enums.add (en);
+ scope.add (en.name, en);
+ }
+
public override void accept (CodeVisitor! visitor) {
visitor.visit_class (this);
}
@@ -362,6 +373,10 @@
foreach (Struct st in structs) {
st.accept (visitor);
}
+
+ foreach (Enum en in enums) {
+ en.accept (visitor);
+ }
}
public override string! get_cprefix () {
Modified: trunk/vala/valainterface.vala
==============================================================================
--- trunk/vala/valainterface.vala (original)
+++ trunk/vala/valainterface.vala Sat Feb 23 17:58:19 2008
@@ -43,7 +43,12 @@
private Gee.List<Field> fields = new ArrayList<Field> ();
private Gee.List<Property> properties = new ArrayList<Property> ();
private Gee.List<Signal> signals = new ArrayList<Signal> ();
-
+
+ // inner types
+ private Gee.List<Class> classes = new ArrayList<Class> ();
+ private Gee.List<Struct> structs = new ArrayList<Struct> ();
+ private Gee.List<Enum> enums = new ArrayList<Enum> ();
+
private string cname;
private string lower_case_csuffix;
private string type_cname;
@@ -201,7 +206,37 @@
public Collection<Signal> get_signals () {
return new ReadOnlyCollection<Signal> (signals);
}
-
+
+ /**
+ * Adds the specified class as an inner class.
+ *
+ * @param cl a class
+ */
+ public void add_class (Class! cl) {
+ classes.add (cl);
+ scope.add (cl.name, cl);
+ }
+
+ /**
+ * Adds the specified struct as an inner struct.
+ *
+ * @param st a struct
+ */
+ public void add_struct (Struct! st) {
+ structs.add (st);
+ scope.add (st.name, st);
+ }
+
+ /**
+ * Adds the specified enum as an inner enum.
+ *
+ * @param en an enum
+ */
+ public void add_enum (Enum en) {
+ enums.add (en);
+ scope.add (en.name, en);
+ }
+
public override string get_cname (bool const_type = false) {
if (cname == null) {
cname = "%s%s".printf (parent_symbol.get_cprefix (), name);
@@ -285,6 +320,18 @@
foreach (Signal sig in signals) {
sig.accept (visitor);
}
+
+ foreach (Class cl in classes) {
+ cl.accept (visitor);
+ }
+
+ foreach (Struct st in structs) {
+ st.accept (visitor);
+ }
+
+ foreach (Enum en in enums) {
+ en.accept (visitor);
+ }
}
public override bool is_reference_type () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]