File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 1212
1313#pragma once
1414
15- #define chef_allow_gsr (t ) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
16- #define chef_allow_s (t ) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
17- #define chef_allow_sr (t ) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
18- #define chef_allow_gs (t ) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
19-
2015/**
2116 * @brief 登记所有贡献者
2217 *
Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ typedef struct Target_t
126126 void (* setfn ) (char * option );
127127 void (* resetfn ) (char * option );
128128
129+ /* 初始化函数,用于填充该 struct 的各种信息 */
130+ void (* preludefn ) (void );
131+ bool inited ; /* 是否执行过了 preludefn() */
132+
129133 Source_t * sources ;
130134 size_t sources_n ;
131135
@@ -167,9 +171,15 @@ TargetRegisterInfo_t;
167171
168172#define def_target (t , aliases ) void t##_getsrc(char *option);void t##_setsrc(char *option);void t##_resetsrc(char *option); Target_t t##_target={aliases};
169173
170- /* 以下宏仅能放在 prelude() 中使用 */
174+ #define chef_allow_gsr (t ) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
175+ #define chef_allow_s (t ) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
176+ #define chef_allow_sr (t ) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
177+ #define chef_allow_gs (t ) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
178+ #define chef_allow_NOOP (t )
179+ #define chef_prep_this (t ,op ) Target_t *this = &t##_target; this->inited = true; chef_allow_##op(t);
180+
171181#define use_this (t ) Target_t *this = &t##_target;
172- #define use_this_source (t ) use_this(t) ; Source_t source = chsrc_yield_source_and_confirm (this, option);
182+ #define use_this_source (t ) Target_t *this = &t##_target ; Source_t source = chsrc_yield_source_and_confirm (this, option);
173183
174184#define def_sources_begin () Source_t sources[] = {
175185#define def_sources_end () }; \
Original file line number Diff line number Diff line change 66 * Contributors : Mikachu2333 <[email protected] > 77 * |
88 * Created On : <2024-08-09>
9- * Last Modified : <2025-08-21 >
9+ * Last Modified : <2025-08-22 >
1010 * -------------------------------------------------------------
1111 * 本文件作为一个通用模板:
1212 *
@@ -58,11 +58,8 @@ RubyMetric = {
5858void
5959< category > _ < target > _prelude (void )
6060{
61- use_this (< category > _ < target > );
62- chef_allow_gsr (< category > _ < target > ); // 代表支持 Get Set Reset 三种操作
63- // chef_allow_s(<category>_<target>); // 以此类推
64- // chef_allow_gs(<category>_<target>);
65- // chef_allow_sr(<category>_<target>);
61+ // op 可以为 NOOP|s|sr|gsr|gs, 代表支持 Get Set Reset 三种操作
62+ chef_prep_this (< category > _ < target > , op );
6663
6764 chef_set_created_on (this , "2024-08-09" ); // 文件创建日期
6865 chef_set_last_updated (this , "2025-08-12" ); // 文件最后一次更新日期
You can’t perform that action at this time.
0 commit comments