掲示板一覧   -   トピック一覧
   EA ソースコード生成・コード生成テンプレート
     コード生成テンプレートに関するTIPS


フラット表示 前のトピック | 次のトピック
投稿者 トピック
tkouno
投稿日時: 2007-1-5 18:37
EA Administrator
投稿: 4292

Re: コード生成テンプレートに関するTIPS

その2:コードテンプレートのカスタマイズ関連です。

2.出力書式の設定

(1)コード生成テンプレートを開き、言語を設定する

・EAのメインメニュー[設定]-[コード生成のテンプレート]
・言語をC++に選択設定する(左上)


(2)多重定義回避用のマクロ文を修正する

File の 16~20行を以下のように変更する。

$guid = "EA_" + %TRIM(eaGUID,"{}")%
$guid = %REPLACE($guid,"-","_")%
$guid += "__INCLUDED_"
#if !defined($guid)
#define $guid\n
%ImportSection%
%list="Namespace" @separator="\n\n"%
#endif // !defined($guid)\n

→$fname = %fileName%
$fname = "T" + %TO_UPPER($fname)%
$fname = %REPLACE($fname,".","")%
#ifndef $fname
#define $fname\n
%ImportSection%
%list="Namespace" @separator="\n\n"%
#endif


(3)括弧{}のスタイルを変更する

Class Body Impl の 12, 16, 21 行目:
){\n\n} →)\n{\n\n} に変更(コンストラクタ,デストラクタ,コピーコンストラクタ用)

Opreation Body の 1行目:
{\n→\n{\nに変更(一般メッソド用)


(4)public,protected,privateフィールドの出力順を逆転する。

Class Body の 68行目以降。以下の3ブロックを希望出力順にブロック単位で並替える

$pubFeatures = %TRIM($pubFeatures, "\n")%
$pubFeatures += "\n" + %list="Attribute" @separator="\n" @indent="\t" attScope=="Public" or
linkAttAccess=="Public" or attScope=="Package" or linkAttAccess=="Package"%

・(途中省略,Publicフィールドのブロック)

%endIf%

$protFeatures = %TRIM($protFeatures, "\n")%
$protFeatures += "\n" + %list="Attribute" @separator="\n" @indent="\t" attScope=="Protected" or
linkAttAccess=="Protected"%

・(途中省略,Protectedフィールドのブロック)

%endIf%

$privFeatures = %TRIM($privFeatures, "\n")%
$privFeatures += "\n" + %list="Attribute" @separator="\n" @indent="\t" attScope=="Private" or
linkAttAccess=="Private"%

・(途中省略,Privateフィールドのブロック)

%endIf%


(5)属性の説明記述を"//"に続く1行表現に変更して直前に空白行を1行追加する。

Attribute Notes の記述を以下のように変更する。

%if genOptGenComments != "T"%
%endTemplate%

%PI=""%
$style = %genOptCPPCommentStyle%

%if $style == "XML.NET"%
$wrapLen = %genOptWrapComment%(注:XML時の記述,wrapLen文コピー移動)
%XML_COMMENT($wrapLen)%
%elseIf $style == "JavaDoc"%
$wrapLen = %genOptWrapComment%(注:Java時の記述,wrapLen文コピー移動)
%JAVADOC_COMMENT($wrapLen)%
%else%
$wrapLen = %genOptWrapComment=="-1" ? "-1" : "40"%(注:C++時の記述,主な変更部分)
$attribute = %WRAP_LINES(attNotes, $wrapLen, "//", "")%
%if $attribute != ""%
\n$attribute(注:空白行を追加)
%endIf%


(6)操作の書式を調整する。

メソッドコードの先頭"{"に続く空白行を削除する
Operation Body の先頭行:\n{\n→\n{

メソッドコードの"{"に続く”振る舞い"の記述後の空白行2行を除く
Operation Body の5行目:$behaviour\n\n→$behaviour

メソッドコードの記述の最後に続けて空白行を1行追加する
Operation の最終行:%endIf% →%endIf%(改行後)\n


3.出力の有効/無効設定

メインメニュー[ツール]-[オプション]からローカルオプションウィンドウを開く。
左ボックスの"ソースコードの生成と読み込み"以下の項目をクリック選択すると、出力機能の細かなON/OFF設定を行える。

フラット表示 前のトピック | 次のトピック

題名 投稿者 日時
   コード生成テンプレートに関するTIPS tkouno 2007-1-5 18:36
   » Re: コード生成テンプレートに関するTIPS tkouno 2007-1-5 18:37