Add a not discardable bool type, hb_success_t

This commit is contained in:
Ebrahim Byagowi 2020-05-07 09:59:01 +04:30
parent 1026b3d0b6
commit 385d64eef1
2 changed files with 14 additions and 2 deletions

View File

@ -604,7 +604,7 @@ struct ArrayOf
hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */)
{ return as_array ().sub_array (start_offset, count); } { return as_array ().sub_array (start_offset, count); }
bool serialize (hb_serialize_context_t *c, unsigned int items_len) hb_success_t serialize (hb_serialize_context_t *c, unsigned items_len)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
@ -614,7 +614,7 @@ struct ArrayOf
} }
template <typename Iterator, template <typename Iterator,
hb_requires (hb_is_source_of (Iterator, Type))> hb_requires (hb_is_source_of (Iterator, Type))>
bool serialize (hb_serialize_context_t *c, Iterator items) hb_success_t serialize (hb_serialize_context_t *c, Iterator items)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
unsigned count = items.len (); unsigned count = items.len ();

View File

@ -318,6 +318,18 @@ extern "C" void hb_free_impl(void *ptr);
# define HB_FALLTHROUGH /* FALLTHROUGH */ # define HB_FALLTHROUGH /* FALLTHROUGH */
#endif #endif
/* A tag to enforce use of return value for a function */
#if __cplusplus >= 201703L
# define HB_NODISCARD [[nodiscard]]
#elif defined(__GNUC__) || defined(__clang__)
# define HB_NODISCARD __attribute__((warn_unused_result))
#elif defined(_MSC_VER)
# define HB_NODISCARD _Check_return_
#else
# define HB_NODISCARD
#endif
#define hb_success_t HB_NODISCARD bool
/* https://github.com/harfbuzz/harfbuzz/issues/1852 */ /* https://github.com/harfbuzz/harfbuzz/issues/1852 */
#if defined(__clang__) && !(defined(_AIX) && (defined(__IBMCPP__) || defined(__ibmxl__))) #if defined(__clang__) && !(defined(_AIX) && (defined(__IBMCPP__) || defined(__ibmxl__)))
/* Disable certain sanitizer errors. */ /* Disable certain sanitizer errors. */