Remove ASSERT_SIZE in favor of the safer DEFINE_SIZE_STATIC
[framework/uifw/harfbuzz.git] / src / hb-open-type-private.hh
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 *" */
45 template <typename Type>
46 inline const char * CharP (const Type* X)
47 { return reinterpret_cast<const char *>(X); }
48 template <typename Type>
49 inline char * CharP (Type* X)
50 { return reinterpret_cast<char *>(X); }
51
52 /* Cast to struct T, reference to reference */
53 template<typename Type, typename TObject>
54 inline const Type& CastR(const TObject &X)
55 { return reinterpret_cast<const Type&> (X); }
56 template<typename Type, typename TObject>
57 inline Type& CastR(TObject &X)
58 { return reinterpret_cast<Type&> (X); }
59
60 /* Cast to struct T, pointer to pointer */
61 template<typename Type, typename TObject>
62 inline const Type* CastP(const TObject *X)
63 { return reinterpret_cast<const Type*> (X); }
64 template<typename Type, typename TObject>
65 inline 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. */
70 template<typename Type, typename TObject>
71 inline const Type& StructAtOffset(const TObject &X, unsigned int offset)
72 { return * reinterpret_cast<const Type*> (CharP(&X) + offset); }
73 template<typename Type, typename TObject>
74 inline 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() */
79 template<typename Type, typename TObject>
80 inline const Type& StructAfter(const TObject &X)
81 { return StructAtOffset<Type>(X, X.get_size()); }
82 template<typename Type, typename TObject>
83 inline Type& StructAfter(TObject &X)
84 { return StructAtOffset<Type>(X, X.get_size()); }
85
86
87
88 /*
89  * Size checking
90  */
91
92 #define DEFINE_SIZE_STATIC(size) \
93   inline void _size_assertion (void) const \
94   { ASSERT_STATIC (sizeof (*this) == (size)); } \
95   static inline unsigned int get_size (void) { return (size); } \
96   static const unsigned int static_size = (size); \
97   static const unsigned int min_size = (size)
98
99 /* Size signifying variable-sized array */
100 #define VAR 1
101 #define VAR0 (VAR+0)
102
103 #define DEFINE_SIZE_VAR0(size) \
104   inline void _size_assertion (void) const \
105   { ASSERT_STATIC (sizeof (*this) == (size)); } \
106   static const unsigned int min_size = (size)
107
108 #define DEFINE_SIZE_VAR(size, _var_type) \
109   inline void _size_assertion (void) const \
110   { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
111   static const unsigned int min_size = (size)
112
113 #define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
114   inline void _size_assertion (void) const \
115   { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); } \
116   static const unsigned int min_size = (size)
117
118
119
120 /*
121  * Null objects
122  */
123
124 /* Global nul-content Null pool.  Enlarge as necessary. */
125 static const void *_NullPool[32 / sizeof (void *)];
126
127 /* Generic template for nul-content sizeof-sized Null objects. */
128 template <typename Type>
129 static inline const Type& Null () {
130   ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
131   return *CastP<Type> (_NullPool);
132 }
133
134 /* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
135 #define DEFINE_NULL_DATA(Type, data) \
136 static const char _Null##Type[Type::min_size + 1] = data; /* +1 is for nul-termination in data */ \
137 template <> \
138 inline const Type& Null<Type> () { \
139   return *CastP<Type> (_Null##Type); \
140 } /* The following line really exists such that we end in a place needing semicolon */ \
141 ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
142
143 /* Accessor macro. */
144 #define Null(Type) Null<Type>()
145
146
147 /*
148  * Trace
149  */
150
151
152 template <int max_depth>
153 struct hb_trace_t {
154   explicit hb_trace_t (unsigned int *pdepth) : pdepth(pdepth) { if (max_depth) ++*pdepth; }
155   ~hb_trace_t (void) { if (max_depth) --*pdepth; }
156
157   inline void log (const char *what, const char *function, const void *obj)
158   {
159     if (*pdepth < max_depth)
160       fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, *pdepth, *pdepth, function);
161   }
162
163   private:
164   unsigned int *pdepth;
165 };
166 template <> /* Optimize when tracing is disabled */
167 struct hb_trace_t<0> {
168   explicit hb_trace_t (unsigned int *p) {}
169   inline void log (const char *what, const char *function, const void *obj) {};
170 };
171
172
173
174 /*
175  * Sanitize
176  */
177
178 #ifndef HB_DEBUG_SANITIZE
179 #define HB_DEBUG_SANITIZE HB_DEBUG+0
180 #endif
181
182
183 #define TRACE_SANITIZE() \
184         hb_trace_t<HB_DEBUG_SANITIZE> trace (&context->debug_depth); \
185         trace.log ("SANITIZE", HB_FUNC, this);
186
187
188 struct hb_sanitize_context_t
189 {
190   inline void init (hb_blob_t *blob)
191   {
192     this->blob = hb_blob_reference (blob);
193     this->start = hb_blob_lock (blob);
194     this->end = this->start + hb_blob_get_length (blob);
195     this->writable = hb_blob_is_writable (blob);
196     this->edit_count = 0;
197     this->debug_depth = 0;
198
199     if (HB_DEBUG_SANITIZE)
200       fprintf (stderr, "sanitize %p init [%p..%p] (%u bytes)\n",
201                this->blob, this->start, this->end, this->end - this->start);
202   }
203
204   inline void finish (void)
205   {
206     if (HB_DEBUG_SANITIZE)
207       fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
208                this->blob, this->start, this->end, this->edit_count);
209
210     hb_blob_unlock (this->blob);
211     hb_blob_destroy (this->blob);
212     this->blob = NULL;
213     this->start = this->end = NULL;
214   }
215
216   inline bool check_range (const void *base, unsigned int len) const
217   {
218     bool ret = this->start <= base &&
219                base <= this->end &&
220                (unsigned int) (this->end - CharP(base)) >= len;
221
222     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \
223       fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
224                base,
225                this->debug_depth, this->debug_depth,
226                base, CharP(base)+len, len,
227                this->start, this->end,
228                ret ? "pass" : "FAIL");
229
230     return likely (ret);
231   }
232
233   inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const
234   {
235     bool overflows = len >= ((unsigned int) -1) / record_size;
236
237     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
238       fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
239                base,
240                this->debug_depth, this->debug_depth,
241                base, CharP(base) + (record_size * len), record_size, len, (unsigned long) record_size * len,
242                this->start, this->end,
243                !overflows ? "does not overflow" : "OVERFLOWS FAIL");
244
245     return likely (!overflows && this->check_range (base, record_size * len));
246   }
247
248   template <typename Type>
249   inline bool check_struct (const Type *obj) const
250   {
251     return likely (this->check_range (obj, sizeof (*obj)));
252   }
253
254   inline bool can_edit (const char *base HB_UNUSED, unsigned int len HB_UNUSED)
255   {
256     this->edit_count++;
257
258     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
259       fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
260                base,
261                this->debug_depth, this->debug_depth,
262                this->edit_count,
263                base, base+len, len,
264                this->start, this->end,
265                this->writable ? "granted" : "REJECTED");
266
267     return this->writable;
268   }
269
270   unsigned int debug_depth;
271   const char *start, *end;
272   bool writable;
273   unsigned int edit_count;
274   hb_blob_t *blob;
275 };
276
277
278
279 /* Template to sanitize an object. */
280 template <typename Type>
281 struct Sanitizer
282 {
283   static hb_blob_t *sanitize (hb_blob_t *blob) {
284     hb_sanitize_context_t context[1] = {{0}};
285     bool sane;
286
287     /* TODO is_sane() stuff */
288
289   retry:
290     if (HB_DEBUG_SANITIZE)
291       fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC);
292
293     context->init (blob);
294
295     Type *t = CastP<Type> (const_cast<char *> (context->start));
296
297     sane = t->sanitize (context);
298     if (sane) {
299       if (context->edit_count) {
300         if (HB_DEBUG_SANITIZE)
301           fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
302                    blob, context->edit_count, HB_FUNC);
303
304         /* sanitize again to ensure no toe-stepping */
305         context->edit_count = 0;
306         sane = t->sanitize (context);
307         if (context->edit_count) {
308           if (HB_DEBUG_SANITIZE)
309             fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
310                      blob, context->edit_count, HB_FUNC);
311           sane = false;
312         }
313       }
314       context->finish ();
315     } else {
316       unsigned int edit_count = context->edit_count;
317       context->finish ();
318       if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
319         /* ok, we made it writable by relocating.  try again */
320         if (HB_DEBUG_SANITIZE)
321           fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC);
322         goto retry;
323       }
324     }
325
326     if (HB_DEBUG_SANITIZE)
327       fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", HB_FUNC);
328     if (sane)
329       return blob;
330     else {
331       hb_blob_destroy (blob);
332       return hb_blob_create_empty ();
333     }
334   }
335 };
336
337
338
339
340 /*
341  *
342  * The OpenType Font File: Data Types
343  */
344
345
346 /* "The following data types are used in the OpenType font file.
347  *  All OpenType fonts use Motorola-style byte ordering (Big Endian):" */
348
349 /*
350  * Int types
351  */
352
353
354 template <typename Type, int Bytes> class BEInt;
355
356 /* LONGTERMTODO: On machines allowing unaligned access, we can make the
357  * following tighter by using byteswap instructions on ints directly. */
358 template <typename Type>
359 class BEInt<Type, 2>
360 {
361   public:
362   inline class BEInt<Type,2>& operator = (Type i) { hb_be_uint16_put (v,i); return *this; }
363   inline operator Type () const { return hb_be_uint16_get (v); }
364   inline bool operator == (const BEInt<Type, 2>& o) const { return hb_be_uint16_cmp (v, o.v); }
365   inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); }
366   private: uint8_t v[2];
367 };
368 template <typename Type>
369 class BEInt<Type, 4>
370 {
371   public:
372   inline class BEInt<Type,4>& operator = (Type i) { hb_be_uint32_put (v,i); return *this; }
373   inline operator Type () const { return hb_be_uint32_get (v); }
374   inline bool operator == (const BEInt<Type, 4>& o) const { return hb_be_uint32_cmp (v, o.v); }
375   inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); }
376   private: uint8_t v[4];
377 };
378
379 /* Integer types in big-endian order and no alignment requirement */
380 template <typename Type>
381 struct IntType
382 {
383   inline void set (Type i) { v = i; }
384   inline operator Type(void) const { return v; }
385   inline bool operator == (const IntType<Type> &o) const { return v == o.v; }
386   inline bool operator != (const IntType<Type> &o) const { return v != o.v; }
387   inline bool sanitize (hb_sanitize_context_t *context) {
388     TRACE_SANITIZE ();
389     return context->check_struct (this);
390   }
391   private:
392   BEInt<Type, sizeof (Type)> v;
393   public:
394   DEFINE_SIZE_STATIC (sizeof (Type));
395 };
396
397 typedef IntType<uint16_t> USHORT;       /* 16-bit unsigned integer. */
398 typedef IntType<int16_t>  SHORT;        /* 16-bit signed integer. */
399 typedef IntType<uint32_t> ULONG;        /* 32-bit unsigned integer. */
400 typedef IntType<int32_t>  LONG;         /* 32-bit signed integer. */
401
402 /* Array of four uint8s (length = 32 bits) used to identify a script, language
403  * system, feature, or baseline */
404 struct Tag : ULONG
405 {
406   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
407   inline operator const char* (void) const { return CharP(this); }
408   inline operator char* (void) { return CharP(this); }
409   public:
410   DEFINE_SIZE_STATIC (4);
411 };
412 DEFINE_NULL_DATA (Tag, "    ");
413
414 /* Glyph index number, same as uint16 (length = 16 bits) */
415 typedef USHORT GlyphID;
416
417 /* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */
418 typedef USHORT Offset;
419
420 /* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */
421 typedef ULONG LongOffset;
422
423
424 /* CheckSum */
425 struct CheckSum : ULONG
426 {
427   static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
428   {
429     uint32_t Sum = 0L;
430     ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
431
432     while (Table < EndPtr)
433       Sum += *Table++;
434     return Sum;
435   }
436   public:
437   DEFINE_SIZE_STATIC (4);
438 };
439
440
441 /*
442  * Version Numbers
443  */
444
445 struct FixedVersion
446 {
447   inline operator uint32_t (void) const { return (major << 16) + minor; }
448
449   inline bool sanitize (hb_sanitize_context_t *context) {
450     TRACE_SANITIZE ();
451     return context->check_struct (this);
452   }
453
454   USHORT major;
455   USHORT minor;
456   public:
457   DEFINE_SIZE_STATIC (4);
458 };
459
460
461
462 /*
463  * Template subclasses of Offset and LongOffset that do the dereferencing.
464  * Use: (base+offset)
465  */
466
467 template <typename OffsetType, typename Type>
468 struct GenericOffsetTo : OffsetType
469 {
470   inline const Type& operator () (const void *base) const
471   {
472     unsigned int offset = *this;
473     if (unlikely (!offset)) return Null(Type);
474     return StructAtOffset<Type> (*CharP(base), offset);
475   }
476
477   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
478     TRACE_SANITIZE ();
479     if (!context->check_struct (this)) return false;
480     unsigned int offset = *this;
481     if (unlikely (!offset)) return true;
482     Type &obj = StructAtOffset<Type> (*CharP(base), offset);
483     return likely (obj.sanitize (context)) || neuter (context);
484   }
485   template <typename T>
486   inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) {
487     TRACE_SANITIZE ();
488     if (!context->check_struct (this)) return false;
489     unsigned int offset = *this;
490     if (unlikely (!offset)) return true;
491     Type &obj = StructAtOffset<Type> (*CharP(base), offset);
492     return likely (obj.sanitize (context, user_data)) || neuter (context);
493   }
494
495   private:
496   /* Set the offset to Null */
497   inline bool neuter (hb_sanitize_context_t *context) {
498     if (context->can_edit (CharP(this), this->static_size)) {
499       this->set (0); /* 0 is Null offset */
500       return true;
501     }
502     return false;
503   }
504 };
505 template <typename Base, typename OffsetType, typename Type>
506 inline const Type& operator + (const Base &base, GenericOffsetTo<OffsetType, Type> offset) { return offset (base); }
507
508 template <typename Type>
509 struct OffsetTo : GenericOffsetTo<Offset, Type> {};
510
511 template <typename Type>
512 struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
513
514
515 /*
516  * Array Types
517  */
518
519 template <typename LenType, typename Type>
520 struct GenericArrayOf
521 {
522   const Type *array(void) const { return &StructAfter<Type> (len); }
523   Type *array(void) { return &StructAfter<Type> (len); }
524
525   const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
526   {
527     unsigned int count = len;
528     if (unlikely (start_offset > count))
529       count = 0;
530     else
531       count -= start_offset;
532     count = MIN (count, *pcount);
533     *pcount = count;
534     return array() + start_offset;
535   }
536
537   inline const Type& operator [] (unsigned int i) const
538   {
539     if (unlikely (i >= len)) return Null(Type);
540     return array()[i];
541   }
542   inline unsigned int get_size () const
543   { return len.static_size + len * Type::static_size; }
544
545   inline bool sanitize (hb_sanitize_context_t *context) {
546     TRACE_SANITIZE ();
547     if (!likely (sanitize_shallow (context))) return false;
548     /* Note: for structs that do not reference other structs,
549      * we do not need to call their sanitize() as we already did
550      * a bound check on the aggregate array size, hence the return.
551      */
552     return true;
553     /* We do keep this code though to make sure the structs pointed
554      * to do have a simple sanitize(), ie. they do not reference
555      * other structs. */
556     unsigned int count = len;
557     for (unsigned int i = 0; i < count; i++)
558       if (array()[i].sanitize (context))
559         return false;
560     return true;
561   }
562   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
563     TRACE_SANITIZE ();
564     if (!likely (sanitize_shallow (context))) return false;
565     unsigned int count = len;
566     for (unsigned int i = 0; i < count; i++)
567       if (!array()[i].sanitize (context, base))
568         return false;
569     return true;
570   }
571   template <typename T>
572   inline bool sanitize (hb_sanitize_context_t *context, void *base, T user_data) {
573     TRACE_SANITIZE ();
574     if (!likely (sanitize_shallow (context))) return false;
575     unsigned int count = len;
576     for (unsigned int i = 0; i < count; i++)
577       if (!array()[i].sanitize (context, base, user_data))
578         return false;
579     return true;
580   }
581
582   private:
583   inline bool sanitize_shallow (hb_sanitize_context_t *context) {
584     TRACE_SANITIZE ();
585     return context->check_struct (this)
586         && context->check_array (this, Type::static_size, len);
587   }
588
589   public:
590   LenType len;
591 /*Type array[VAR];*/
592   public:
593   DEFINE_SIZE_VAR0 (sizeof (LenType));
594 };
595
596 /* An array with a USHORT number of elements. */
597 template <typename Type>
598 struct ArrayOf : GenericArrayOf<USHORT, Type> {};
599
600 /* An array with a ULONG number of elements. */
601 template <typename Type>
602 struct LongArrayOf : GenericArrayOf<ULONG, Type> {};
603
604 /* Array of Offset's */
605 template <typename Type>
606 struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {};
607
608 /* Array of LongOffset's */
609 template <typename Type>
610 struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {};
611
612 /* LongArray of LongOffset's */
613 template <typename Type>
614 struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {};
615
616 /* Array of offsets relative to the beginning of the array itself. */
617 template <typename Type>
618 struct OffsetListOf : OffsetArrayOf<Type>
619 {
620   inline const Type& operator [] (unsigned int i) const
621   {
622     if (unlikely (i >= this->len)) return Null(Type);
623     return this+this->array()[i];
624   }
625
626   inline bool sanitize (hb_sanitize_context_t *context) {
627     TRACE_SANITIZE ();
628     return OffsetArrayOf<Type>::sanitize (context, CharP(this));
629   }
630   template <typename T>
631   inline bool sanitize (hb_sanitize_context_t *context, T user_data) {
632     TRACE_SANITIZE ();
633     return OffsetArrayOf<Type>::sanitize (context, CharP(this), user_data);
634   }
635 };
636
637
638 /* An array with a USHORT number of elements,
639  * starting at second element. */
640 template <typename Type>
641 struct HeadlessArrayOf
642 {
643   const Type *array(void) const { return &StructAfter<Type> (len); }
644   Type *array(void) { return &StructAfter<Type> (len); }
645
646   inline const Type& operator [] (unsigned int i) const
647   {
648     if (unlikely (i >= len || !i)) return Null(Type);
649     return array()[i-1];
650   }
651   inline unsigned int get_size () const
652   { return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
653
654   inline bool sanitize_shallow (hb_sanitize_context_t *context) {
655     return context->check_struct (this)
656         && context->check_array (this, Type::static_size, len);
657   }
658
659   inline bool sanitize (hb_sanitize_context_t *context) {
660     TRACE_SANITIZE ();
661     if (!likely (sanitize_shallow (context))) return false;
662     /* Note: for structs that do not reference other structs,
663      * we do not need to call their sanitize() as we already did
664      * a bound check on the aggregate array size, hence the return.
665      */
666     return true;
667     /* We do keep this code though to make sure the structs pointed
668      * to do have a simple sanitize(), ie. they do not reference
669      * other structs. */
670     unsigned int count = len ? len - 1 : 0;
671     Type *a = array();
672     for (unsigned int i = 0; i < count; i++)
673       if (!a[i].sanitize (context))
674         return false;
675     return true;
676   }
677
678   USHORT len;
679 /*Type array[VAR];*/
680 };
681
682
683 #endif /* HB_OPEN_TYPE_PRIVATE_HH */