Commit Graph

249 Commits

Author SHA1 Message Date
Behdad Esfahbod 7a2eda7817 Move code around 2021-03-29 17:49:12 -06:00
Behdad Esfahbod bcb57dccaa [sanitize] Add short-circuit to ArrayOfM1
Like the sibling ArrayOf types.
2021-03-29 17:49:08 -06:00
Garret Rieger b14475d2ae [subset] further changes to serializer error handling.
- Rename enum type and enum members.
- in_errors() now returns true for any error having been set. hb-subset now looks for offset overflow only errors to divert to repacker.
- Added INT_OVERFLOW and ARRAY_OVERFLOW enum values.
2021-03-18 10:51:26 -07:00
Garret Rieger 73ed59f7a6 [subset] store errors in the serializer as a flag set.
Make check_assign/check_equal specify the type of error to set.
2021-03-17 15:58:34 -07:00
Behdad Esfahbod 486da35cc0 m Add comments to IntType cast out operator
Okay, bots seem to be happy. Merging.
2021-02-23 13:58:35 -07:00
Behdad Esfahbod d6bd00a488 Revert back IntType out cast to signed/unsigned
Previous commit didn't fix the bots. Putting it back now that I
understand why I initially did the "Wide" casts.  But only doing
it for out-cast this time.  This causes "narrowing" warnings
whenever we are converting signed/unsigned to smaller HBUINT16
etc.  But those are valuable warnings.  We should address those
separately instead of ignoring.

Maybe we should start using uint16_t more liberally in the
internal subsetter function signatures then.
2021-02-22 22:42:50 -07:00
Behdad Esfahbod 0983601399 Add back wider cast to IntType
My local clang12 is fine, but many bots are not:

../src/hb-ot-cff1-table.hh: In instantiation of ‘bool CFF::Charset1_2<TYPE>::sanitize(hb_sanitize_context_t*, unsigned int) const [with TYPE = OT::IntType<unsigned char>]’:
../src/hb-ot-cff1-table.hh:554:13:   required from here
../src/hb-ot-cff1-table.hh:377:60: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1)))
                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Enabling the extra cast operator mentioned in previous commit to see if
that fixes this case.

Again, I'd be happy to say "use 1u instead of 1" if this was universally
erred on.  But since some compilers happily compile this while others
err, it would be a huge headache. Let's see...

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:33:17 -07:00
Behdad Esfahbod 567cedcc5f Narrow down cast operators on IntType
Say for USHORT, we were implementing casts from and to unsigned.
With this change, we cast from and to uint16_t only.  This allows
compiler more opportunities to catch possible narrowing issues in
the code.

It needed a couple of fixes in the codebase though, because
previously, if a USHORT was participating in arithmetic with signed
numbers, eg. "u + 1", the result would have been unsigned.  With
this change, it would be signed.  The correct fix is to update the
code to read "u + 1u".

