]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't hold reference of CodeContext in TypeRegisterFunction
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 10:35:20 +0000 (11:35 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 10:36:41 +0000 (11:36 +0100)
codegen/valaccodestructmodule.vala
codegen/valaclassregisterfunction.vala
codegen/valaenumregisterfunction.vala
codegen/valagtypemodule.vala
codegen/valainterfaceregisterfunction.vala
codegen/valastructregisterfunction.vala
codegen/valatyperegisterfunction.vala

index 654894812f3f9d4fcac25a58c3fead15580b4ec8..0ce9dae17edcd8d16b31a07276eaebf7f33799b5 100644 (file)
@@ -59,8 +59,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                        var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
                        decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (st), macro));
 
-                       var type_fun = new StructRegisterFunction (st, context);
-                       type_fun.init_from_type (false, true);
+                       var type_fun = new StructRegisterFunction (st);
+                       type_fun.init_from_type (context, false, true);
                        decl_space.add_type_member_declaration (type_fun.get_declaration ());
                }
 
index b7d5a42e470499a46d37d0d5f8c3f763ac5bb7b9..dcff2ed6323d3477e558599b52c1a724bcbc3bb1 100644 (file)
@@ -37,9 +37,8 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
         * @param cl a class
         * @return   newly created class register function
         */
