diff options
author | Michael B. Trausch <mike@trausch.us> | 2009-09-27 22:22:57 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2009-09-27 22:24:29 +0200 |
commit | 728bb93c7fce2725413627a4012fe4a5230bec50 (patch) | |
tree | b655b1d52f43f4956038aabdf51227cddd7b093b /ccode | |
parent | 0d0e8a786f330fd2a536bb43e3ad553b54fd18b8 (diff) | |
download | vala-728bb93c7fce2725413627a4012fe4a5230bec50.tar.gz |
Add `do not modify' note at the top of generated C files
Fixes bug 595797.
Diffstat (limited to 'ccode')
-rw-r--r-- | ccode/valaccodewriter.vala | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala index 11559cd54..ff0677bce 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); } |