[HarfBuzz] harfbuzz-ng: Branch 'master' - 20 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Apr 22 06:36:51 PDT 2010


 README                               |    2 
 src/hb-blob.c                        |    2 
 src/hb-blob.h                        |    2 
 src/hb-buffer-private.h              |    2 
 src/hb-buffer.c                      |    2 
 src/hb-buffer.h                      |    2 
 src/hb-common.h                      |    2 
 src/hb-font-private.h                |    2 
 src/hb-font.cc                       |    2 
 src/hb-font.h                        |    2 
 src/hb-ft.c                          |    2 
 src/hb-ft.h                          |    2 
 src/hb-glib.c                        |    2 
 src/hb-glib.h                        |    2 
 src/hb-icu.c                         |    2 
 src/hb-icu.h                         |    2 
 src/hb-language.c                    |    2 
 src/hb-language.h                    |    2 
 src/hb-object-private.h              |    2 
 src/hb-open-file-private.hh          |   14 +--
 src/hb-open-type-private.hh          |  133 ++++++++++++++++++++---------------
 src/hb-ot-layout-common-private.hh   |   28 +++----
 src/hb-ot-layout-gdef-private.hh     |    6 -
 src/hb-ot-layout-gpos-private.hh     |   42 +++++------
 src/hb-ot-layout-gsub-private.hh     |   24 +++---
 src/hb-ot-layout-gsubgpos-private.hh |   65 ++++++++---------
 src/hb-ot-layout-private.h           |    2 
 src/hb-ot-layout.cc                  |    2 
 src/hb-ot-layout.h                   |    2 
 src/hb-ot-shape-private.h            |    2 
 src/hb-ot-shape.c                    |    2 
 src/hb-ot-tag.c                      |    2 
 src/hb-ot-tag.h                      |    2 
 src/hb-ot.h                          |    2 
 src/hb-private.h                     |    2 
 src/hb-shape.c                       |    2 
 src/hb-shape.h                       |    2 
 src/hb-unicode-private.h             |    2 
 src/hb-unicode.c                     |    2 
 src/hb-unicode.h                     |    2 
 src/hb.h                             |    2 
 src/main.cc                          |    2 
 42 files changed, 201 insertions(+), 181 deletions(-)

New commits:
commit bb1e16335e537231246f44740f73cc23c0707364
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 01:01:35 2010 -0400

    Improve Subst/Pos SubTable access and sanitize

diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index bebde66..1454b5b 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -1440,7 +1440,7 @@ struct PosLookupSubTable
 struct PosLookup : Lookup
 {
   inline const PosLookupSubTable& get_subtable (unsigned int i) const
-  { return (const PosLookupSubTable&) Lookup::get_subtable (i); }
+  { return this+CONST_CAST (OffsetArrayOf<PosLookupSubTable>, subTable, 0)[i]; }
 
   /* Like get_type(), but looks through extension lookups.
    * Never returns Extension */
@@ -1519,7 +1519,7 @@ struct PosLookup : Lookup
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     if (!Lookup::sanitize (SANITIZE_ARG)) return false;
-    OffsetArrayOf<PosLookupSubTable> &list = (OffsetArrayOf<PosLookupSubTable> &) subTable;
+    OffsetArrayOf<PosLookupSubTable> &list = CAST (OffsetArrayOf<PosLookupSubTable>, subTable, 0);
     return SANITIZE_THIS (list);
   }
 };
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 1a49edb..d04ea99 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -736,7 +736,7 @@ struct SubstLookupSubTable
 struct SubstLookup : Lookup
 {
   inline const SubstLookupSubTable& get_subtable (unsigned int i) const
-  { return CONST_CAST (SubstLookupSubTable, Lookup::get_subtable (i), 0); }
+  { return this+CONST_CAST (OffsetArrayOf<SubstLookupSubTable>, subTable, 0)[i]; }
 
   /* Like get_type(), but looks through extension lookups.
    * Never returns Extension */
@@ -829,7 +829,7 @@ struct SubstLookup : Lookup
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     if (!Lookup::sanitize (SANITIZE_ARG)) return false;
-    OffsetArrayOf<SubstLookupSubTable> &list = (OffsetArrayOf<SubstLookupSubTable> &) subTable;
+    OffsetArrayOf<SubstLookupSubTable> &list = CAST (OffsetArrayOf<SubstLookupSubTable>, subTable, 0);
     return SANITIZE_THIS (list);
   }
 };
commit 81f2af40f9afd5bb9695018e6baddcd4aa3361c1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:58:49 2010 -0400

    Simplify Extension offset now that our int types have no alignment

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 5d19c7e..a68e5a4 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -835,10 +835,9 @@ struct ExtensionFormat1
 
   protected:
   inline unsigned int get_type (void) const { return extensionLookupType; }
-  inline unsigned int get_offset (void) const { return (extensionOffset[0] << 16) + extensionOffset[1]; }
   inline const LookupSubTable& get_subtable (void) const
   {
-    unsigned int offset = get_offset ();
+    unsigned int offset = extensionOffset;
     if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
     return CONST_CAST (LookupSubTable, *this, offset);
   }
@@ -853,10 +852,8 @@ struct ExtensionFormat1
   USHORT	extensionLookupType;	/* Lookup type of subtable referenced
 					 * by ExtensionOffset (i.e. the
 					 * extension subtable). */
-  USHORT	extensionOffset[2];	/* Offset to the extension subtable,
-					 * of lookup type subtable.
-					 * Defined as two shorts to avoid
-					 * alignment requirements. */
+  ULONG		extensionOffset;	/* Offset to the extension subtable,
+					 * of lookup type subtable. */
 };
 ASSERT_SIZE (ExtensionFormat1, 8);
 
