Commit f4f655d2 authored by Jürg Billeter's avatar Jürg Billeter

Replace CCodeDeclarationSpace by CCodeFile

parent ceb6c387
......@@ -32,6 +32,7 @@ libvalaccode_la_VALASOURCES = \
valaccodeenumvalue.vala \
valaccodeexpression.vala \
valaccodeexpressionstatement.vala \
valaccodefile.vala \
valaccodeformalparameter.vala \
valaccodeforstatement.vala \
valaccodefragment.vala \
......
/* valaccodedeclarationspace.vala
/* valaccodefile.vala
*
* Copyright (C) 2009 Jürg Billeter
* Copyright (C) 2009-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -21,16 +21,18 @@
*/
public class Vala.CCodeDeclarationSpace {
public class Vala.CCodeFile {
public bool is_header { get; set; }
Set<string> declarations = new HashSet<string> (str_hash, str_equal);
Set<string> includes = new HashSet<string> (str_hash, str_equal);
internal CCodeFragment include_directives = new CCodeFragment ();
internal CCodeFragment type_declaration = new CCodeFragment ();
internal CCodeFragment type_definition = new CCodeFragment ();
internal CCodeFragment type_member_declaration = new CCodeFragment ();
internal CCodeFragment constant_declaration = new CCodeFragment ();
CCodeFragment comments = new CCodeFragment ();
CCodeFragment include_directives = new CCodeFragment ();
CCodeFragment type_declaration = new CCodeFragment ();
CCodeFragment type_definition = new CCodeFragment ();
CCodeFragment type_member_declaration = new CCodeFragment ();
CCodeFragment constant_declaration = new CCodeFragment ();
CCodeFragment type_member_definition = new CCodeFragment ();
public bool add_declaration (string name) {
if (name in declarations) {
......@@ -40,6 +42,10 @@ public class Vala.CCodeDeclarationSpace {
return false;
}
public void add_comment (CCodeComment comment) {
comments.append (comment);
}
public void add_include (string filename, bool local = false) {
if (!(filename in includes)) {
include_directives.append (new CCodeIncludeDirective (filename, local));
......@@ -62,5 +68,106 @@ public class Vala.CCodeDeclarationSpace {
public void add_constant_declaration (CCodeNode node) {
constant_declaration.append (node);
}
public void add_type_member_definition (CCodeNode node) {
type_member_definition.append (node);
}
public void add_function (CCodeFunction func) {
type_member_definition.append (func);
}
public List<string> get_symbols () {
var symbols = new ArrayList<string> ();
foreach (CCodeNode node in type_member_declaration.get_children ()) {
var func = node as CCodeFunction;
if (func != null) {
symbols.add (func.name);
}
}
return symbols;
}
static string get_define_for_filename (string filename) {
var define = new StringBuilder ("__");
var i = filename;
while (i.length > 0) {
var c = i.get_char ();
if (c.isalnum () && c < 0x80) {
define.append_unichar (c.toupper ());
} else {
define.append_c ('_');
}
i = i.next_char ();
}
define.append ("__");
return define.str;
}
public bool store (string filename, string? source_filename, bool write_version, bool line_directives, string? begin_decls = null, string? end_decls = null) {
var writer = new CCodeWriter (filename, source_filename);
if (!writer.open (write_version)) {
return false;
}
if (!is_header) {
writer.line_directives = line_directives;
comments.write (writer);
writer.write_newline ();
include_directives.write (writer);
writer.write_newline ();
type_declaration.write_combined (writer);
writer.write_newline ();
type_definition.write_combined (writer);
writer.write_newline ();
type_member_declaration.write_declaration (writer);
writer.write_newline ();
type_member_declaration.write (writer);
writer.write_newline ();
constant_declaration.write_combined (writer);
writer.write_newline ();
type_member_definition.write (writer);
writer.write_newline ();
} else {
writer.write_newline ();
var once = new CCodeOnceSection (get_define_for_filename (writer.filename));
once.append (new CCodeNewline ());
once.append (include_directives);
once.append (new CCodeNewline ());
if (begin_decls != null) {
once.append (new CCodeIdentifier (begin_decls));
once.append (new CCodeNewline ());
}
once.append (new CCodeNewline ());
once.append (type_declaration);
once.append (new CCodeNewline ());
once.append (type_definition);
once.append (new CCodeNewline ());
once.append (type_member_declaration);
once.append (new CCodeNewline ());
once.append (constant_declaration);
once.append (new CCodeNewline ());
if (begin_decls != null) {
once.append (new CCodeIdentifier (end_decls));
once.append (new CCodeNewline ());
}
once.append (new CCodeNewline ());
once.write (writer);
}
writer.close ();
return true;
}
}
......@@ -20,7 +20,6 @@ libvala_la_VALASOURCES = \
valaccodebasemodule.vala \
valaccodecompiler.vala \
valaccodecontrolflowmodule.vala \
valaccodedeclarationspace.vala \
valaccodedelegatemodule.vala \
valaccodememberaccessmodule.vala \
valaccodemethodcallmodule.vala \
......
......@@ -61,7 +61,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
CCodeFunctionCall gnew;
if (context.profile == Profile.POSIX) {
source_declarations.add_include ("stdlib.h");
cfile.add_include ("stdlib.h");
gnew = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
} else {
gnew = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
......@@ -479,7 +479,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
public override string? append_struct_array_free (Struct st) {
string cname = "_vala_%s_array_free".printf (st.get_cname ());;
if (source_declarations.add_declaration (cname)) {
if (cfile.add_declaration (cname)) {
return cname;
}
......@@ -487,7 +487,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("array", "%s*".printf (st.get_cname ())));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
var cdofree = new CCodeBlock ();
......@@ -506,7 +506,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
carrfree.add_argument (new CCodeIdentifier ("array"));
fun.block.add_statement (new CCodeExpressionStatement (carrfree));
source_type_member_definition.append (fun);
cfile.add_function (fun);
return cname;
}
......@@ -540,7 +540,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
fun.add_parameter (new CCodeFormalParameter ("destroy_func", "GDestroyNotify"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
var cdofree = new CCodeBlock ();
......@@ -556,7 +556,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.block = new CCodeBlock ();
fun.block.add_statement (cif);
source_type_member_definition.append (fun);
cfile.add_function (fun);
// _vala_array_free frees elements and array
......@@ -565,7 +565,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
fun.add_parameter (new CCodeFormalParameter ("array_length", "gint"));
fun.add_parameter (new CCodeFormalParameter ("destroy_func", "GDestroyNotify"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
// call _vala_array_destroy to free the array elements
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_destroy"));
......@@ -580,11 +580,11 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
carrfree.add_argument (new CCodeIdentifier ("array"));
fun.block.add_statement (new CCodeExpressionStatement (carrfree));
source_type_member_definition.append (fun);
cfile.add_function (fun);
}
public override void append_vala_array_move () {
source_declarations.add_include ("string.h");
cfile.add_include ("string.h");
// assumes that overwritten array elements are null before invocation
// FIXME will leak memory if that's not the case
......@@ -595,7 +595,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.add_parameter (new CCodeFormalParameter ("src", "gint"));
fun.add_parameter (new CCodeFormalParameter ("dest", "gint"));
fun.add_parameter (new CCodeFormalParameter ("length", "gint"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
var array = new CCodeCastExpression (new CCodeIdentifier ("array"), "char*");
var element_size = new CCodeIdentifier ("element_size");
......@@ -630,14 +630,14 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.block.add_statement (new CCodeIfStatement (new CCodeBinaryExpression (CCodeBinaryOperator.LESS_THAN, src, dest), czeroblock1, czeroblock2));
source_type_member_definition.append (fun);
cfile.add_function (fun);
}
public override void append_vala_array_length () {
var fun = new CCodeFunction ("_vala_array_length", "gint");
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("array", "gpointer"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
var block = new CCodeBlock ();
......@@ -662,7 +662,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
fun.block = block;
source_type_member_definition.append (fun);
cfile.add_function (fun);
}
public override CCodeExpression? get_ref_cexpression (DataType expression_type, CCodeExpression cexpr, Expression? expr, CodeNode node) {
......@@ -805,10 +805,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
source_declarations.add_type_member_declaration (function.copy ());
cfile.add_type_member_declaration (function.copy ());
function.block = block;
source_type_member_definition.append (function);
cfile.add_function (function);
return dup_func;
}
......@@ -854,7 +854,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
pop_context ();
} else {
source_declarations.add_include ("string.h");
cfile.add_include ("string.h");
var dup_call = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
dup_call.add_argument (new CCodeIdentifier ("dest"));
......@@ -869,10 +869,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
source_declarations.add_type_member_declaration (function.copy ());
cfile.add_type_member_declaration (function.copy ());
function.block = block;
source_type_member_definition.append (function);
cfile.add_function (function);
return dup_func;
}
......@@ -941,10 +941,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// append to file
source_declarations.add_type_member_declaration (function.copy ());
cfile.add_type_member_declaration (function.copy ());
function.block = block;
source_type_member_definition.append (function);
cfile.add_function (function);
return add_func;
}
......@@ -985,7 +985,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
assignment.ccodenode = ccall;
}
public override void generate_parameter (FormalParameter param, CCodeDeclarationSpace decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
public override void generate_parameter (FormalParameter param, CCodeFile decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
if (!(param.variable_type is ArrayType)) {
base.generate_parameter (param, decl_space, cparam_map, carg_map);
return;
......
......@@ -34,7 +34,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
var prop = (Property) assignment.left.symbol_reference;
if (!(prop is DynamicProperty)) {
generate_property_accessor_declaration (prop.set_accessor, source_declarations);
generate_property_accessor_declaration (prop.set_accessor, cfile);
if (!prop.external && prop.external_package) {
// internal VAPI properties
......@@ -212,7 +212,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
source_declarations.add_include ("string.h");
cfile.add_include ("string.h");
// it is necessary to use memcpy for fixed-length (stack-allocated) arrays
// simple assignments do not work in C
......
......@@ -148,19 +148,16 @@ public class Vala.CCodeBaseModule : CodeGenerator {
return block;
}
public CCodeDeclarationSpace header_declarations;
public CCodeDeclarationSpace internal_header_declarations;
public CCodeDeclarationSpace source_declarations;
public CCodeFile header_file;
public CCodeFile internal_header_file;
public CCodeFile cfile;
public CCodeFragment source_signal_marshaller_declaration;
public CCodeFragment source_type_member_definition;
public CCodeFragment class_init_fragment;
public CCodeFragment base_init_fragment;
public CCodeFragment class_finalize_fragment;
public CCodeFragment base_finalize_fragment;
public CCodeFragment instance_init_fragment;
public CCodeFragment instance_finalize_fragment;
public CCodeFragment source_signal_marshaller_definition;
public CCodeStruct param_spec_struct;
public CCodeStruct closure_struct;
......@@ -412,10 +409,10 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
}
header_declarations = new CCodeDeclarationSpace ();
header_declarations.is_header = true;
internal_header_declarations = new CCodeDeclarationSpace ();
internal_header_declarations.is_header = true;
header_file = new CCodeFile ();
header_file.is_header = true;
internal_header_file = new CCodeFile ();
internal_header_file.is_header = true;
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
......@@ -433,12 +430,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
return;
}
foreach (CCodeNode node in header_declarations.type_member_declaration.get_children ()) {
if (node is CCodeFunction) {
var func = (CCodeFunction) node;
stream.puts (func.name);
stream.putc ('\n');
}
foreach (string symbol in header_file.get_symbols ()) {
stream.puts (symbol);
stream.putc ('\n');
}
stream = null;
......@@ -446,80 +440,28 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// generate C header file for public API
if (context.header_filename != null) {
var writer = new CCodeWriter (context.header_filename);
if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
}
writer.write_newline ();
var once = new CCodeOnceSection (get_define_for_filename (writer.filename));
once.append (new CCodeNewline ());
once.append (header_declarations.include_directives);
once.append (new CCodeNewline ());
bool ret;
if (context.profile == Profile.GOBJECT) {
once.append (new CCodeIdentifier ("G_BEGIN_DECLS"));
once.append (new CCodeNewline ());
ret = header_file.store (context.header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
} else {
ret = header_file.store (context.header_filename, null, context.version_header, false);
}
once.append (new CCodeNewline ());
once.append (header_declarations.type_declaration);
once.append (new CCodeNewline ());
once.append (header_declarations.type_definition);
once.append (new CCodeNewline ());
once.append (header_declarations.type_member_declaration);
once.append (new CCodeNewline ());
once.append (header_declarations.constant_declaration);
once.append (new CCodeNewline ());
if (context.profile == Profile.GOBJECT) {
once.append (new CCodeIdentifier ("G_END_DECLS"));
once.append (new CCodeNewline ());
if (!ret) {
Report.error (null, "unable to open `%s' for writing".printf (context.header_filename));
}
once.append (new CCodeNewline ());
once.write (writer);
writer.close ();
}
// generate C header file for internal API
if (context.internal_header_filename != null) {
var writer = new CCodeWriter (context.internal_header_filename);
if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
}
writer.write_newline ();
var once = new CCodeOnceSection (get_define_for_filename (writer.filename));
once.append (new CCodeNewline ());
once.append (internal_header_declarations.include_directives);
once.append (new CCodeNewline ());
bool ret;
if (context.profile == Profile.GOBJECT) {
once.append (new CCodeIdentifier ("G_BEGIN_DECLS"));
once.append (new CCodeNewline ());
ret = internal_header_file.store (context.internal_header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
} else {
ret = internal_header_file.store (context.internal_header_filename, null, context.version_header, false);
}
once.append (new CCodeNewline ());
once.append (internal_header_declarations.type_declaration);
once.append (new CCodeNewline ());
once.append (internal_header_declarations.type_definition);
once.append (new CCodeNewline ());
once.append (internal_header_declarations.type_member_declaration);
once.append (new CCodeNewline ());
once.append (internal_header_declarations.constant_declaration);
once.append (new CCodeNewline ());
if (context.profile == Profile.GOBJECT) {
once.append (new CCodeIdentifier ("G_END_DECLS"));
once.append (new CCodeNewline ());
if (!ret) {
Report.error (null, "unable to open `%s' for writing".printf (context.internal_header_filename));
}
once.append (new CCodeNewline ());
once.write (writer);
writer.close ();
}
}
......@@ -540,7 +482,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
}
public bool add_symbol_declaration (CCodeDeclarationSpace decl_space, Symbol sym, string name) {
public bool add_symbol_declaration (CCodeFile decl_space, Symbol sym, string name) {
if (decl_space.add_declaration (name)) {
return true;
}
......@@ -603,13 +545,13 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
private void append_vala_strcmp0 () {
source_declarations.add_include ("string.h");;
cfile.add_include ("string.h");;
var fun = new CCodeFunction ("_vala_strcmp0", "int");
fun.modifiers = CCodeModifiers.STATIC;
fun.add_parameter (new CCodeFormalParameter ("str1", "const char *"));
fun.add_parameter (new CCodeFormalParameter ("str2", "const char *"));
source_declarations.add_type_member_declaration (fun.copy ());
cfile.add_type_member_declaration (fun.copy ());
// (str1 != str2)
var cineq = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("str1"), new CCodeIdentifier ("str2"));
......@@ -637,14 +579,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
// return strcmp (str1, str2);
fun.block.add_statement (new CCodeReturnStatement (ccall));
source_type_member_definition.append (fun);
cfile.add_function (fun);
}
public override void visit_source_file (SourceFile source_file) {
source_declarations = new CCodeDeclarationSpace ();
source_type_member_definition = new CCodeFragment ();
source_signal_marshaller_definition = new CCodeFragment ();
source_signal_marshaller_declaration = new CCodeFragment ();
cfile = new CCodeFile ();
user_marshal_set = new HashSet<string> (str_hash, str_equal);
......@@ -660,10 +599,10 @@ public class Vala.CCodeBaseModule : CodeGenerator {
generated_external_symbols = new HashSet<Symbol> ();
if (context.profile == Profile.GOBJECT) {
header_declarations.add_include ("glib.h");
internal_header_declarations.add_include ("glib.h");
source_declarations.add_include ("glib.h");
source_declarations.add_include ("glib-object.h");
header_file.add_include ("glib.h");
internal_header_file.add_include ("glib.h");
cfile.add_include ("glib.h");
cfile.add_include ("glib-object.h");
}
source_file.accept_children (this);
......@@ -686,73 +625,25 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
if (gvaluecollector_h_needed) {
source_declarations.add_include ("gobject/gvaluecollector.h");
}
var writer = new CCodeWriter (source_file.get_csource_filename (), source_file.filename);
if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
cfile.add_include ("gobject/gvaluecollector.h");
}
writer.line_directives = context.debug;
var comments = source_file.get_comments();
if (comments != null) {
foreach (Comment comment in comments) {
var ccomment = new CCodeComment (comment.content);
ccomment.write (writer);
}
}
writer.write_newline ();
source_declarations.include_directives.write (writer);
writer.write_newline ();
source_declarations.type_declaration.write_combined (writer);
writer.write_newline ();
source_declarations.type_definition.write_combined (writer);
writer.write_newline ();
source_declarations.type_member_declaration.write_declaration (writer);
writer.write_newline ();
source_declarations.type_member_declaration.write (writer);
writer.write_newline ();
source_declarations.constant_declaration.write_combined (writer);
writer.write_newline ();
source_signal_marshaller_declaration.write_declaration (writer);
source_signal_marshaller_declaration.write (writer);
writer.write_newline ();
source_type_member_definition.write (writer);
writer.write_newline ();
source_signal_marshaller_definition.write (writer);
writer.write_newline ();
writer.close ();
source_declarations = null;
source_type_member_definition = null;
source_signal_marshaller_definition = null;
source_signal_marshaller_declaration = null;
}
private static string get_define_for_filename (string filename) {
var define = new StringBuilder ("__");
var i = filename;
while (i.length > 0) {
var c = i.get_char ();
if (c.isalnum () && c < 0x80) {
define.append_unichar (c.toupper ());
} else {
define.append_c ('_');
cfile.add_comment (ccomment);
}
i = i.next_char ();
}
define.append ("__");
return define.str;
if (!cfile.store (source_file.get_csource_filename (), source_file.filename, context.version_header, context.debug)) {
Report.error (null, "unable to open `%s' for writing".printf (source_file.get_csource_filename ()));
}
cfile = null;
}
public virtual bool generate_enum_declaration (Enum en, CCodeDeclarationSpace decl_space) {
public virtual bool generate_enum_declaration (Enum en, CCodeFile decl_space) {
if (add_symbol_declaration (decl_space, en, en.get_cname ())) {
return false;
}
......@@ -809,16 +700,16 @@ public class Vala.CCodeBaseModule : CodeGenerator {
en.accept_children (this);
if (en.comment != null) {
source_type_member_definition.append (new CCodeComment (en.comment.content));
cfile.add_type_member_definition (new CCodeComment (en.comment.content));
}
generate_enum_declaration (en, source_declarations);
generate_enum_declaration (en, cfile);
if (!en.is_internal_symbol ()) {
generate_enum_declaration (en, header_declarations);
generate_enum_declaration (en, header_file);
}
if (!en.is_private_symbol ()) {
generate_enum_declaration (en, internal_header_declarations);
generate_enum_declaration (en, internal_header_file);
}
}
......@@ -855,7 +746,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
}
public void generate_constant_declaration (Constant c, CCodeDeclarationSpace decl_space, bool definition = false) {
public void generate_constant_declaration (Constant c, CCodeFile decl_space, bool definition = false) {
if (add_symbol_declaration (decl_space, c, c.get_cname ())) {
return;
}
......@@ -896,17 +787,17 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
public override void visit_constant (Constant c) {
generate_constant_declaration (c, source_declarations, true);
generate_constant_declaration (c, cfile, true);
if (!c.is_internal_symbol ()) {
generate_constant_declaration (c, header_declarations);
generate_constant_declaration (c, header_file);
}
if (!c.is_private_symbol ()) {
generate_constant_declaration (c, internal_header_declarations);
generate_constant_declaration (c, internal_header_file);
}
}
public void generate_field_declaration (Field f, CCodeDeclarationSpace decl_space) {
public void generate_field_declaration (Field f, CCodeFile decl_space) {
if (add_symbol_declaration (decl_space, f, f.get_cname ())) {
return;
}
......@@ -1105,13 +996,13 @@ public class Vala.CCodeBaseModule : CodeGenerator {
temp_ref_vars.clear ();
}
} else {
generate_field_declaration (f, source_declarations);
generate_field_declaration (f, cfile);
if (!f.is_internal_symbol ()) {
generate_field_declaration (f, header_declarations);
generate_field_declaration (f, header_file);
}
if (!f.is_private_symbol ()) {
generate_field_declaration (f, internal_header_declarations);
generate_field_declaration (f, internal_header_file);
}
lhs = new CCodeIdentifier (f.get_cname ());
......@@ -1133,7 +1024,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
} else {
var_def.modifiers = CCodeModifiers.STATIC;
}
source_declarations.add_type_member_declaration (var_def);
cfile.add_type_member_declaration (var_def);
/* add array length fields where necessary */
if (f.variable_type is ArrayType && !f.no_array_length) {
......@@ -1150,7 +1041,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
} else {
len_def.modifiers = CCodeModifiers.STATIC;
}