●ソースファイル・テンプレート 【補足】 基本的なモジュールは、ソースファイルとヘッダファイルが1組になります。 【使い方】 新規モジュールを作成するときは以下の手順を踏みます。 ・ソースファイルをコピーして作成します。(全てのセクションをコピーします) ・ソースファイルをヘッダして作成します。(全てのセクションをコピーします) ・すべての XXX と Xxx をモジュール名に置換します。 ・すべての(モジュール名)をモジュール名に置換します。 ◆ヘッダファイル /************************************************************************** * <<< (モジュール名) (Xxx) >>> ***************************************************************************/ #ifndef __XXX_H #define __XXX_H /************************************************************************* * <<< 優先ヘッダ >>> **************************************************************************/ #ifndef USES_PRIORITY_HEADER /*[START_OF_PRIORITY_HEADER]*/ #define USES_XXX typedef struct _Xxx Xxx; #define Xxx_Err_Some (0) /* エラーコード */ /* 派生属性の設定 */ #if defined(XXX_SOME) #define XXX_OTHER #endif /*[END_OF_PRIORITY_HEADER]*/ #endif /*--------------------------------------------------------------*/ /*<<< Interface Area -------------------------------------- >>> */ /*--------------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /************************************************************************** * <<< [Xxx] (モジュール名) >>> *【補足】 *・(未記入) ***************************************************************************/ struct _Xxx { int dummy; ERRORS_INITCHK_VAR }; void Xxx_init( Xxx* ); void Xxx_finish( Xxx* ); void Xxx_setStat( Xxx* ); void Xxx_getStat( Xxx* ); void Xxx_onEvent( Xxx* ); /* 以下は内部用 */ void Xxx_init_imp( Xxx* ); #ifdef __cplusplus } #endif /*--------------------------------------------------------------*/ /*<<< Mapping Area ---------------------------------------- >>> */ /*--------------------------------------------------------------*/ /************************************************************************** * <<< [Xxx_init] (マクロの概要) >>> *【引数】 * ・Xxx* this; (モジュール名) *【補足】 *・ ***************************************************************************/ #define Xxx_init( this ) #endif ◆ソースファイル /************************************************************************** * <<< (モジュール名) (Xxx) >>> ***************************************************************************/ #include /*---------------------------------------------------------------------*/ /* <<<◆(Xxx) (モジュール名) >>> */ /*---------------------------------------------------------------------*/ /************************************************************************** * <<< [Xxx_init] 初期化する >>> *【引数】 * ・Xxx* this; (モジュール名) *【補足】 *・ ***************************************************************************/ #ifdef USES_OTHER void Xxx_init( Xxx* this ) { int a; ERRORS_INITCHK( this, 0 ); ASSERT( a >= 0 ); this->a = a; ERRORS_FINISHCHK_FOR_INIT( Xxx_finish ); } #endif /************************************************************************** * <<< [Xxx_finish] 後始末する >>> ***************************************************************************/ #ifdef USES_OTHER void Xxx_finish( Xxx* this ) { ERRORS_INITCHK( this, 1 ); ERRORS_FINISHCHK_FOR_FINISH( Xxx_finish ); Other_finish( &this->a ); } #endif /************************************************************************** * <<< [Xxx_getStat] 〜を返す、〜を格納する >>> *【引数】 * ・Xxx* this; (モジュール名) *【補足】 *・ ***************************************************************************/ #ifdef USES_OTHER int Xxx_getStat( Xxx* this ) { ERRORS_INITCHK( this, 1 ); return this->a; } #endif /************************************************************************** * <<< [Xxx_setStat] 〜を設定する >>> *【引数】 * ・Xxx* this; (モジュール名) *【補足】 *・ ***************************************************************************/ #ifdef USES_OTHER void Xxx_setStat( Xxx* this, int a ) { ERRORS_INITCHK( this, 1 ); ASSERT( a >= 0 ); this->a = a; } #endif /************************************************************************** * <<< [Xxx_onEvent] 〜が起きたときの処理 >>> *【引数】 * ・Xxx* this; (モジュール名) *【補足】 *・ ***************************************************************************/ #ifdef USES_OTHER void Xxx_onEvent( Xxx* this ) { ERRORS_INITCHK( this, 1 ); } #endif