commit 19828ad42d8117563412aae3c70887aa117805a9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:49:16 2010 -0400

    Sanitize shallow in Lookup since the generic SubLookup has no methods

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 080d9f5..38d1983 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -295,7 +295,7 @@ struct Lookup
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    if (!(SANITIZE_SELF () && SANITIZE_THIS (subTable))) return false;
+    if (!(SANITIZE_SELF () && HB_LIKELY ((subTable).sanitize_shallow (SANITIZE_ARG)))) return false;
     if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
     {
       USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
commit e5546a4352c54311ac4a9ef138b187378155ebe1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:45:42 2010 -0400

    Watch for overflow in Array sanitize

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 8328684..ba1bf0e 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -256,7 +256,6 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 
 #define SANITIZE_SELF() SANITIZE_OBJ (*this)
 #define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
-#define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ())
 
 #define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CharP(B), (L)))
 
@@ -541,9 +540,14 @@ struct GenericArrayOf
   inline unsigned int get_size () const
   { return len.get_size () + len * Type::get_size (); }
 
+  inline bool sanitize_shallow (SANITIZE_ARG_DEF) {
+    TRACE_SANITIZE ();
+    return SANITIZE_SELF() && SANITIZE_ARRAY (this, Type::get_size (), len);
+  }
+
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    if (!SANITIZE_GET_SIZE()) return false;
+    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
     /* Note: for structs that do not reference other structs,
      * we do not need to call their sanitize() as we already did
      * a bound check on the aggregate array size, hence the return.
@@ -560,7 +564,7 @@ struct GenericArrayOf
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
-    if (!SANITIZE_GET_SIZE()) return false;
+    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       if (!array()[i].sanitize (SANITIZE_ARG, base))
@@ -569,7 +573,7 @@ struct GenericArrayOf
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
-    if (!SANITIZE_GET_SIZE()) return false;
+    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       if (!array()[i].sanitize (SANITIZE_ARG, base, base2))
@@ -578,7 +582,7 @@ struct GenericArrayOf
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
-    if (!SANITIZE_GET_SIZE()) return false;
+    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
       if (!array()[i].sanitize (SANITIZE_ARG, base, user_data))
@@ -647,9 +651,14 @@ struct HeadlessArrayOf
   inline unsigned int get_size () const
   { return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
 
+  inline bool sanitize_shallow (SANITIZE_ARG_DEF) {
+    TRACE_SANITIZE ();
+    return SANITIZE_SELF() && SANITIZE_ARRAY (this, Type::get_size (), len);
+  }
+
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    if (!SANITIZE_GET_SIZE()) return false;
+    if (!HB_LIKELY (sanitize_shallow (SANITIZE_ARG))) return false;
     /* Note: for structs that do not reference other structs,
      * we do not need to call their sanitize() as we already did
      * a bound check on the aggregate array size, hence the return.
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 4e232d4..080d9f5 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -604,7 +604,7 @@ struct Device
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    return SANITIZE_GET_SIZE ();
+    return SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ());
   }
 
   private:
commit 4f5f1c34dda1e0629bfa6d7b0ffa2e1ce003b7c7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:27:39 2010 -0400

    Rename const_sub_array to sub_array since all consts are implicit now

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 7079862..8328684 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -521,7 +521,7 @@ struct GenericArrayOf
   const Type *array(void) const { return &StructAfter<Type> (len); }
   Type *array(void) { return &StructAfter<Type> (len); }
 
-  const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
+  const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
   {
     unsigned int count = len;
     if (HB_UNLIKELY (start_offset > count))
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 5623de4..4e232d4 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -76,7 +76,7 @@ struct RecordArrayOf : ArrayOf<Record<Type> > {
 				hb_tag_t     *record_tags /* OUT */) const
   {
     if (record_count) {
-      const Record<Type> *array = this->const_sub_array (start_offset, record_count);
+      const Record<Type> *array = this->sub_array (start_offset, record_count);
       unsigned int count = *record_count;
       for (unsigned int i = 0; i < count; i++)
 	record_tags[i] = array[i].tag;
@@ -129,7 +129,7 @@ struct IndexArray : ArrayOf<USHORT>
 				   unsigned int *_indexes /* OUT */) const
   {
     if (_count) {
-      const USHORT *array = this->const_sub_array (start_offset, _count);
+      const USHORT *array = this->sub_array (start_offset, _count);
       unsigned int count = *_count;
       for (unsigned int i = 0; i < count; i++)
 	_indexes[i] = array[i];
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 0122fcc..4f6c1d9 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -58,7 +58,7 @@ struct AttachList
     const AttachPoint &points = this+attachPoint[index];
 
     if (point_count) {
-      const USHORT *array = points.const_sub_array (start_offset, point_count);
+      const USHORT *array = points.sub_array (start_offset, point_count);
       unsigned int count = *point_count;
       for (unsigned int i = 0; i < count; i++)
 	point_array[i] = array[i];
@@ -196,7 +196,7 @@ struct LigGlyph
 				      int *caret_array /* OUT */) const
   {
     if (caret_count) {
-      const OffsetTo<CaretValue> *array = carets.const_sub_array (start_offset, caret_count);
+      const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
       unsigned int count = *caret_count;
       for (unsigned int i = 0; i < count; i++)
 	caret_array[i] = (this+array[i]).get_caret_value (context, glyph_id);
commit 0795b784dd1009976c185482a376df250167e73b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:23:14 2010 -0400

    Cosmetic

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 35e6a70..5623de4 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -608,9 +608,9 @@ struct Device
   }
 
   private:
-  USHORT	startSize;	/* Smallest size to correct--in ppem */
-  USHORT	endSize;	/* Largest size to correct--in ppem */
-  USHORT	deltaFormat;	/* Format of DeltaValue array data: 1, 2, or 3 */
+  USHORT	startSize;		/* Smallest size to correct--in ppem */
+  USHORT	endSize;		/* Largest size to correct--in ppem */
+  USHORT	deltaFormat;		/* Format of DeltaValue array data: 1, 2, or 3 */
   USHORT	deltaValue[VAR];	/* Array of compressed data */
 };
 ASSERT_SIZE_VAR (Device, 6, USHORT);
commit 2d98d3bbaa0ddadcb08b5a8f437b18c211c50768
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:19:30 2010 -0400

    Simplify Lookup sanitize

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 9651d4e..35e6a70 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -295,7 +295,7 @@ struct Lookup
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    if (!(SANITIZE (lookupType) && SANITIZE (lookupFlag) && SANITIZE_THIS (subTable))) return false;
+    if (!(SANITIZE_SELF () && SANITIZE_THIS (subTable))) return false;
     if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
     {
       USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
commit c755cb3e3ac55156d0d2ec05adea7a650b97cc41
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 22 00:11:43 2010 -0400

    Change header comment

diff --git a/README b/README
index 42d0104..29f2b1e 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is HarfBuzz, an OpenType Layout engine.
+This is HarfBuzz, a text shaping library.
 
 Bug reports on these files should be sent to the HarfBuzz mailing list as
 listed on http://freedesktop.org/wiki/Software/harfbuzz
diff --git a/src/hb-blob.c b/src/hb-blob.c
index 3afad8a..c5f8726 100644
--- a/src/hb-blob.c
+++ b/src/hb-blob.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-blob.h b/src/hb-blob.h
index 131a282..d13bb0d 100644
--- a/src/hb-blob.h
+++ b/src/hb-blob.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-buffer-private.h b/src/hb-buffer-private.h
index 821a481..c2bd885 100644
--- a/src/hb-buffer-private.h
+++ b/src/hb-buffer-private.h
@@ -2,7 +2,7 @@
  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
  * Copyright (C) 2004,2007,2009  Red Hat, Inc.
  *
- * This is part of HarfBuzz, an OpenType Layout engine library.
+ * This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index 4dd18ed..ac6b47d 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
  * Copyright (C) 2004,2007  Red Hat, Inc.
  *
- * This is part of HarfBuzz, an OpenType Layout engine library.
+ * This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 0bceada..d1772d4 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -2,7 +2,7 @@
  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
  * Copyright (C) 2004,2007,2009  Red Hat, Inc.
  *
- * This is part of HarfBuzz, an OpenType Layout engine library.
+ * This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-common.h b/src/hb-common.h
index 25249cc..a2bc114 100644
--- a/src/hb-common.h
+++ b/src/hb-common.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-font-private.h b/src/hb-font-private.h
index 4293b7e..65e54c9 100644
--- a/src/hb-font-private.h
+++ b/src/hb-font-private.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-font.cc b/src/hb-font.cc
index b284477..e1b0b87 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-font.h b/src/hb-font.h
index 532d3f5..fee8ada 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ft.c b/src/hb-ft.c
index fb8e566..18b6e0b 100644
--- a/src/hb-ft.c
+++ b/src/hb-ft.c
@@ -2,7 +2,7 @@
  * Copyright (C) 2009  Red Hat, Inc.
  * Copyright (C) 2009  Keith Stribley <devel at thanlwinsoft.org>
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ft.h b/src/hb-ft.h
index b73a02c..8930804 100644
--- a/src/hb-ft.h
+++ b/src/hb-ft.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-glib.c b/src/hb-glib.c
index 604c7dd..f1497d9 100644
--- a/src/hb-glib.c
+++ b/src/hb-glib.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-glib.h b/src/hb-glib.h
index d7b9c15..76f7676 100644
--- a/src/hb-glib.h
+++ b/src/hb-glib.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-icu.c b/src/hb-icu.c
index 2b28aa1..8e4ef94 100644
--- a/src/hb-icu.c
+++ b/src/hb-icu.c
@@ -2,7 +2,7 @@
  * Copyright (C) 2009  Red Hat, Inc.
  * Copyright (C) 2009  Keith Stribley <devel at thanlwinsoft.org>
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-icu.h b/src/hb-icu.h
index ca8031c..cdb55b4 100644
--- a/src/hb-icu.h
+++ b/src/hb-icu.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-language.c b/src/hb-language.c
index 07ff347..ff25d7b 100644
--- a/src/hb-language.c
+++ b/src/hb-language.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-language.h b/src/hb-language.h
index e93a112..d366cad 100644
--- a/src/hb-language.h
+++ b/src/hb-language.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-object-private.h b/src/hb-object-private.h
index b371d73..610ae68 100644
--- a/src/hb-object-private.h
+++ b/src/hb-object-private.h
@@ -2,7 +2,7 @@
  * Copyright (C) 2007 Chris Wilson
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index c4b362f..091d994 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 0cdffbd..7079862 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009,2010  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 55ecc51..9651d4e 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index d9b0005..0122fcc 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 8f9b9e5..bebde66 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index b77aba8..1a49edb 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index aea849a..5d19c7e 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout-private.h b/src/hb-ot-layout-private.h
index fb7bfe4..a9d4c57 100644
--- a/src/hb-ot-layout-private.h
+++ b/src/hb-ot-layout-private.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 4a17af2..22f31f4 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -3,7 +3,7 @@
  * Copyright (C) 2006  Behdad Esfahbod
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index c65b059..d8c862b 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-shape-private.h b/src/hb-ot-shape-private.h
index bece36d..1183a63 100644
--- a/src/hb-ot-shape-private.h
+++ b/src/hb-ot-shape-private.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-shape.c b/src/hb-ot-shape.c
index 795fd54..f535183 100644
--- a/src/hb-ot-shape.c
+++ b/src/hb-ot-shape.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index dc92f1e..9597b7f 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot-tag.h b/src/hb-ot-tag.h
index 72896af..2dab2e8 100644
--- a/src/hb-ot-tag.h
+++ b/src/hb-ot-tag.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-ot.h b/src/hb-ot.h
index eab888e..51cc4aa 100644
--- a/src/hb-ot.h
+++ b/src/hb-ot.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-private.h b/src/hb-private.h
index 1c52744..0f3484e 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-shape.c b/src/hb-shape.c
index cde599d..a3315bb 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-shape.h b/src/hb-shape.h
index 714fe97..621c6ab 100644
--- a/src/hb-shape.h
+++ b/src/hb-shape.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-unicode-private.h b/src/hb-unicode-private.h
index 1a970b4..ba530d2 100644
--- a/src/hb-unicode-private.h
+++ b/src/hb-unicode-private.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-unicode.c b/src/hb-unicode.c
index a897f23..e155d6d 100644
--- a/src/hb-unicode.c
+++ b/src/hb-unicode.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb-unicode.h b/src/hb-unicode.h
index 6b63352..dc70bd1 100644
--- a/src/hb-unicode.h
+++ b/src/hb-unicode.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/hb.h b/src/hb.h
index f556553..905fd7b 100644
--- a/src/hb.h
+++ b/src/hb.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
diff --git a/src/main.cc b/src/main.cc
index 23d1e82..0251759 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
  *
- *  This is part of HarfBuzz, an OpenType Layout engine library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
commit 243d20e011e251462a07947275e0e98cc19c7e9b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:57:01 2010 -0400

    More cast simplification

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 3ae134d..0cdffbd 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -484,21 +484,21 @@ struct GenericOffsetTo : OffsetType
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE (CAST(Type, *CharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE (CAST(Type, *CharP(base), offset)) || NEUTER (CAST(OffsetType,*this,0), 0);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), base2) || NEUTER (CAST(OffsetType,*this,0), 0);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), user_data) || NEUTER (CAST(OffsetType,*this,0), 0);
   }
 };
 template <typename Base, typename OffsetType, typename Type>
