| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
| 3 * Copyright © 2012 Google, Inc. | 3 * Copyright © 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 { | 643 { |
| 644 TRACE_SANITIZE (this); | 644 TRACE_SANITIZE (this); |
| 645 return_trace (likely (c->check_struct (this))); | 645 return_trace (likely (c->check_struct (this))); |
| 646 } | 646 } |
| 647 protected: | 647 protected: |
| 648 BEInt<Type, Size> v; | 648 BEInt<Type, Size> v; |
| 649 public: | 649 public: |
| 650 DEFINE_SIZE_STATIC (Size); | 650 DEFINE_SIZE_STATIC (Size); |
| 651 }; | 651 }; |
| 652 | 652 |
| 653 typedef IntType<int8_t , 1> CHAR; /* 8-bit signed integer. */ |
| 653 typedef IntType<uint8_t , 1> BYTE; /* 8-bit unsigned integer. */ | 654 typedef IntType<uint8_t , 1> BYTE; /* 8-bit unsigned integer. */ |
| 654 typedef IntType<uint16_t, 2> USHORT; /* 16-bit unsigned integer. */ | 655 typedef IntType<uint16_t, 2> USHORT; /* 16-bit unsigned integer. */ |
| 655 typedef IntType<int16_t, 2> SHORT; /* 16-bit signed integer. */ | 656 typedef IntType<int16_t, 2> SHORT; /* 16-bit signed integer. */ |
| 656 typedef IntType<uint32_t, 4> ULONG; /* 32-bit unsigned integer. */ | 657 typedef IntType<uint32_t, 4> ULONG; /* 32-bit unsigned integer. */ |
| 657 typedef IntType<int32_t, 4> LONG; /* 32-bit signed integer. */ | 658 typedef IntType<int32_t, 4> LONG; /* 32-bit signed integer. */ |
| 658 typedef IntType<uint32_t, 3> UINT24; /* 24-bit unsigned integer. */ | 659 typedef IntType<uint32_t, 3> UINT24; /* 24-bit unsigned integer. */ |
| 659 | 660 |
| 660 /* 16-bit signed integer (SHORT) that describes a quantity in FUnits. */ | 661 /* 16-bit signed integer (SHORT) that describes a quantity in FUnits. */ |
| 661 typedef SHORT FWORD; | 662 typedef SHORT FWORD; |
| 662 | 663 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ | 799 this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ |
| 799 return *t; | 800 return *t; |
| 800 } | 801 } |
| 801 | 802 |
| 802 inline bool sanitize (hb_sanitize_context_t *c, const void *base) const | 803 inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 803 { | 804 { |
| 804 TRACE_SANITIZE (this); | 805 TRACE_SANITIZE (this); |
| 805 if (unlikely (!c->check_struct (this))) return_trace (false); | 806 if (unlikely (!c->check_struct (this))) return_trace (false); |
| 806 unsigned int offset = *this; | 807 unsigned int offset = *this; |
| 807 if (unlikely (!offset)) return_trace (true); | 808 if (unlikely (!offset)) return_trace (true); |
| 809 if (unlikely (!c->check_range (base, offset))) return_trace (false); |
| 808 const Type &obj = StructAtOffset<Type> (base, offset); | 810 const Type &obj = StructAtOffset<Type> (base, offset); |
| 809 return_trace (likely (obj.sanitize (c)) || neuter (c)); | 811 return_trace (likely (obj.sanitize (c)) || neuter (c)); |
| 810 } | 812 } |
| 811 template <typename T> | 813 template <typename T> |
| 812 inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data)
const | 814 inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data)
const |
| 813 { | 815 { |
| 814 TRACE_SANITIZE (this); | 816 TRACE_SANITIZE (this); |
| 815 if (unlikely (!c->check_struct (this))) return_trace (false); | 817 if (unlikely (!c->check_struct (this))) return_trace (false); |
| 816 unsigned int offset = *this; | 818 unsigned int offset = *this; |
| 817 if (unlikely (!offset)) return_trace (true); | 819 if (unlikely (!offset)) return_trace (true); |
| 820 if (unlikely (!c->check_range (base, offset))) return_trace (false); |
| 818 const Type &obj = StructAtOffset<Type> (base, offset); | 821 const Type &obj = StructAtOffset<Type> (base, offset); |
| 819 return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); | 822 return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); |
| 820 } | 823 } |
| 821 | 824 |
| 822 /* Set the offset to Null */ | 825 /* Set the offset to Null */ |
| 823 inline bool neuter (hb_sanitize_context_t *c) const { | 826 inline bool neuter (hb_sanitize_context_t *c) const { |
| 824 return c->try_set (this, 0); | 827 return c->try_set (this, 0); |
| 825 } | 828 } |
| 826 DEFINE_SIZE_STATIC (sizeof(OffsetType)); | 829 DEFINE_SIZE_STATIC (sizeof(OffsetType)); |
| 827 }; | 830 }; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1057 } |
| 1055 return -1; | 1058 return -1; |
| 1056 } | 1059 } |
| 1057 }; | 1060 }; |
| 1058 | 1061 |
| 1059 | 1062 |
| 1060 } /* namespace OT */ | 1063 } /* namespace OT */ |
| 1061 | 1064 |
| 1062 | 1065 |
| 1063 #endif /* HB_OPEN_TYPE_PRIVATE_HH */ | 1066 #endif /* HB_OPEN_TYPE_PRIVATE_HH */ |
| OLD | NEW |