That said, I think about conditionally adding back the cast
out to signed/unsigned, to facilitate better type deduction.
But I couldn't think of a real situation where that would help
with anything.  So I didn't add.  Here's what it was:

  template <typename Type2 = hb_conditional<hb_is_signed (Type), signed, unsigned>,
           hb_enable_if (sizeof (Type) < sizeof (Type2))>
  operator hb_type_identity_t<Type2> () const { return v; }

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:32:42 -07:00
Behdad Esfahbod cc16b26ef4 [constexpr] IntType
See https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 21:59:56 -07:00
Behdad Esfahbod 8b2f9adf29 m Simplify Tag operator char* 2021-02-22 17:42:24 -07:00
Behdad Esfahbod e5b7bc424d m Add default value to BEInt<> Size template parameter 2021-02-20 15:14:15 -07:00
Behdad Esfahbod 98374cebe1 Conditionalize IntType::cmp() so it never fails to compile
Useful with lfind() since that calls hb_equal() which SFINAEs which
cmp() to use.
2021-02-09 18:48:05 -07:00
Behdad Esfahbod 25c0a792e3 Remove unused+wrong UnsizedArrayOf<> operators
Said compiler is wrong to err since they are unused. But yeah, they
didn't make sense and were copy/paste leftover.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2763
2020-12-10 14:29:47 -07:00
Ebrahim Byagowi 7e3edfa454
minor 2020-07-18 19:03:36 +04:30
Ebrahim Byagowi 08d57d9eca
Add hb_array_t::lfind 2020-06-28 13:13:25 +04:30
Ebrahim Byagowi 385d64eef1 Add a not discardable bool type, hb_success_t 2020-05-07 10:26:45 +04:30
Ebrahim Byagowi 07acd1a042 [subset] Rename src_base args to base to match sanitize methods
So it will become easier to follow that serialize methods signatures should
match with their sanitize methods counterparts.
2020-03-08 23:39:26 +03:30
ariza 188a0a47c2 removed default base; replaced w/ bias if required 2020-03-08 22:59:43 +03:30
ariza 4aa354beba chain second OffsetTo::serialize_copy() to first 2020-02-21 10:17:26 -08:00
ariza 4ca8e0d989 re-implement Tail; rewrote name table with it 2020-02-21 10:17:25 -08:00
Qunxin Liu 82afc75835 [subset] GPOS4 MarkBase subsetting support 2020-02-06 10:46:05 -08:00
Behdad Esfahbod b1dc676eaa [algs] Reduce one more bsearch() impl
Ouch, there were three more left.  Down one.  Two to go.
2019-12-10 12:13:40 -06:00
Ebrahim Byagowi 0558413f27 Minor, tweak spaces 2019-10-01 13:50:11 +03:30
Ebrahim Byagowi d512087e4d Rename GlyphID to HBGlyphID
Avoid collision with macOS's ATSUnicodeTypes.h GlyphID
2019-09-14 11:55:53 +04:30
Behdad Esfahbod 229ef1d29d Rename Fixed to HBFixed
Fixes(!!) https://github.com/harfbuzz/harfbuzz/issues/1966
2019-09-10 10:31:07 -07:00
Behdad Esfahbod 0e294c455e Rename VAR to HB_VAR_ARRAY 2019-09-06 16:54:27 -04:00
Behdad Esfahbod dc2c9aa0c3 Rename 2019-08-28 15:05:49 -07:00
Behdad Esfahbod 42d887bd22 Beef up HeadlessArrayOf<>
Should be merged with ArrayOf...
https://github.com/harfbuzz/harfbuzz/issues/1937
2019-08-28 14:47:14 -07:00
Behdad Esfahbod 3ca809e362 Add ArrayOf::pop() 2019-08-28 13:49:35 -07:00
Behdad Esfahbod 307bd6d79f Add arithmetic operators to IntType<> 2019-08-28 13:49:17 -07:00
Behdad Esfahbod 062cad5e28 Add ArrayOf::serialize_append 2019-08-28 13:48:55 -07:00
Ebrahim Byagowi a0b4ac4dce Turn 8 spaces to tab across the project
According to the current code style of the project
2019-08-27 02:40:41 +04:30
Ebrahim Byagowi aab8e08487
minor spacing fix (#1869) 2019-07-26 02:19:22 +04:30
Behdad Esfahbod 6492b2345c Minor 2019-06-17 14:19:13 -07:00
Behdad Esfahbod 8938dd23c6 Use injected class name 2019-06-17 14:12:11 -07:00
Behdad Esfahbod 1834cf86d4 [serialize] Pass offset to serialize_subset() 2019-05-31 14:39:32 -07:00
Behdad Esfahbod 9260441624 [serialize] Pass offset to serialize_copy() 2019-05-31 14:35:01 -07:00
Behdad Esfahbod dfa5e42971 Add back symmetric OffsetTo<>::friend operator+
Finally seems to be working now.
2019-05-15 21:18:14 -07:00
Behdad Esfahbod 203ea58bf6 More adjustment to OffsetTo<>::friend opeator+
Let's see if I break any bots.  But yeah, it wasn't accepting a
non-const pointer.  It just happens that we don't use that in the
code it seems.
2019-05-15 16:14:40 -07:00
Behdad Esfahbod 763ea4224b Another try 2019-05-15 01:21:32 -07:00
Behdad Esfahbod e1b2edb04a Completely revert the thing back 2019-05-15 01:12:04 -07:00
Behdad Esfahbod c58eeb5fb3 Another try at fix
Fails locally.  Trying to understand.  Sigh
2019-05-15 01:10:31 -07:00
Behdad Esfahbod 004edf3bda Ugh. How was the Travis bot happy before, but isn't now?! :( 2019-05-15 01:02:50 -07:00
Behdad Esfahbod e01c7b1648 Move OffsetTo operator+ back out of class
Apparently there's different overload resolution rules that apply, at
least with some (older?) version of gcc.

hb-ot-name-table.hh: In member function ‘void OT::name::accelerator_t::init(hb_face_t*)’:
hb-ot-name-table.hh:244:62: error: ambiguous overload for ‘operator+’ (operand types are ‘hb_blob_ptr_t<OT::name>’ and ‘OT::NNOffsetTo<OT::UnsizedArrayOf<OT::IntType<unsigned char, 1u> > > {aka const OT::OffsetTo<OT::UnsizedArrayOf<OT::IntType<unsigned char, 1u> >, OT::IntType<short unsigned int, 2u>, false>}’)
       this->pool = (const char *) (const void *) (this->table+this->table->stringOffset);
                                                              ^
hb-ot-name-table.hh:244:62: note: candidates are:
hb-ot-name-table.hh:244:62: note: operator+(const C*, long int) <built-in>
hb-ot-name-table.hh:244:62: note: operator+(const char*, long int) <built-in>
2019-05-15 00:52:17 -07:00
Behdad Esfahbod b213042f87 Revert "Revert symmetric OffsetTo overloads"
This reverts commit 01912efb74.

Actually this didn't break things.  Fixing
2019-05-15 00:50:48 -07:00
Behdad Esfahbod 01912efb74 Revert symmetric OffsetTo overloads
Reverts 57f65ae935

Caused ambiguous-overload on some gcc...
2019-05-15 00:42:47 -07:00
Behdad Esfahbod 57f65ae935 Add symmetric friend operator+ for OffsetTo 2019-05-14 22:52:59 -07:00
Behdad Esfahbod 71208e5047 Move OffsetTo<> deref operators in-class as friends 2019-05-14 22:51:59 -07:00
Behdad Esfahbod 9bfe22af61 [sanitize] Fix previous commit 2019-05-10 22:44:19 -07:00
Behdad Esfahbod 4dcf65328f [sanitize] Simplify 2019-05-10 22:23:24 -07:00
Behdad Esfahbod 23168c3981 [sanitize] Use hb_is_trivially_copyable() 2019-05-10 22:20:47 -07:00
Behdad Esfahbod 707ff5b59d Minor 2019-05-10 20:31:20 -07:00
Behdad Esfahbod ed972d5d73 [iter] Rewrite test functions
Notably, add hb_is_source_of(,) and hb_is_sink_of(,) to replace most
uses of hb_is_iterator_of(,).
2019-05-09 16:58:28 -07:00
Behdad Esfahbod e2a51ff726 Remove unused var 2019-05-08 16:41:39 -07:00
Behdad Esfahbod e8b45c1933 [array] Add .copy() 2019-05-08 16:37:38 -07:00
Behdad Esfahbod 7166bd5634 Minor 2019-05-08 15:08:33 -07:00
Behdad Esfahbod dfc5780245 Fix more double-promotion errors
WHy do only some of the clang bots catch this I have no idea :(.
2019-05-07 23:26:09 -07:00
Behdad Esfahbod af571dbffc [meta] Replace most hb_enable_if with hb_requires
They do absolutely same thing.  hb_requires is to encode constraints,
whereas hb_enable_if is for more conditional enabling.
2019-05-07 21:39:20 -07:00
Behdad Esfahbod 83e3eabd84 Whitespace 2019-05-07 20:58:43 -07:00
Behdad Esfahbod 41248cce0e Remove MIN/MAX in favor of hb_min/hb_max 2019-05-07 20:54:31 -07:00
Behdad Esfahbod 95426ea983 Add comment 2019-05-07 15:56:51 -07:00
Behdad Esfahbod b10f65933a [dispatch] Use functionality from previous commit
To remove a couple of unwanted wrapper methods
2019-05-05 09:23:35 -07:00
Behdad Esfahbod 8a32c9eecb [serialize] Misc getting copy() to work 2019-05-02 16:20:18 -07:00
Behdad Esfahbod 998b0b68ac [serializer] Add copy() to (Unsized)ArrayOf 2019-05-02 14:39:52 -07:00
Behdad Esfahbod 88a4147240 [serializer] Accept exact type in serialize_subset/copy() 2019-05-02 14:22:31 -07:00
Behdad Esfahbod 88fdeeecc0 [serialize] Take arguments in copy() 2019-05-02 14:14:33 -07:00
Behdad Esfahbod 273ed6127b [serializer] Add serialize_copy() 2019-05-02 14:04:51 -07:00
Ebrahim Byagowi 92588782d7
Remove space between right angle brackets now that we have C++11 (#1689) 2019-04-30 13:05:10 -07:00
Behdad Esfahbod c69f02784a Fix sign-compare error on 32-bit systems 2019-04-24 16:31:37 -07:00
Behdad Esfahbod 915b9ea5f4 [serialize] Add c->check_assign()
To check for assignment overflows.
2019-04-24 10:07:19 -04:00
Behdad Esfahbod 27377a7e28 Rely on variadic parameter pack more 2019-04-24 09:22:14 -04:00
Behdad Esfahbod 3ad20c38ad [serialize] Fix a few overflow TODO items 2019-04-24 09:09:00 -04:00
Behdad Esfahbod 441cca2354 Use hb_forward() when forwarding parameter pack 2019-04-23 23:51:59 -04:00
Behdad Esfahbod 20f3134789 Use variadic templates in OffsetTo<> and various ArrayOf<>s 2019-04-23 12:59:17 -04:00
Behdad Esfahbod 07776b6096 More tweaks to previous commit
Delete assignment operator of OffsetTo<> instead of Offset<>.

In simple ArrayOf<>::sanitize() assert that Type has assignment operator.
Ideally we should SFINAE this and fallback to calling Type::sanitize()
if assignment operator is not available.  But we don't have a case of
that in the codebase.
2019-04-15 16:43:34 -04:00
Behdad Esfahbod 699de689e9 Delete default assignment operator Offset<> 2019-04-15 16:00:20 -04:00
Behdad Esfahbod 95df00aec1 Hide a few static methods
Looks like static methods that do not get inlined end up exported.
We have a lot more.  Need to protect all at some point.  Wish there
was an easier way, like the visibility flag we pass that automatically
hides all inline methods.

Was exposed by check-symbols.sh when compiling on OS X 10.14 with:

$ make CPPFLAGS=-Oz CXXFLAGS=-flto=thin LDFLAGS=-lc++
2019-04-12 17:51:14 -04:00
Behdad Esfahbod b52c0e54b9 Use injected class name to simplify macros 2019-04-11 11:20:10 -04:00
Behdad Esfahbod 824fd342d5 Rename a few macros 2019-04-11 11:16:01 -04:00
Behdad Esfahbod aa2293a55e [serialize] Minor 2019-04-02 17:42:10 -07:00
Behdad Esfahbod e42b82c828 [serialize] Handle non-nullable offsets 2019-04-02 17:23:16 -07:00
Behdad Esfahbod 7f73c9744e [serialize] Minor 2019-04-02 17:12:24 -07:00
Behdad Esfahbod bfa02bef45 [serialize] Switch to tetris-packing 2019-04-01 21:36:13 -07:00
Behdad Esfahbod 4c38a9f601 Remove hb_assign()
Not needed anymore.  We just use operator= now.
2019-03-29 20:23:07 -07:00
Behdad Esfahbod b986c6a321 [C++11] Remove IntType::set() in favor of operator= 2019-03-29 20:21:21 -07:00
Behdad Esfahbod 489faf826c [C++11] Use type aliases for template partial instantiations 2019-03-29 20:01:37 -07:00
Behdad Esfahbod 9a5b15dc1e [C++11] Replace BEInt.set() with operator= 2019-03-29 17:58:19 -07:00
Behdad Esfahbod 0aa59b1de3 [C++11] Add operator= to IntType<>
Now that we require C++11 we can do this.
2019-03-29 17:58:15 -07:00
Behdad Esfahbod 3f36c89f2e Inline explicit_operator macro
Now that we require C++11, no need to macro.
2019-03-29 15:22:46 -07:00
Behdad Esfahbod 090fe56dc6 Merge branch 'master' into iter 2019-01-25 16:06:52 +01:00
Behdad Esfahbod 70a52d6bd8 Convert all other enum class consts to static constexpr
Fixes https://github.com/harfbuzz/harfbuzz/issues/1553
2019-01-22 12:17:26 +01:00
Behdad Esfahbod 5d4b0377b9 Convert unsigned enum class consts to static constexpr
Part of https://github.com/harfbuzz/harfbuzz/issues/1553
2019-01-22 12:17:26 +01:00
Behdad Esfahbod 7987095e64 [meta] Remove hb_enable_if_t
It was only used for C++<11 which does not allow default parameters
in function templates.  Looks like we cannot support <11 anyway, so,
start cleaning up.
2019-01-20 20:12:12 -05:00
Behdad Esfahbod a4ea0d3680 [iter] Change from const_iter_t/iter_t to iter_t/writer_t 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 362d4e7cc3 [iter] Implement for OT::ArrayOf / OT::SortedArrayOf 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 2f837a365c [SortedArrayOf] Fix sub_array() return type 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 445364d80a [iter] Rename hb_is_[sorted_]iterator() -> hb_is_[sorted_]iterator_of() 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 8237809f06 [serialize] Make SortedArrayOf:;serialize() take sorted-iterator 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 255085bd59 [iter] Const correctness 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 415f3f4320 Add operator= to IntType, commented out
https://github.com/harfbuzz/harfbuzz/pull/1510
2019-01-20 20:12:12 -05:00