diff options
author | Hal Canary <halcanary@google.com> | 2018-06-12 12:37:31 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-12 18:39:33 +0000 |
commit | 22be4c4801f957f2820b9001b02b892f4b87a157 (patch) | |
tree | bcbf77f46a726d9718dcd36f59d2bffcbe809bc4 /include | |
parent | 8ea971bfefb687a813f5b7cb62137b5d7b742dee (diff) |
SkMacros split from SkTypes.h
Change-Id: I383719ee181c6925ebf62ffc70e1c0f12ee7cf84
Reviewed-on: https://skia-review.googlesource.com/134326
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkCanvas.h | 1 | ||||
-rw-r--r-- | include/core/SkTime.h | 1 | ||||
-rw-r--r-- | include/core/SkTypes.h | 43 | ||||
-rw-r--r-- | include/private/SkMacros.h | 53 | ||||
-rw-r--r-- | include/private/SkMutex.h | 1 |
5 files changed, 56 insertions, 43 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index d3b2e5890e..f42c5a3db9 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -18,6 +18,7 @@ #ifndef SkCanvas_DEFINED #define SkCanvas_DEFINED +#include "../private/SkMacros.h" #include "SkBlendMode.h" #include "SkClipOp.h" #include "SkDeque.h" diff --git a/include/core/SkTime.h b/include/core/SkTime.h index e9a894812b..8a40c21313 100644 --- a/include/core/SkTime.h +++ b/include/core/SkTime.h @@ -10,6 +10,7 @@ #ifndef SkTime_DEFINED #define SkTime_DEFINED +#include "../private/SkMacros.h" #include "SkTypes.h" class SkString; diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index db694e9f8b..65867509e5 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -82,49 +82,6 @@ SK_API extern void sk_abort_no_print(void); // depend on SkString forward declaration below. Remove this once dependencies are fixed. class SkString; -/* - * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab - * - * SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly - * - */ -#define SK_MACRO_CONCAT(X, Y) SK_MACRO_CONCAT_IMPL_PRIV(X, Y) -#define SK_MACRO_CONCAT_IMPL_PRIV(X, Y) X ## Y - -/* - * Usage: SK_MACRO_APPEND_LINE(foo) to make foo123, where 123 is the current - * line number. Easy way to construct - * unique names for local functions or - * variables. - */ -#define SK_MACRO_APPEND_LINE(name) SK_MACRO_CONCAT(name, __LINE__) - -/** - * For some classes, it's almost always an error to instantiate one without a name, e.g. - * { - * SkAutoMutexAcquire(&mutex); - * <some code> - * } - * In this case, the writer meant to hold mutex while the rest of the code in the block runs, - * but instead the mutex is acquired and then immediately released. The correct usage is - * { - * SkAutoMutexAcquire lock(&mutex); - * <some code> - * } - * - * To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR - * like this: - * class classname { - * <your class> - * }; - * #define classname(...) SK_REQUIRE_LOCAL_VAR(classname) - * - * This won't work with templates, and you must inline the class' constructors and destructors. - * Take a look at SkAutoFree and SkAutoMalloc in this file for examples. - */ -#define SK_REQUIRE_LOCAL_VAR(classname) \ - static_assert(false, "missing name for " #classname) - /////////////////////////////////////////////////////////////////////// /** diff --git a/include/private/SkMacros.h b/include/private/SkMacros.h new file mode 100644 index 0000000000..3d79d52230 --- /dev/null +++ b/include/private/SkMacros.h @@ -0,0 +1,53 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef SkMacros_DEFINED +#define SkMacros_DEFINED + +/* + * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab + * + * SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly + * + */ +#define SK_MACRO_CONCAT(X, Y) SK_MACRO_CONCAT_IMPL_PRIV(X, Y) +#define SK_MACRO_CONCAT_IMPL_PRIV(X, Y) X ## Y + +/* + * Usage: SK_MACRO_APPEND_LINE(foo) to make foo123, where 123 is the current + * line number. Easy way to construct + * unique names for local functions or + * variables. + */ +#define SK_MACRO_APPEND_LINE(name) SK_MACRO_CONCAT(name, __LINE__) + +/** + * For some classes, it's almost always an error to instantiate one without a name, e.g. + * { + * SkAutoMutexAcquire(&mutex); + * <some code> + * } + * In this case, the writer meant to hold mutex while the rest of the code in the block runs, + * but instead the mutex is acquired and then immediately released. The correct usage is + * { + * SkAutoMutexAcquire lock(&mutex); + * <some code> + * } + * + * To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR + * like this: + * class classname { + * <your class> + * }; + * #define classname(...) SK_REQUIRE_LOCAL_VAR(classname) + * + * This won't work with templates, and you must inline the class' constructors and destructors. + * Take a look at SkAutoFree and SkAutoMalloc in this file for examples. + */ +#define SK_REQUIRE_LOCAL_VAR(classname) \ + static_assert(false, "missing name for " #classname) + +#endif // SkMacros_DEFINED diff --git a/include/private/SkMutex.h b/include/private/SkMutex.h index 7cfdb1132c..9af23adadf 100644 --- a/include/private/SkMutex.h +++ b/include/private/SkMutex.h @@ -8,6 +8,7 @@ #ifndef SkMutex_DEFINED #define SkMutex_DEFINED +#include "../private/SkMacros.h" #include "../private/SkSemaphore.h" #include "../private/SkThreadID.h" #include "SkTypes.h" |