commit 0dfcc13a4668cdd2c2ebdd5f4a7540a51222cf2f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:41:26 2010 -0400

    Rename ConstCharP to CharP (overloaded now)

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 0f3a363..c4b362f 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -52,7 +52,7 @@ typedef struct TableDirectory
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE (tag) &&
-	   SANITIZE_MEM (ConstCharP(base) + (unsigned long) offset, length);
+	   SANITIZE_MEM (CharP(base) + (unsigned long) offset, length);
   }
 
   Tag		tag;		/* 4-byte identifier. */
@@ -180,8 +180,8 @@ struct OpenTypeFontFile
   {
     switch (tag) {
     default: return 0;
-    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (ConstCharP(this)).get_face_count ();
-    case TTCTag: return TTCHeader::get_for_data (ConstCharP(this)).get_face_count ();
+    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CharP(this)).get_face_count ();
+    case TTCTag: return TTCHeader::get_for_data (CharP(this)).get_face_count ();
     }
   }
   inline const OpenTypeFontFace& get_face (unsigned int i) const
@@ -191,8 +191,8 @@ struct OpenTypeFontFile
     /* Note: for non-collection SFNT data we ignore index.  This is because
      * Apple dfont container is a container of SFNT's.  So each SFNT is a
      * non-TTC, but the index is more than zero. */
-    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (ConstCharP(this));
-    case TTCTag: return TTCHeader::get_for_data (ConstCharP(this)).get_face (i);
+    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CharP(this));
+    case TTCTag: return TTCHeader::get_for_data (CharP(this)).get_face (i);
     }
   }
 
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index b4bb1ee..3ae134d 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -40,12 +40,12 @@
  * Casts
  */
 
-/* Cast to const char *, to char *, or to char * dropping const-ness */
-template <typename Type> inline const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
-template <typename Type> inline char * CharP (Type X) { return reinterpret_cast<char *>(X); }
+/* Cast to "const char *" and "char *" */
+template <typename Type> inline const char * CharP (const Type* X) { return reinterpret_cast<const char *>(X); }
+template <typename Type> inline char * CharP (Type* X) { return reinterpret_cast<char *>(X); }
 
-#define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + Ofs)))
-#define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)ConstCharP(&(X)) + Ofs)))
+#define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(CharP(&(X)) + Ofs)))
+#define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)CharP(&(X)) + Ofs)))
 #define CAST(T,X,Ofs) 		(*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
 
 
