Remove const and references when binding Null()
Fixes https://github.com/harfbuzz/harfbuzz/issues/1299 Removes anomaly I was seeing in cpal table trying to use implicit Null(NameID).
This commit is contained in:
parent
b18acab7bc
commit
07386ea410
|
@ -278,14 +278,11 @@ struct hb_atomic_int_t
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T> struct hb_remove_ptr_t { typedef T value; };
|
|
||||||
template <typename T> struct hb_remove_ptr_t<T *> { typedef T value; };
|
|
||||||
|
|
||||||
#define HB_ATOMIC_PTR_INIT(V) {V}
|
#define HB_ATOMIC_PTR_INIT(V) {V}
|
||||||
template <typename P>
|
template <typename P>
|
||||||
struct hb_atomic_ptr_t
|
struct hb_atomic_ptr_t
|
||||||
{
|
{
|
||||||
typedef typename hb_remove_ptr_t<P>::value T;
|
typedef typename hb_remove_pointer<P>::value T;
|
||||||
|
|
||||||
inline void init (T* v_ = nullptr) { set_relaxed (v_); }
|
inline void init (T* v_ = nullptr) { set_relaxed (v_); }
|
||||||
inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
|
inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
|
||||||
|
|
|
@ -761,7 +761,7 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv)
|
||||||
static void free_static_C_locale (void);
|
static void free_static_C_locale (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<HB_LOCALE_T>::value,
|
static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<HB_LOCALE_T>::value,
|
||||||
hb_C_locale_lazy_loader_t>
|
hb_C_locale_lazy_loader_t>
|
||||||
{
|
{
|
||||||
static inline HB_LOCALE_T create (void)
|
static inline HB_LOCALE_T create (void)
|
||||||
|
|
|
@ -737,7 +737,7 @@ hb_ft_font_create_referenced (FT_Face ft_face)
|
||||||
static void free_static_ft_library (void);
|
static void free_static_ft_library (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<FT_Library>::value,
|
static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<FT_Library>::value,
|
||||||
hb_ft_library_lazy_loader_t>
|
hb_ft_library_lazy_loader_t>
|
||||||
{
|
{
|
||||||
static inline FT_Library create (void)
|
static inline FT_Library create (void)
|
||||||
|
|
|
@ -47,7 +47,7 @@ static inline Type const & Null (void) {
|
||||||
static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
|
static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
|
||||||
return *reinterpret_cast<Type const *> (_hb_NullPool);
|
return *reinterpret_cast<Type const *> (_hb_NullPool);
|
||||||
}
|
}
|
||||||
#define Null(Type) Null<Type>()
|
#define Null(Type) Null<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
|
||||||
|
|
||||||
/* Specializations for arbitrary-content Null objects expressed in bytes. */
|
/* Specializations for arbitrary-content Null objects expressed in bytes. */
|
||||||
#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
|
#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
|
||||||
|
@ -90,7 +90,7 @@ static inline Type& Crap (void) {
|
||||||
*obj = Null(Type);
|
*obj = Null(Type);
|
||||||
return *obj;
|
return *obj;
|
||||||
}
|
}
|
||||||
#define Crap(Type) Crap<Type>()
|
#define Crap(Type) Crap<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>()
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct CrapOrNull {
|
struct CrapOrNull {
|
||||||
|
|
|
@ -149,16 +149,14 @@ struct Tag : HBUINT32
|
||||||
/* Glyph index number, same as uint16 (length = 16 bits) */
|
/* Glyph index number, same as uint16 (length = 16 bits) */
|
||||||
typedef HBUINT16 GlyphID;
|
typedef HBUINT16 GlyphID;
|
||||||
|
|
||||||
/* Name-table index, same as uint16 (length = 16 bits) */
|
|
||||||
struct NameID : HBUINT16 {};
|
|
||||||
DECLARE_NULL_NAMESPACE_BYTES (OT, NameID);
|
|
||||||
|
|
||||||
/* Script/language-system/feature index */
|
/* Script/language-system/feature index */
|
||||||
struct Index : HBUINT16 {
|
struct Index : HBUINT16 {
|
||||||
enum { NOT_FOUND_INDEX = 0xFFFFu };
|
enum { NOT_FOUND_INDEX = 0xFFFFu };
|
||||||
};
|
};
|
||||||
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
|
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
|
||||||
|
|
||||||
|
typedef Index NameID;
|
||||||
|
|
||||||
/* Offset, Null offset = 0 */
|
/* Offset, Null offset = 0 */
|
||||||
template <typename Type, bool has_null=true>
|
template <typename Type, bool has_null=true>
|
||||||
struct Offset : Type
|
struct Offset : Type
|
||||||
|
|
|
@ -63,9 +63,7 @@ struct CPALV1Tail
|
||||||
unsigned int palette_index,
|
unsigned int palette_index,
|
||||||
unsigned int palette_count) const
|
unsigned int palette_count) const
|
||||||
{
|
{
|
||||||
/* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
|
if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
|
||||||
* and remove the explicit bound check. */
|
|
||||||
if (!paletteLabelsZ || palette_index >= palette_count) return HB_NAME_ID_INVALID;
|
|
||||||
return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
|
return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +72,7 @@ struct CPALV1Tail
|
||||||
unsigned int color_index,
|
unsigned int color_index,
|
||||||
unsigned int color_count) const
|
unsigned int color_count) const
|
||||||
{
|
{
|
||||||
/* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
|
if (!colorLabelsZ) return HB_NAME_ID_INVALID;
|
||||||
* and remove the explicit bound check. */
|
|
||||||
if (!colorLabelsZ || color_index >= color_count) return HB_NAME_ID_INVALID;
|
|
||||||
return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
|
return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
|
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
|
||||||
/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
|
/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
|
||||||
|
|
||||||
DEFINE_NULL_NAMESPACE_BYTES (OT, NameID) = {0xFF,0xFF};
|
|
||||||
DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
|
DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
|
||||||
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
|
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
|
||||||
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
|
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
|
||||||
|
|
|
@ -495,6 +495,15 @@ _hb_memalign(void **memptr, size_t alignment, size_t size)
|
||||||
#define HB_SCRIPT_MYANMAR_ZAWGYI ((hb_script_t) HB_TAG ('Q','a','a','g'))
|
#define HB_SCRIPT_MYANMAR_ZAWGYI ((hb_script_t) HB_TAG ('Q','a','a','g'))
|
||||||
|
|
||||||
|
|
||||||
|
/* Some really basic things everyone wants. */
|
||||||
|
template <typename T> struct hb_remove_const { typedef T value; };
|
||||||
|
template <typename T> struct hb_remove_const<const T> { typedef T value; };
|
||||||
|
template <typename T> struct hb_remove_reference { typedef T value; };
|
||||||
|
template <typename T> struct hb_remove_reference<T &> { typedef T value; };
|
||||||
|
template <typename T> struct hb_remove_pointer { typedef T value; };
|
||||||
|
template <typename T> struct hb_remove_pointer<T *> { typedef T value; };
|
||||||
|
|
||||||
|
|
||||||
/* Headers we include for everyone. Keep sorted. They express dependency amongst
|
/* Headers we include for everyone. Keep sorted. They express dependency amongst
|
||||||
* themselves, but no other file should include them.*/
|
* themselves, but no other file should include them.*/
|
||||||
#include "hb-atomic.hh"
|
#include "hb-atomic.hh"
|
||||||
|
|
Loading…
Reference in New Issue