Set vim/emacs to read-only for LCP generated files

Reviewers: mtomic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1459
This commit is contained in:
Teon Banek 2018-06-28 16:53:32 +02:00
parent 86a00b00fa
commit 8fb6f3b5ce

View File

@ -22,6 +22,8 @@
(in-package #:lcp)
(defconstant +whitespace-chars+ '(#\Newline #\Space #\Return #\Linefeed #\Tab))
(defconstant +vim-read-only+ "vim: readonly")
(defconstant +emacs-read-only+ "-*- buffer-read-only: t; -*-")
(defstruct raw-cpp
(string "" :type string :read-only t))
@ -1498,7 +1500,9 @@ written to CPP-OUT stream. This source file will include the provided HPP-FILE.
Original LCP-FILE is used just to insert a comment about the source of the
code generation."
(with-open-file (out capnp-file :direction :output :if-exists :supersede)
(format out "# Autogenerated using LCP from '~A'~%# DO NOT EDIT!~2%" lcp-file)
(format out "~@{# ~A~%~}" +emacs-read-only+ +vim-read-only+)
(format out "# DO NOT EDIT! Generated using LCP from '~A'~2%"
(file-namestring lcp-file))
(format out "~A;~2%" capnp-id)
(write-line "using Cxx = import \"/capnp/c++.capnp\";" out)
(format out "$Cxx.namespace(\"~A::capnp\");~2%" *capnp-namespace*)
@ -1569,7 +1573,9 @@ file."
;; cpp-code. This allows us to generate code which may rely on
;; evaluation done after the code definition.
(with-open-file (out hpp-file :direction :output :if-exists :supersede)
(format out "// Autogenerated using LCP from '~A'~%// DO NOT EDIT!~2%" lcp-file)
(format out "~@{// ~A~%~}" +emacs-read-only+ +vim-read-only+)
(format out "// DO NOT EDIT! Generated using LCP from '~A'~2%"
(file-namestring lcp-file))
(dolist (res (read-lcp lcp-file))
(write-line (cpp-code res) out)))
(when *cpp-namespaces*
@ -1581,7 +1587,9 @@ file."
;; When we have either capnp or C++ code for the .cpp file, generate the .cpp file
(when (or *cpp-impl* types-for-capnp)
(with-open-file (out cpp-file :direction :output :if-exists :supersede)
(format out "// Autogenerated using LCP from '~A'~%// DO NOT EDIT!~2%" lcp-file)
(format out "~@{// ~A~%~}" +emacs-read-only+ +vim-read-only+)
(format out "// DO NOT EDIT! Generated using LCP from '~A'~2%"
(file-namestring lcp-file))
(format out "#include \"~A\"~2%" (file-namestring hpp-file))
;; First output the C++ code from the user
(let (open-namespaces)