Date: Wed, 31 Jul 2019 09:32:30 -0400
> On Jul 31, 2019, at 4:07 AM, Michael Nicolella via SG7 <sg7_at_[hidden]> wrote:
>
> Hi all,
>
> Starting to browse over the reflection proposals but I didn't notice anything talking about custom user attributes on members?
>
> In gamedev, we often define structures that will be reflected to a GUI for game designers and artists to use. We use this to inform the users and the tooling. Below is a trivial example of how we might want to use custom metadata to mark up a C++ structure.
>
> Are there any proposals related to reflection that provide a way to have user defined attributes like this, and tie it in to reflection so that this metadata can be collected?
I’m not aware of a formal proposal yet. That said, some of us are looking into something like it. However, because attributes are generally meant to be ignorable, we’re looking at introducing a slight syntactic variation (that would not be ignorable since it must tie to reflection). E.g.:
[[+tag(x, y, z)]] struct S { … };
Daveed
>
> struct Description
> {
> Description(const char* text):text(text){}
> const char* text;
> };
>
> struct IntRange
> {
> IntRange(int min, int max):min(min),max(max){}
> int min;
> int max;
> };
>
> [[Description("describes a rectangle")]]
> struct Rect
> {
> [[IntRange(0, 100)]]
> [[Description("specifies the rect width")]]
> int width;
>
> [[IntRange(0, 100)]]
> [[Description("specifies the rect height")]]
> int height;
> };
> --
> SG7 mailing list
> SG7_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/sg7
>
> Hi all,
>
> Starting to browse over the reflection proposals but I didn't notice anything talking about custom user attributes on members?
>
> In gamedev, we often define structures that will be reflected to a GUI for game designers and artists to use. We use this to inform the users and the tooling. Below is a trivial example of how we might want to use custom metadata to mark up a C++ structure.
>
> Are there any proposals related to reflection that provide a way to have user defined attributes like this, and tie it in to reflection so that this metadata can be collected?
I’m not aware of a formal proposal yet. That said, some of us are looking into something like it. However, because attributes are generally meant to be ignorable, we’re looking at introducing a slight syntactic variation (that would not be ignorable since it must tie to reflection). E.g.:
[[+tag(x, y, z)]] struct S { … };
Daveed
>
> struct Description
> {
> Description(const char* text):text(text){}
> const char* text;
> };
>
> struct IntRange
> {
> IntRange(int min, int max):min(min),max(max){}
> int min;
> int max;
> };
>
> [[Description("describes a rectangle")]]
> struct Rect
> {
> [[IntRange(0, 100)]]
> [[Description("specifies the rect width")]]
> int width;
>
> [[IntRange(0, 100)]]
> [[Description("specifies the rect height")]]
> int height;
> };
> --
> SG7 mailing list
> SG7_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/sg7
Received on 2019-07-31 08:34:31