| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_PUBLIC_SYSTEM_MACROS_H_ | 5 #ifndef MOJO_PUBLIC_SYSTEM_MACROS_H_ |
| 6 #define MOJO_PUBLIC_SYSTEM_MACROS_H_ | 6 #define MOJO_PUBLIC_SYSTEM_MACROS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 |
| 8 #ifdef __cplusplus | 10 #ifdef __cplusplus |
| 9 | 11 |
| 10 // Annotate a virtual method indicating it must be overriding a virtual | 12 // Annotate a virtual method indicating it must be overriding a virtual method |
| 11 // method in the parent class. | 13 // in the parent class. |
| 12 // Use like: | 14 // Use like: |
| 13 // virtual void foo() OVERRIDE; | 15 // virtual void foo() OVERRIDE; |
| 14 #if defined(_MSC_VER) || defined(__clang__) | 16 #if defined(_MSC_VER) || defined(__clang__) |
| 15 #define MOJO_OVERRIDE override | 17 #define MOJO_OVERRIDE override |
| 16 #else | 18 #else |
| 17 #define MOJO_OVERRIDE | 19 #define MOJO_OVERRIDE |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 20 // A macro to disallow the copy constructor and operator= functions | 22 // A macro to disallow the copy constructor and operator= functions. |
| 21 // This should be used in the private: declarations for a class | 23 // This should be used in the private: declarations for a class. |
| 22 #define MOJO_DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 24 #define MOJO_DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 23 TypeName(const TypeName&); \ | 25 TypeName(const TypeName&); \ |
| 24 void operator=(const TypeName&) | 26 void operator=(const TypeName&) |
| 25 | 27 |
| 26 // Used to assert things at compile time. | 28 // Used to assert things at compile time. |
| 27 namespace mojo { template <bool> struct CompileAssert {}; } | 29 namespace mojo { template <bool> struct CompileAssert {}; } |
| 28 #define MOJO_COMPILE_ASSERT(expr, msg) \ | 30 #define MOJO_COMPILE_ASSERT(expr, msg) \ |
| 29 typedef ::mojo::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] | 31 typedef ::mojo::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] |
| 30 | 32 |
| 33 // Use to calculate the number of elements in an array. |
| 34 // (See |arraysize()| in Chromium's base/basictypes.h for more details.) |
| 35 namespace mojo { |
| 36 template <typename T, size_t N> |
| 37 char (&ArraySizeHelper(T (&array)[N]))[N]; |
| 38 #if !defined(_MSC_VER) |
| 39 template <typename T, size_t N> |
| 40 char (&ArraySizeHelper(const T (&array)[N]))[N]; |
| 41 #endif |
| 42 } // namespace mojo |
| 43 #define MOJO_ARRAYSIZE(array) (sizeof(::mojo::ArraySizeHelper(array))) |
| 44 |
| 31 #endif // __cplusplus | 45 #endif // __cplusplus |
| 32 | 46 |
| 33 #endif // MOJO_PUBLIC_SYSTEM_MACROS_H_ | 47 #endif // MOJO_PUBLIC_SYSTEM_MACROS_H_ |
| OLD | NEW |