@@ -54,7 +54,7 @@ template <typename Type> inline char * CharP (Type X) { return reinterpret_cast<
 template<typename Type, typename TObject>
 inline const Type& StructAfter(const TObject &X)
 {
-  return * reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
+  return * reinterpret_cast<const Type*> (CharP (&X) + X.get_size());
 }
 template<typename Type, typename TObject>
 inline Type& StructAfter(TObject &X)
@@ -129,7 +129,7 @@ inline const Type& Null<Type> () { \
 	HB_STMT_START { \
 	    if (sanitize_depth < HB_DEBUG_SANITIZE) \
 		fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \
-			 (ConstCharP (this) == ConstCharP (&NullPool)) ? 0 : this, \
+			 (CharP (this) == CharP (&NullPool)) ? 0 : this, \
 			 sanitize_depth, sanitize_depth, \
 			 __PRETTY_FUNCTION__); \
 	} HB_STMT_END
@@ -258,9 +258,9 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 #define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
 #define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ())
 
-#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, ConstCharP(B), (L)))
+#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CharP(B), (L)))
 
-#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, ConstCharP(A), S, L))
+#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CharP(A), S, L))
 
 #define NEUTER(Var, Val) \
 	(SANITIZE_OBJ (Var) && \
@@ -285,7 +285,7 @@ struct Sanitizer
 
     _hb_sanitize_init (&context, blob);
 
-    Type *t = &CAST (Type, * (char *) ConstCharP(context.start), 0);
+    Type *t = &CAST (Type, * (char *) CharP(context.start), 0);
 
     sane = t->sanitize (SANITIZE_ARG_INIT);
     if (sane) {
@@ -403,7 +403,7 @@ ASSERT_SIZE (LONG, 4);
 struct Tag : ULONG
 {
   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
-  inline operator const char* (void) const { return ConstCharP(this); }
+  inline operator const char* (void) const { return CharP(this); }
   inline operator char* (void) { return CharP(this); }
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -476,7 +476,7 @@ struct GenericOffsetTo : OffsetType
   {
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return Null(Type);
-    return CONST_CAST(Type, *ConstCharP(base), offset);
+    return CONST_CAST(Type, *CharP(base), offset);
   }
 
   inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 9dfda97..8f9b9e5 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -413,7 +413,7 @@ struct SinglePosFormat1
     if (HB_LIKELY (index == NOT_COVERED))
       return false;
 
-    valueFormat.apply_value (context, ConstCharP(this), values, CURPOSITION ());
+    valueFormat.apply_value (context, CharP(this), values, CURPOSITION ());
 
     buffer->in_pos++;
     return true;
@@ -453,7 +453,7 @@ struct SinglePosFormat2
     if (HB_LIKELY (index >= valueCount))
       return false;
 
-    valueFormat.apply_value (context, ConstCharP(this),
+    valueFormat.apply_value (context, CharP(this),
 			     &values[index * valueFormat.get_len ()],
 			     CURPOSITION ());
 
@@ -582,8 +582,8 @@ struct PairPosFormat1
     {
       if (IN_GLYPH (j) == record->secondGlyph)
       {
-	valueFormat1.apply_value (context, ConstCharP(this), &record->values[0], CURPOSITION ());
-	valueFormat2.apply_value (context, ConstCharP(this), &record->values[len1], POSITION (j));
+	valueFormat1.apply_value (context, CharP(this), &record->values[0], CURPOSITION ());
+	valueFormat2.apply_value (context, CharP(this), &record->values[len1], POSITION (j));
 	if (len2)
 	  j++;
 	buffer->in_pos = j;
@@ -673,8 +673,8 @@ struct PairPosFormat2
       return false;
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
-    valueFormat1.apply_value (context, ConstCharP(this), v, CURPOSITION ());
-    valueFormat2.apply_value (context, ConstCharP(this), v + len1, POSITION (j));
+    valueFormat1.apply_value (context, CharP(this), v, CURPOSITION ());
+    valueFormat2.apply_value (context, CharP(this), v + len1, POSITION (j));
 
     if (len2)
       j++;
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index d7949b1..b77aba8 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -591,10 +591,10 @@ struct ReverseChainSingleSubstFormat1
 
     if (match_backtrack (APPLY_ARG,
 			 backtrack.len, (USHORT *) backtrack.array(),
-			 match_coverage, ConstCharP(this)) &&
+			 match_coverage, CharP(this)) &&
         match_lookahead (APPLY_ARG,
 			 lookahead.len, (USHORT *) lookahead.array(),
-			 match_coverage, ConstCharP(this),
+			 match_coverage, CharP(this),
 			 1))
     {
       IN_CURGLYPH () = substitute[index];
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 7be8edf..aea849a 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -44,7 +44,7 @@
 	HB_STMT_START { \
 	    if (apply_depth < HB_DEBUG_APPLY) \
 		fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
-			 (ConstCharP (this) == ConstCharP (&NullPool)) ? 0 : this, \
+			 (CharP (this) == CharP (&NullPool)) ? 0 : this, \
 			 apply_depth, apply_depth, \
 			 __PRETTY_FUNCTION__); \
 	} HB_STMT_END
@@ -411,7 +411,7 @@ struct ContextFormat2
      */
     struct ContextLookupContext lookup_context = {
      {match_class, apply_func},
-      ConstCharP(&class_def)
+      CharP(&class_def)
     };
     return rule_set.apply (APPLY_ARG, lookup_context);
   }
@@ -451,7 +451,7 @@ struct ContextFormat3
     const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, coverage[0].get_size () * glyphCount);
     struct ContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-       ConstCharP(this)
+       CharP(this)
     };
     return context_lookup (APPLY_ARG,
 			   glyphCount, (const USHORT *) (coverage + 1),
@@ -696,9 +696,9 @@ struct ChainContextFormat2
      */
     struct ChainContextLookupContext lookup_context = {
      {match_class, apply_func},
-     {ConstCharP(&backtrack_class_def),
-      ConstCharP(&input_class_def),
-      ConstCharP(&lookahead_class_def)}
+     {CharP(&backtrack_class_def),
+      CharP(&input_class_def),
+      CharP(&lookahead_class_def)}
     };
     return rule_set.apply (APPLY_ARG, lookup_context);
   }
@@ -752,7 +752,7 @@ struct ChainContextFormat3
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     struct ChainContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-      {ConstCharP(this), ConstCharP(this), ConstCharP(this)}
+      {CharP(this), CharP(this), CharP(this)}
     };
     return chain_context_lookup (APPLY_ARG,
 				 backtrack.len, (const USHORT *) backtrack.array(),
commit 62c0fd75737a69721dbf29e773405a4c529f8b6d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:30:48 2010 -0400

    Cleanup de-const-casting during sanitize

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index c15fffd..0f3a363 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -150,7 +150,7 @@ struct TTCHeader
     TRACE_SANITIZE ();
     if (!SANITIZE (version)) return false;
     if (version.major < 1 || version.major > 2) return true;
-    return table.sanitize (SANITIZE_ARG, ConstCharP(this), ConstCharP(this));
+    return table.sanitize (SANITIZE_ARG, CharP(this), CharP(this));
   }
 
   private:
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index d81116d..b4bb1ee 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -43,7 +43,6 @@
 /* Cast to const char *, to char *, or to char * dropping const-ness */
 template <typename Type> inline const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
 template <typename Type> inline char * CharP (Type X) { return reinterpret_cast<char *>(X); }
-template <typename Type> inline char * DeConstCharP (const Type X) { return (char *) reinterpret_cast<const char *>(X); }
 
 #define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + Ofs)))
 #define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)ConstCharP(&(X)) + Ofs)))
@@ -248,7 +247,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 #define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG))
 #define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y))
 
-#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, ConstCharP(this)))
+#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CharP(this)))
 #define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y))
 #define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z))
 
@@ -265,7 +264,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 
 #define NEUTER(Var, Val) \
 	(SANITIZE_OBJ (Var) && \
-	 _hb_sanitize_edit (SANITIZE_ARG, ConstCharP(&(Var)), sizeof (Var)) && \
+	 _hb_sanitize_edit (SANITIZE_ARG, CharP(&(Var)), sizeof (Var)) && \
 	 ((Var).set (Val), true))
 
 
@@ -286,7 +285,7 @@ struct Sanitizer
 
     _hb_sanitize_init (&context, blob);
 
-    Type *t = &CAST (Type, *DeConstCharP(context.start), 0);
+    Type *t = &CAST (Type, * (char *) ConstCharP(context.start), 0);
 
     sane = t->sanitize (SANITIZE_ARG_INIT);
     if (sane) {
@@ -480,26 +479,26 @@ struct GenericOffsetTo : OffsetType
     return CONST_CAST(Type, *ConstCharP(base), offset);
   }
 
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE (CAST(Type, *DeConstCharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE (CAST(Type, *CharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *CharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
 };
 template <typename Base, typename OffsetType, typename Type>
@@ -559,7 +558,7 @@ struct GenericArrayOf
         return false;
     return true;
   }
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
     if (!SANITIZE_GET_SIZE()) return false;
     unsigned int count = len;
@@ -568,7 +567,7 @@ struct GenericArrayOf
         return false;
     return true;
   }
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
     TRACE_SANITIZE ();
     if (!SANITIZE_GET_SIZE()) return false;
     unsigned int count = len;
@@ -577,7 +576,7 @@ struct GenericArrayOf
         return false;
     return true;
   }
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
     if (!SANITIZE_GET_SIZE()) return false;
     unsigned int count = len;
@@ -623,11 +622,11 @@ struct OffsetListOf : OffsetArrayOf<Type>
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this));
+    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this));
   }
   inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this), user_data);
+    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this), user_data);
   }
 };
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index fd224b7..55ecc51 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -53,7 +53,7 @@ struct Record
 {
   static inline unsigned int get_size () { return sizeof (Record<Type>); }
 
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
     return SANITIZE (tag) && SANITIZE_BASE (offset, base);
   }
@@ -111,7 +111,7 @@ struct RecordListOf : RecordArrayOf<Type>
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this));
+    return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this));
   }
 };
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index da80d99..9dfda97 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -344,7 +344,7 @@ struct MarkRecord
 
   static inline unsigned int get_size () { return sizeof (MarkRecord); }
 
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_BASE (markAnchor, base);
   }
@@ -602,7 +602,7 @@ struct PairPosFormat1
     unsigned int len2 = valueFormat2.get_len ();
 
     if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
-	  pairSet.sanitize (SANITIZE_ARG, ConstCharP(this), len1 + len2))) return false;
+	  pairSet.sanitize (SANITIZE_ARG, CharP(this), len1 + len2))) return false;
 
     if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
 
