Re: c++ reflection (was (no subject))

Peter Thierolf <[email protected]> Thu, 17 Jun 2010 09:36:30 +0200
Newsgroups gmane.games.devel.sweng
Message-ID <[email protected]>
Have you thought about declaring your reflectable structures outside of 
c++, then letting your build process create the c++ structure for you as 
well as any meta-information you like to have in the runtime ?

I'm currently working on such a system where we define a schema for data 
that allows us to automatically create the header files for c++, but as 
well use a generic editor that understands the schema to edit files, 
plus we can then transform the files into the requirements of different 
platforms, think endianness and alignment and such.

If you are on top of your build process it is quite simple to get this 
into c++ or many other languages whilst at the same time you stay 
completely portable and compiler agnostic - and can use it outside of 
your runtime, too.

Cheers,

Peter

Am 17.06.2010 00:12, schrieb Jon Watte:
>
> Mail formatting still all messed up :-(
>
> Anyway, the example you had (PFC_MONO()) doesn't actually add all the 
> annotations you want for editing and serialization in addition to the 
> general reflection information.
>
> You can get rid of the ellipsis requirement by doing something like:
>
> #define MEMBERS(Type, x) \
>   typedef mytype Type; \
>   inline static Member *GetMembers() { \
>     static Member<mytype>[] members = { \
>       x \
>     }; \
>     return x; \
>   }
>
> #define MEMBER(x, desc) Member<mytype>(&mytype::x, #x, desc),
>
> Use it like so:
>
> struct MyStruct {
>   int x;
>   float b;
>   MEMBERS(MyStruct,
>     MEMBER(x, "Some integer value")
>     MEMBER(b, "The amount of float-ness"))
> };
>
> Note that the comma lives in the MEMBER() macro, and the members are 
> just listed without comma within the MEMBERS() macro. The MEMBER() 
> macro should take the union of all information you need about the 
> member (editor information, networking, etc).
>
> Sincerely,
>
> jw
>
> --
> Americans might object: there is no way we would sacrifice our living 
> standards for the benefit of people in the rest of the world. 
> Nevertheless, whether we get there willingly or not, we shall soon 
> have lower consumption rates, because our present rates are 
> unsustainable.
>
>

_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com