Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: components/mus/public/cpp/window_property.h

Issue 1468803002: Switch to static_assert. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@assert1
Patch Set: win Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 // This header should be included by code that defines WindowProperties. It 10 // This header should be included by code that defines WindowProperties. It
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \ 121 #define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \
122 template EXPORT void mus::Window::SetLocalProperty( \ 122 template EXPORT void mus::Window::SetLocalProperty( \
123 const mus::WindowProperty<T>*, T); \ 123 const mus::WindowProperty<T>*, T); \
124 template EXPORT T mus::Window::GetLocalProperty( \ 124 template EXPORT T mus::Window::GetLocalProperty( \
125 const mus::WindowProperty<T>*) const; \ 125 const mus::WindowProperty<T>*) const; \
126 template EXPORT void mus::Window::ClearLocalProperty( \ 126 template EXPORT void mus::Window::ClearLocalProperty( \
127 const mus::WindowProperty<T>*); 127 const mus::WindowProperty<T>*);
128 #define DECLARE_WINDOW_PROPERTY_TYPE(T) \ 128 #define DECLARE_WINDOW_PROPERTY_TYPE(T) \
129 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T) 129 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T)
130 130
131 #define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 131 #define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
132 COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \ 132 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property_type_too_large"); \
133 namespace { \ 133 namespace { \
134 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ 134 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
135 } \ 135 } \
136 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; 136 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value;
137 137
138 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 138 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
139 COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \ 139 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property_type_too_large"); \
140 namespace { \ 140 namespace { \
141 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ 141 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
142 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; \ 142 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; \
143 } 143 }
144 144
145 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 145 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
146 namespace { \ 146 namespace { \
147 void Deallocator##NAME(int64_t p) { \ 147 void Deallocator##NAME(int64_t p) { \
148 enum { type_must_be_complete = sizeof(TYPE) }; \ 148 enum { type_must_be_complete = sizeof(TYPE) }; \
149 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \ 149 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \
150 } \ 150 } \
151 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ 151 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \
152 &Deallocator##NAME}; \ 152 &Deallocator##NAME}; \
153 } \ 153 } \
154 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value; 154 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value;
155 155
156 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 156 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698