📄 c-r.rep
字号:
// differences from c.rep:// `metaroot_ctor() does not call super_ctor() -- no need to, we hope// first arguments to ctor are copied to struct in order of declaration// then argumentlist is shared with other `meta_ctor()s// memcpy() performs binary inheritance// there is no way to generate `root and `metaroot descriptions and init()//// note that 'ctor' and its calling convention are burnt into this file//% init // implement %init request for root class`{dcl `{if `class `root `%selectors static void * `metaroot _ctor (void * _self, va_list * app) { `n `t struct `metaroot * self = _self; `n `t const size_t offset = offsetof(struct `metaroot , ctor); `n `t typedef void (* voidf) (); `n `t voidf selector; `n `t va_list ap; `n `n `{struct `metaroot `{if `name super `t self -> `name = cast( `metaroot (), va_arg(* app, `type )); `n `} `{else `t self -> `name = va_arg(* app, `type ); `n `}fi `}n `t memcpy((char *) self + offset, ` \ (char *) self -> super + offset, `n `t `t sizeOf(self -> super) - offset); `n `n `t ap = * app; `n `%meta-ctor-loop `t return self; `n } `n `n// we assume that `root and `metaroot are statically initialized structures const void * `%const `root (void) { `n `t return & _ `root ; `n } `n `n const void * `%const `metaroot (void) { `n `t return & _ `metaroot ; `n } `n `n `}fi`}dcl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -