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 ());
}
* @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 () {
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;
* @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 () {
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 ());
}
}
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 ());
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 ());
}
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 ());
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 ();
}
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 ();
}
*/
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 () {
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;
* @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 () {
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;
}
if (!declaration_only) {
- get_type_interface_init_statements (type_init, plugin);
+ get_type_interface_init_statements (context, type_init, plugin);
}
if (!plugin) {
/**
* 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 () {