[vala/staging] vala: Respect --abi-stability in Class/Interface.accept_children()



commit d2f016f787c33e8f1ee573f19999c22a059f41eb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Oct 5 22:47:48 2019 +0200

    vala: Respect --abi-stability in Class/Interface.accept_children()
    
    Add common implementation to ObjectTypeSymbol.accept_children() and match
    generate_class_struct_declaration() and generate_interface_declaration()
    
    Accepting fields earlier for interfaces in not a concern while there is
    no support for instance/class fields yet.

 vala/valaclass.vala            | 42 ++------------------------------------
 vala/valainterface.vala        | 42 ++------------------------------------
 vala/valaobjecttypesymbol.vala | 46 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 80 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index fcf239b33..289cc7459 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -390,34 +390,8 @@ public class Vala.Class : ObjectTypeSymbol {
                        type.accept (visitor);
                }
 
-               foreach (TypeParameter p in get_type_parameters ()) {
-                       p.accept (visitor);
-               }
-
-               /* process enums first to avoid order problems in C code */
-               foreach (Enum en in get_enums ()) {
-                       en.accept (visitor);
-               }
-
-               foreach (Field f in get_fields ()) {
-                       f.accept (visitor);
-               }
-
-               foreach (Constant c in get_constants ()) {
-                       c.accept (visitor);
-               }
-
-               foreach (Method m in get_methods ()) {
-                       m.accept (visitor);
-               }
-
-               foreach (Property prop in get_properties ()) {
-                       prop.accept (visitor);
-               }
-
-               foreach (Signal sig in get_signals ()) {
-                       sig.accept (visitor);
-               }
+               // Invoke common implementation in ObjectTypeSymbol
+               base.accept_children (visitor);
 
                if (constructor != null) {
                        constructor.accept (visitor);
@@ -442,18 +416,6 @@ public class Vala.Class : ObjectTypeSymbol {
                if (class_destructor != null) {
                        class_destructor.accept (visitor);
                }
-
-               foreach (Class cl in get_classes ()) {
-                       cl.accept (visitor);
-               }
-
-               foreach (Struct st in get_structs ()) {
-                       st.accept (visitor);
-               }
-
-               foreach (Delegate d in get_delegates ()) {
-                       d.accept (visitor);
-               }
        }
 
        public override bool is_reference_type () {
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 2d0933eda..5cbb2ed78 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -117,46 +117,8 @@ public class Vala.Interface : ObjectTypeSymbol {
                        type.accept (visitor);
                }
 
-               foreach (TypeParameter p in get_type_parameters ()) {
-                       p.accept (visitor);
-               }
-
-               /* process enums first to avoid order problems in C code */
-               foreach (Enum en in get_enums ()) {
-                       en.accept (visitor);
-               }
-
-               foreach (Method m in get_methods ()) {
-                       m.accept (visitor);
-               }
-
-               foreach (Field f in get_fields ()) {
-                       f.accept (visitor);
-               }
-
-               foreach (Constant c in get_constants ()) {
-                       c.accept (visitor);
-               }
-
-               foreach (Property prop in get_properties ()) {
-                       prop.accept (visitor);
-               }
-
-               foreach (Signal sig in get_signals ()) {
-                       sig.accept (visitor);
-               }
-
-               foreach (Class cl in get_classes ()) {
-                       cl.accept (visitor);
-               }
-
-               foreach (Struct st in get_structs ()) {
-                       st.accept (visitor);
-               }
-
-               foreach (Delegate d in get_delegates ()) {
-                       d.accept (visitor);
-               }
+               // Invoke common implementation in ObjectTypeSymbol
+               base.accept_children (visitor);
        }
 
        public override bool is_reference_type () {
diff --git a/vala/valaobjecttypesymbol.vala b/vala/valaobjecttypesymbol.vala
index c15be3e34..33f99b30d 100644
--- a/vala/valaobjecttypesymbol.vala
+++ b/vala/valaobjecttypesymbol.vala
@@ -315,4 +315,50 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
 
                scope.add (null, m);
        }
+
+       public override void accept_children (CodeVisitor visitor) {
+               foreach (TypeParameter p in get_type_parameters ()) {
+                       p.accept (visitor);
+               }
+
+               /* process enums first to avoid order problems in C code */
+               foreach (Enum en in get_enums ()) {
+                       en.accept (visitor);
+               }
+
+               foreach (Constant c in get_constants ()) {
+                       c.accept (visitor);
+               }
+
+               foreach (Class cl in get_classes ()) {
+                       cl.accept (visitor);
+               }
+
+               foreach (Struct st in get_structs ()) {
+                       st.accept (visitor);
+               }
+
+               foreach (Delegate d in get_delegates ()) {
+                       d.accept (visitor);
+               }
+
+               if (CodeContext.get ().abi_stability) {
+                       foreach (Symbol s in get_members ()) {
+                               s.accept (visitor);
+                       }
+               } else {
+                       foreach (Field f in get_fields ()) {
+                               f.accept (visitor);
+                       }
+                       foreach (Method m in get_methods ()) {
+                               m.accept (visitor);
+                       }
+                       foreach (Property prop in get_properties ()) {
+                               prop.accept (visitor);
+                       }
+                       foreach (Signal sig in get_signals ()) {
+                               sig.accept (visitor);
+                       }
+               }
+       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]