[vala/0.10-parallel: 22/46] SourceFile: Introduce SourceFileType enumeration
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.10-parallel: 22/46] SourceFile: Introduce SourceFileType enumeration
- Date: Fri, 10 Sep 2010 16:15:44 +0000 (UTC)
commit b36cc08042ace2f77cd1fb948d8fda599b3bc0b7
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Aug 24 19:01:39 2010 +0200
SourceFile: Introduce SourceFileType enumeration
SourceFileType has 2 possible values:
SOURCE
PACKAGE
and replaces the CodeWriter.external_package boolean with a new field
called 'file_type'.
codegen/valaccodebasemodule.vala | 4 ++--
codegen/valaccodecompiler.vala | 4 ++--
codegen/valadovabasemodule.vala | 2 +-
compiler/valacompiler.vala | 8 ++++----
vala/valaflowanalyzer.vala | 2 +-
vala/valagenieparser.vala | 20 ++++++++++----------
vala/valaparser.vala | 24 ++++++++++++------------
vala/valasourcefile.vala | 12 ++++++++----
vala/valasymbol.vala | 2 +-
vapigen/valavapicheck.vala | 4 ++--
vapigen/valavapigen.vala | 6 +++---
11 files changed, 46 insertions(+), 42 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 2b9a9ab..496e20b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -420,7 +420,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
- if (!file.external_package) {
+ if (file.file_type == SourceFileType.SOURCE) {
file.accept (this);
}
}
@@ -843,7 +843,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
return;
}
- if (!c.external) {
+ if (c.source_reference.file.file_type != SourceFileType.PACKAGE) {
generate_type_declaration (c.type_reference, decl_space);
c.value.emit (this);
diff --git a/codegen/valaccodecompiler.vala b/codegen/valaccodecompiler.vala
index 6bec313..09ab3d6 100644
--- a/codegen/valaccodecompiler.vala
+++ b/codegen/valaccodecompiler.vala
@@ -105,7 +105,7 @@ public class Vala.CCodeCompiler {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
- if (!file.external_package) {
+ if (file.file_type == SourceFileType.SOURCE) {
cmdline += " " + Shell.quote (file.get_csource_filename ());
}
}
@@ -137,7 +137,7 @@ public class Vala.CCodeCompiler {
/* remove generated C source and header files */
foreach (SourceFile file in source_files) {
- if (!file.external_package) {
+ if (file.file_type == SourceFileType.SOURCE) {
if (!context.save_csources) {
FileUtils.unlink (file.get_csource_filename ());
}
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 5feabfd..a679d4e 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -293,7 +293,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
- if (!file.external_package) {
+ if (file.file_type == SourceFileType.SOURCE) {
file.accept (this);
}
}
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 9536ba7..37bf15c 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -151,7 +151,7 @@ class Vala.Compiler {
return false;
}
- context.add_source_file (new SourceFile (context, gir_path, true));
+ context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, gir_path));
return true;
}
@@ -170,7 +170,7 @@ class Vala.Compiler {
context.add_package (pkg);
- context.add_source_file (new SourceFile (context, package_path, true));
+ context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, package_path));
var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
@@ -352,7 +352,7 @@ class Vala.Compiler {
if (FileUtils.test (source, FileTest.EXISTS)) {
var rpath = realpath (source);
if (run_output || source.has_suffix (".vala") || source.has_suffix (".gs")) {
- var source_file = new SourceFile (context, rpath);
+ var source_file = new SourceFile (context, SourceFileType.SOURCE, rpath);
source_file.relative_filename = source;
if (context.profile == Profile.POSIX) {
@@ -374,7 +374,7 @@ class Vala.Compiler {
context.add_source_file (source_file);
} else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) {
- var source_file = new SourceFile (context, rpath, true);
+ var source_file = new SourceFile (context, SourceFileType.PACKAGE, rpath);
source_file.relative_filename = source;
context.add_source_file (source_file);
diff --git a/vala/valaflowanalyzer.vala b/vala/valaflowanalyzer.vala
index 74c35f6..5394e86 100644
--- a/vala/valaflowanalyzer.vala
+++ b/vala/valaflowanalyzer.vala
@@ -108,7 +108,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
- if (!file.external_package) {
+ if (file.file_type == SourceFileType.SOURCE) {
file.accept (this);
}
}
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 28ffbac..73cabb6 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2639,7 +2639,7 @@ public class Vala.Genie.Parser : CodeVisitor {
parse_declarations (cl);
// ensure there is always a default construction method
- if (!scanner.source_file.external_package
+ if (scanner.source_file.file_type == SourceFileType.SOURCE
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
m.access = SymbolAccessibility.PUBLIC;
@@ -2753,7 +2753,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var c = new Constant (id, type, initializer, get_src (begin), comment);
c.access = get_access (id);
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
c.external = true;
}
if (ModifierFlags.NEW in flags) {
@@ -2789,7 +2789,7 @@ public class Vala.Genie.Parser : CodeVisitor {
set_attributes (f, attrs);
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
f.external = true;
}
if (ModifierFlags.NEW in flags) {
@@ -3008,7 +3008,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (accept_block ()) {
method.body = parse_block ();
- } else if (scanner.source_file.external_package) {
+ } else if (scanner.source_file.file_type == SourceFileType.PACKAGE) {
method.external = true;
}
return method;
@@ -3056,7 +3056,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (ModifierFlags.NEW in flags) {
prop.hides = true;
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
prop.external = true;
}
@@ -3138,7 +3138,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect_terminator ();
}
- if (!prop.is_abstract && !scanner.source_file.external_package) {
+ if (!prop.is_abstract && scanner.source_file.file_type == SourceFileType.SOURCE) {
var needs_var = (readonly && (prop.get_accessor != null && prop.get_accessor.body == null));
if (!needs_var) {
@@ -3321,7 +3321,7 @@ public class Vala.Genie.Parser : CodeVisitor {
} else {
iface.access = get_access (sym.name);
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
iface.external = true;
}
set_attributes (iface, attrs);
@@ -3390,7 +3390,7 @@ public class Vala.Genie.Parser : CodeVisitor {
} else {
en.access = get_access (sym.name);
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
en.external = true;
}
set_attributes (en, attrs);
@@ -3650,7 +3650,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (accept_block ()) {
method.body = parse_block ();
- } else if (scanner.source_file.external_package) {
+ } else if (scanner.source_file.file_type == SourceFileType.PACKAGE) {
method.external = true;
}
@@ -3711,7 +3711,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (!(ModifierFlags.STATIC in flags)) {
d.has_target = true;
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
d.external = true;
}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 9f4f34d..eb4755e 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2378,7 +2378,7 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.ABSTRACT in flags) {
cl.is_abstract = true;
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
cl.external = true;
}
set_attributes (cl, attrs);
@@ -2392,7 +2392,7 @@ public class Vala.Parser : CodeVisitor {
parse_declarations (cl);
// ensure there is always a default construction method
- if (!scanner.source_file.external_package
+ if (scanner.source_file.file_type == SourceFileType.SOURCE
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
m.access = SymbolAccessibility.PUBLIC;
@@ -2500,7 +2500,7 @@ public class Vala.Parser : CodeVisitor {
var c = new Constant (id, type, initializer, get_src (begin), comment);
c.access = access;
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
c.external = true;
}
if (ModifierFlags.NEW in flags) {
@@ -2535,7 +2535,7 @@ public class Vala.Parser : CodeVisitor {
|| ModifierFlags.OVERRIDE in flags) {
Report.error (f.source_reference, "abstract, virtual, and override modifiers are not applicable to fields");
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
f.external = true;
}
if (ModifierFlags.NEW in flags) {
@@ -2704,7 +2704,7 @@ public class Vala.Parser : CodeVisitor {
}
if (!accept (TokenType.SEMICOLON)) {
method.body = parse_block ();
- } else if (scanner.source_file.external_package) {
+ } else if (scanner.source_file.file_type == SourceFileType.PACKAGE) {
method.external = true;
}
return method;
@@ -2750,7 +2750,7 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.ASYNC in flags) {
Report.error (prop.source_reference, "async properties are not supported yet");
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
prop.external = true;
}
if (context.profile == Profile.DOVA) {
@@ -2938,7 +2938,7 @@ public class Vala.Parser : CodeVisitor {
}
var st = new Struct (sym.name, get_src (begin), comment);
st.access = access;
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
st.external = true;
}
set_attributes (st, attrs);
@@ -2998,7 +2998,7 @@ public class Vala.Parser : CodeVisitor {
}
var iface = new Interface (sym.name, get_src (begin), comment);
iface.access = access;
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
iface.external = true;
}
set_attributes (iface, attrs);
@@ -3059,7 +3059,7 @@ public class Vala.Parser : CodeVisitor {
var sym = parse_symbol_name ();
var en = new Enum (sym.name, get_src (begin), comment);
en.access = access;
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
en.external = true;
}
set_attributes (en, attrs);
@@ -3123,7 +3123,7 @@ public class Vala.Parser : CodeVisitor {
var sym = parse_symbol_name ();
var ed = new ErrorDomain (sym.name, get_src (begin), comment);
ed.access = access;
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
ed.external = true;
}
set_attributes (ed, attrs);
@@ -3375,7 +3375,7 @@ public class Vala.Parser : CodeVisitor {
set_attributes (method, attrs);
if (!accept (TokenType.SEMICOLON)) {
method.body = parse_block ();
- } else if (scanner.source_file.external_package) {
+ } else if (scanner.source_file.file_type == SourceFileType.PACKAGE) {
method.external = true;
}
return method;
@@ -3403,7 +3403,7 @@ public class Vala.Parser : CodeVisitor {
} else {
d.has_target = true;
}
- if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
+ if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) {
d.external = true;
}
foreach (TypeParameter type_param in type_param_list) {
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index e58e009..ff4be85 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -40,7 +40,7 @@ public class Vala.SourceFile {
/**
* Specifies whether this file is a VAPI package file.
*/
- public bool external_package { get; set; }
+ public SourceFileType file_type { get; set; }
/**
* GIR Namespace for this source file, if it's a VAPI package
@@ -91,10 +91,10 @@ public class Vala.SourceFile {
* @param pkg true if this is a VAPI package file
* @return newly created source file
*/
- public SourceFile (CodeContext context, string filename, bool pkg = false, string? content = null) {
- this.filename = filename;
- this.external_package = pkg;
+ public SourceFile (CodeContext context, SourceFileType type, string filename, string? content = null) {
this.context = context;
+ this.file_type = type;
+ this.filename = filename;
this.content = content;
}
@@ -314,3 +314,7 @@ public class Vala.SourceFile {
}
}
+public enum SourceFileType {
+ SOURCE,
+ PACKAGE
+}
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 1ec1864..a093b1f 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -156,7 +156,7 @@ public abstract class Vala.Symbol : CodeNode {
*/
public bool external_package {
get {
- return (source_reference != null && source_reference.file.external_package);
+ return (source_reference != null && source_reference.file.file_type == SourceFileType.PACKAGE);
}
}
diff --git a/vapigen/valavapicheck.vala b/vapigen/valavapicheck.vala
index 4a98c96..a17d2de 100644
--- a/vapigen/valavapicheck.vala
+++ b/vapigen/valavapicheck.vala
@@ -24,8 +24,8 @@ using GLib;
class Vala.VAPICheck : Object {
public VAPICheck (string gidlname, CodeContext context = new CodeContext ()) {
- gidl = new SourceFile (context, gidlname);
- metadata = new SourceFile (context, gidlname.substring (0, gidlname.length - 5) + ".metadata");
+ gidl = new SourceFile (context, SourceFileType.SOURCE, gidlname);
+ metadata = new SourceFile (context, SourceFileType.SOURCE, gidlname.substring (0, gidlname.length - 5) + ".metadata");
this.context = context;
}
diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala
index 403fa89..577d519 100644
--- a/vapigen/valavapigen.vala
+++ b/vapigen/valavapigen.vala
@@ -77,7 +77,7 @@ class Vala.VAPIGen : Object {
context.add_package (pkg);
- context.add_source_file (new SourceFile (context, package_path, true));
+ context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, package_path));
var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
@@ -176,7 +176,7 @@ class Vala.VAPIGen : Object {
foreach (string source in sources) {
if (FileUtils.test (source, FileTest.EXISTS)) {
- context.add_source_file (new SourceFile (context, source, true));
+ context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, source));
} else {
Report.error (null, "%s not found".printf (source));
}
@@ -240,7 +240,7 @@ class Vala.VAPIGen : Object {
// interface writer ignores external packages
foreach (SourceFile file in context.get_source_files ()) {
if (!file.filename.has_suffix (".vapi")) {
- file.external_package = false;
+ file.file_type = SourceFileType.SOURCE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]