Reflection in RegEngine - Part 2

Warning! Some information on this page is older than 3 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Jul 2010

Reflection in RegEngine - Part 2

In the Part 1 I've shown the basics of my reflection system - classes that describe a class, property and enum. Now the question arises about how do I actually create these objects? Where do I get the information about the classes and properties in my code from? There are many possibilities which I considered:

[*] The simplest one would be to explicitly build these data structures by hand - white some initialization code that would do new Class(...);, new FloatProperty(...) and so on. Oviously this is also the most inconvenient way.

[*] Objects describing classes and properties could be automatically generated by code created by some smart usage of C++ macros and templates. I mean declaring classes and their field using something like DECLARE_CLASS(MyClass, ParentClass) and DECLARE_PROPERTY(Prop1, float), either instead or next to the real class and member declarations. This might be a good idea.

[*] Finally, a separate file with either description of classes and properties in some format or a direct C++ code for building it could be generated from some input data. These input data could be extracted from:

I've decided to create class- and property-describing objects by hand in C++ code but on top of that I've coded an optional tool that takes description file in a special language and automtically generates such code. The code written by hand looks like this:

// Header file

class ComplexItemObject : public ItemObject
    static void RegisterClass_();
    static Class * GetClass() { return m_Class; }
    virtual Class * Object_GetClass() { return m_Class; }
    static Class *m_Class;
    wstring m_Name;
    bool m_B1;
    common::COLORF m_Colorf;

// CPP file

Class * ComplexItemObject::m_Class;

void ComplexItemObject::RegisterClass_()
    m_Class = new Class(L"ComplexItemObject", ItemObject::GetClass(), &CreateFunc, &CloneFunc);
    m_Class->SetLabel(L"Complex Item Object");

    StlStringProperty *prop1 = new StlStringProperty();
    prop1->Init(L"Name", 0);

    BoolProperty *prop2 = new BoolProperty();
    prop2->Init(L"B1", 1);

    FloatVectorProperty *prop3 = new FloatVectorProperty(3, VectorProperty::SEMANTICS_COLOR);
    prop3->Init(L"Colorf", 2);


Similar code can be automatically generated by my console tool called ReflectionAuto from a .reflect file. The file format is a description language based on my Tokenizer. ReflectionAuto takes in as input and outputs a separate C++ file that adds this boring reflection initialization code to the described classes. The description of the class shown above looks like:

class ComplexItemObject {
    extends ItemObject;
    label "Complex Item Object";
    property string Name { access m_Name; };
    property bool B1 { access m_B1; };
    property int4(color) Colori { access m_Colori; };

That covers the basics (not everything I actually have) when it comes to building description of the classes and properties from my code to make the reflection system aware of them. In the next part I'll show how do I access real objects from my reflection system, including reading and writing properties, as well as creating and manipulation whole objects.

Comments (1) | Tags: c++ RegEngine engine | Author: Adam Sawicki | Share


2015-06-05 04:11:52
burberry outlet,
christian louboutin outlet,
tory burch sandals,
abercrombie and fitch,
abercrombie and fitch,
nike huarache,
air jordan,
air jordan shoes,
nike air max 2015,
air max,
babyliss pro,
basketball shoes,
beats by dre outlet,
beats by dre,
monster beats outlet,
beats headphones,
burberry outlet online,
burberry outlet,
burberry factory,
cheap calvin kleins,
celine handbags,
chanel handbags,
easton bats,
christian louboutin shoes,
nfl jerseys,
cheap jordans,
cheap michael kors,
nike shoes,
cheap oakley sunglasses,
cheap oakley ,
cheap oakley sunglasses,
cheap ray ban,
boots on sale,
cheap ugg boots,
flat iron,
christian louboutin,
louboutin shoes,
christian louboutin shoes,
coach outlet online,
coach factory,
coach outlet usa,
coach outlet,
coach store online,
coach outlet,
chanel sunglasses,
converse shoes,
coach handbags,
eyeglasses online,
eyeglass frames,
burberry clothes,
salvatore ferragamo,
ferragamo shoes,
hair straightener,
gucci shoes outlet,
gucci handbags,
gucci factory,
gucci outlet,
gucci shoes,
gucci shoes,
hermes birkin,
hermes outlet online,
hollister clothing,
insanity workout,
iphone cases,
jimmy choo,
jordan retro,
jordan shoes,
juicy couture outlet,
juicy couture handbags,
kate spade,
kate spade handbags,
kate spade outlet online,
longchamp handbags,
louis vuitton canada,
louis vuitton bags,
louis vuitton,
vuitton handbags,
louis vuitton outlet online,
louis vuitton,
louis vuitton,
marc jacobs handbags,
mcm bags,
mcm backpack,
michael kors,
cheap michael kors,
michael kors bags sale,
michael kors,
michael kors outlet online,
michael kors outlet,
michael kors outlet,
michael kors outlet online,
michael kors outlet online sale,
michael kors outlet store,
michael kors uk,
mont blanc pens,
new balance,
nike air max,
nike factory,
nike free,
nike free run,
nike free,
air jordans,
nike mercurial,
nike roshe,
nike outlet store,
north face,
north face clearance,
oakley outlet,
oakley sunglasses,
oakley sunglasses cheap,
oakley sunglasses,
omega watches,
pandora charms,
pandora jewelry,
polo outlet,
prada outlet,
prada handbags,
prada outlet,
ralph lauren uk,
polo ralph lauren outlet,
ralph lauren,
ralph lauren shirts,
ralph lauren outlet,
polo ralph lauren,
ray ban outlet,
ray bans,
ray ban sunglasses,
ray-ban sunglasses,
ray ban sunglasses outlet,
ray ban wayfarer,
replica handbags,
rolex watches,
retro jordans,
rolex watches,
nike roshe,
roshe run,
salvatore ferragamo,
soccer shoes,
baseball bats,
supra shoes,
swarovski crystal,
swarovski jewelry,
the north face,
the north face jackets,
north face,
north face outlet,
north face outlet,
thomas sabo,
tiffany and co,
tiffany jewelry,
timberland outlet,
timberland boots,
tommy hilfiger outlet,
tommy hilfiger kids,
toms shoes outlet,
toms outlet,
toms shoes,
tory burch outlet,
tory burch outlet,
true religion,
true religion jeans,
true religion outlet,
ugg australia,
ugg boots,
ugg boots clearance,
uggs on sale,
uggs outlet,
coach outlet,
vans shoes,
wedding dresses,
yoga pants,
ugg boot sale,
polo ralph lauren outlet,
burberry outlet online,
toms outlet,,
christian louboutin,
tory burch sale,
prada outlet,
longchamp handbags,
longchamp outlet,
chanel bags,
true religion outlet,
abercrombie and fitch kids,
hollister clothing,
new balance shoes,
converse shoes,
lululemon outlet,
nfl jerseys,
cheap jerseys,
rolex watches,
rolex watches for sale,
p90x workout,
giuseppe zanotti,
mac cosmetics,
instyler ionic styler,
mizuno wave,
designer handbags,
tommy hilfiger,
ed hardy,
levi's jeans,
bcbg max,
bebe dresses,
gucci outlet,
ralph lauren outlet online,

Post comment

Nick *
Your name or nickname
Your contact information (optional, will not be shown)
Text *
Content of your comment
Calculate *
(* - required field)
STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2017 Adam Sawicki
Copyright © 2004-2017 Adam Sawicki