-
Notifications
You must be signed in to change notification settings - Fork 93
Add base color error msgs #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
89017a8
00d33c5
9f4dd41
22685b5
f756531
877ed74
8053cf8
a6939b3
02be38b
60d2a68
8e89135
b05e431
ee1b44e
0f0f6d2
fa5fc51
2e64a61
848ce5e
c87e436
df0155c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,21 @@ | |
|
|
||
| #include "blade_style.h" | ||
|
|
||
| template<class BASE, class L1> class Compose; // forward-declare Layers node | ||
|
|
||
| namespace style_base_check_detail { | ||
| template<class T> struct TopBase { using type = T; }; | ||
| template<class B, class L> struct TopBase<Compose<B,L>> : TopBase<B> {}; | ||
| template<class STYLE> | ||
| inline void AssertLayersBaseOpaque() { | ||
| using _TopBaseT = typename TopBase<STYLE>::type; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this, we can just check if STYLE is transparent.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that, but it doesn’t correctly catch the case where a Layers<> starts with a transparent color because by the time the check runs, it already combined with the next layer, so we get the Layers error instead of the intended “Style must be solid color, not transparent” error.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would only happen if you have a transparent base and a solid layer somewhere after, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say yes. I was testing using But you've conditioned me to cover all the what-ifs.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there are two errors in the code, I don't think we should be particularly picky about which one shows up. |
||
| using _TopBaseCol = decltype(std::declval<_TopBaseT&>().getColor(0)); | ||
| static_assert(color_details::IsOpaqueColor<_TopBaseCol>::value, | ||
| "\n\n" | ||
| "*** StylePtr<> error: Style must be a solid color, not transparent.\n"); | ||
| } | ||
| } | ||
|
|
||
| // Usage: StylePtr<BLADE> | ||
| // BLADE: COLOR | ||
| // return value: suitable for preset array | ||
|
|
@@ -133,14 +148,15 @@ class ChargingStyle : public Style<T> { | |
| // Get a pointer to class. | ||
| template<class STYLE> | ||
| StyleAllocator StylePtr() { | ||
| style_base_check_detail::AssertLayersBaseOpaque<STYLE>(); | ||
| static StyleFactoryImpl<Style<STYLE> > factory; | ||
| return &factory; | ||
| }; | ||
| } | ||
|
|
||
| class StyleFactoryWithDefault : public StyleFactory { | ||
| public: | ||
| StyleFactoryWithDefault(StyleFactory* allocator, | ||
| const char* default_arguments) : | ||
| const char* default_arguments) : | ||
| allocator_(allocator), default_arguments_(default_arguments) { | ||
| } | ||
| BladeStyle* make() override { | ||
|
|
@@ -164,6 +180,7 @@ StyleAllocator StylePtr(const char* default_arguments) { | |
| // that you can't turn it on/off, and the battery low warning is disabled. | ||
| template<class STYLE> | ||
| StyleAllocator ChargingStylePtr() { | ||
| style_base_check_detail::AssertLayersBaseOpaque<STYLE>(); | ||
| static StyleFactoryImpl<ChargingStyle<STYLE> > factory; | ||
| return &factory; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.