| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 #ifndef HB_INTERNAL | 89 #ifndef HB_INTERNAL |
| 90 # if !defined(__MINGW32__) && !defined(__CYGWIN__) | 90 # if !defined(__MINGW32__) && !defined(__CYGWIN__) |
| 91 # define HB_INTERNAL __attribute__((__visibility__("hidden"))) | 91 # define HB_INTERNAL __attribute__((__visibility__("hidden"))) |
| 92 # else | 92 # else |
| 93 # define HB_INTERNAL | 93 # define HB_INTERNAL |
| 94 # endif | 94 # endif |
| 95 #endif | 95 #endif |
| 96 | 96 |
| 97 #ifdef _MSC_VER | |
| 98 #undef inline | |
| 99 #define inline __inline | |
| 100 #endif | |
| 101 | |
| 102 #ifdef __STRICT_ANSI__ | |
| 103 #undef inline | |
| 104 #define inline __inline__ | |
| 105 #endif | |
| 106 | |
| 107 #if __GNUC__ >= 3 | 97 #if __GNUC__ >= 3 |
| 108 #define HB_FUNC __PRETTY_FUNCTION__ | 98 #define HB_FUNC __PRETTY_FUNCTION__ |
| 109 #elif defined(_MSC_VER) | 99 #elif defined(_MSC_VER) |
| 110 #define HB_FUNC __FUNCSIG__ | 100 #define HB_FUNC __FUNCSIG__ |
| 111 #else | 101 #else |
| 112 #define HB_FUNC __func__ | 102 #define HB_FUNC __func__ |
| 113 #endif | 103 #endif |
| 114 | 104 |
| 115 #if defined(_WIN32) || defined(__CYGWIN__) | 105 #if defined(_WIN32) || defined(__CYGWIN__) |
| 116 /* We need Windows Vista for both Uniscribe backend and for | 106 /* We need Windows Vista for both Uniscribe backend and for |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 static inline bool | 566 static inline bool |
| 577 _hb_debug (unsigned int level, | 567 _hb_debug (unsigned int level, |
| 578 unsigned int max_level) | 568 unsigned int max_level) |
| 579 { | 569 { |
| 580 return level < max_level; | 570 return level < max_level; |
| 581 } | 571 } |
| 582 | 572 |
| 583 #define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT)) | 573 #define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT)) |
| 584 #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0)) | 574 #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0)) |
| 585 | 575 |
| 576 static inline void |
| 577 _hb_print_func (const char *func) |
| 578 { |
| 579 if (func) |
| 580 { |
| 581 unsigned int func_len = strlen (func); |
| 582 /* Skip "static" */ |
| 583 if (0 == strncmp (func, "static ", 7)) |
| 584 func += 7; |
| 585 /* Skip "typename" */ |
| 586 if (0 == strncmp (func, "typename ", 9)) |
| 587 func += 9; |
| 588 /* Skip return type */ |
| 589 const char *space = strchr (func, ' '); |
| 590 if (space) |
| 591 func = space + 1; |
| 592 /* Skip parameter list */ |
| 593 const char *paren = strchr (func, '('); |
| 594 if (paren) |
| 595 func_len = paren - func; |
| 596 fprintf (stderr, "%.*s", func_len, func); |
| 597 } |
| 598 } |
| 599 |
| 586 template <int max_level> static inline void | 600 template <int max_level> static inline void |
| 587 _hb_debug_msg_va (const char *what, | 601 _hb_debug_msg_va (const char *what, |
| 588 const void *obj, | 602 const void *obj, |
| 589 const char *func, | 603 const char *func, |
| 590 bool indented, | 604 bool indented, |
| 591 unsigned int level, | 605 unsigned int level, |
| 592 int level_dir, | 606 int level_dir, |
| 593 const char *message, | 607 const char *message, |
| 594 va_list ap) HB_PRINTF_FUNC(7, 0); | 608 va_list ap) HB_PRINTF_FUNC(7, 0); |
| 595 template <int max_level> static inline void | 609 template <int max_level> static inline void |
| (...skipping 25 matching lines...) Expand all Loading... |
| 621 #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ | 635 #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ |
| 622 #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ | 636 #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ |
| 623 static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
VBAR VBAR VBAR VBAR; | 637 static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
VBAR VBAR VBAR VBAR; |
| 624 fprintf (stderr, "%2u %s" VRBAR "%s", | 638 fprintf (stderr, "%2u %s" VRBAR "%s", |
| 625 level, | 639 level, |
| 626 bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsi
gned int) (sizeof (VBAR) - 1) * level), | 640 bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsi
gned int) (sizeof (VBAR) - 1) * level), |
| 627 level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR); | 641 level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR); |
| 628 } else | 642 } else |
| 629 fprintf (stderr, " " VRBAR LBAR); | 643 fprintf (stderr, " " VRBAR LBAR); |
| 630 | 644 |
| 631 if (func) | 645 _hb_print_func (func); |
| 632 { | |
| 633 unsigned int func_len = strlen (func); | |
| 634 #ifndef HB_DEBUG_VERBOSE | |
| 635 /* Skip "typename" */ | |
| 636 if (0 == strncmp (func, "typename ", 9)) | |
| 637 func += 9; | |
| 638 /* Skip return type */ | |
| 639 const char *space = strchr (func, ' '); | |
| 640 if (space) | |
| 641 func = space + 1; | |
| 642 /* Skip parameter list */ | |
| 643 const char *paren = strchr (func, '('); | |
| 644 if (paren) | |
| 645 func_len = paren - func; | |
| 646 #endif | |
| 647 fprintf (stderr, "%.*s: ", func_len, func); | |
| 648 } | |
| 649 | 646 |
| 650 if (message) | 647 if (message) |
| 648 { |
| 649 fprintf (stderr, ": "); |
| 651 vfprintf (stderr, message, ap); | 650 vfprintf (stderr, message, ap); |
| 651 } |
| 652 | 652 |
| 653 fprintf (stderr, "\n"); | 653 fprintf (stderr, "\n"); |
| 654 } | 654 } |
| 655 template <> inline void | 655 template <> inline void |
| 656 _hb_debug_msg_va<0> (const char *what HB_UNUSED, | 656 _hb_debug_msg_va<0> (const char *what HB_UNUSED, |
| 657 const void *obj HB_UNUSED, | 657 const void *obj HB_UNUSED, |
| 658 const char *func HB_UNUSED, | 658 const char *func HB_UNUSED, |
| 659 bool indented HB_UNUSED, | 659 bool indented HB_UNUSED, |
| 660 unsigned int level HB_UNUSED, | 660 unsigned int level HB_UNUSED, |
| 661 int level_dir HB_UNUSED, | 661 int level_dir HB_UNUSED, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 template <> class hb_assert_unsigned_t<unsigned short> {}; | 813 template <> class hb_assert_unsigned_t<unsigned short> {}; |
| 814 template <> class hb_assert_unsigned_t<unsigned int> {}; | 814 template <> class hb_assert_unsigned_t<unsigned int> {}; |
| 815 template <> class hb_assert_unsigned_t<unsigned long> {}; | 815 template <> class hb_assert_unsigned_t<unsigned long> {}; |
| 816 | 816 |
| 817 template <typename T> static inline bool | 817 template <typename T> static inline bool |
| 818 hb_in_range (T u, T lo, T hi) | 818 hb_in_range (T u, T lo, T hi) |
| 819 { | 819 { |
| 820 /* The sizeof() is here to force template instantiation. | 820 /* The sizeof() is here to force template instantiation. |
| 821 * I'm sure there are better ways to do this but can't think of | 821 * I'm sure there are better ways to do this but can't think of |
| 822 * one right now. Declaring a variable won't work as HB_UNUSED | 822 * one right now. Declaring a variable won't work as HB_UNUSED |
| 823 * is unsable on some platforms and unused types are less likely | 823 * is unusable on some platforms and unused types are less likely |
| 824 * to generate a warning than unused variables. */ | 824 * to generate a warning than unused variables. */ |
| 825 ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0); | 825 ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0); |
| 826 | 826 |
| 827 /* The casts below are important as if T is smaller than int, | 827 /* The casts below are important as if T is smaller than int, |
| 828 * the subtract results will become a signed int! */ | 828 * the subtract results will become a signed int! */ |
| 829 return (T)(u - lo) <= (T)(hi - lo); | 829 return (T)(u - lo) <= (T)(hi - lo); |
| 830 } | 830 } |
| 831 | 831 |
| 832 template <typename T> static inline bool | 832 template <typename T> static inline bool |
| 833 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) | 833 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 hb_options (void) | 931 hb_options (void) |
| 932 { | 932 { |
| 933 if (unlikely (!_hb_options.i)) | 933 if (unlikely (!_hb_options.i)) |
| 934 _hb_options_init (); | 934 _hb_options_init (); |
| 935 | 935 |
| 936 return _hb_options.opts; | 936 return _hb_options.opts; |
| 937 } | 937 } |
| 938 | 938 |
| 939 | 939 |
| 940 #endif /* HB_PRIVATE_HH */ | 940 #endif /* HB_PRIVATE_HH */ |
| OLD | NEW |