2008-02-23 Jürg Billeter <j@bitron.ch>
+ * vala/parser.y, vala/valaclass.vala, vala/valainterface.vala:
+ support inner enums, support inner types in interfaces,
+ fixes bug 518258
+
+2008-02-23 Jürg Billeter <j@bitron.ch>
+
* vapi/gconf-2.0.vapi, vapi/gdk-2.0.vapi, vapi/gdk-pixbuf-2.0.vapi,
vapi/gio-2.0.vapi, vapi/gnet-2.0.vapi, vapi/gnome-vfs-2.0.vapi,
vapi/gstreamer-0.10.vapi, vapi/gstreamer-audio-0.10.vapi,
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));
}
| class_declaration
| struct_declaration
+ | enum_declaration
;
constant_declaration
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));
g_object_unref ($1);
}
}
+ | class_declaration
+ | struct_declaration
+ | enum_declaration
;
enum_declaration
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;
// 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.
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);
}
foreach (Struct st in structs) {
st.accept (visitor);
}
+
+ foreach (Enum en in enums) {
+ en.accept (visitor);
+ }
}
public override string! get_cprefix () {
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;
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);
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 () {