OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), \ |
| 133 "Property type must fit in 64 bits"); \ |
133 namespace { \ | 134 namespace { \ |
134 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ | 135 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ |
135 } \ | 136 } \ |
136 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; | 137 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; |
137 | 138 |
138 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ | 139 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ |
139 COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \ | 140 static_assert(sizeof(TYPE) <= sizeof(int64_t), \ |
| 141 "Property type must fit in 64 bits"); \ |
140 namespace { \ | 142 namespace { \ |
141 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ | 143 const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ |
142 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; \ | 144 const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; \ |
143 } | 145 } |
144 | 146 |
145 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ | 147 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ |
146 namespace { \ | 148 namespace { \ |
147 void Deallocator##NAME(int64_t p) { \ | 149 void Deallocator##NAME(int64_t p) { \ |
148 enum { type_must_be_complete = sizeof(TYPE) }; \ | 150 enum { type_must_be_complete = sizeof(TYPE) }; \ |
149 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \ | 151 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \ |
150 } \ | 152 } \ |
151 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ | 153 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ |
152 &Deallocator##NAME}; \ | 154 &Deallocator##NAME}; \ |
153 } \ | 155 } \ |
154 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value; | 156 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value; |
155 | 157 |
156 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ | 158 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ |
OLD | NEW |