]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add `do not modify' note at the top of generated C files
authorMichael B. Trausch <mike@trausch.us>
Sun, 27 Sep 2009 20:22:57 +0000 (22:22 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 27 Sep 2009 20:24:29 +0000 (22:24 +0200)
Fixes bug 595797.

ccode/valaccodewriter.vala
codegen/valaccodebasemodule.vala

index 11559cd54b8c32e44af1030b9e57f1ab23bee7d2..ff0677bceba4239b83d63c79ccfca05a32aaba78 100644 (file)
@@ -31,6 +31,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.
         */
@@ -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);
        }
 
index 50fd405a254d0d4812a1dc427e78f54fa60aa20c..38662ba5d09d54e6a7a9c44ae232f56146c9c790 100644 (file)
@@ -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;