diff options
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-set.cc')
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-set.cc | 174 |
1 files changed, 140 insertions, 34 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-set.cc b/src/3rdparty/harfbuzz-ng/src/hb-set.cc index 86bf70034c..a9386c5c91 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-set.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-set.cc @@ -40,7 +40,7 @@ /** - * hb_set_create: (Xconstructor) + * hb_set_create: * * Creates a new, initially empty set. * @@ -56,8 +56,6 @@ hb_set_create () if (!(set = hb_object_create<hb_set_t> ())) return hb_set_get_empty (); - set->init_shallow (); - return set; } @@ -107,9 +105,7 @@ hb_set_destroy (hb_set_t *set) { if (!hb_object_destroy (set)) return; - set->fini_shallow (); - - free (set); + hb_free (set); } /** @@ -122,7 +118,7 @@ hb_set_destroy (hb_set_t *set) * * Attaches a user-data key/data pair to the specified set. * - * Return value: %true if success, %false otherwise + * Return value: `true` if success, `false` otherwise * * Since: 0.9.2 **/ @@ -149,7 +145,7 @@ hb_set_set_user_data (hb_set_t *set, * Since: 0.9.2 **/ void * -hb_set_get_user_data (hb_set_t *set, +hb_set_get_user_data (const hb_set_t *set, hb_user_data_key_t *key) { return hb_object_get_user_data (set, key); @@ -162,14 +158,35 @@ hb_set_get_user_data (hb_set_t *set, * * Tests whether memory allocation for a set was successful. * - * Return value: %true if allocation succeeded, %false otherwise + * Return value: `true` if allocation succeeded, `false` otherwise * * Since: 0.9.2 **/ hb_bool_t hb_set_allocation_successful (const hb_set_t *set) { - return set->successful; + return !set->in_error (); +} + +/** + * hb_set_copy: + * @set: A set + * + * Allocate a copy of @set. + * + * Return value: (transfer full): Newly-allocated set. + * + * Since: 2.8.2 + **/ +hb_set_t * +hb_set_copy (const hb_set_t *set) +{ + hb_set_t *copy = hb_set_create (); + if (unlikely (copy->in_error ())) + return hb_set_get_empty (); + + copy->set (*set); + return copy; } /** @@ -183,9 +200,7 @@ hb_set_allocation_successful (const hb_set_t *set) void hb_set_clear (hb_set_t *set) { - if (unlikely (hb_object_is_immutable (set))) - return; - + /* Immutable-safe. */ set->clear (); } @@ -195,7 +210,7 @@ hb_set_clear (hb_set_t *set) * * Tests whether a set is empty (contains no elements). * - * Return value: %true if @set is empty + * Return value: `true` if @set is empty * * Since: 0.9.7 **/ @@ -212,7 +227,7 @@ hb_set_is_empty (const hb_set_t *set) * * Tests whether @codepoint belongs to @set. * - * Return value: %true if @codepoint is in @set, %false otherwise + * Return value: `true` if @codepoint is in @set, `false` otherwise * * Since: 0.9.2 **/ @@ -236,10 +251,34 @@ void hb_set_add (hb_set_t *set, hb_codepoint_t codepoint) { + /* Immutable-safe. */ set->add (codepoint); } /** + * hb_set_add_sorted_array: + * @set: A set + * @sorted_codepoints: (array length=num_codepoints): Array of codepoints to add + * @num_codepoints: Length of @sorted_codepoints + * + * Adds @num_codepoints codepoints to a set at once. + * The codepoints array must be in increasing order, + * with size at least @num_codepoints. + * + * Since: 4.1.0 + */ +HB_EXTERN void +hb_set_add_sorted_array (hb_set_t *set, + const hb_codepoint_t *sorted_codepoints, + unsigned int num_codepoints) +{ + /* Immutable-safe. */ + set->add_sorted_array (sorted_codepoints, + num_codepoints, + sizeof(hb_codepoint_t)); +} + +/** * hb_set_add_range: * @set: A set * @first: The first element to add to @set @@ -255,6 +294,7 @@ hb_set_add_range (hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last) { + /* Immutable-safe. */ set->add_range (first, last); } @@ -271,6 +311,7 @@ void hb_set_del (hb_set_t *set, hb_codepoint_t codepoint) { + /* Immutable-safe. */ set->del (codepoint); } @@ -283,6 +324,9 @@ hb_set_del (hb_set_t *set, * Removes all of the elements from @first to @last * (inclusive) from @set. * + * If @last is #HB_SET_VALUE_INVALID, then all values + * greater than or equal to @first are removed. + * * Since: 0.9.7 **/ void @@ -290,6 +334,7 @@ hb_set_del_range (hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last) { + /* Immutable-safe. */ set->del_range (first, last); } @@ -301,7 +346,7 @@ hb_set_del_range (hb_set_t *set, * Tests whether @set and @other are equal (contain the same * elements). * - * Return value: %true if the two sets are equal, %false otherwise. + * Return value: `true` if the two sets are equal, `false` otherwise. * * Since: 0.9.7 **/ @@ -309,7 +354,24 @@ hb_bool_t hb_set_is_equal (const hb_set_t *set, const hb_set_t *other) { - return set->is_equal (other); + return set->is_equal (*other); +} + +/** + * hb_set_hash: + * @set: A set + * + * Creates a hash representing @set. + * + * Return value: + * A hash of @set. + * + * Since: 4.4.0 + **/ +HB_EXTERN unsigned int +hb_set_hash (const hb_set_t *set) +{ + return set->hash (); } /** @@ -319,7 +381,7 @@ hb_set_is_equal (const hb_set_t *set, * * Tests whether @set is a subset of @larger_set. * - * Return value: %true if the @set is a subset of (or equal to) @larger_set, %false otherwise. + * Return value: `true` if the @set is a subset of (or equal to) @larger_set, `false` otherwise. * * Since: 1.8.1 **/ @@ -327,7 +389,7 @@ hb_bool_t hb_set_is_subset (const hb_set_t *set, const hb_set_t *larger_set) { - return set->is_subset (larger_set); + return set->is_subset (*larger_set); } /** @@ -343,7 +405,8 @@ void hb_set_set (hb_set_t *set, const hb_set_t *other) { - set->set (other); + /* Immutable-safe. */ + set->set (*other); } /** @@ -359,7 +422,8 @@ void hb_set_union (hb_set_t *set, const hb_set_t *other) { - set->union_ (other); + /* Immutable-safe. */ + set->union_ (*other); } /** @@ -375,7 +439,8 @@ void hb_set_intersect (hb_set_t *set, const hb_set_t *other) { - set->intersect (other); + /* Immutable-safe. */ + set->intersect (*other); } /** @@ -391,7 +456,8 @@ void hb_set_subtract (hb_set_t *set, const hb_set_t *other) { - set->subtract (other); + /* Immutable-safe. */ + set->subtract (*other); } /** @@ -408,25 +474,40 @@ void hb_set_symmetric_difference (hb_set_t *set, const hb_set_t *other) { - set->symmetric_difference (other); + /* Immutable-safe. */ + set->symmetric_difference (*other); } -#ifndef HB_DISABLE_DEPRECATED /** * hb_set_invert: * @set: A set * * Inverts the contents of @set. * - * Since: 0.9.10 - * - * Deprecated: 1.6.1 + * Since: 3.0.0 **/ void -hb_set_invert (hb_set_t *set HB_UNUSED) +hb_set_invert (hb_set_t *set) { + /* Immutable-safe. */ + set->invert (); +} + +/** + * hb_set_is_inverted: + * @set: A set + * + * Returns whether the set is inverted. + * + * Return value: `true` if the set is inverted, `false` otherwise + * + * Since: 7.0.0 + **/ +hb_bool_t +hb_set_is_inverted (const hb_set_t *set) +{ + return set->is_inverted (); } -#endif /** * hb_set_get_population: @@ -486,7 +567,7 @@ hb_set_get_max (const hb_set_t *set) * * Set @codepoint to #HB_SET_VALUE_INVALID to get started. * - * Return value: %true if there was a next value, %false otherwise + * Return value: `true` if there was a next value, `false` otherwise * * Since: 0.9.2 **/ @@ -507,7 +588,7 @@ hb_set_next (const hb_set_t *set, * * Set @codepoint to #HB_SET_VALUE_INVALID to get started. * - * Return value: %true if there was a previous value, %false otherwise + * Return value: `true` if there was a previous value, `false` otherwise * * Since: 1.8.0 **/ @@ -530,7 +611,7 @@ hb_set_previous (const hb_set_t *set, * * Set @last to #HB_SET_VALUE_INVALID to get started. * - * Return value: %true if there was a next range, %false otherwise + * Return value: `true` if there was a next range, `false` otherwise * * Since: 0.9.7 **/ @@ -554,7 +635,7 @@ hb_set_next_range (const hb_set_t *set, * * Set @first to #HB_SET_VALUE_INVALID to get started. * - * Return value: %true if there was a previous range, %false otherwise + * Return value: `true` if there was a previous range, `false` otherwise * * Since: 1.8.0 **/ @@ -565,3 +646,28 @@ hb_set_previous_range (const hb_set_t *set, { return set->previous_range (first, last); } + +/** + * hb_set_next_many: + * @set: A set + * @codepoint: Outputting codepoints starting after this one. + * Use #HB_SET_VALUE_INVALID to get started. + * @out: (array length=size): An array of codepoints to write to. + * @size: The maximum number of codepoints to write out. + * + * Finds the next element in @set that is greater than @codepoint. Writes out + * codepoints to @out, until either the set runs out of elements, or @size + * codepoints are written, whichever comes first. + * + * Return value: the number of values written. + * + * Since: 4.2.0 + **/ +unsigned int +hb_set_next_many (const hb_set_t *set, + hb_codepoint_t codepoint, + hb_codepoint_t *out, + unsigned int size) +{ + return set->next_many (codepoint, out, size); +} |