|
インクルードガードの挿入(GUID使用)
- ページ: Macro/投稿
- 作者: げんた
- カテゴリー: js
- 投稿日: 2007-11-28 (水) 19:25:34
メッセージ
GUIDを使ったuniqueなインクルードガードを挿入します.ライセンス文を併せて挿入する機能も入っています.
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| |
var header_prefix = "SAKURA_"
var header_postfix = "_H_"
var license = zlib_license
var EOL = ["\r\n", "\r", "\n" ][Editor.GetLineCode()]
var filepart = Editor.ExpandParameter("$g").toUpperCase()
var guidpart = GUIDGen().toUpperCase()
var guardkey = header_prefix + filepart + "_" + guidpart + header_postfix
Editor.GoFileTop()
if( license ){
Editor.InsText( license() )
}
Editor.InsText("#ifndef " + guardkey + EOL )
Editor.InsText("#define " + guardkey + EOL )
Editor.GoFileEnd()
Editor.InsText( EOL + "#endif /* " + guardkey + " */" + EOL + "/*[EOF]*/" + EOL )
function GUIDGen()
{
try
{
var x = new ActiveXObject("Scriptlet.TypeLib");
return x.GUID.replace(/[{}\0]/g, "" ).replace(/-/g,"_");
}
catch (e)
{
return ("_GUARD_");
}
}
function zlib_license (){
return "/*" + EOL +
" Copyright (C) **YEAR**, **AUTHOR**" + EOL +
"" + EOL +
" This software is provided 'as-is', without any express or implied" + EOL +
" warranty. In no event will the authors be held liable for any damages" + EOL +
" arising from the use of this software." + EOL +
"" + EOL +
" Permission is granted to anyone to use this software for any purpose," + EOL +
" including commercial applications, and to alter it and redistribute it" + EOL +
" freely, subject to the following restrictions:" + EOL +
"" + EOL +
" 1. The origin of this software must not be misrepresented;" + EOL +
" you must not claim that you wrote the original software." + EOL +
" If you use this software in a product, an acknowledgment" + EOL +
" in the product documentation would be appreciated but is" + EOL +
" not required." + EOL +
"" + EOL +
" 2. Altered source versions must be plainly marked as such," + EOL +
" and must not be misrepresented as being the original software." + EOL +
"" + EOL +
" 3. This notice may not be removed or altered from any source" + EOL +
" distribution." + EOL +
"*/" + EOL
;
}
|
|
|