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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-private.hh

Issue 1476763003: Roll HarfBuzz to 1.1.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows line height rebaseline 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 /* 1 /*
2 * Copyright © 2007,2008,2009 Red Hat, Inc. 2 * Copyright © 2007,2008,2009 Red Hat, Inc.
3 * Copyright © 2011,2012 Google, Inc. 3 * Copyright © 2011,2012 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #endif 112 #endif
113 113
114 #if __GNUC__ >= 3 114 #if __GNUC__ >= 3
115 #define HB_FUNC __PRETTY_FUNCTION__ 115 #define HB_FUNC __PRETTY_FUNCTION__
116 #elif defined(_MSC_VER) 116 #elif defined(_MSC_VER)
117 #define HB_FUNC __FUNCSIG__ 117 #define HB_FUNC __FUNCSIG__
118 #else 118 #else
119 #define HB_FUNC __func__ 119 #define HB_FUNC __func__
120 #endif 120 #endif
121 121
122 /*
123 * Borrowed from https://bugzilla.mozilla.org/show_bug.cgi?id=1215411
124 * HB_FALLTHROUGH is an annotation to suppress compiler warnings about switch
125 * cases that fall through without a break or return statement. HB_FALLTHROUGH
126 * is only needed on cases that have code:
127 *
128 * switch (foo) {
129 * case 1: // These cases have no code. No fallthrough annotations are needed.
130 * case 2:
131 * case 3:
132 * foo = 4; // This case has code, so a fallthrough annotation is needed:
133 * HB_FALLTHROUGH;
134 * default:
135 * return foo;
136 * }
137 */
138 #if defined(__clang__) && __cplusplus >= 201103L
139 /* clang's fallthrough annotations are only available starting in C++11. */
140 # define HB_FALLTHROUGH [[clang::fallthrough]]
141 #elif defined(_MSC_VER)
142 /*
143 * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
144 * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx
145 */
146 # include <sal.h>
147 # define HB_FALLTHROUGH __fallthrough
148 #else
149 # define HB_FALLTHROUGH /* FALLTHROUGH */
150 #endif
151
122 #if defined(_WIN32) || defined(__CYGWIN__) 152 #if defined(_WIN32) || defined(__CYGWIN__)
123 /* We need Windows Vista for both Uniscribe backend and for 153 /* We need Windows Vista for both Uniscribe backend and for
124 * MemoryBarrier. We don't support compiling on Windows XP, 154 * MemoryBarrier. We don't support compiling on Windows XP,
125 * though we run on it fine. */ 155 * though we run on it fine. */
126 # if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 156 # if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
127 # undef _WIN32_WINNT 157 # undef _WIN32_WINNT
128 # endif 158 # endif
129 # ifndef _WIN32_WINNT 159 # ifndef _WIN32_WINNT
130 # define _WIN32_WINNT 0x0600 160 # define _WIN32_WINNT 0x0600
131 # endif 161 # endif
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 /* A const version, but does not detect erratically being called on pointers. */ 233 /* A const version, but does not detect erratically being called on pointers. */
204 #define ARRAY_LENGTH_CONST(__array) ((signed int) (sizeof (__array) / sizeof (__ array[0]))) 234 #define ARRAY_LENGTH_CONST(__array) ((signed int) (sizeof (__array) / sizeof (__ array[0])))
205 235
206 #define HB_STMT_START do 236 #define HB_STMT_START do
207 #define HB_STMT_END while (0) 237 #define HB_STMT_END while (0)
208 238
209 #define _ASSERT_STATIC1(_line, _cond) HB_UNUSED typedef int _static_assert_on_ line_##_line##_failed[(_cond)?1:-1] 239 #define _ASSERT_STATIC1(_line, _cond) HB_UNUSED typedef int _static_assert_on_ line_##_line##_failed[(_cond)?1:-1]
210 #define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond)) 240 #define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
211 #define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond)) 241 #define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
212 242
213 /* Note: C++ allows sizeof() of variable-lengh arrays. So, if _cond is not 243 template <unsigned int cond> class hb_assert_constant_t {};
214 * constant, it still compiles (ouch!), but at least we'll get a -Wvla warning. */ 244
215 #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * sizeof (char[(_cond) ? 1 : -1])) 245 #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * (unsigned int) sizeof (hb_assert_con stant_t<_cond>))
216 246
217 #define _PASTE1(a,b) a##b 247 #define _PASTE1(a,b) a##b
218 #define PASTE(a,b) _PASTE1(a,b) 248 #define PASTE(a,b) _PASTE1(a,b)
219 249
220 /* Lets assert int types. Saves trouble down the road. */ 250 /* Lets assert int types. Saves trouble down the road. */
221 251
222 ASSERT_STATIC (sizeof (int8_t) == 1); 252 ASSERT_STATIC (sizeof (int8_t) == 1);
223 ASSERT_STATIC (sizeof (uint8_t) == 1); 253 ASSERT_STATIC (sizeof (uint8_t) == 1);
224 ASSERT_STATIC (sizeof (int16_t) == 2); 254 ASSERT_STATIC (sizeof (int16_t) == 2);
225 ASSERT_STATIC (sizeof (uint16_t) == 2); 255 ASSERT_STATIC (sizeof (uint16_t) == 2);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); 884 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2);
855 } 885 }
856 886
857 template <typename T> static inline bool 887 template <typename T> static inline bool
858 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) 888 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3)
859 { 889 {
860 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range ( u, lo3, hi3); 890 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range ( u, lo3, hi3);
861 } 891 }
862 892
863 893
894 /* Enable bitwise ops on enums marked as flags_t */
895 /* To my surprise, looks like the function resolver is happy to silently cast
896 * one enum to another... So this doesn't provide the type-checking that I
897 * originally had in mind... :(.
898 *
899 * For MSVC warnings, see: https://github.com/behdad/harfbuzz/pull/163
900 */
901 #ifdef _MSC_VER
902 # pragma warning(disable:4200)
903 # pragma warning(disable:4800)
904 #endif
905 #define HB_MARK_AS_FLAG_T(T) \
906 extern "C++" { \
907 static inline T operator | (T l, T r) { return T ((unsigned) l | (unsi gned) r); } \
908 static inline T operator & (T l, T r) { return T ((unsigned) l & (unsi gned) r); } \
909 static inline T operator ^ (T l, T r) { return T ((unsigned) l ^ (unsi gned) r); } \
910 static inline T operator ~ (T r) { return T (~(unsigned int) r); } \
911 static inline T& operator |= (T &l, T r) { l = l | r; return l; } \
912 static inline T& operator &= (T& l, T r) { l = l & r; return l; } \
913 static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \
914 }
915
916
864 /* Useful for set-operations on small enums. 917 /* Useful for set-operations on small enums.
865 * For example, for testing "x ∈ {x1, x2, x3}" use: 918 * For example, for testing "x ∈ {x1, x2, x3}" use:
866 * (FLAG_SAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3))) 919 * (FLAG_SAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3)))
867 */ 920 */
868 #define FLAG(x) (ASSERT_STATIC_EXPR_ZERO ((x) < 32) + (1U << (x))) 921 #define FLAG(x) (ASSERT_STATIC_EXPR_ZERO ((x) < 32) + (1U << (x)))
869 #define FLAG_SAFE(x) (1U << (x)) 922 #define FLAG_SAFE(x) (1U << (x))
870 #define FLAG_UNSAFE(x) ((x) < 32 ? FLAG_SAFE(x) : 0) 923 #define FLAG_UNSAFE(x) ((x) < 32 ? FLAG_SAFE(x) : 0)
871 #define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG( x)) 924 #define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG( x))
872 925
873 926
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 hb_options (void) 997 hb_options (void)
945 { 998 {
946 if (unlikely (!_hb_options.i)) 999 if (unlikely (!_hb_options.i))
947 _hb_options_init (); 1000 _hb_options_init ();
948 1001
949 return _hb_options.opts; 1002 return _hb_options.opts;
950 } 1003 }
951 1004
952 1005
953 #endif /* HB_PRIVATE_HH */ 1006 #endif /* HB_PRIVATE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc ('k') | third_party/harfbuzz-ng/src/hb-unicode-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698