Re: (no subject)

"Jarkko Lempiainen [Profoundic]" <[email protected]> Thu, 17 Jun 2010 11:49:27 +0300
Newsgroups gmane.games.devel.sweng
Organization Profoundic Technologies, Inc.
Message-ID <000d01cb0df9$ffa91540$fefb3fc0$@com>
Duh, well I’ll try another smtp & plain text formatting. Hope this works better.

The example I posted was just a simple use case. You can list all the variables separately as well, in which case it has pretty much the same syntax as your MEMBER() macro:

struct my_struct
{ PFC_MONO(my_struct) {PFC_VAR(a); PFC_VAR(b); PFC_VAR(b);}
  int a, b, c;
};

It's just more convenient to use PFC_VAR#() to list multiple variables with the same annotation, that’s something I do frequently. There are also different macros for convenience for different common annotations like PFC_MVAR() which I use often to declare editable variables, or PFC_MVAR_CALL() which defines editable variables with a callback upon edit. Because the macro expands to a function call to a property enumerator interface, you could quite easily add other custom annotations as well with syntax like:

struct my_struct
{ PFC_MONO(my_struct)
  {
    PFC_MVAR(a).desc("Car velocity").color(0x123456);
    PFC_MVAR_MCALL(b, foobar());
    PFC_VAR(c);
  }
  void foobar() {/*do stuff after editing b*/}
  int a, b, c;
};

But it would be nicer to have something like:
struct my_struct
{
  int a {serialized, editable, desc("Car velocity"), color(0x123456)};
  int b {serialized, editable, call(foobar())};
  int c, d, e {serialized};
  int f; // non-reflected variable
};


Cheers, Jarkko


From: [email protected] [mailto:[email protected]] On Behalf Of Jon Watte
Sent: Thursday, June 17, 2010 1:13 AM
To: [email protected]
Subject: Re: [Sweng-Gamedev] (no subject)


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