Macro/投稿/184

http://sakura.qp.land.to/?Macro%2F%C5%EA%B9%C6%2F184


Top > Macro > 投稿 > 184

インクルードガードの挿入(GUID使用)

メッセージ

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
//
//  Include Guard Generator
//
//  Copyright (C) 2007, genta
//
// GUIDGen : http://p2p.wrox.com/topic.asp?TOPIC_ID=20339
//
 
// ------------------------
// Options
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");
        // Note: GUID contains \0 !!
        return x.GUID.replace(/[{}\0]/g, "" ).replace(/-/g,"_");
    }
    catch (e)
    {
        // set default string if GUID is not available
        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
    ;
}

URL B I U SIZE Black Maroon Green Olive Navy Purple Teal Gray Silver Red Lime Yellow Blue Fuchsia Aqua White

添付ファイル: fileguardgen_with_guid.js 145件 [詳細]

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2007-11-28 (水) 19:27:36 (3919d)