@@ -765,7 +765,7 @@ struct EntryExitRecord
 {
   static inline unsigned int get_size () { return sizeof (EntryExitRecord); }
 
-  inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
+  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
     TRACE_SANITIZE ();
     return SANITIZE_BASE2 (entryAnchor, exitAnchor, base);
   }
@@ -1050,7 +1050,7 @@ struct MarkBasePosFormat1
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, baseCoverage) &&
-	   SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
+	   SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount);
   }
 
   private:
@@ -1171,7 +1171,7 @@ struct MarkLigPosFormat1
     TRACE_SANITIZE ();
     return SANITIZE_SELF () &&
 	   SANITIZE_THIS2 (markCoverage, ligatureCoverage) &&
-	   SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
+	   SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount);
   }
 
   private:
@@ -1270,7 +1270,7 @@ struct MarkMarkPosFormat1
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS2 (mark1Coverage, mark2Coverage) &&
-	   SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
+	   SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount);
   }
 
   private:
commit dd155870567cfb9647b2e71593ace8b2705d7cff
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:13:33 2010 -0400

    Add more comments

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 3273b86..d81116d 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -40,6 +40,7 @@
  * Casts
  */
 
+/* Cast to const char *, to char *, or to char * dropping const-ness */
 template <typename Type> inline const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
 template <typename Type> inline char * CharP (Type X) { return reinterpret_cast<char *>(X); }
 template <typename Type> inline char * DeConstCharP (const Type X) { return (char *) reinterpret_cast<const char *>(X); }
commit c85c3620675f38ffdca59134aeec2641485f40ca
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:12:54 2010 -0400

    Add comment

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 4fea4d4..3273b86 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -32,6 +32,7 @@
 #include "hb-blob.h"
 
 
+/* Table/script/language-system/feature/... not found */
 #define NO_INDEX		((unsigned int) 0xFFFF)
 
 
commit 2467c669c2aee4de2a6621a9d06cba0262376d41
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:11:45 2010 -0400

    Add comment

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index a334a48..4fea4d4 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -371,6 +371,7 @@ class BEInt<Type, 4>
   private: uint8_t v[4];
 };
 
+/* Integer types in big-endian order and no alignment requirement */
 template <typename Type>
 struct IntType
 {
commit 29c3f5e1b6212c775a7b911becd44ba093b7b0eb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 23:01:00 2010 -0400

    Improve comment

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 2c675f5..a334a48 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -49,7 +49,7 @@ template <typename Type> inline char * DeConstCharP (const Type X) { return (cha
 
 
 /* StructAfter<T>(X) returns the struct T& that is placed after X.
- * Works with X of variable size also. */
+ * Works with X of variable size also.  X must implement get_size() */
 template<typename Type, typename TObject>
 inline const Type& StructAfter(const TObject &X)
 {
commit 01c01618e98283611628cd54d5ba4bf122f24cd9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 22:49:56 2010 -0400

    Further simplify IntType struct defs

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 2a9fe00..2c675f5 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -354,18 +354,20 @@ template <typename Type>
 class BEInt<Type, 2>
 {
   public:
-  inline void put (Type i) { hb_be_uint16_put (v,i); }
-  inline Type get () const { return hb_be_uint16_get (v); }
-  inline bool cmp (const BEInt<Type, 2> o) const { return hb_be_uint16_cmp (v, o.v); }
+  inline class BEInt<Type,2>& operator = (Type i) { hb_be_uint16_put (v,i); return *this; }
+  inline operator Type () const { return hb_be_uint16_get (v); }
+  inline bool operator == (const BEInt<Type, 2>& o) const { return hb_be_uint16_cmp (v, o.v); }
+  inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); }
   private: uint8_t v[2];
 };
 template <typename Type>
 class BEInt<Type, 4>
 {
   public:
-  inline void put (Type i) { hb_be_uint32_put (v,i); }
-  inline Type get () const { return hb_be_uint32_get (v); }
-  inline bool cmp (const BEInt<Type, 4> o) const { return hb_be_uint32_cmp (v, o.v); }
+  inline class BEInt<Type,4>& operator = (Type i) { hb_be_uint32_put (v,i); return *this; }
+  inline operator Type () const { return hb_be_uint32_get (v); }
+  inline bool operator == (const BEInt<Type, 4>& o) const { return hb_be_uint32_cmp (v, o.v); }
+  inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); }
   private: uint8_t v[4];
 };
 
