[cfe-dev] Reflection

Gwaredd Mountain gwmounta at microsoft.com
Thu Dec 16 10:00:16 PST 2010


Well, one big reason is I can't rely on clang being available for every bespoke platform I write code for ;) Unless all compilers supported it and implementation specifics could be controlled through pragmas or compiler flags then it is safer, easier and more workable to mange this myself.


-----Original Message-----
Date: Thu, 16 Dec 2010 01:54:15 +0100
From: "variadic.template" <variadic.template at googlemail.com>
Subject: Re: [cfe-dev] Reflection
To: "Gwaredd Mountain" <gwmounta at microsoft.com>
Cc: "cfe-dev at cs.uiuc.edu" <cfe-dev at cs.uiuc.edu>

Thank you for sharing your code! I will have a look into it.
Can you give some examples of your reasons why you don't want that the compiler generates such kind of data? I thought that RTTI gets only turned off by performance-reasons - i am highly interested what else reasons are out there.

> I've been messing around with something related to this recently.
>
> My requirements comes from games development where game entity details 
> need to be shared across multiple systems (the game editor, scripting 
> language, serialised over the network, load/save, etc). Property 
> systems in game engines are typically implemented using some horrible 
> macro nonsense that register types during setup but that has never 
> been particularly satisfactory. Getting the compiler to do the work 
> would be much better :)
>
> However, there are a number of reasons why I don't want the compiler 
> to actually generate any data (such as the Objective-C approach). I 
> still want to maintain tight control over the implementation and 
> determine what does and doesn't get reflected etc. This is why almost 
> all games turn off the built in RTTI and roll their own for example.
>
> I've knocked up a prototype (based on clang naturally) that looks for 
> declaration annotations (either comments or GNU annotate attribute) 
> when walking the AST and spits out the details and metadata to an XML file.
> The final step of generating some code is pretty trivial formality 
> from that point. The idea would be to use this tool as some kind of 
> pre-build step.
>
> It's only rough but if anyone is interested the code is shared here.
>
> 	http://dl.dropbox.com/u/3810428/reflector.rar
>
> Cheers
>
> Gwaredd






More information about the cfe-dev mailing list