[vala] Add `do not modify' note at the top of generated C files
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Add `do not modify' note at the top of generated C files
- Date: Sun, 27 Sep 2009 20:25:30 +0000 (UTC)
commit 728bb93c7fce2725413627a4012fe4a5230bec50
Author: Michael B. Trausch <mike trausch us>
Date: Sun Sep 27 22:22:57 2009 +0200
Add `do not modify' note at the top of generated C files
Fixes bug 595797.
ccode/valaccodewriter.vala | 20 +++++++++++++++++++-
codegen/valaccodebasemodule.vala | 2 +-
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 11559cd..ff0677b 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -32,6 +32,11 @@ public class Vala.CCodeWriter {
public string filename { get; set; }
/**
+ * Specifies the source file used to generate this one.
+ */
+ private string source_filename;
+
+ /**
* Specifies whether to emit line directives.
*/
public bool line_directives { get; set; }
@@ -55,8 +60,9 @@ public class Vala.CCodeWriter {
/* at begin of line */
private bool _bol = true;
- public CCodeWriter (string filename) {
+ public CCodeWriter (string filename, string? source_filename = null) {
this.filename = filename;
+ this.source_filename = source_filename;
}
/**
@@ -74,6 +80,18 @@ public class Vala.CCodeWriter {
stream = FileStream.open (filename, "w");
}
+ write_string ("/* %s generated by valac, the Vala compiler".printf (Path.get_basename (filename)));
+
+ // Write the file name if known
+ if (source_filename != null) {
+ write_newline ();
+ write_string (" * generated from %s".printf (Path.get_basename (source_filename)));
+ }
+
+ write_string (", do not modify */");
+ write_newline ();
+ write_newline ();
+
return (stream != null);
}
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 50fd405..38662ba 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -651,7 +651,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
source_type_member_definition.append (cfunc);
}
- var writer = new CCodeWriter (source_file.get_csource_filename ());
+ var writer = new CCodeWriter (source_file.get_csource_filename (), source_file.filename);
if (!writer.open ()) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]