Closed Innokentiy-Alaytsev closed 4 years ago
I'll retest it a bit later - after new failed attempt to fix the duplicate bug. But previous testing showed that it works just fine.
Trying to attach to properties for which both key and value have the same type results in duplicate assertion fail due to both properties using the same local static variables.
Is this true also on wip
? I cannot reproduce it. Can you give me a hint in this sense?
I implemented yet another horrible duplicate bug fix. I need this fix to properly test my implementation of annotations and property tuples.
I used the following reflection for test:
entt::meta<annotated_data_type>()
.type("annotated_data"_hs)
.data<&annotated_data_type::i, entt::as_alias_t>("i"_hs)
.prop (name_annotation{ std::string{"i"} })
.props (
int_value_range_annotation{-5, 5},
[](){
return std::pair{ "from_lambda"_hs, true};
},
std::pair{"int_prop"_hs, 42},
std::pair{"double_prop"_hs, 3.141592653},
"key_only"_hs,
std::tuple{1,2,3,4})
.prop (
std::tuple{
std::pair{"tup_1"_hs, 1},
& nesting_annotation,
std::pair{"tup_2"_hs, 2},
std::pair{"tup_3"_hs, 3} });
Annotations:
name_annotation
- an object of a callable type returning a property (std::pair
);int_value_range_annotation
- an object of a callable type returning a list of properties (std::tuple<std::pair>
);nesting_annotation
- an annotation returning a mixed list of properties and annotations, where one of the returned annotations returns a single property.Direct use of a list of properties (std::tuple{1,2,3,4})
is present. Another instance of passing a list of properties in the form of a tuple is also present.
All tests are green.
Trying to attach to properties for which both key and value have the same type results in duplicate assertion fail due to both properties using the same local static variables.
Is this true also on
wip
? I cannot reproduce it. Can you give me a hint in this sense?
Yes, it is on wip
. Here's how you can reproduce in:
entt::meta<properties>()
.data<properties::prop_bool>("prop_bool"_hs)
.prop(properties::prop_int, 0)
+ .prop(properties::prop_bool, 0)
.data<properties::prop_int>("prop_int"_hs)
.prop(std::make_tuple(std::make_pair(properties::prop_bool, true), std::make_pair(properties::prop_int, 0)))
Ok, wip
contains a version that shouldn't suffer anymore from this problem. Let me know if I'm wrong.
I think it's done now
The purpose of annotated meta-data is to provide better runtime-introspection abilities with less code. Annotations are just properties created with reusable function or functional object.
https://github.com/Innokentiy-Alaytsev/entt/tree/runtime-annotations
I've implemented one of the functions I think is useful. I've renamed the concept from 'decoration' to 'annotation' - I think the new word better represents the purpose. I've only implemented the function for registering meta-data without setter and getter. If you say everything is fine, I'll add implementations for annotated meta-data with setter and getter, annotated meta-type (reflect_annotated), maybe annotated meta-function (func_annotated). Also, I'll try to find a way to minimise the amount of the required code - it's very straight forward, but it may be a support burden.