mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-09 11:35:51 +08:00
添加 chef_prep_this()
This commit is contained in:
parent
0a51b7ebd8
commit
12e69edb86
@ -12,11 +12,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
|
||||
/**
|
||||
* @brief 登记所有贡献者
|
||||
*
|
||||
|
@ -126,6 +126,10 @@ typedef struct Target_t
|
||||
void (*setfn) (char *option);
|
||||
void (*resetfn) (char *option);
|
||||
|
||||
/* 初始化函数,用于填充该 struct 的各种信息 */
|
||||
void (*preludefn) (void);
|
||||
bool inited; /* 是否执行过了 preludefn() */
|
||||
|
||||
Source_t *sources;
|
||||
size_t sources_n;
|
||||
|
||||
@ -167,9 +171,15 @@ TargetRegisterInfo_t;
|
||||
|
||||
#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};
|
||||
|
||||
/* 以下宏仅能放在 prelude() 中使用 */
|
||||
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
#define chef_allow_NOOP(t)
|
||||
#define chef_prep_this(t,op) Target_t *this = &t##_target; this->inited = true; chef_allow_##op(t);
|
||||
|
||||
#define use_this(t) Target_t *this = &t##_target;
|
||||
#define use_this_source(t) use_this(t); Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
#define use_this_source(t) Target_t *this = &t##_target; Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
|
||||
#define def_sources_begin() Source_t sources[] = {
|
||||
#define def_sources_end() }; \
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
* |
|
||||
* Created On : <2024-08-09>
|
||||
* Last Modified : <2025-08-21>
|
||||
* Last Modified : <2025-08-22>
|
||||
* -------------------------------------------------------------
|
||||
* 本文件作为一个通用模板:
|
||||
*
|
||||
@ -58,11 +58,8 @@ RubyMetric = {
|
||||
void
|
||||
<category>_<target>_prelude (void)
|
||||
{
|
||||
use_this(<category>_<target>);
|
||||
chef_allow_gsr(<category>_<target>); // 代表支持 Get Set Reset 三种操作
|
||||
// chef_allow_s(<category>_<target>); // 以此类推
|
||||
// chef_allow_gs(<category>_<target>);
|
||||
// chef_allow_sr(<category>_<target>);
|
||||
// op 可以为 NOOP|s|sr|gsr|gs, 代表支持 Get Set Reset 三种操作
|
||||
chef_prep_this (<category>_<target>, op);
|
||||
|
||||
chef_set_created_on (this, "2024-08-09"); // 文件创建日期
|
||||
chef_set_last_updated (this, "2025-08-12"); // 文件最后一次更新日期
|
||||
|
Loading…
x
Reference in New Issue
Block a user