@@ -373,9 +375,10 @@ template <typename Type>
 struct IntType
 {
   static inline unsigned int get_size () { return sizeof (Type); }
-  inline void set (Type i) { v.put (i); }
-  inline operator Type(void) const { return v.get (); }
-  inline bool operator == (const IntType<Type> &o) const { return v.cmp (o.v); }
+  inline void set (Type i) { v = i; }
+  inline operator Type(void) const { return v; }
+  inline bool operator == (const IntType<Type> &o) const { return v == o.v; }
+  inline bool operator != (const IntType<Type> &o) const { return v != o.v; }
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF ();
commit 2cb08458f674301cde9d962c13911035a251f7c5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 22:37:31 2010 -0400

    Rename const_array() to array() (overloaded)

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 2176e38..2a9fe00 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -513,7 +513,7 @@ struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
 template <typename LenType, typename Type>
 struct GenericArrayOf
 {
-  const Type *const_array(void) const { return &StructAfter<Type> (len); }
+  const Type *array(void) const { return &StructAfter<Type> (len); }
   Type *array(void) { return &StructAfter<Type> (len); }
 
   const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
@@ -525,13 +525,13 @@ struct GenericArrayOf
       count -= start_offset;
     count = MIN (count, *pcount);
     *pcount = count;
-    return const_array() + start_offset;
+    return array() + start_offset;
   }
 
   inline const Type& operator [] (unsigned int i) const
   {
     if (HB_UNLIKELY (i >= len)) return Null(Type);
-    return const_array()[i];
+    return array()[i];
   }
   inline unsigned int get_size () const
   { return len.get_size () + len * Type::get_size (); }
@@ -612,7 +612,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
   inline const Type& operator [] (unsigned int i) const
   {
     if (HB_UNLIKELY (i >= this->len)) return Null(Type);
-    return this+this->const_array()[i];
+    return this+this->array()[i];
   }
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -631,13 +631,13 @@ struct OffsetListOf : OffsetArrayOf<Type>
 template <typename Type>
 struct HeadlessArrayOf
 {
-  const Type *const_array(void) const { return &StructAfter<Type> (len); }
+  const Type *array(void) const { return &StructAfter<Type> (len); }
   Type *array(void) { return &StructAfter<Type> (len); }
 
   inline const Type& operator [] (unsigned int i) const
   {
     if (HB_UNLIKELY (i >= len || !i)) return Null(Type);
-    return const_array()[i-1];
+    return array()[i-1];
   }
   inline unsigned int get_size () const
   { return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 595e640..fd224b7 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -88,7 +88,7 @@ struct RecordArrayOf : ArrayOf<Record<Type> > {
     Tag t;
     t.set (tag);
     // TODO bsearch
-    const Record<Type> *a = this->const_array();
+    const Record<Type> *a = this->array();
     unsigned int count = this->len;
     for (unsigned int i = 0; i < count; i++)
     {
@@ -122,7 +122,7 @@ struct IndexArray : ArrayOf<USHORT>
   {
     if (HB_UNLIKELY (i >= this->len))
       return NO_INDEX;
-    return this->const_array()[i];
+    return this->array()[i];
   }
   inline unsigned int get_indexes (unsigned int start_offset,
 				   unsigned int *_count /* IN/OUT */,
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 8299116..d7949b1 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -159,7 +159,7 @@ struct Sequence
       return false;
 
     _hb_buffer_add_output_glyphs_be16 (buffer, 1,
-				       substitute.len, (const uint16_t *) substitute.const_array(),
+				       substitute.len, (const uint16_t *) substitute.array(),
 				       0xFFFF, 0xFFFF);
 
     /* This is a guess only ... */
@@ -590,10 +590,10 @@ struct ReverseChainSingleSubstFormat1
     const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
 
     if (match_backtrack (APPLY_ARG,
-			 backtrack.len, (USHORT *) backtrack.const_array(),
+			 backtrack.len, (USHORT *) backtrack.array(),
 			 match_coverage, ConstCharP(this)) &&
         match_lookahead (APPLY_ARG,
-			 lookahead.len, (USHORT *) lookahead.const_array(),
+			 lookahead.len, (USHORT *) lookahead.array(),
 			 match_coverage, ConstCharP(this),
 			 1))
     {
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index cc0542b..7be8edf 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -573,10 +573,10 @@ struct ChainRule
     const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return chain_context_lookup (APPLY_ARG,
-				 backtrack.len, backtrack.const_array(),
-				 input.len, input.const_array(),
-				 lookahead.len, lookahead.const_array(),
-				 lookup.len, lookup.const_array(),
+				 backtrack.len, backtrack.array(),
+				 input.len, input.array(),
+				 lookahead.len, lookahead.array(),
+				 lookup.len, lookup.array(),
 				 lookup_context);
     return false;
   }
@@ -755,10 +755,10 @@ struct ChainContextFormat3
       {ConstCharP(this), ConstCharP(this), ConstCharP(this)}
     };
     return chain_context_lookup (APPLY_ARG,
-				 backtrack.len, (const USHORT *) backtrack.const_array(),
-				 input.len, (const USHORT *) input.const_array() + 1,
-				 lookahead.len, (const USHORT *) lookahead.const_array(),
-				 lookup.len, lookup.const_array(),
+				 backtrack.len, (const USHORT *) backtrack.array(),
+				 input.len, (const USHORT *) input.array() + 1,
+				 lookahead.len, (const USHORT *) lookahead.array(),
+				 lookup.len, lookup.array(),
 				 lookup_context);
     return false;
   }
commit 2e2f43edf2f49f4047e28b1ce2ea95938536de9c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 22:30:36 2010 -0400

    Remove ArrayAfter, use StructAfter in place

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 7c87705..2176e38 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -48,6 +48,8 @@ template <typename Type> inline char * DeConstCharP (const Type X) { return (cha
 #define CAST(T,X,Ofs) 		(*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
 
 
+/* StructAfter<T>(X) returns the struct T& that is placed after X.
+ * Works with X of variable size also. */
 template<typename Type, typename TObject>
 inline const Type& StructAfter(const TObject &X)
 {
@@ -59,17 +61,6 @@ inline Type& StructAfter(TObject &X)
   return * reinterpret_cast<Type*> (CharP (&X) + X.get_size());
 }
 
-template<typename Type, typename TObject>
-inline const Type* ArrayAfter(const TObject &X)
-{
-  return reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
-}
-template<typename Type, typename TObject>
-inline Type* ArrayAfter(TObject &X)
-{
-  return reinterpret_cast<Type*> (CharP (&X) + X.get_size());
-}
-
 
 /*
  * Class features
@@ -522,8 +513,8 @@ struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
 template <typename LenType, typename Type>
 struct GenericArrayOf
 {
-  const Type *const_array(void) const { return ArrayAfter<Type> (len); }
-  Type *array(void) { return ArrayAfter<Type> (len); }
+  const Type *const_array(void) const { return &StructAfter<Type> (len); }
+  Type *array(void) { return &StructAfter<Type> (len); }
 
   const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
   {
@@ -640,8 +631,8 @@ struct OffsetListOf : OffsetArrayOf<Type>
 template <typename Type>
 struct HeadlessArrayOf
 {
-  const Type *const_array(void) const { return ArrayAfter<Type> (len); }
-  Type *array(void) { return ArrayAfter<Type> (len); }
+  const Type *const_array(void) const { return &StructAfter<Type> (len); }
+  Type *array(void) { return &StructAfter<Type> (len); }
 
   inline const Type& operator [] (unsigned int i) const
   {
commit e961c86c579fd98ee604342a9c70c4e7f8d4f220
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 15:56:11 2010 -0400

    Convert NEXT() and ARRAY_AFTER() macros to templates

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 0ccec1d..7c87705 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -39,19 +39,37 @@
  * Casts
  */
 
-template <typename Type> const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
-template <typename Type> char * CharP (Type X) { return reinterpret_cast<char *>(X); }
-template <typename Type> char * DeConstCharP (const Type X) { return (char *) reinterpret_cast<const char *>(X); }
+template <typename Type> inline const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
+template <typename Type> inline char * CharP (Type X) { return reinterpret_cast<char *>(X); }
+template <typename Type> inline char * DeConstCharP (const Type X) { return (char *) reinterpret_cast<const char *>(X); }
 
 #define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + Ofs)))
 #define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)ConstCharP(&(X)) + Ofs)))
 #define CAST(T,X,Ofs) 		(*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
 
-#define CONST_NEXT(T,X)		(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + (X).get_size ())))
-#define NEXT(T,X)		(*(reinterpret_cast<T *>(CharP(&(X)) + (X).get_size ())))
 
-#define CONST_ARRAY_AFTER(T,X)	((reinterpret_cast<const T *>(ConstCharP(&(X)) + X.get_size ())))
-#define ARRAY_AFTER(T,X)	((reinterpret_cast<T *>(CharP(&(X)) + X.get_size ())))
+template<typename Type, typename TObject>
+inline const Type& StructAfter(const TObject &X)
+{
+  return * reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
+}
+template<typename Type, typename TObject>
+inline Type& StructAfter(TObject &X)
+{
+  return * reinterpret_cast<Type*> (CharP (&X) + X.get_size());
+}
+
+template<typename Type, typename TObject>
+inline const Type* ArrayAfter(const TObject &X)
+{
+  return reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
+}
+template<typename Type, typename TObject>
+inline Type* ArrayAfter(TObject &X)
+{
+  return reinterpret_cast<Type*> (CharP (&X) + X.get_size());
+}
+
 
 /*
  * Class features
@@ -504,8 +522,8 @@ struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
 template <typename LenType, typename Type>
 struct GenericArrayOf
 {
-  const Type *const_array(void) const { return CONST_ARRAY_AFTER (Type, len); }
-  Type *array(void) { return ARRAY_AFTER (Type, len); }
+  const Type *const_array(void) const { return ArrayAfter<Type> (len); }
+  Type *array(void) { return ArrayAfter<Type> (len); }
 
   const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
   {
@@ -622,8 +640,8 @@ struct OffsetListOf : OffsetArrayOf<Type>
 template <typename Type>
 struct HeadlessArrayOf
 {
-  const Type *const_array(void) const { return CONST_ARRAY_AFTER (Type, len); }
-  Type *array(void) { return ARRAY_AFTER (Type, len); }
+  const Type *const_array(void) const { return ArrayAfter<Type> (len); }
+  Type *array(void) { return ArrayAfter<Type> (len); }
 
   inline const Type& operator [] (unsigned int i) const
   {
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 05daebd..595e640 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -287,7 +287,7 @@ struct Lookup
     unsigned int flag = lookupFlag;
     if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet))
     {
-      const USHORT &markFilteringSet = CONST_NEXT (USHORT, subTable);
+      const USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
       flag += (markFilteringSet << 16);
     }
     return flag;
@@ -298,7 +298,7 @@ struct Lookup
     if (!(SANITIZE (lookupType) && SANITIZE (lookupFlag) && SANITIZE_THIS (subTable))) return false;
     if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
     {
-      USHORT &markFilteringSet = NEXT (USHORT, subTable);
+      USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
       if (!SANITIZE (markFilteringSet)) return false;
     }
     return true;
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index a828337..8299116 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -586,8 +586,8 @@ struct ReverseChainSingleSubstFormat1
     if (HB_LIKELY (index == NOT_COVERED))
       return false;
 
-    const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
-    const ArrayOf<GlyphID> &substitute = CONST_NEXT (ArrayOf<GlyphID>, lookahead);
+    const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
+    const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
 
     if (match_backtrack (APPLY_ARG,
 			 backtrack.len, (USHORT *) backtrack.const_array(),
@@ -609,10 +609,10 @@ struct ReverseChainSingleSubstFormat1
     TRACE_SANITIZE ();
     if (!SANITIZE_THIS2 (coverage, backtrack))
       return false;
-    OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, backtrack);
+    OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
     if (!SANITIZE_THIS (lookahead))
       return false;
-    ArrayOf<GlyphID> &substitute = NEXT (ArrayOf<GlyphID>, lookahead);
+    ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
     return SANITIZE (substitute);
   }
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 9418e71..cc0542b 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -569,9 +569,9 @@ struct ChainRule
   inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
   {
     TRACE_APPLY ();
-    const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack);
-    const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input);
-    const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
+    const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
+    const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
+    const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return chain_context_lookup (APPLY_ARG,
 				 backtrack.len, backtrack.const_array(),
 				 input.len, input.const_array(),
@@ -585,11 +585,11 @@ struct ChainRule
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     if (!SANITIZE (backtrack)) return false;
-    HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack);
+    HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
     if (!SANITIZE (input)) return false;
-    ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input);
+    ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
     if (!SANITIZE (lookahead)) return false;
-    ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
+    ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return SANITIZE (lookup);
   }
 
@@ -742,14 +742,14 @@ struct ChainContextFormat3
   inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
+    const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
 
     unsigned int index = (this+input[0]) (IN_CURGLYPH ());
     if (HB_LIKELY (index == NOT_COVERED))
       return false;
 
-    const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input);
-    const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
+    const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
+    const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     struct ChainContextLookupContext lookup_context = {
       {match_coverage, apply_func},
       {ConstCharP(this), ConstCharP(this), ConstCharP(this)}
@@ -766,11 +766,11 @@ struct ChainContextFormat3
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     if (!SANITIZE_THIS (backtrack)) return false;
-    OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack);
+    OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
     if (!SANITIZE_THIS (input)) return false;
-    OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input);
+    OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
     if (!SANITIZE_THIS (lookahead)) return false;
-    ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
+    ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return SANITIZE (lookup);
   }
 
commit 198facdc55756cb48cdfb8ba7fa50916fac54ec3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Apr 21 13:35:36 2010 -0400

    Use templates for const char * casts

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index ce5140f..c15fffd 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -52,7 +52,7 @@ typedef struct TableDirectory
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE (tag) &&
-	   SANITIZE_MEM (CONST_CHARP(base) + (unsigned long) offset, length);
+	   SANITIZE_MEM (ConstCharP(base) + (unsigned long) offset, length);
   }
 
   Tag		tag;		/* 4-byte identifier. */
@@ -150,7 +150,7 @@ struct TTCHeader
     TRACE_SANITIZE ();
     if (!SANITIZE (version)) return false;
     if (version.major < 1 || version.major > 2) return true;
-    return table.sanitize (SANITIZE_ARG, CONST_CHARP(this), CONST_CHARP(this));
+    return table.sanitize (SANITIZE_ARG, ConstCharP(this), ConstCharP(this));
   }
 
   private:
@@ -180,8 +180,8 @@ struct OpenTypeFontFile
   {
     switch (tag) {
     default: return 0;
-    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this)).get_face_count ();
-    case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face_count ();
+    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (ConstCharP(this)).get_face_count ();
+    case TTCTag: return TTCHeader::get_for_data (ConstCharP(this)).get_face_count ();
     }
   }
   inline const OpenTypeFontFace& get_face (unsigned int i) const
@@ -191,8 +191,8 @@ struct OpenTypeFontFile
     /* Note: for non-collection SFNT data we ignore index.  This is because
      * Apple dfont container is a container of SFNT's.  So each SFNT is a
      * non-TTC, but the index is more than zero. */
-    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this));
-    case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face (i);
+    case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (ConstCharP(this));
+    case TTCTag: return TTCHeader::get_for_data (ConstCharP(this)).get_face (i);
     }
   }
 
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 94d5b5e..0ccec1d 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -39,19 +39,19 @@
  * Casts
  */
 
