Commit d927d209 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Allow property setter function to take any arg type.

Instead of forcing ArgType<T>, just generically match a signature type.
This allows classes to choose to implement e.g. by reference or value,
at the cost of possibly-more-cryptic template errors when people don't
implement a setter.

We could probably give better errors than this with some helper structs
to restrict to e.g. single-arg member functions whose arg is convertible
from ArgType, but this seems good enough for now.

Bug: none
Change-Id: I079fd9dd5cd3cb51297855d2ccabde65148c0b6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363562
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarWei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801146}
parent 0be5bd1c
...@@ -48,11 +48,12 @@ ...@@ -48,11 +48,12 @@
DISALLOW_COPY_AND_ASSIGN(METADATA_CLASS_NAME_INTERNAL(class_name)); \ DISALLOW_COPY_AND_ASSIGN(METADATA_CLASS_NAME_INTERNAL(class_name)); \
} }
#define METADATA_PROPERTY_TYPE_INTERNAL(class_name, property_type, \ #define METADATA_PROPERTY_TYPE_INTERNAL(class_name, property_type, \
property_name) \ property_name) \
views::metadata::ClassPropertyMetaData< \ views::metadata::ClassPropertyMetaData< \
class_name, property_type, &class_name::Set##property_name, \ class_name, property_type, decltype(&class_name::Set##property_name), \
decltype(std::declval<class_name>().Get##property_name()), \ &class_name::Set##property_name, \
decltype(std::declval<class_name>().Get##property_name()), \
&class_name::Get##property_name> &class_name::Get##property_name>
#define METADATA_READONLY_PROPERTY_TYPE_INTERNAL(class_name, property_type, \ #define METADATA_READONLY_PROPERTY_TYPE_INTERNAL(class_name, property_type, \
......
...@@ -49,7 +49,8 @@ class ClassPropertyReadOnlyMetaData : public MemberMetaDataBase { ...@@ -49,7 +49,8 @@ class ClassPropertyReadOnlyMetaData : public MemberMetaDataBase {
// (so it will trigger things like property changed notifications). // (so it will trigger things like property changed notifications).
template <typename TClass, template <typename TClass,
typename TValue, typename TValue,
void (TClass::*Set)(ArgType<TValue>), typename TSig,
TSig Set,
typename TRet, typename TRet,
TRet (TClass::*Get)() const> TRet (TClass::*Get)() const>
class ClassPropertyMetaData class ClassPropertyMetaData
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment