[vala/wip/abi: 3/4] codegen: Add public/private separator comments to type/instance structs



commit 5ab6ff727341010b16c234f18c8b2d8ed6f31a53
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jan 17 13:09:06 2018 +0100

    codegen: Add public/private separator comments to type/instance structs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789069

 codegen/valagtypemodule.vala |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 688523c..6a4b67b 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -225,16 +225,28 @@ public class Vala.GTypeModule : GErrorModule {
                        instance_struct.add_field ("volatile int", "ref_count");
                }
 
+               if (context.abi_stability) {
+                       // add "/*< public >*/" separator
+                       instance_struct.add_comment ("< public >");
+               }
+
                if (is_gtypeinstance) {
                        decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %sPrivate".printf 
(instance_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (cl)))));
 
-                       instance_struct.add_field ("%sPrivate *".printf (get_ccode_name (cl)), "priv");
+                       if (!context.abi_stability) {
+                               instance_struct.add_field ("%sPrivate *".printf (get_ccode_name (cl)), 
"priv");
+                       }
                        if (is_fundamental) {
                                type_struct.add_field ("GTypeClass", "parent_class");
                        } else {
                                type_struct.add_field ("%sClass".printf (get_ccode_name (cl.base_class)), 
"parent_class");
                        }
 
+                       if (context.abi_stability) {
+                               // add "/*< public >*/" separator
+                               type_struct.add_comment ("< public >");
+                       }
+
                        if (is_fundamental) {
                                type_struct.add_field ("void", "(*finalize) (%s *self)".printf 
(get_ccode_name (cl)));
                        }
@@ -374,6 +386,12 @@ public class Vala.GTypeModule : GErrorModule {
                        }
                }
 
+               if (context.abi_stability) {
+                       // add "/*< private >*/" separator
+                       instance_struct.add_comment ("< private >");
+                       type_struct.add_comment ("< private >");
+               }
+
                if (cl.is_compact && cl.base_class == null && !has_struct_member) {
                        // add dummy member, C doesn't allow empty structs
                        instance_struct.add_field ("int", "dummy");
@@ -385,6 +403,9 @@ public class Vala.GTypeModule : GErrorModule {
                }
 
                if (is_gtypeinstance) {
+                       if (context.abi_stability) {
+                               instance_struct.add_field ("%sPrivate *".printf (get_ccode_name (cl)), 
"priv");
+                       }
                        decl_space.add_type_definition (type_struct);
                }
        }
@@ -2023,6 +2044,11 @@ public class Vala.GTypeModule : GErrorModule {
 
                type_struct.add_field ("GTypeInterface", "parent_iface");
 
+               if (context.abi_stability) {
+                       // add "/*< public >*/" separator
+                       type_struct.add_comment ("< public >");
+               }
+
                if (iface.get_attribute ("GenericAccessors") != null) {
                        foreach (TypeParameter p in iface.get_type_parameters ()) {
                                string method_name = "get_%s_type".printf (p.name.down ());
@@ -2124,6 +2150,11 @@ public class Vala.GTypeModule : GErrorModule {
                        }
                }
 
+               if (context.abi_stability) {
+                       // add "/*< private >*/" separator
+                       type_struct.add_comment ("< private >");
+               }
+
                decl_space.add_type_definition (type_struct);
 
                var type_fun = new InterfaceRegisterFunction (iface);


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