-#define CONST_CHARP(X)		(reinterpret_cast<const char *>(X))
-#define DECONST_CHARP(X)	((char *)reinterpret_cast<const char *>(X))
-#define CHARP(X)		(reinterpret_cast<char *>(X))
+template <typename Type> const char * ConstCharP (const Type X) { return reinterpret_cast<const char *>(X); }
+template <typename Type> char * CharP (Type X) { return reinterpret_cast<char *>(X); }
+template <typename Type> char * DeConstCharP (const Type X) { return (char *) reinterpret_cast<const char *>(X); }
 
-#define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + Ofs)))
-#define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)CONST_CHARP(&(X)) + Ofs)))
-#define CAST(T,X,Ofs) 		(*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs)))
+#define CONST_CAST(T,X,Ofs)	(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + Ofs)))
+#define DECONST_CAST(T,X,Ofs)	(*(reinterpret_cast<T *>((char *)ConstCharP(&(X)) + Ofs)))
+#define CAST(T,X,Ofs) 		(*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
 
-#define CONST_NEXT(T,X)		(*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + (X).get_size ())))
-#define NEXT(T,X)		(*(reinterpret_cast<T *>(CHARP(&(X)) + (X).get_size ())))
+#define CONST_NEXT(T,X)		(*(reinterpret_cast<const T *>(ConstCharP(&(X)) + (X).get_size ())))
+#define NEXT(T,X)		(*(reinterpret_cast<T *>(CharP(&(X)) + (X).get_size ())))
 
