]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
move iteration of data types from accept to accept_children method
authorJürg Billeter <j@bitron.ch>
Fri, 15 Jun 2007 12:36:34 +0000 (12:36 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 15 Jun 2007 12:36:34 +0000 (12:36 +0000)
2007-06-15  Jürg Billeter  <j@bitron.ch>

* vala/valaattributeprocessor.vala, vala/valacodevisitor.vala,
  vala/valainterfacewriter.vala, vala/valamemorymanager.vala,
  vala/valaparser.vala, vala/valasemanticanalyzer.vala,
  vala/valasymbolbuilder.vala, vala/valasymbolresolver.vala,
  vala/valacallback.vala, vala/valaclass.vala, vala/valaenum.vala,
  vala/valaflags.vala, vala/valainterface.vala, vala/valastruct.vala,
  gobject/valacodegenerator.class, gobject/valacodegeneratorclass.vala,
  gobject/valacodegeneratorinterface.vala,
  gobject/valacodegeneratorstruct.vala: move iteration of data types
  from accept to accept_children method

svn path=/trunk/; revision=323

19 files changed:
ChangeLog
gobject/valacodegenerator.vala
gobject/valacodegeneratorclass.vala
gobject/valacodegeneratorinterface.vala
gobject/valacodegeneratorstruct.vala
vala/valaattributeprocessor.vala
vala/valacallback.vala
vala/valaclass.vala
vala/valacodevisitor.vala
vala/valaenum.vala
vala/valaflags.vala
vala/valainterface.vala
vala/valainterfacewriter.vala
vala/valamemorymanager.vala
vala/valaparser.vala
vala/valasemanticanalyzer.vala
vala/valastruct.vala
vala/valasymbolbuilder.vala
vala/valasymbolresolver.vala

index 202e9c129ddc3cd99b095d2ce9db0ba1fb054ff6..bef993df7a9c255b96002dfc53fe1ec3445d2c66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-06-15  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaattributeprocessor.vala, vala/valacodevisitor.vala,
+         vala/valainterfacewriter.vala, vala/valamemorymanager.vala,
+         vala/valaparser.vala, vala/valasemanticanalyzer.vala,
+         vala/valasymbolbuilder.vala, vala/valasymbolresolver.vala,
+         vala/valacallback.vala, vala/valaclass.vala, vala/valaenum.vala,
+         vala/valaflags.vala, vala/valainterface.vala, vala/valastruct.vala,
+         gobject/valacodegenerator.class, gobject/valacodegeneratorclass.vala,
+         gobject/valacodegeneratorinterface.vala,
+         gobject/valacodegeneratorstruct.vala: move iteration of data types
+         from accept to accept_children method
+
 2007-06-15  Jürg Billeter  <j@bitron.ch>
 
        * vala/valaattributeprocessor.vala, vala/valacodevisitor.vala,
index e1791a9e74c0a74f6881fc57db38ee0bbba78e24..729e0dd8ea6d52b4fd76eb11710390a093230c45 100644 (file)
@@ -258,13 +258,15 @@ public class Vala.CodeGenerator : CodeVisitor {
                ns.accept_children (this);
        }
 
-       public override void visit_begin_enum (Enum! en) {
+       public override void visit_enum (Enum! en) {
                cenum = new CCodeEnum (en.get_cname ());
 
                if (en.source_reference.comment != null) {
                        header_type_definition.append (new CCodeComment (en.source_reference.comment));
                }
                header_type_definition.append (cenum);
+
+               en.accept_children (this);
        }
 
        public override void visit_enum_value (EnumValue! ev) {
@@ -278,13 +280,15 @@ public class Vala.CodeGenerator : CodeVisitor {
                cenum.add_value (ev.get_cname (), val);
        }
 
-       public override void visit_begin_flags (Flags! fl) {
+       public override void visit_flags (Flags! fl) {
                cenum = new CCodeEnum (fl.get_cname ());
 
                if (fl.source_reference.comment != null) {
                        header_type_definition.append (new CCodeComment (fl.source_reference.comment));
                }
                header_type_definition.append (cenum);
+
+               fl.accept_children (this);
        }
 
        public override void visit_flags_value (FlagsValue! fv) {
@@ -298,7 +302,9 @@ public class Vala.CodeGenerator : CodeVisitor {
                cenum.add_value (fv.get_cname (), val);
        }
 
-       public override void visit_end_callback (Callback! cb) {
+       public override void visit_callback (Callback! cb) {
+               cb.accept_children (this);
+
                var cfundecl = new CCodeFunctionDeclarator (cb.get_cname ());
                foreach (FormalParameter param in cb.get_parameters ()) {
                        cfundecl.add_parameter ((CCodeFormalParameter) param.ccodenode);
index ac24723c5cb392235679711a6eeae5aab489fea0..ce4de0b12856e01986f810cf6fe3b18706e6a47d 100644 (file)
@@ -24,7 +24,7 @@
 using GLib;
 
 public class Vala.CodeGenerator {
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
                current_symbol = cl.symbol;
                current_type_symbol = cl.symbol;
                current_class = cl;
@@ -85,9 +85,9 @@ public class Vala.CodeGenerator {
                        source_type_member_declaration.append (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
                }
                source_type_member_declaration.append (prop_enum);
-       }
-       
-       public override void visit_end_class (Class! cl) {
+
+               cl.accept_children (this);
+
                if (!cl.is_static) {
                        if (class_has_readable_properties (cl)) {
                                add_get_property_function (cl);
index 8252993aafa0a32546de02931efaf16b8e791aba..5ca47eda6690e373781542c876ec64e30326e071 100644 (file)
 using GLib;
 
 public class Vala.CodeGenerator {
-       public override void visit_begin_interface (Interface! iface) {
+       public override void visit_interface (Interface! iface) {
                current_symbol = iface.symbol;
                current_type_symbol = iface.symbol;
 
-               if (iface.is_static) {
-                       return;
-               }
+               if (!iface.is_static) {
+                       type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
+                       
+                       header_type_declaration.append (new CCodeNewline ());
+                       var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
+                       header_type_declaration.append (new CCodeMacroReplacement (iface.get_upper_case_cname ("TYPE_"), macro));
 
-               type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
-               
-               header_type_declaration.append (new CCodeNewline ());
-               var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
-               header_type_declaration.append (new CCodeMacroReplacement (iface.get_upper_case_cname ("TYPE_"), macro));
+                       macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_upper_case_cname ("TYPE_"), iface.get_cname ());
+                       header_type_declaration.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
 
-               macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_upper_case_cname ("TYPE_"), iface.get_cname ());
-               header_type_declaration.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
+                       macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_upper_case_cname ("TYPE_"));
+                       header_type_declaration.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname ("IS_")), macro));
 
-               macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_upper_case_cname ("TYPE_"));
-               header_type_declaration.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname ("IS_")), macro));
+                       macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_upper_case_cname ("TYPE_"), iface.get_type_cname ());
+                       header_type_declaration.append (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
+                       header_type_declaration.append (new CCodeNewline ());
 
-               macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_upper_case_cname ("TYPE_"), iface.get_type_cname ());
-               header_type_declaration.append (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
-               header_type_declaration.append (new CCodeNewline ());
 
+                       if (iface.source_reference.file.cycle == null) {
+                               header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
+                               header_type_declaration.append (new CCodeTypeDefinition ("struct %s".printf (type_struct.name), new CCodeVariableDeclarator (iface.get_type_cname ())));
+                       }
+                       
+                       type_struct.add_field ("GTypeInterface", "parent");
 
-               if (iface.source_reference.file.cycle == null) {
-                       header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
-                       header_type_declaration.append (new CCodeTypeDefinition ("struct %s".printf (type_struct.name), new CCodeVariableDeclarator (iface.get_type_cname ())));
+                       if (iface.source_reference.comment != null) {
+                               header_type_definition.append (new CCodeComment (iface.source_reference.comment));
+                       }
+                       header_type_definition.append (type_struct);
                }
-               
-               type_struct.add_field ("GTypeInterface", "parent");
 
-               if (iface.source_reference.comment != null) {
-                       header_type_definition.append (new CCodeComment (iface.source_reference.comment));
-               }
-               header_type_definition.append (type_struct);
-       }
+               iface.accept_children (this);
 
-       public override void visit_end_interface (Interface! iface) {
                if (!iface.is_static) {
                        add_interface_base_init_function (iface);
 
index 2176c048825b0c4bf943925d58fdced4160d3712..65e5657530260c27038be26016c6176d4bb22782 100644 (file)
@@ -24,7 +24,7 @@
 using GLib;
 
 public class Vala.CodeGenerator {
-       public override void visit_begin_struct (Struct! st) {
+       public override void visit_struct (Struct! st) {
                current_type_symbol = st.symbol;
 
                instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
@@ -37,9 +37,9 @@ public class Vala.CodeGenerator {
                        header_type_definition.append (new CCodeComment (st.source_reference.comment));
                }
                header_type_definition.append (instance_struct);
-       }
-       
-       public override void visit_end_struct (Struct! st) {
+
+               st.accept_children (this);
+
                current_type_symbol = null;
        }
 }
index 9300718fe01c4086c5d6d8fccd38a5b4a6b64c3c..d70dcccf0c9e68bf989abdb0f629ad254f48818d 100644 (file)
@@ -46,23 +46,29 @@ public class Vala.AttributeProcessor : CodeVisitor {
                ns.accept_children (this);
        }
 
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
                cl.process_attributes ();
+
+               cl.accept_children (this);
        }
 
-       public override void visit_begin_struct (Struct! st) {
+       public override void visit_struct (Struct! st) {
                st.process_attributes ();
+
+               st.accept_children (this);
        }
 
-       public override void visit_begin_interface (Interface! iface) {
+       public override void visit_interface (Interface! iface) {
                iface.process_attributes ();
+
+               iface.accept_children (this);
        }
 
-       public override void visit_begin_enum (Enum! en) {
+       public override void visit_enum (Enum! en) {
                en.process_attributes ();
        }
 
-       public override void visit_begin_flags (Flags! fl) {
+       public override void visit_flags (Flags! fl) {
                fl.process_attributes ();
        }
 
@@ -78,7 +84,7 @@ public class Vala.AttributeProcessor : CodeVisitor {
                prop.process_attributes ();
        }
 
-       public override void visit_begin_callback (Callback! cb) {
+       public override void visit_callback (Callback! cb) {
                cb.process_attributes ();
        }
 
index c563622f05f1fb3b9cae52f065b434300d316578..c2d3fd7f8497b4d2ea383fa10338de69ecb18d56 100644 (file)
@@ -130,10 +130,12 @@ public class Vala.Callback : DataType {
                
                return true;
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_callback (this);
+               visitor.visit_callback (this);
+       }
 
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (TypeParameter p in type_parameters) {
                        p.accept (visitor);
                }
@@ -143,8 +145,6 @@ public class Vala.Callback : DataType {
                foreach (FormalParameter! param in parameters) {
                        param.accept (visitor);
                }
-
-               visitor.visit_end_callback (this);
        }
 
        public override string get_cname (bool const_type = false) {
index 24303e3a889f9c72e5c20d3fd3775c587f536432..d960ec9cfa9ee090d6a2394eb3d125ca7342b826 100644 (file)
@@ -229,10 +229,12 @@ public class Vala.Class : DataType {
        public ref List<weak Signal> get_signals () {
                return signals.copy ();
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_class (this);
-               
+               visitor.visit_class (this);
+       }
+
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (TypeReference type in base_types) {
                        type.accept (visitor);
                }
@@ -268,10 +270,8 @@ public class Vala.Class : DataType {
                if (destructor != null) {
                        destructor.accept (visitor);
                }
-
-               visitor.visit_end_class (this);
        }
-       
+
        public override string get_cname (bool const_type = false) {
                if (cname == null) {
                        cname = "%s%s".printf (@namespace.get_cprefix (), name);
index eab68f1b638817ef372e282c21d8368be82dbb3b..3c669e5ec4403632e0bd34e23b1fc61c2522572c 100644 (file)
@@ -44,67 +44,35 @@ public abstract class Vala.CodeVisitor {
        }
 
        /**
-        * Visit operation called at beginning of classes.
+        * Visit operation called for classes.
         *
         * @param cl a class
         */
-       public virtual void visit_begin_class (Class! cl) {
+       public virtual void visit_class (Class! cl) {
        }
 
        /**
-        * Visit operation called at end of classes.
-        *
-        * @param cl a class
-        */
-       public virtual void visit_end_class (Class! cl) {
-       }
-
-       /**
-        * Visit operation called at beginning of structs.
-        *
-        * @param st a struct
-        */
-       public virtual void visit_begin_struct (Struct! st) {
-       }
-
-       /**
-        * Visit operation called at end of structs.
+        * Visit operation called for structs.
         *
         * @param st a struct
         */
-       public virtual void visit_end_struct (Struct! st) {
-       }
-
-       /**
-        * Visit operation called at beginning of interfaces.
-        *
-        * @param iface an interface
-        */
-       public virtual void visit_begin_interface (Interface! iface) {
+       public virtual void visit_struct (Struct! st) {
        }
 
        /**
-        * Visit operation called at end of interfaces.
+        * Visit operation called for interfaces.
         *
         * @param iface an interface
         */
-       public virtual void visit_end_interface (Interface! iface) {
+       public virtual void visit_interface (Interface! iface) {
        }
 
        /**
-        * Visit operation called at beginning of enums.
+        * Visit operation called for enums.
         *
         * @param en an enum
         */
-       public virtual void visit_begin_enum (Enum! en) {
-       }
-
-       /**
-        * Visit operation called at end of enums.
-        *
-        * @param en an enum
-        */
-       public virtual void visit_end_enum (Enum! en) {
+       public virtual void visit_enum (Enum! en) {
        }
 
        /**
@@ -116,19 +84,11 @@ public abstract class Vala.CodeVisitor {
        }
 
        /**
-        * Visit operation called at beginning of flags.
-        *
-        * @param fl a flags
-        */
-       public virtual void visit_begin_flags (Flags! fl) {
-       }
-
-       /**
-        * Visit operation called at end of flags.
+        * Visit operation called for flags.
         *
         * @param fl a flags
         */
-       public virtual void visit_end_flags (Flags! fl) {
+       public virtual void visit_flags (Flags! fl) {
        }
 
        /**
@@ -140,19 +100,11 @@ public abstract class Vala.CodeVisitor {
        }
 
        /**
-        * Visit operation called at beginning of callbacks.
-        *
-        * @param cb a callback
-        */
-       public virtual void visit_begin_callback (Callback! cb) {
-       }
-
-       /**
-        * Visit operation called at end of callbacks.
+        * Visit operation called for callbacks.
         *
         * @param cb a callback
         */
-       public virtual void visit_end_callback (Callback! cb) {
+       public virtual void visit_callback (Callback! cb) {
        }
        
        /**
index a759c00cd507230a5a412d63067691a5d115fa65..63ac6af0a50ff96591af5a9e3f4a6857016ae122 100644 (file)
@@ -1,6 +1,6 @@
 /* valaenum.vala
  *
- * Copyright (C) 2006  Jürg Billeter
+ * Copyright (C) 2006-2007  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -50,15 +50,15 @@ public class Vala.Enum : DataType {
        public void add_value (EnumValue! value) {
                values.append (value);
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_enum (this);
-               
+               visitor.visit_enum (this);
+       }
+
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (EnumValue value in values) {
                        value.accept (visitor);
                }
-
-               visitor.visit_end_enum (this);
        }
 
        public override string get_cname (bool const_type = false) {
index d47cb8b826a3db0305245c93ded2ce9df08cd17a..8d8374720800c9786e0f42587f206529e1130321 100644 (file)
@@ -50,13 +50,13 @@ public class Vala.Flags : DataType {
        }
 
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_flags (this);
+               visitor.visit_flags (this);
+       }
 
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (FlagsValue value in values) {
                        value.accept (visitor);
                }
-
-               visitor.visit_end_flags (this);
        }
 
        public override string get_cname (bool const_type = false) {
index a9abea8f4afd8df235581e3d273154c110da74b5..2a76469418ddc1d61a25f8f9dd4d54950f20e0af 100644 (file)
@@ -184,10 +184,12 @@ public class Vala.Interface : DataType {
        public override ref string get_upper_case_cname (string infix) {
                return get_lower_case_cname (infix).up ();
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_interface (this);
-               
+               visitor.visit_interface (this);
+       }
+
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (TypeReference type in prerequisites) {
                        type.accept (visitor);
                }
@@ -207,8 +209,6 @@ public class Vala.Interface : DataType {
                foreach (Signal sig in signals) {
                        sig.accept (visitor);
                }
-
-               visitor.visit_end_interface (this);
        }
 
        public override bool is_reference_type () {
index e2bf4281bd7fadfc2fb83299fc7b9beb9695732f..2decde1eb023f72a3c3b61b5debfb62c56a9c07d 100644 (file)
@@ -34,9 +34,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
        int indent;
        /* at begin of line */
        bool bol = true;
-       
-       bool internal_scope = false;
-       
+
        string current_cheader_filename;
 
        /**
@@ -88,9 +86,8 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_newline ();
        }
 
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
                if (cl.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = true;
                        return;
                }
                
@@ -132,21 +129,15 @@ public class Vala.InterfaceWriter : CodeVisitor {
                        }
                }
                write_begin_block ();
-       }
 
-       public override void visit_end_class (Class! cl) {
-               if (cl.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = false;
-                       return;
-               }
-               
+               cl.accept_children (this);
+
                write_end_block ();
                write_newline ();
        }
 
-       public override void visit_begin_struct (Struct! st) {
+       public override void visit_struct (Struct! st) {
                if (st.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = true;
                        return;
                }
                
@@ -159,21 +150,15 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_string ("public struct ");
                write_identifier (st.name);
                write_begin_block ();
-       }
 
-       public override void visit_end_struct (Struct! st) {
-               if (st.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = false;
-                       return;
-               }
-               
+               st.accept_children (this);
+
                write_end_block ();
                write_newline ();
        }
 
-       public override void visit_begin_interface (Interface! iface) {
+       public override void visit_interface (Interface! iface) {
                if (iface.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = true;
                        return;
                }
                
@@ -183,21 +168,15 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_identifier (iface.name);
 
                write_begin_block ();
-       }
 
-       public override void visit_end_interface (Interface! iface) {
-               if (iface.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = false;
-                       return;
-               }
-               
+               iface.accept_children (this);
+
                write_end_block ();
                write_newline ();
        }
 
-       public override void visit_begin_enum (Enum! en) {
+       public override void visit_enum (Enum! en) {
                if (en.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = true;
                        return;
                }
 
@@ -208,32 +187,22 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_string ("public enum ");
                write_identifier (en.name);
                write_begin_block ();
-       }
 
-       public override void visit_end_enum (Enum! en) {
-               if (en.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = false;
-                       return;
-               }
+               en.accept_children (this);
 
                write_end_block ();
                write_newline ();
        }
 
        public override void visit_enum_value (EnumValue! ev) {
-               if (internal_scope) {
-                       return;
-               }
-
                write_indent ();
                write_identifier (ev.name);
                write_string (",");
                write_newline ();
        }
 
-       public override void visit_begin_flags (Flags! fl) {
+       public override void visit_flags (Flags! fl) {
                if (fl.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = true;
                        return;
                }
 
@@ -244,23 +213,14 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_string ("public flags ");
                write_identifier (fl.name);
                write_begin_block ();
-       }
 
-       public override void visit_end_flags (Flags! fl) {
-               if (fl.access == MemberAccessibility.PRIVATE) {
-                       internal_scope = false;
-                       return;
-               }
+               fl.accept_children (this);
 
                write_end_block ();
                write_newline ();
        }
 
        public override void visit_flags_value (FlagsValue! fv) {
-               if (internal_scope) {
-                       return;
-               }
-
                write_indent ();
                write_identifier (fv.name);
                write_string (",");
@@ -268,10 +228,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
        }
 
        public override void visit_constant (Constant! c) {
-               if (internal_scope) {
-                       return;
-               }
-               
                write_indent ();
                write_string ("public const ");
                write_string (c.type_reference.data_type.symbol.get_full_name ());
@@ -283,7 +239,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
        }
 
        public override void visit_field (Field! f) {
-               if (internal_scope || f.access == MemberAccessibility.PRIVATE) {
+               if (f.access == MemberAccessibility.PRIVATE) {
                        return;
                }
                
@@ -366,8 +322,8 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_string (")");
        }
 
-       public override void visit_begin_callback (Callback! cb) {
-               if (internal_scope || cb.access == MemberAccessibility.PRIVATE) {
+       public override void visit_callback (Callback! cb) {
+               if (cb.access == MemberAccessibility.PRIVATE) {
                        return;
                }
                
@@ -397,7 +353,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
        }
 
        public override void visit_begin_method (Method! m) {
-               if (internal_scope || m.access == MemberAccessibility.PRIVATE || m.overrides) {
+               if (m.access == MemberAccessibility.PRIVATE || m.overrides) {
                        return;
                }
                
@@ -482,10 +438,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
        }
 
        public override void visit_begin_property (Property! prop) {
-               if (internal_scope) {
-                       return;
-               }
-               
                if (prop.no_accessor_method) {
                        write_indent ();
                        write_string ("[NoAccessorMethod]");
@@ -530,7 +482,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
        }
 
        public override void visit_begin_signal (Signal! sig) {
-               if (internal_scope || sig.access == MemberAccessibility.PRIVATE) {
+               if (sig.access == MemberAccessibility.PRIVATE) {
                        return;
                }
                
index fa8291c08ebdc4526b6a44dba85fd717c4c58d1f..175fef0a243b6f53fd9898a2162d0923b5953716 100644 (file)
@@ -69,6 +69,18 @@ public class Vala.MemoryManager : CodeVisitor {
                ns.accept_children (this);
        }
 
+       public override void visit_class (Class! cl) {
+               cl.accept_children (this);
+       }
+
+       public override void visit_struct (Struct! st) {
+               st.accept_children (this);
+       }
+
+       public override void visit_interface (Interface! iface) {
+               iface.accept_children (this);
+       }
+
        public override void visit_field (Field! f) {
                if (f.initializer != null) {
                        if (f.type_reference.takes_ownership) {
index 11b7f57b81bb50a2061fbd67fb13f907d6eefee5..517959b5d95f1a242591ed2b69ca884648729335 100644 (file)
@@ -45,8 +45,6 @@ public class Vala.Parser : CodeVisitor {
                        source_file.comment = _file_comment;
                }
 
-               source_file.accept_children (this);
-
                _file_comment = null;
        }
 
index 35c562d6caead29c3f80f761afe599b0c2786cfd..bdb685273849dd4102218a0e8a59c1faacfc1b8c 100644 (file)
@@ -118,7 +118,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_symbol = current_symbol.parent_symbol;
        }
 
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
                current_symbol = cl.symbol;
                current_class = cl;
 
@@ -129,48 +129,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                foreach (TypeReference base_type_reference in cl.get_base_types ()) {
                        current_source_file.add_symbol_dependency (base_type_reference.data_type.symbol, SourceFileDependencyType.HEADER_FULL);
                }
-       }
-
-       private ref List<DataType> get_all_prerequisites (Interface! iface) {
-               List<DataType> ret = null;
-
-               foreach (TypeReference prereq in iface.get_prerequisites ()) {
-                       DataType type = prereq.data_type;
-                       /* skip on previous errors */
-                       if (type == null) {
-                               continue;
-                       }
-
-                       ret.prepend (type);
-                       if (type is Interface) {
-                               ret.concat (get_all_prerequisites ((Interface) type));
-
-                       }
-               }
-
-               ret.reverse ();
-               return #ret;
-       }
 
-       private bool class_is_a (Class! cl, DataType! t) {
-               if (cl == t) {
-                       return true;
-               }
+               cl.accept_children (this);
 
-               foreach (TypeReference base_type in cl.get_base_types ()) {
-                       if (base_type.data_type is Class) {
-                               if (class_is_a ((Class) base_type.data_type, t)) {
-                                       return true;
-                               }
-                       } else if (base_type.data_type == t) {
-                               return true;
-                       }
-               }
-
-               return false;
-       }
-
-       public override void visit_end_class (Class! cl) {
                /* gather all prerequisites */
                List<DataType> prerequisites = null;
                foreach (TypeReference base_type in cl.get_base_types ()) {
@@ -248,25 +209,64 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_class = null;
        }
 
-       public override void visit_begin_struct (Struct! st) {
+       private ref List<DataType> get_all_prerequisites (Interface! iface) {
+               List<DataType> ret = null;
+
+               foreach (TypeReference prereq in iface.get_prerequisites ()) {
+                       DataType type = prereq.data_type;
+                       /* skip on previous errors */
+                       if (type == null) {
+                               continue;
+                       }
+
+                       ret.prepend (type);
+                       if (type is Interface) {
+                               ret.concat (get_all_prerequisites ((Interface) type));
+
+                       }
+               }
+
+               ret.reverse ();
+               return #ret;
+       }
+
+       private bool class_is_a (Class! cl, DataType! t) {
+               if (cl == t) {
+                       return true;
+               }
+
+               foreach (TypeReference base_type in cl.get_base_types ()) {
+                       if (base_type.data_type is Class) {
+                               if (class_is_a ((Class) base_type.data_type, t)) {
+                                       return true;
+                               }
+                       } else if (base_type.data_type == t) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
+       public override void visit_struct (Struct! st) {
                current_symbol = st.symbol;
                current_struct = st;
-       }
 
-       public override void visit_end_struct (Struct! st) {
+               st.accept_children (this);
+
                current_symbol = current_symbol.parent_symbol;
                current_struct = null;
        }
 
-       public override void visit_begin_interface (Interface! iface) {
+       public override void visit_interface (Interface! iface) {
                current_symbol = iface.symbol;
 
                foreach (TypeReference prerequisite_reference in iface.get_prerequisites ()) {
                        current_source_file.add_symbol_dependency (prerequisite_reference.data_type.symbol, SourceFileDependencyType.HEADER_FULL);
                }
-       }
 
-       public override void visit_end_interface (Interface! iface) {
+               iface.accept_children (this);
+
                /* check prerequisites */
                Class prereq_class;
                foreach (TypeReference prereq in iface.get_prerequisites ()) {
@@ -291,6 +291,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_symbol = current_symbol.parent_symbol;
        }
 
+       public override void visit_callback (Callback! cb) {
+               cb.accept_children (this);
+       }
+
        public override void visit_constant (Constant! c) {
                if (!current_source_file.pkg) {
                        if (c.initializer == null) {
index 09c587aedd4eaaa50ffb0d2b821a6647f9acda5d..0cf748288bcb75cad70669cac0ce96566f7fb0be 100644 (file)
@@ -122,10 +122,12 @@ public class Vala.Struct : DataType {
        public ref List<weak Method> get_methods () {
                return methods.copy ();
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_struct (this);
-               
+               visitor.visit_struct (this);
+       }
+
+       public override void accept_children (CodeVisitor! visitor) {
                foreach (TypeParameter p in type_parameters) {
                        p.accept (visitor);
                }
@@ -141,10 +143,8 @@ public class Vala.Struct : DataType {
                foreach (Method m in methods) {
                        m.accept (visitor);
                }
-
-               visitor.visit_end_struct (this);
        }
-       
+
        public override string get_cname (bool const_type = false) {
                if (const_type && const_cname != null) {
                        return const_cname;
index 39018d156fdc2a97fcd2e67a683885d2f3deddb7..a3843a3988f4bb29728e812b20a75abba5908481 100644 (file)
@@ -86,7 +86,12 @@ public class Vala.SymbolBuilder : CodeVisitor {
                return node.symbol;
        }
 
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
+               if (cl.error) {
+                       /* skip classes with errors */
+                       return;
+               }
+
                var class_symbol = current_symbol.lookup (cl.name);
                if (class_symbol == null || !(class_symbol.node is Class)) {
                        class_symbol = add_symbol (cl.name, cl);
@@ -127,14 +132,9 @@ public class Vala.SymbolBuilder : CodeVisitor {
                }
 
                current_symbol = class_symbol;
-       }
-       
-       public override void visit_end_class (Class! cl) {
-               if (cl.error) {
-                       /* skip classes with errors */
-                       return;
-               }
-               
+
+               cl.accept_children (this);
+
                current_symbol = current_symbol.parent_symbol;
 
                if (cl.symbol == null) {
@@ -142,54 +142,54 @@ public class Vala.SymbolBuilder : CodeVisitor {
                        cl.@namespace.remove_class (cl);
                }
        }
-       
-       public override void visit_begin_struct (Struct! st) {
+
+       public override void visit_struct (Struct! st) {
+               if (st.error) {
+                       /* skip structs with errors */
+                       return;
+               }
+
                if (add_symbol (st.name, st) == null) {
                        return;
                }
                
                current_symbol = st.symbol;
+
+               st.accept_children (this);
+
+               current_symbol = current_symbol.parent_symbol;
        }
-       
-       public override void visit_end_struct (Struct! st) {
-               if (st.error) {
-                       /* skip structs with errors */
+
+       public override void visit_interface (Interface! iface) {
+               if (iface.error) {
+                       /* skip interfaces with errors */
                        return;
                }
                
-               current_symbol = current_symbol.parent_symbol;
-       }
-
-       public override void visit_begin_interface (Interface! iface) {
                if (add_symbol (iface.name, iface) == null) {
                        return;
                }
                
                current_symbol = iface.symbol;
+
+               iface.accept_children (this);
+
+               current_symbol = current_symbol.parent_symbol;
        }
-       
-       public override void visit_end_interface (Interface! iface) {
-               if (iface.error) {
-                       /* skip interfaces with errors */
+
+       public override void visit_enum (Enum! en) {
+               if (en.error) {
+                       /* skip enums with errors */
                        return;
                }
-               
-               current_symbol = current_symbol.parent_symbol;
-       }
 
-       public override void visit_begin_enum (Enum! en) {
                if (add_symbol (en.name, en) == null) {
                        return;
                }
 
                current_symbol = en.symbol;
-       }
 
-       public override void visit_end_enum (Enum! en) {
-               if (en.error) {
-                       /* skip enums with errors */
-                       return;
-               }
+               en.accept_children (this);
 
                current_symbol = current_symbol.parent_symbol;
        }
@@ -199,19 +199,19 @@ public class Vala.SymbolBuilder : CodeVisitor {
                current_symbol.add (ev.name, ev.symbol);
        }
 
-       public override void visit_begin_flags (Flags! fl) {
+       public override void visit_flags (Flags! fl) {
+               if (fl.error) {
+                       /* skip flags with errors */
+                       return;
+               }
+
                if (add_symbol (fl.name, fl) == null) {
                        return;
                }
                
                current_symbol = fl.symbol;
-       }
 
-       public override void visit_end_flags (Flags! fl) {
-               if (fl.error) {
-                       /* skip flags with errors */
-                       return;
-               }
+               fl.accept_children (this);
 
                current_symbol = current_symbol.parent_symbol;
        }
@@ -221,15 +221,15 @@ public class Vala.SymbolBuilder : CodeVisitor {
                current_symbol.add (fv.name, fv.symbol);
        }
 
-       public override void visit_begin_callback (Callback! cb) {
+       public override void visit_callback (Callback! cb) {
                if (add_symbol (cb.name, cb) == null) {
                        return;
                }
                
                current_symbol = cb.symbol;
-       }
-       
-       public override void visit_end_callback (Callback! cb) {
+
+               cb.accept_children (this);
+
                if (cb.error) {
                        /* skip enums with errors */
                        return;
index eb7bd33b381e720672c8758203fd5f18fb8f0278..ec1566e76cd700edc8c7acf4ba7d34bce7b027a0 100644 (file)
@@ -68,11 +68,11 @@ public class Vala.SymbolResolver : CodeVisitor {
                current_scope = root_symbol;
        }
 
-       public override void visit_begin_class (Class! cl) {
+       public override void visit_class (Class! cl) {
                current_scope = cl.symbol;
-       }
 
-       public override void visit_end_class (Class! cl) {
+               cl.accept_children (this);
+
                foreach (TypeReference type in cl.get_base_types ()) {
                        if (type.data_type is Class) {
                                if (cl.base_class != null) {
@@ -92,27 +92,27 @@ public class Vala.SymbolResolver : CodeVisitor {
                current_scope = current_scope.parent_symbol;
        }
 
-       public override void visit_begin_struct (Struct! st) {
+       public override void visit_struct (Struct! st) {
                current_scope = st.symbol;
-       }
 
-       public override void visit_end_struct (Struct! st) {
+               st.accept_children (this);
+
                current_scope = current_scope.parent_symbol;
        }
 
-       public override void visit_begin_interface (Interface! iface) {
+       public override void visit_interface (Interface! iface) {
                current_scope = iface.symbol;
-       }
 
-       public override void visit_end_interface (Interface! iface) {
+               iface.accept_children (this);
+
                current_scope = current_scope.parent_symbol;
        }
 
-       public override void visit_begin_callback (Callback! cb) {
+       public override void visit_callback (Callback! cb) {
                current_scope = cb.symbol;
-       }
 
-       public override void visit_end_callback (Callback! cb) {
+               cb.accept_children (this);
+
                current_scope = current_scope.parent_symbol;
        }