-       public ClassRegisterFunction (Class cl, CodeContext context) {
+       public ClassRegisterFunction (Class cl) {
                class_reference = cl;
-               this.context = context;
        }
        
        public override TypeSymbol get_type_declaration () {
@@ -171,7 +170,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
                return frag;
        }
 
-       public override void get_type_interface_init_statements (CCodeBlock block, bool plugin) {
+       public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
                foreach (DataType base_type in class_reference.get_base_types ()) {
                        if (!(base_type.data_type is Interface)) {
                                continue;
index ee6ab69d91e1d3836ce56752bbad5a5ec4374c71..c2235a3a06923aad24f7cf189b4e09991185b56c 100644 (file)
@@ -38,9 +38,8 @@ public class Vala.EnumRegisterFunction : TypeRegisterFunction {
         * @param en an enum
         * @return   newly created enum register function
         */
-       public EnumRegisterFunction (Enum en, CodeContext context) {
+       public EnumRegisterFunction (Enum en) {
                enum_reference = en;
-               this.context = context;
        }
 
        public override TypeSymbol get_type_declaration () {
index 1370c75792640892c17785950cfcdfcea3d995b6..c282f2c3a53e98aa8111ceda060cb793e6329a8c 100644 (file)
@@ -186,8 +186,8 @@ public class Vala.GTypeModule : GErrorModule {
                if (is_gtypeinstance) {
                        decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%sClass".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("%sClass".printf (get_ccode_name (cl)))));
 
-                       var type_fun = new ClassRegisterFunction (cl, context);
-                       type_fun.init_from_type (in_plugin, true);
+                       var type_fun = new ClassRegisterFunction (cl);
+                       type_fun.init_from_type (context, in_plugin, true);
                        decl_space.add_type_member_declaration (type_fun.get_declaration ());
                }
        }
@@ -670,8 +670,8 @@ public class Vala.GTypeModule : GErrorModule {
                                cfile.add_type_member_definition (new CCodeComment (cl.comment.content));
                        }
 
-                       var type_fun = new ClassRegisterFunction (cl, context);
-                       type_fun.init_from_type (in_plugin, false);
+                       var type_fun = new ClassRegisterFunction (cl);
+                       type_fun.init_from_type (context, in_plugin, false);
                        cfile.add_type_member_declaration (type_fun.get_source_declaration ());
                        cfile.add_type_member_definition (type_fun.get_definition ());
 
@@ -2064,8 +2064,8 @@ public class Vala.GTypeModule : GErrorModule {
 
                decl_space.add_type_definition (type_struct);
 
-               var type_fun = new InterfaceRegisterFunction (iface, context);
-               type_fun.init_from_type (in_plugin, true);
+               var type_fun = new InterfaceRegisterFunction (iface);
+               type_fun.init_from_type (context, in_plugin, true);
                decl_space.add_type_member_declaration (type_fun.get_declaration ());
        }
 
@@ -2110,8 +2110,8 @@ public class Vala.GTypeModule : GErrorModule {
                        cfile.add_type_member_definition (new CCodeComment (iface.comment.content));
                }
 
-               var type_fun = new InterfaceRegisterFunction (iface, context);
-               type_fun.init_from_type (in_plugin, false);
+               var type_fun = new InterfaceRegisterFunction (iface);
+               type_fun.init_from_type (context, in_plugin, false);
                cfile.add_type_member_declaration (type_fun.get_source_declaration ());
                cfile.add_type_member_definition (type_fun.get_definition ());
 
@@ -2213,8 +2213,8 @@ public class Vala.GTypeModule : GErrorModule {
 
                if (get_ccode_has_type_id (st)) {
                        push_line (st.source_reference);
-                       var type_fun = new StructRegisterFunction (st, context);
-                       type_fun.init_from_type (false, false);
+                       var type_fun = new StructRegisterFunction (st);
+                       type_fun.init_from_type (context, false, false);
                        cfile.add_type_member_definition (type_fun.get_definition ());
                        pop_line ();
                }
@@ -2225,8 +2225,8 @@ public class Vala.GTypeModule : GErrorModule {
 
                if (get_ccode_has_type_id (en)) {
                        push_line (en.source_reference);
-                       var type_fun = new EnumRegisterFunction (en, context);
-                       type_fun.init_from_type (false, false);
+                       var type_fun = new EnumRegisterFunction (en);
+                       type_fun.init_from_type (context, false, false);
                        cfile.add_type_member_definition (type_fun.get_definition ());
                        pop_line ();
                }
index 7f20c786f5079fb167bf60285341eed66e30e467..505766900ced22546f5336b973b78dad9ee1d2e5 100644 (file)
@@ -33,9 +33,8 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
         */
        public weak Interface interface_reference { get; set; }
        
-       public InterfaceRegisterFunction (Interface iface, CodeContext context) {
+       public InterfaceRegisterFunction (Interface iface) {
                interface_reference = iface;
-               this.context = context;
        }
        
        public override TypeSymbol get_type_declaration () {
@@ -78,7 +77,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
                return interface_reference.access;
        }
 
-       public override void get_type_interface_init_statements (CCodeBlock block, bool plugin) {
+       public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
                /* register all prerequisites */
                foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
                        var prereq = prereq_ref.data_type;
index 404e412b7cb2d178965a6f6618a82fae10b54f47..90234bd1164ef939e01a614b08e10ef084753b43 100644 (file)
@@ -37,9 +37,8 @@ public class Vala.StructRegisterFunction : TypeRegisterFunction {
         * @param st a struct
         * @return   newly created struct register function
         */
-       public StructRegisterFunction (Struct st, CodeContext context) {
+       public StructRegisterFunction (Struct st) {
                struct_reference = st;
-               this.context = context;
        }
        
        public override TypeSymbol get_type_declaration () {
index 97dcf9a6a816df205ea67fac8025421817c98232..4a0c59c2065a53c4ad5c810fb5e9829c89edcf8c 100644 (file)
@@ -30,12 +30,10 @@ public abstract class Vala.TypeRegisterFunction {
        CCodeFragment declaration_fragment = new CCodeFragment ();
        CCodeFragment definition_fragment = new CCodeFragment ();
 
-       public CodeContext context { get; set; }
-
        /**
         * Constructs the C function from the specified type.
         */
-       public void init_from_type (bool plugin, bool declaration_only) {
+       public void init_from_type (CodeContext context, bool plugin, bool declaration_only) {
                bool use_thread_safe = !plugin;
 
                bool fundamental = false;
@@ -215,7 +213,7 @@ public abstract class Vala.TypeRegisterFunction {
                }
 
                if (!declaration_only) {
-                       get_type_interface_init_statements (type_init, plugin);
+                       get_type_interface_init_statements (context, type_init, plugin);
                }
 
                if (!plugin) {
@@ -414,7 +412,7 @@ public abstract class Vala.TypeRegisterFunction {
        /**
         * Returns additional C initialization statements to setup interfaces.
         */
-       public virtual void get_type_interface_init_statements (CCodeBlock block, bool plugin) {
+       public virtual void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
        }
        
        public CCodeFragment get_source_declaration () {