Merged in Governor-Tarkin/swg-src (pull request #17)
[swg-src.git] / tools / swg.el
blob3afefaccf032aff1c8ba018be0b2a3c4f669745e
1 (defun swg-comment-block ()
2 "Insert an empty comment block, in the Javadoc style."
3 (interactive)
4 (insert "/** \n")
5 (insert " *\n")
6 (insert " * @param \n")
7 (insert " * @return \n")
8 (insert " * @see \n")
9 (insert " */\n"))
11 (defun swg-single-line ()
12 "Insert a line of dashes, for separating functions or sections of a file."
13 (interactive)
14 (insert "// ----------------------------------------------------------------------\n"))
16 (defun swg-double-line ()
17 "Insert a line of equals, for separating functions or sections of a file."
18 (interactive)
19 (insert "// ======================================================================\n"))
21 (defun swg-new-source ()
22 "Add template for a new source file. Assumes filename ends in .cpp"
23 (interactive)
24 (let* ((bufname (buffer-name (current-buffer)))
25 (chopname (substring bufname 0 -4)))
26 (swg-double-line)
27 (insert "//\n")
28 (insert (concat "// " (buffer-name (current-buffer)) "\n"))
29 (insert "// copyright (c) 2004 Sony Online Entertainment\n")
30 (insert "//\n")
31 (swg-double-line)
32 (insert "\n")
33 (insert "#include \"FirstGame.h\"\n")
34 (insert (concat "#include \"" chopname ".h\"\n"))
35 (insert "\n")
36 (swg-double-line)
37 (insert "\n")
38 (swg-double-line)))
40 (defun swg-new-header ()
41 "Add template for a new header file. Assumes filename ends in .h"
42 (interactive)
43 (let* ((bufname (buffer-name (current-buffer)))
44 (chopname (substring bufname 0 -2)))
45 (swg-double-line)
46 (insert "//\n")
47 (insert (concat "// " bufname "\n"))
48 (insert "// copyright (c) 2004 Sony Online Entertainment\n")
49 (insert "//\n")
50 (swg-double-line)
51 (insert "\n")
52 (insert (concat "#ifndef INCLUDED_" chopname "_H\n"))
53 (insert (concat "#define INCLUDED_" chopname "_H\n"))
54 (insert "\n")
55 (swg-double-line)
56 (insert "\n")
57 (swg-double-line)
58 (insert "\n")
59 (insert "#endif\n")))
61 (defun swg-insert-classname ()
62 "Insert the likely classname (based on the current filename)"
63 (interactive)
64 (let* ((bufname (buffer-name (current-buffer)))
65 (chopname (substring bufname 0 -4)))
66 (insert chopname)))
68 (defun swg-new-class (classname)
69 "Template to create a new class declaration"
70 (interactive "sClassName: ")
71 (insert (concat "class " classname "\n"))
72 (insert "{\n")
73 (insert "public:\n")
74 (insert "\n")
75 (insert "};\n")
76 (previous-line 2))
78 (defun swg-lint ()
79 "Run Lint on the current buffer."
80 (interactive)
81 (let (old-command compile-command)
82 (compile (concat "swglint.sh " (buffer-file-name)))
83 (setq compile-command old-command)))
85 (defun swg-perforce-comment (reviewedby keyfrom)
86 "Create a Perforce checkin description with all the necessary tags"
87 (interactive "sReviewed by: \nsKey from: ")
88 (insert "\t[key-from ")
89 (insert keyfrom)
90 (insert " ")
91 (call-process "getP4KeyFrom.pl" nil t nil keyfrom)
92 (delete-backward-char 1)
93 (insert "]\n")
94 (insert "\t[internal]\n")
95 (insert "\n")
96 (insert "\t[public]\n")
97 (insert "\tnone\n")
98 (insert "\t[testplan]\n")
99 (insert "\tnone\n")
100 (insert (concat "\t[reviewed-by " reviewedby "]\n"))
101 (insert "\t[linted]\n")
102 (previous-line 7)
103 (insert "\t")
106 (provide 'swg)