зеркало из https://github.com/mozilla/gecko-dev.git
Bug 826144 - Add MOZ_UTF16_HELPER() intermediary macro to handle UTF-16 stringification and concatenation correctly. r=waldo
--HG-- extra : rebase_source : 4c68df10e6e59af34db1e325232d4671492cc72f
This commit is contained in:
Родитель
a70aae143a
Коммит
1e64862110
|
@ -28,17 +28,27 @@
|
|||
* expressions (and pass char16_t pointers to Windows APIs). We #define our
|
||||
* char16_t as a macro to override yval.h's typedef of the same name.
|
||||
*/
|
||||
# define MOZ_UTF16(s) L##s
|
||||
# define MOZ_UTF16_HELPER(s) L##s
|
||||
# include <yvals.h>
|
||||
# define char16_t wchar_t
|
||||
#elif defined(__cplusplus) && \
|
||||
(__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
|
||||
/* C++11 has a builtin char16_t type. */
|
||||
# define MOZ_UTF16(s) u##s
|
||||
# define MOZ_UTF16_HELPER(s) u##s
|
||||
#else
|
||||
# error "Char16.h requires C++11 (or something like it) for UTF-16 support."
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macro arguments used in concatenation or stringification won't be expanded.
|
||||
* Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to
|
||||
* expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper
|
||||
* macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro
|
||||
* argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the
|
||||
* CPP manual for a more accurate and precise explanation.
|
||||
*/
|
||||
#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
|
||||
|
||||
MOZ_STATIC_ASSERT(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
|
||||
MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
|
||||
MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
|
||||
|
|
Загрузка…
Ссылка в новой задаче