};
-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}
template <typename P>
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 set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
static void free_static_C_locale (void);
#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>
{
static inline HB_LOCALE_T create (void)
static void free_static_ft_library (void);
#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>
{
static inline FT_Library create (void)
static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
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. */
#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \
*obj = Null(Type);
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>
struct CrapOrNull {
/* Glyph index number, same as uint16 (length = 16 bits) */
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 */
struct Index : HBUINT16 {
enum { NOT_FOUND_INDEX = 0xFFFFu };
};
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
+typedef Index NameID;
+
/* Offset, Null offset = 0 */
template <typename Type, bool has_null=true>
struct Offset : Type
unsigned int palette_index,
unsigned int palette_count) const
{
- /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
- * and remove the explicit bound check. */
- if (!paletteLabelsZ || palette_index >= palette_count) return HB_NAME_ID_INVALID;
+ if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
}
unsigned int color_index,
unsigned int color_count) const
{
- /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
- * and remove the explicit bound check. */
- if (!colorLabelsZ || color_index >= color_count) return HB_NAME_ID_INVALID;
+ if (!colorLabelsZ) return HB_NAME_ID_INVALID;
return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
}
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)] = {};
-DEFINE_NULL_NAMESPACE_BYTES (OT, NameID) = {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, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
#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
* themselves, but no other file should include them.*/
#include "hb-atomic.hh"