metaobj-test.cc
来自「这个程序是关于OpenC++的反射植入机制的编译器」· CC 代码 · 共 61 行
CC
61 行
/* Copyright (C) 1997,1998 Shigeru Chiba, University of Tsukuba. Permission to use, copy, distribute and modify this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Shigeru Chiba makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. July 1997: rewritten by Toru Takimoto for version 2.5.*///@beginlicenses@//@license{xerox}{}@//@endlicenses@/* This is a sample program using RtmopClass. We define a new runtime metaobject VerboseObj to control the behavior of Person objects.*/#include <stdio.h>#include "metaobj.h"// --- Runtime Meta Levelclass VerboseObj : public MetaObj {public: void Reflect(int member, char* arglist, int arglist_size){ puts("*** member function call!"); Reify(member, arglist); }};// --- Base Level// Syntax: metaclass RtmopClass <class name>(<runtime metaobject>);metaclass RtmopClass Person(VerboseObj);class Person {public: Person(int i) { age = i; } int Age() { return age; }private: int age;};int main(){ Person billy(24); printf("age %d\n", billy.Age()); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?