-#define CONST_ARRAY_AFTER(T,X)	((reinterpret_cast<const T *>(CONST_CHARP(&(X)) + X.get_size ())))
-#define ARRAY_AFTER(T,X)	((reinterpret_cast<T *>(CHARP(&(X)) + X.get_size ())))
+#define CONST_ARRAY_AFTER(T,X)	((reinterpret_cast<const T *>(ConstCharP(&(X)) + X.get_size ())))
+#define ARRAY_AFTER(T,X)	((reinterpret_cast<T *>(CharP(&(X)) + X.get_size ())))
 
 /*
  * Class features
@@ -119,7 +119,7 @@ inline const Type& Null<Type> () { \
 	HB_STMT_START { \
 	    if (sanitize_depth < HB_DEBUG_SANITIZE) \
 		fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \
-			 (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
+			 (ConstCharP (this) == ConstCharP (&NullPool)) ? 0 : this, \
 			 sanitize_depth, sanitize_depth, \
 			 __PRETTY_FUNCTION__); \
 	} HB_STMT_END
@@ -237,7 +237,7 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 #define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG))
 #define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y))
 
-#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CONST_CHARP(this)))
+#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, ConstCharP(this)))
 #define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y))
 #define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z))
 
@@ -248,13 +248,13 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
 #define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
 #define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ())
 
-#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CONST_CHARP(B), (L)))
+#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, ConstCharP(B), (L)))
 
-#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CONST_CHARP(A), S, L))
+#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, ConstCharP(A), S, L))
 
 #define NEUTER(Var, Val) \
 	(SANITIZE_OBJ (Var) && \
-	 _hb_sanitize_edit (SANITIZE_ARG, CONST_CHARP(&(Var)), sizeof (Var)) && \
+	 _hb_sanitize_edit (SANITIZE_ARG, ConstCharP(&(Var)), sizeof (Var)) && \
 	 ((Var).set (Val), true))
 
 
@@ -275,7 +275,7 @@ struct Sanitizer
 
     _hb_sanitize_init (&context, blob);
 
-    Type *t = &CAST (Type, *DECONST_CHARP(context.start), 0);
+    Type *t = &CAST (Type, *DeConstCharP(context.start), 0);
 
     sane = t->sanitize (SANITIZE_ARG_INIT);
     if (sane) {
@@ -389,8 +389,8 @@ ASSERT_SIZE (LONG, 4);
 struct Tag : ULONG
 {
   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
-  inline operator const char* (void) const { return CONST_CHARP(this); }
-  inline operator char* (void) { return CHARP(this); }
+  inline operator const char* (void) const { return ConstCharP(this); }
+  inline operator char* (void) { return CharP(this); }
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
@@ -462,7 +462,7 @@ struct GenericOffsetTo : OffsetType
   {
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return Null(Type);
-    return CONST_CAST(Type, *CONST_CHARP(base), offset);
+    return CONST_CAST(Type, *ConstCharP(base), offset);
   }
 
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
@@ -470,21 +470,21 @@ struct GenericOffsetTo : OffsetType
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE (CAST(Type, *DECONST_CHARP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE (CAST(Type, *DeConstCharP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
   inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) {
     TRACE_SANITIZE ();
     if (!SANITIZE_SELF ()) return false;
     unsigned int offset = *this;
     if (HB_UNLIKELY (!offset)) return true;
-    return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
+    return SANITIZE_BASE (CAST(Type, *DeConstCharP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
   }
 };
 template <typename Base, typename OffsetType, typename Type>
@@ -608,11 +608,11 @@ struct OffsetListOf : OffsetArrayOf<Type>
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this));
+    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this));
   }
   inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this), user_data);
+    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this), user_data);
   }
 };
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 6c6d7ac..05daebd 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -111,7 +111,7 @@ struct RecordListOf : RecordArrayOf<Type>
 
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
-    return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this));
+    return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, ConstCharP(this));
   }
 };
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 9598831..da80d99 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -413,7 +413,7 @@ struct SinglePosFormat1
     if (HB_LIKELY (index == NOT_COVERED))
       return false;
 
-    valueFormat.apply_value (context, CONST_CHARP(this), values, CURPOSITION ());
+    valueFormat.apply_value (context, ConstCharP(this), values, CURPOSITION ());
 
     buffer->in_pos++;
     return true;
@@ -422,7 +422,7 @@ struct SinglePosFormat1
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
-	   valueFormat.sanitize_value (SANITIZE_ARG, CHARP(this), values);
+	   valueFormat.sanitize_value (SANITIZE_ARG, CharP(this), values);
   }
 
   private:
@@ -453,7 +453,7 @@ struct SinglePosFormat2
     if (HB_LIKELY (index >= valueCount))
       return false;
 
-    valueFormat.apply_value (context, CONST_CHARP(this),
+    valueFormat.apply_value (context, ConstCharP(this),
 			     &values[index * valueFormat.get_len ()],
 			     CURPOSITION ());
 
@@ -464,7 +464,7 @@ struct SinglePosFormat2
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
-	   valueFormat.sanitize_values (SANITIZE_ARG, CHARP(this), values, valueCount);
+	   valueFormat.sanitize_values (SANITIZE_ARG, CharP(this), values, valueCount);
   }
 
   private:
@@ -582,8 +582,8 @@ struct PairPosFormat1
     {
       if (IN_GLYPH (j) == record->secondGlyph)
       {
-	valueFormat1.apply_value (context, CONST_CHARP(this), &record->values[0], CURPOSITION ());
-	valueFormat2.apply_value (context, CONST_CHARP(this), &record->values[len1], POSITION (j));
+	valueFormat1.apply_value (context, ConstCharP(this), &record->values[0], CURPOSITION ());
+	valueFormat2.apply_value (context, ConstCharP(this), &record->values[len1], POSITION (j));
 	if (len2)
 	  j++;
 	buffer->in_pos = j;
@@ -602,7 +602,7 @@ struct PairPosFormat1
     unsigned int len2 = valueFormat2.get_len ();
 
     if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
-	  pairSet.sanitize (SANITIZE_ARG, CONST_CHARP(this), len1 + len2))) return false;
+	  pairSet.sanitize (SANITIZE_ARG, ConstCharP(this), len1 + len2))) return false;
 
     if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
 
@@ -614,8 +614,8 @@ struct PairPosFormat1
 
       unsigned int count2 = pair_set.len;
       const PairValueRecord *record = pair_set.array;
-      if (!(valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[0], count2, stride) &&
-	    valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[len1], count2, stride)))
+      if (!(valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CharP(this), &record->values[0], count2, stride) &&
+	    valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CharP(this), &record->values[len1], count2, stride)))
         return false;
     }
 
@@ -673,8 +673,8 @@ struct PairPosFormat2
       return false;
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
-    valueFormat1.apply_value (context, CONST_CHARP(this), v, CURPOSITION ());
-    valueFormat2.apply_value (context, CONST_CHARP(this), v + len1, POSITION (j));
+    valueFormat1.apply_value (context, ConstCharP(this), v, CURPOSITION ());
+    valueFormat2.apply_value (context, ConstCharP(this), v + len1, POSITION (j));
 
     if (len2)
       j++;
@@ -694,8 +694,8 @@ struct PairPosFormat2
     unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
     unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
     return SANITIZE_ARRAY (values, record_size, count) &&
-	   valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[0], count, stride) &&
-	   valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[len1], count, stride);
+	   valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CharP(this), &values[0], count, stride) &&
+	   valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CharP(this), &values[len1], count, stride);
   }
 
   private:
@@ -1050,7 +1050,7 @@ struct MarkBasePosFormat1
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, baseCoverage) &&
-	   SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
+	   SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
   }
 
   private:
@@ -1171,7 +1171,7 @@ struct MarkLigPosFormat1
     TRACE_SANITIZE ();
     return SANITIZE_SELF () &&
 	   SANITIZE_THIS2 (markCoverage, ligatureCoverage) &&
-	   SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
+	   SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
   }
 
   private:
@@ -1270,7 +1270,7 @@ struct MarkMarkPosFormat1
   inline bool sanitize (SANITIZE_ARG_DEF) {
     TRACE_SANITIZE ();
     return SANITIZE_SELF () && SANITIZE_THIS2 (mark1Coverage, mark2Coverage) &&
-	   SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
+	   SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, ConstCharP(this), classCount);
   }
 
   private:
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index d979749..a828337 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -591,10 +591,10 @@ struct ReverseChainSingleSubstFormat1
 
     if (match_backtrack (APPLY_ARG,
 			 backtrack.len, (USHORT *) backtrack.const_array(),
-			 match_coverage, CONST_CHARP(this)) &&
+			 match_coverage, ConstCharP(this)) &&
         match_lookahead (APPLY_ARG,
 			 lookahead.len, (USHORT *) lookahead.const_array(),
-			 match_coverage, CONST_CHARP(this),
+			 match_coverage, ConstCharP(this),
 			 1))
     {
       IN_CURGLYPH () = substitute[index];
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index c006191..9418e71 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -44,7 +44,7 @@
 	HB_STMT_START { \
 	    if (apply_depth < HB_DEBUG_APPLY) \
 		fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
-			 (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
+			 (ConstCharP (this) == ConstCharP (&NullPool)) ? 0 : this, \
 			 apply_depth, apply_depth, \
 			 __PRETTY_FUNCTION__); \
 	} HB_STMT_END
@@ -411,7 +411,7 @@ struct ContextFormat2
      */
     struct ContextLookupContext lookup_context = {
      {match_class, apply_func},
-      CONST_CHARP(&class_def)
+      ConstCharP(&class_def)
     };
     return rule_set.apply (APPLY_ARG, lookup_context);
   }
@@ -451,7 +451,7 @@ struct ContextFormat3
     const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, coverage[0].get_size () * glyphCount);
     struct ContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-       CONST_CHARP(this)
+       ConstCharP(this)
     };
     return context_lookup (APPLY_ARG,
 			   glyphCount, (const USHORT *) (coverage + 1),
@@ -696,9 +696,9 @@ struct ChainContextFormat2
      */
     struct ChainContextLookupContext lookup_context = {
      {match_class, apply_func},
-     {CONST_CHARP(&backtrack_class_def),
-      CONST_CHARP(&input_class_def),
-      CONST_CHARP(&lookahead_class_def)}
+     {ConstCharP(&backtrack_class_def),
+      ConstCharP(&input_class_def),
+      ConstCharP(&lookahead_class_def)}
     };
     return rule_set.apply (APPLY_ARG, lookup_context);
   }
@@ -752,7 +752,7 @@ struct ChainContextFormat3
     const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
     struct ChainContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-      {CONST_CHARP(this), CONST_CHARP(this), CONST_CHARP(this)}
+      {ConstCharP(this), ConstCharP(this), ConstCharP(this)}
     };
     return chain_context_lookup (APPLY_ARG,
 				 backtrack.len, (const USHORT *) backtrack.const_array(),



More information about the HarfBuzz mailing list