hb-open-type-private.hh revision bb029af943faa9905e652d58856998687e60c31d
1/*
2 * Copyright (C) 2007,2008,2009,2010  Red Hat, Inc.
3 *
4 *  This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Red Hat Author(s): Behdad Esfahbod
25 */
26
27#ifndef HB_OPEN_TYPES_PRIVATE_HH
28#define HB_OPEN_TYPES_PRIVATE_HH
29
30#include "hb-private.h"
31
32#include "hb-blob.h"
33
34
35/* Table/script/language-system/feature/... not found */
36#define NO_INDEX		((unsigned int) 0xFFFF)
37
38
39
40/*
41 * Casts
42 */
43
44/* Cast to "const char *" and "char *" */
45template <typename Type>
46inline const char * CharP (const Type* X)
47{ return reinterpret_cast<const char *>(X); }
48template <typename Type>
49inline char * CharP (Type* X)
50{ return reinterpret_cast<char *>(X); }
51
52/* Cast to struct T, reference to reference */
53template<typename Type, typename TObject>
54inline const Type& CastR(const TObject &X)
55{ return reinterpret_cast<const Type&> (X); }
56template<typename Type, typename TObject>
57inline Type& CastR(TObject &X)
58{ return reinterpret_cast<Type&> (X); }
59
60/* Cast to struct T, pointer to pointer */
61template<typename Type, typename TObject>
62inline const Type* CastP(const TObject *X)
63{ return reinterpret_cast<const Type*> (X); }
64template<typename Type, typename TObject>
65inline Type* CastP(TObject *X)
66{ return reinterpret_cast<Type*> (X); }
67
68/* StructAtOffset<T>(X,Ofs) returns the struct T& that is placed at memory
69 * location of X plus Ofs bytes. */
70template<typename Type, typename TObject>
71inline const Type& StructAtOffset(const TObject &X, unsigned int offset)
72{ return * reinterpret_cast<const Type*> (CharP(&X) + offset); }
73template<typename Type, typename TObject>
74inline Type& StructAtOffset(TObject &X, unsigned int offset)
75{ return * reinterpret_cast<Type*> (CharP(&X) + offset); }
76
77/* StructAfter<T>(X) returns the struct T& that is placed after X.
78 * Works with X of variable size also.  X must implement get_size() */
79template<typename Type, typename TObject>
80inline const Type& StructAfter(const TObject &X)
81{ return StructAtOffset<Type>(X, X.get_size()); }
82template<typename Type, typename TObject>
83inline Type& StructAfter(TObject &X)
84{ return StructAtOffset<Type>(X, X.get_size()); }
85
86
87
88/*
89 * Null objects
90 */
91
92/* Global nul-content Null pool.  Enlarge as necessary. */
93static const void *_NullPool[32 / sizeof (void *)];
94
95/* Generic template for nul-content sizeof-sized Null objects. */
96template <typename Type>
97static inline const Type& Null () {
98  ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
99  return *CastP<Type> (_NullPool);
100}
101
102/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
103#define DEFINE_NULL_DATA(Type, size, data) \
104static const char _Null##Type[size + 1] = data; /* +1 is for nul-termination in data */ \
105template <> \
106inline const Type& Null<Type> () { \
107  return *CastP<Type> (_Null##Type); \
108} /* The following line really exists such that we end in a place needing semicolon */ \
109ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
110
111/* Accessor macro. */
112#define Null(Type) Null<Type>()
113
114
115
116/*
117 * Sanitize
118 */
119
120#ifndef HB_DEBUG_SANITIZE
121#define HB_DEBUG_SANITIZE HB_DEBUG+0
122#endif
123
124#define TRACE_SANITIZE() \
125	HB_STMT_START { \
126	  if (HB_DEBUG_SANITIZE) \
127		  _hb_trace ("SANITIZE", HB_FUNC, this, sanitize_depth, HB_DEBUG_SANITIZE); \
128	} HB_STMT_END
129
130
131#define SANITIZE_ARG_DEF \
132	hb_sanitize_context_t *context, \
133	unsigned int sanitize_depth HB_UNUSED
134#define SANITIZE_ARG \
135	context, \
136	(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
137
138struct hb_sanitize_context_t
139{
140  const char *start, *end;
141  hb_bool_t writable;
142  unsigned int edit_count;
143};
144
145
146static inline void
147_hb_sanitize_init (hb_sanitize_context_t *context,
148		   hb_blob_t *blob)
149{
150  context->start = hb_blob_lock (blob);
151  context->end = context->start + hb_blob_get_length (blob);
152  context->writable = hb_blob_is_writable (blob);
153  context->edit_count = 0;
154
155  if (HB_DEBUG_SANITIZE)
156    fprintf (stderr, "sanitize %p init [%p..%p] (%u bytes)\n",
157	     blob, context->start, context->end, context->end - context->start);
158}
159
160static inline void
161_hb_sanitize_fini (hb_sanitize_context_t *context HB_UNUSED,
162		   hb_blob_t *blob)
163{
164  if (HB_DEBUG_SANITIZE)
165    fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
166	     blob, context->start, context->end, context->edit_count);
167
168  hb_blob_unlock (blob);
169}
170
171static inline bool
172_hb_sanitize_check (SANITIZE_ARG_DEF,
173		    const char *base,
174		    unsigned int len)
175{
176  bool ret = context->start <= base &&
177	     base <= context->end &&
178	     (unsigned int) (context->end - base) >= len;
179
180  if (HB_DEBUG_SANITIZE && (int) sanitize_depth < (int) HB_DEBUG_SANITIZE) \
181    fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
182	     base,
183	     sanitize_depth, sanitize_depth,
184	     base, base+len, len,
185	     context->start, context->end,
186	     ret ? "pass" : "FAIL");
187
188  return ret;
189}
190
191static inline bool
192_hb_sanitize_array (SANITIZE_ARG_DEF,
193		    const char *base,
194		    unsigned int record_size,
195		    unsigned int len)
196{
197  bool overflows = len >= ((unsigned int) -1) / record_size;
198
199
200  if (HB_DEBUG_SANITIZE && (int) sanitize_depth < (int) HB_DEBUG_SANITIZE)
201    fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
202	     base,
203	     sanitize_depth, sanitize_depth,
204	     base, base + (record_size * len), record_size, len, (unsigned long) record_size * len,
205	     context->start, context->end,
206	     !overflows ? "does not overflow" : "OVERFLOWS FAIL");
207
208  return likely (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len);
209}
210
211static inline bool
212_hb_sanitize_edit (SANITIZE_ARG_DEF,
213		   const char *base HB_UNUSED,
214		   unsigned int len HB_UNUSED)
215{
216  context->edit_count++;
217
218  if (HB_DEBUG_SANITIZE && (int) sanitize_depth < (int) HB_DEBUG_SANITIZE)
219    fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
220	     base,
221	     sanitize_depth, sanitize_depth,
222	     context->edit_count,
223	     base, base+len, len,
224	     context->start, context->end,
225	     context->writable ? "granted" : "REJECTED");
226
227  return context->writable;
228}
229
230#define SANITIZE(X) likely ((X).sanitize (SANITIZE_ARG))
231
232#define SANITIZE_WITH_BASE(B,X) likely ((X).sanitize (SANITIZE_ARG, CharP(B)))
233
234#define SANITIZE_SELF() SANITIZE_MEM(this, sizeof (*this))
235
236#define SANITIZE_MEM(B,L) likely (_hb_sanitize_check (SANITIZE_ARG, CharP(B), (L)))
237
238#define SANITIZE_ARRAY(A,S,L) likely (_hb_sanitize_array (SANITIZE_ARG, CharP(A), S, L))
239
240
241/* Template to sanitize an object. */
242template <typename Type>
243struct Sanitizer
244{
245  static hb_blob_t *sanitize (hb_blob_t *blob) {
246    hb_sanitize_context_t context[1];
247    unsigned int sanitize_depth = 0;
248    bool sane;
249
250    /* TODO is_sane() stuff */
251
252  retry:
253    if (HB_DEBUG_SANITIZE)
254      fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC);
255
256    _hb_sanitize_init (context, blob);
257
258    Type *t = CastP<Type> (const_cast<char *> (context->start));
259
260    sane = t->sanitize (SANITIZE_ARG);
261    if (sane) {
262      if (context->edit_count) {
263	if (HB_DEBUG_SANITIZE)
264	  fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
265		   blob, context->edit_count, HB_FUNC);
266
267        /* sanitize again to ensure no toe-stepping */
268        context->edit_count = 0;
269	sane = t->sanitize (SANITIZE_ARG);
270	if (context->edit_count) {
271	  if (HB_DEBUG_SANITIZE)
272	    fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
273		     blob, context->edit_count, HB_FUNC);
274	  sane = false;
275	}
276      }
277      _hb_sanitize_fini (context, blob);
278    } else {
279      unsigned int edit_count = context->edit_count;
280      _hb_sanitize_fini (context, blob);
281      if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
282        /* ok, we made it writable by relocating.  try again */
283	if (HB_DEBUG_SANITIZE)
284	  fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC);
285        goto retry;
286      }
287    }
288
289    if (HB_DEBUG_SANITIZE)
290      fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", HB_FUNC);
291    if (sane)
292      return blob;
293    else {
294      hb_blob_destroy (blob);
295      return hb_blob_create_empty ();
296    }
297  }
298};
299
300
301
302
303/*
304 *
305 * The OpenType Font File: Data Types
306 */
307
308
309/* "The following data types are used in the OpenType font file.
310 *  All OpenType fonts use Motorola-style byte ordering (Big Endian):" */
311
312/*
313 * Int types
314 */
315
316
317template <typename Type, int Bytes> class BEInt;
318
319/* LONGTERMTODO: On machines allowing unaligned access, we can make the
320 * following tighter by using byteswap instructions on ints directly. */
321template <typename Type>
322class BEInt<Type, 2>
323{
324  public:
325  inline class BEInt<Type,2>& operator = (Type i) { hb_be_uint16_put (v,i); return *this; }
326  inline operator Type () const { return hb_be_uint16_get (v); }
327  inline bool operator == (const BEInt<Type, 2>& o) const { return hb_be_uint16_cmp (v, o.v); }
328  inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); }
329  private: uint8_t v[2];
330};
331template <typename Type>
332class BEInt<Type, 4>
333{
334  public:
335  inline class BEInt<Type,4>& operator = (Type i) { hb_be_uint32_put (v,i); return *this; }
336  inline operator Type () const { return hb_be_uint32_get (v); }
337  inline bool operator == (const BEInt<Type, 4>& o) const { return hb_be_uint32_cmp (v, o.v); }
338  inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); }
339  private: uint8_t v[4];
340};
341
342/* Integer types in big-endian order and no alignment requirement */
343template <typename Type>
344struct IntType
345{
346  static inline unsigned int get_size () { return sizeof (Type); }
347  inline void set (Type i) { v = i; }
348  inline operator Type(void) const { return v; }
349  inline bool operator == (const IntType<Type> &o) const { return v == o.v; }
350  inline bool operator != (const IntType<Type> &o) const { return v != o.v; }
351  inline bool sanitize (SANITIZE_ARG_DEF) {
352    TRACE_SANITIZE ();
353    return SANITIZE_SELF ();
354  }
355  private: BEInt<Type, sizeof (Type)> v;
356};
357
358typedef IntType<uint16_t> USHORT;	/* 16-bit unsigned integer. */
359typedef IntType<int16_t>  SHORT;	/* 16-bit signed integer. */
360typedef IntType<uint32_t> ULONG;	/* 32-bit unsigned integer. */
361typedef IntType<int32_t>  LONG;		/* 32-bit signed integer. */
362
363ASSERT_SIZE (USHORT, 2);
364ASSERT_SIZE (SHORT, 2);
365ASSERT_SIZE (ULONG, 4);
366ASSERT_SIZE (LONG, 4);
367
368/* Array of four uint8s (length = 32 bits) used to identify a script, language
369 * system, feature, or baseline */
370struct Tag : ULONG
371{
372  /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
373  inline operator const char* (void) const { return CharP(this); }
374  inline operator char* (void) { return CharP(this); }
375};
376ASSERT_SIZE (Tag, 4);
377DEFINE_NULL_DATA (Tag, 4, "    ");
378
379/* Glyph index number, same as uint16 (length = 16 bits) */
380typedef USHORT GlyphID;
381
382/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */
383typedef USHORT Offset;
384
385/* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */
386typedef ULONG LongOffset;
387
388
389/* CheckSum */
390struct CheckSum : ULONG
391{
392  static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
393  {
394    uint32_t Sum = 0L;
395    ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::get_size ();
396
397    while (Table < EndPtr)
398      Sum += *Table++;
399    return Sum;
400  }
401};
402ASSERT_SIZE (CheckSum, 4);
403
404
405/*
406 * Version Numbers
407 */
408
409struct FixedVersion
410{
411  inline operator uint32_t (void) const { return (major << 16) + minor; }
412
413  inline bool sanitize (SANITIZE_ARG_DEF) {
414    TRACE_SANITIZE ();
415    return SANITIZE_SELF ();
416  }
417
418  USHORT major;
419  USHORT minor;
420};
421ASSERT_SIZE (FixedVersion, 4);
422
423
424
425/*
426 * Template subclasses of Offset and LongOffset that do the dereferencing.
427 * Use: (base+offset)
428 */
429
430template <typename OffsetType, typename Type>
431struct GenericOffsetTo : OffsetType
432{
433  inline const Type& operator () (const void *base) const
434  {
435    unsigned int offset = *this;
436    if (unlikely (!offset)) return Null(Type);
437    return StructAtOffset<Type> (*CharP(base), offset);
438  }
439
440  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
441    TRACE_SANITIZE ();
442    if (!SANITIZE_SELF ()) return false;
443    unsigned int offset = *this;
444    if (unlikely (!offset)) return true;
445    Type &obj = StructAtOffset<Type> (*CharP(base), offset);
446    return likely (obj.sanitize (SANITIZE_ARG)) || neuter (SANITIZE_ARG);
447  }
448  inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
449    TRACE_SANITIZE ();
450    if (!SANITIZE_SELF ()) return false;
451    unsigned int offset = *this;
452    if (unlikely (!offset)) return true;
453    Type &obj = StructAtOffset<Type> (*CharP(base), offset);
454    return likely (obj.sanitize (SANITIZE_ARG, base2)) || neuter (SANITIZE_ARG);
455  }
456  inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
457    TRACE_SANITIZE ();
458    if (!SANITIZE_SELF ()) return false;
459    unsigned int offset = *this;
460    if (unlikely (!offset)) return true;
461    Type &obj = StructAtOffset<Type> (*CharP(base), offset);
462    return likely (obj.sanitize (SANITIZE_ARG, user_data)) || neuter (SANITIZE_ARG);
463  }
464
465  private:
466  /* Set the offset to Null */
467  inline bool neuter (SANITIZE_ARG_DEF) {
468    if (_hb_sanitize_edit (SANITIZE_ARG, CharP(this), this->get_size ())) {
469      this->set (0); /* 0 is Null offset */
470      return true;
471    }
472    return false;
473  }
474};
475template <typename Base, typename OffsetType, typename Type>
476inline const Type& operator + (const Base &base, GenericOffsetTo<OffsetType, Type> offset) { return offset (base); }
477
478template <typename Type>
479struct OffsetTo : GenericOffsetTo<Offset, Type> {};
480
481template <typename Type>
482struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
483
484
485/*
486 * Array Types
487 */
488
489template <typename LenType, typename Type>
490struct GenericArrayOf
491{
492  const Type *array(void) const { return &StructAfter<Type> (len); }
493  Type *array(void) { return &StructAfter<Type> (len); }
494
495  const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
496  {
497    unsigned int count = len;
498    if (unlikely (start_offset > count))
499      count = 0;
500    else
501      count -= start_offset;
502    count = MIN (count, *pcount);
503    *pcount = count;
504    return array() + start_offset;
505  }
506
507  inline const Type& operator [] (unsigned int i) const
508  {
509    if (unlikely (i >= len)) return Null(Type);
510    return array()[i];
511  }
512  inline unsigned int get_size () const
513  { return len.get_size () + len * Type::get_size (); }
514
515  inline bool sanitize (SANITIZE_ARG_DEF) {
516    TRACE_SANITIZE ();
517    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
518    /* Note: for structs that do not reference other structs,
519     * we do not need to call their sanitize() as we already did
520     * a bound check on the aggregate array size, hence the return.
521     */
522    return true;
523    /* We do keep this code though to make sure the structs pointed
524     * to do have a simple sanitize(), ie. they do not reference
525     * other structs. */
526    unsigned int count = len;
527    for (unsigned int i = 0; i < count; i++)
528      if (!SANITIZE (array()[i]))
529        return false;
530    return true;
531  }
532  inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
533    TRACE_SANITIZE ();
534    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
535    unsigned int count = len;
536    for (unsigned int i = 0; i < count; i++)
537      if (!array()[i].sanitize (SANITIZE_ARG, base))
538        return false;
539    return true;
540  }
541  inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) {
542    TRACE_SANITIZE ();
543    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
544    unsigned int count = len;
545    for (unsigned int i = 0; i < count; i++)
546      if (!array()[i].sanitize (SANITIZE_ARG, base, base2))
547        return false;
548    return true;
549  }
550  inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) {
551    TRACE_SANITIZE ();
552    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
553    unsigned int count = len;
554    for (unsigned int i = 0; i < count; i++)
555      if (!array()[i].sanitize (SANITIZE_ARG, base, user_data))
556        return false;
557    return true;
558  }
559
560  private:
561  inline bool sanitize_shallow (SANITIZE_ARG_DEF) {
562    TRACE_SANITIZE ();
563    return SANITIZE_SELF() && SANITIZE_ARRAY (this, Type::get_size (), len);
564  }
565
566  public:
567  LenType len;
568/*Type array[VAR];*/
569};
570
571/* An array with a USHORT number of elements. */
572template <typename Type>
573struct ArrayOf : GenericArrayOf<USHORT, Type> {};
574
575/* An array with a ULONG number of elements. */
576template <typename Type>
577struct LongArrayOf : GenericArrayOf<ULONG, Type> {};
578
579/* Array of Offset's */
580template <typename Type>
581struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {};
582
583/* Array of LongOffset's */
584template <typename Type>
585struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {};
586
587/* LongArray of LongOffset's */
588template <typename Type>
589struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {};
590
591/* Array of offsets relative to the beginning of the array itself. */
592template <typename Type>
593struct OffsetListOf : OffsetArrayOf<Type>
594{
595  inline const Type& operator [] (unsigned int i) const
596  {
597    if (unlikely (i >= this->len)) return Null(Type);
598    return this+this->array()[i];
599  }
600
601  inline bool sanitize (SANITIZE_ARG_DEF) {
602    TRACE_SANITIZE ();
603    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this));
604  }
605  inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) {
606    TRACE_SANITIZE ();
607    return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this), user_data);
608  }
609};
610
611
612/* An array with a USHORT number of elements,
613 * starting at second element. */
614template <typename Type>
615struct HeadlessArrayOf
616{
617  const Type *array(void) const { return &StructAfter<Type> (len); }
618  Type *array(void) { return &StructAfter<Type> (len); }
619
620  inline const Type& operator [] (unsigned int i) const
621  {
622    if (unlikely (i >= len || !i)) return Null(Type);
623    return array()[i-1];
624  }
625  inline unsigned int get_size () const
626  { return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
627
628  inline bool sanitize_shallow (SANITIZE_ARG_DEF) {
629    TRACE_SANITIZE ();
630    return SANITIZE_SELF() && SANITIZE_ARRAY (this, Type::get_size (), len);
631  }
632
633  inline bool sanitize (SANITIZE_ARG_DEF) {
634    TRACE_SANITIZE ();
635    if (!likely (sanitize_shallow (SANITIZE_ARG))) return false;
636    /* Note: for structs that do not reference other structs,
637     * we do not need to call their sanitize() as we already did
638     * a bound check on the aggregate array size, hence the return.
639     */
640    return true;
641    /* We do keep this code though to make sure the structs pointed
642     * to do have a simple sanitize(), ie. they do not reference
643     * other structs. */
644    unsigned int count = len ? len - 1 : 0;
645    Type *a = array();
646    for (unsigned int i = 0; i < count; i++)
647      if (!SANITIZE (a[i]))
648        return false;
649    return true;
650  }
651
652  USHORT len;
653/*Type array[VAR];*/
654};
655
656
657#endif /* HB_OPEN_TYPE_PRIVATE_HH */
658