Commit c6494702 authored by Raffaele Sandrini's avatar Raffaele Sandrini Committed by Raffaele Sandrini
Browse files

add cheader filename logic usable for all Vala.Member types. parse

2007-07-22  Raffaele Sandrini  <raffaele@sandrini.ch>

	* vala/valamember.vala: add cheader filename logic usable for all
	  Vala.Member types.
	* vala/valamethod.vala: parse cheader_filename CCode attribute
	  argument
	* vala/valadatatype.vala: fix get_cheader_filenames method signature
	  to override the Symbol method instead of defining a new virtual
	  method
	* vala/valasourcefile.vala: adopt add_symbol_dependency to use the fact
	  all Vala.Symbol types maintain their list of headers

svn path=/trunk/; revision=371
parent d9597e68
2007-07-22 Raffaele Sandrini <raffaele@sandrini.ch>
* vala/valamember.vala: add cheader filename logic usable for all
Vala.Member types.
* vala/valamethod.vala: parse cheader_filename CCode attribute
argument
* vala/valadatatype.vala: fix get_cheader_filenames method signature
to override the Symbol method instead of defining a new virtual
method
* vala/valasourcefile.vala: adopt add_symbol_dependency to use the fact
all Vala.Symbol types maintain their list of headers
2007-07-22 Jürg Billeter <j@bitron.ch>
* vala/valainterfacewriter.vala: more fixes for libraries with generic
......
......@@ -178,13 +178,7 @@ public abstract class Vala.DataType : Symbol {
return null;
}
/**
* Returns a list of C header filenames users of this data type must
* include.
*
* @return list of C header filenames for this data type
*/
public virtual List<weak string> get_cheader_filenames () {
public override List<weak string> get_cheader_filenames () {
if (cheader_filenames == null) {
/* default to header filenames of the namespace */
foreach (string filename in parent_symbol.get_cheader_filenames ()) {
......
......@@ -20,11 +20,40 @@
* Raffaele Sandrini <rasa@gmx.ch>
*/
using GLib;
/**
* Represents a general class member.
*/
public class Vala.Member : Symbol {
private List<string> cheader_filenames;
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
}
public override List<weak string> get_cheader_filenames () {
if (cheader_filenames == null) {
/* default to header filenames of the namespace */
foreach (string filename in parent_symbol.get_cheader_filenames ()) {
add_cheader_filename (filename);
}
if (cheader_filenames == null && source_reference != null && !source_reference.file.pkg) {
// don't add default include directives for VAPI files
cheader_filenames.append (source_reference.file.get_cinclude_filename ());
}
}
return cheader_filenames.copy ();
}
/**
* Adds a filename to the list of C header filenames users of this data
* type must include.
*
* @param filename a C header filename
*/
public void add_cheader_filename (string! filename) {
cheader_filenames.append (filename);
}
}
......@@ -136,6 +136,7 @@ public class Vala.Method : Member, Invokable {
private string cname;
private bool _no_array_length;
private List<TypeReference> error_domains;
private List<string> cheader_filenames;
/**
* Creates a new method.
......@@ -251,6 +252,12 @@ public class Vala.Method : Member, Invokable {
if (a.has_argument ("cname")) {
set_cname (a.get_string ("cname"));
}
if (a.has_argument ("cheader_filename")) {
var val = a.get_string ("cheader_filename");
foreach (string filename in val.split (",")) {
add_cheader_filename (filename);
}
}
}
/**
......
......@@ -205,32 +205,18 @@ public class Vala.SourceFile {
* @param dep_type type of dependency
*/
public void add_symbol_dependency (Symbol! sym, SourceFileDependencyType dep_type) {
DataType t;
Symbol s;
if (sym is DataType) {
t = (DataType) sym;
} else if (sym is Method || sym is Field) {
if (sym.parent_symbol is DataType) {
t = (DataType) sym.parent_symbol;
} else {
return;
}
} else if (sym is Property) {
t = (DataType) sym.parent_symbol;
} else if (sym is Constant) {
if (sym.parent_symbol is DataType) {
t = (DataType) sym.parent_symbol;
} else if (sym.parent_symbol is Namespace) {
var ns = (Namespace) sym.parent_symbol;
source_internal_includes.concat (ns.get_cheader_filenames ());
return;
} else {
return;
}
if (sym is DataType ||
sym is Method ||
sym is Field ||
sym is Property ||
sym is Constant) {
s = sym;
} else if (sym is FormalParameter) {
var fp = (FormalParameter) sym;
t = fp.type_reference.data_type;
if (t == null) {
s = fp.type_reference.data_type;
if (s == null) {
/* generic type parameter */
return;
}
......@@ -239,26 +225,26 @@ public class Vala.SourceFile {
}
if (dep_type == SourceFileDependencyType.SOURCE) {
if (t.source_reference.file.pkg) {
source_external_includes.concat (t.get_cheader_filenames ());
if (s.source_reference.file.pkg) {
source_external_includes.concat (s.get_cheader_filenames ());
} else {
source_internal_includes.concat (t.get_cheader_filenames ());
source_internal_includes.concat (s.get_cheader_filenames ());
}
return;
}
if (t.source_reference.file.pkg) {
if (s.source_reference.file.pkg) {
/* external package */
header_external_includes.concat (t.get_cheader_filenames ());
header_external_includes.concat (s.get_cheader_filenames ());
return;
}
if (dep_type == SourceFileDependencyType.HEADER_FULL || !t.is_reference_type ()) {
header_internal_includes.concat (t.get_cheader_filenames ());
header_internal_full_dependencies.append (t.source_reference.file);
if (dep_type == SourceFileDependencyType.HEADER_FULL || (s is DataType && !((DataType)s).is_reference_type ())) {
header_internal_includes.concat (s.get_cheader_filenames ());
header_internal_full_dependencies.append (s.source_reference.file);
}
header_internal_dependencies.append (t.source_reference.file);
header_internal_dependencies.append (s.source_reference.file);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment