summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-12-14 11:35:20 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2017-12-14 11:36:41 +0100
commit2127e9b09ea9fd065578def3e757e0eafaaf57a7 (patch)
treea7d5f224e02fbe8abbed16aa1ff64623994dcbb8
parent2dc47785171f8f62f7f017939681e0d5cf3e9847 (diff)
downloadvala-2127e9b09ea9fd065578def3e757e0eafaaf57a7.tar.gz
codegen: Don't hold reference of CodeContext in TypeRegisterFunction
-rw-r--r--codegen/valaccodestructmodule.vala4
-rw-r--r--codegen/valaclassregisterfunction.vala5
-rw-r--r--codegen/valaenumregisterfunction.vala3
-rw-r--r--codegen/valagtypemodule.vala24
-rw-r--r--codegen/valainterfaceregisterfunction.vala5
-rw-r--r--codegen/valastructregisterfunction.vala3
-rw-r--r--codegen/valatyperegisterfunction.vala8
7 files changed, 23 insertions, 29 deletions
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 654894812..0ce9dae17 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -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 ());
}
diff --git a/codegen/valaclassregisterfunction.vala b/codegen/valaclassregisterfunction.vala
index b7d5a42e4..dcff2ed63 100644
--- a/codegen/valaclassregisterfunction.vala
+++ b/codegen/valaclassregisterfunction.vala
@@ -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;
diff --git a/codegen/valaenumregisterfunction.vala b/codegen/valaenumregisterfunction.vala
index ee6ab69d9..c2235a3a0 100644
--- a/codegen/valaenumregisterfunction.vala
+++ b/codegen/valaenumregisterfunction.vala
@@ -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 () {
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 1370c7579..c282f2c3a 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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 ();
}
diff --git a/codegen/valainterfaceregisterfunction.vala b/codegen/valainterfaceregisterfunction.vala
index 7f20c786f..505766900 100644
--- a/codegen/valainterfaceregisterfunction.vala
+++ b/codegen/valainterfaceregisterfunction.vala
@@ -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;
diff --git a/codegen/valastructregisterfunction.vala b/codegen/valastructregisterfunction.vala
index 404e412b7..90234bd11 100644
--- a/codegen/valastructregisterfunction.vala
+++ b/codegen/valastructregisterfunction.vala
@@ -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 () {
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index 97dcf9a6a..4a0c59c20 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -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 () {