]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/layout/StateTables.h
ICU-59180.0.1.tar.gz
[apple/icu.git] / icuSources / layout / StateTables.h
index 8b5f867770a4bffde85f430f811bd0b88bba1d1d..8635d1dcdee3c8e0fcf700cfeeac7c40826b5762 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2016 - All Rights Reserved
  *
  */
 
 
 #include "LETypes.h"
 #include "LayoutTables.h"
+#include "LETableReference.h"
 
 U_NAMESPACE_BEGIN
 
+
+
+
+/* 
+ * State table loop detection. 
+ * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
+ * 
+ * Usage (pseudocode):
+ *
+ * {
+ *   LE_STATE_PATIENCE_INIT();
+ *
+ *   int g=0; // the glyph index - expect it to be moving
+ * 
+ *   for(;;) {
+ *     if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
+ *        // ran out of patience, get out.
+ *        break;
+ *     }
+ *     
+ *     LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
+ *     state = newState(state,g);
+ *     g+= <something, could be zero>;
+ *     LE_STATE_PATIENCE_INCR(g);  // if g has moved, increment the patience counter. Otherwise leave it.
+ *   }
+ * 
+ */
+
+#define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
+#define LE_STATE_PATIENCE_INIT()  le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
+#define LE_STATE_PATIENCE_DECR()  --le_patience_count==0
+#define LE_STATE_PATIENCE_CURR(type,x)  type le_patience_curr=(x)
+#define LE_STATE_PATIENCE_INCR(x)    if((x)!=le_patience_curr) ++le_patience_count;
+
+
 struct StateTableHeader
 {
     le_int16 stateSize;
@@ -25,6 +61,14 @@ struct StateTableHeader
     ByteOffset entryTableOffset;
 };
 
+struct StateTableHeader2 
+{
+    le_uint32 nClasses;
+    le_uint32 classTableOffset;
+    le_uint32 stateArrayOffset;
+    le_uint32 entryTableOffset;
+};
+
 enum ClassCodes
 {
     classCodeEOT = 0,
@@ -43,6 +87,7 @@ struct ClassTable
     le_uint16 nGlyphs;
     ClassCode classArray[ANY_NUMBER];
 };
+LE_VAR_ARRAY(ClassTable, classArray)
 
 enum StateNumber
 {
@@ -60,6 +105,14 @@ struct StateEntry
     le_int16    flags;
 };
 
+typedef le_uint16 EntryTableIndex2;
+
+struct StateEntry2 // same struct different interpretation
+{
+    le_uint16    newStateIndex;
+    le_uint16    flags;
+};
+
 U_NAMESPACE_END
 #endif