-#define CCL_ReadMultibyteCharacter 0x00 /* Read Multibyte Character
- 1:ExtendedCOMMNDRrrRRRrrrXXXXX
-
- Read a multibyte characeter.
- A code point is stored
- into rrr register.
- A charset ID is stored
- into RRR register.
- */
-#define CCL_WriteMultibyteCharacter 0x01 /* Write Multibyte Character
- 1:ExtendedCOMMNDRrrRRRrrrXXXXX
-
- Write a multibyte character.
- Write a character whose code point
- is in rrr register, and its charset ID
- is in RRR charset.
- */
-#define CCL_UnifyCharacter 0x02 /* Unify Multibyte Character
- 1:ExtendedCOMMNDRrrRRRrrrXXXXX
-
- Unify a character where its code point
- is in rrr register, and its charset ID
- is in RRR register with the table of
- the unification table ID
- in Rrr register.
-
- Return a unified character where its
- code point is in rrr register, and its
- charset ID is in RRR register.
- */
-#define CCL_UnifyCharacterConstTbl 0x03 /* Unify Multibyte Character
- 1:ExtendedCOMMNDRrrRRRrrrXXXXX
- 2:ARGUMENT(Unification Table ID)
-
- Unify a character where its code point
- is in rrr register, and its charset ID
- is in RRR register with the table of
- the unification table ID
- in 2nd argument.
-
- Return a unified character where its
- code point is in rrr register, and its
- charset ID is in RRR register.
- */
-#define CCL_IterateMultipleMap 0x10 /* Iterate Multiple Map
- 1:ExtendedCOMMNDXXXRRRrrrXXXXX
- 2:NUMBER of TABLES
- 3:TABLE-ID1
- 4:TABLE-ID2
- ...
-
- iterate to lookup tables from a number
- until finding a value.
-
- Each table consists of a vector
- whose element is number or
- nil or t or lambda.
- If the element is nil,
- its table is neglected.
- In the case of t or lambda,
- return the original value.
-
- */
-#define CCL_TranslateMultipleMap 0x11 /* Translate Multiple Map
- 1:ExtendedCOMMNDXXXRRRrrrXXXXX
- 2:NUMBER of TABLE-IDs and SEPARATERs
- (i.e. m1+m2+m3+...mk+k-1)
- 3:TABLE-ID 1,1
- 4:TABLE-ID 1,2
- ...
- m1+2:TABLE-ID 1,m1
- m1+3: -1 (SEPARATOR)
- m1+4:TABLE-ID 2,1
- ...
- m1+m2+4:TABLE-ID 2,m2
- m1+m2+5: -1
- ...
- m1+m2+...+mk+k+1:TABLE-ID k,mk
-
- Translate the code point in
- rrr register by tables.
- Translation starts from the table
- where RRR register points out.
-
- We translate the given value
- from the tables which are separated
- by -1.
- When each translation is failed to find
- any values, we regard the traslation
- as identity.
-
- We iterate to traslate by using each
- table set(tables separated by -1)
- until lookup the last table except
- lookup lambda.
-
- Each table consists of a vector
- whose element is number
- or nil or t or lambda.
- If the element is nil,
- it is neglected and use the next table.
- In the case of t,
- it is translated to the original value.
- In the case of lambda,
- it cease the translation and return the
- current value.
-
- */
-#define CCL_TranslateSingleMap 0x12 /* Translate Single Map
- 1:ExtendedCOMMNDXXXRRRrrrXXXXX
- 2:TABLE-ID
-
- Translate a number in rrr register.
- If it is not found any translation,
- set RRR register -1 but rrr register
- is not changed.
- */
+/* Read a multibyte characeter.
+ A code point is stored into reg[rrr]. A charset ID is stored into
+ reg[RRR]. */
+
+#define CCL_ReadMultibyteChar2 0x00 /* Read Multibyte Character
+ 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
+
+/* Write a multibyte character.
+ Write a character whose code point is reg[rrr] and the charset ID
+ is reg[RRR]. */
+
+#define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character
+ 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
+
+/* Translate a character whose code point is reg[rrr] and the charset
+ ID is reg[RRR] by a translation table whose ID is reg[Rrr].
+
+ A translated character is set in reg[rrr] (code point) and reg[RRR]
+ (charset ID). */
+
+#define CCL_TranslateCharacter 0x02 /* Translate a multibyte character
+ 1:ExtendedCOMMNDRrrRRRrrrXXXXX */
+
+/* Translate a character whose code point is reg[rrr] and the charset
+ ID is reg[RRR] by a translation table whose ID is ARGUMENT.
+
+ A translated character is set in reg[rrr] (code point) and reg[RRR]
+ (charset ID). */
+
+#define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character
+ 1:ExtendedCOMMNDRrrRRRrrrXXXXX
+ 2:ARGUMENT(Translation Table ID)
+ */
+
+/* Iterate looking up MAPs for reg[rrr] starting from the Nth (N =
+ reg[RRR]) MAP until some value is found.
+
+ Each MAP is a Lisp vector whose element is number, nil, t, or
+ lambda.
+ If the element is nil, ignore the map and proceed to the next map.
+ If the element is t or lambda, finish without changing reg[rrr].
+ If the element is a number, set reg[rrr] to the number and finish.
+
+ Detail of the map structure is descibed in the comment for
+ CCL_MapMultiple below. */
+
+#define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps
+ 1:ExtendedCOMMNDXXXRRRrrrXXXXX
+ 2:NUMBER of MAPs
+ 3:MAP-ID1
+ 4:MAP-ID2
+ ...
+ */
+
+/* Map the code in reg[rrr] by MAPs starting from the Nth (N =
+ reg[RRR]) map.
+
+ MAPs are supplied in the succeeding CCL codes as follows:
+
+ When CCL program gives this nested structure of map to this command:
+ ((MAP-ID11
+ MAP-ID12
+ (MAP-ID121 MAP-ID122 MAP-ID123)
+ MAP-ID13)
+ (MAP-ID21
+ (MAP-ID211 (MAP-ID2111) MAP-ID212)
+ MAP-ID22)),
+ the compiled CCL codes has this sequence:
+ CCL_MapMultiple (CCL code of this command)
+ 16 (total number of MAPs and SEPARATORs)
+ -7 (1st SEPARATOR)
+ MAP-ID11
+ MAP-ID12
+ -3 (2nd SEPARATOR)
+ MAP-ID121
+ MAP-ID122
+ MAP-ID123
+ MAP-ID13
+ -7 (3rd SEPARATOR)
+ MAP-ID21
+ -4 (4th SEPARATOR)
+ MAP-ID211
+ -1 (5th SEPARATOR)
+ MAP_ID2111
+ MAP-ID212
+ MAP-ID22
+
+ A value of each SEPARATOR follows this rule:
+ MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+
+ SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET)
+
+ (*)....Nest level of MAP-SET must not be over than MAX_MAP_SET_LEVEL.
+
+ When some map fails to map (i.e. it doesn't have a value for
+ reg[rrr]), the mapping is treated as identity.
+
+ The mapping is iterated for all maps in each map set (set of maps
+ separated by SEPARATOR) except in the case that lambda is
+ encountered. More precisely, the mapping proceeds as below:
+
+ At first, VAL0 is set to reg[rrr], and it is translated by the
+ first map to VAL1. Then, VAL1 is translated by the next map to
+ VAL2. This mapping is iterated until the last map is used. The
+ result of the mapping is the last value of VAL?. When the mapping
+ process reached to the end of the map set, it moves to the next
+ map set. If the next does not exit, the mapping process terminates,
+ and regard the last value as a result.
+
+ But, when VALm is mapped to VALn and VALn is not a number, the
+ mapping proceed as below:
+
+ If VALn is nil, the lastest map is ignored and the mapping of VALm
+ proceed to the next map.
+
+ In VALn is t, VALm is reverted to reg[rrr] and the mapping of VALm
+ proceed to the next map.
+
+ If VALn is lambda, move to the next map set like reaching to the
+ end of the current map set.
+
+ If VALn is a symbol, call the CCL program refered by it.
+ Then, use reg[rrr] as a mapped value except for -1, -2 and -3.
+ Such special values are regarded as nil, t, and lambda respectively.
+
+ Each map is a Lisp vector of the following format (a) or (b):
+ (a)......[STARTPOINT VAL1 VAL2 ...]
+ (b)......[t VAL STARTPOINT ENDPOINT],
+ where
+ STARTPOINT is an offset to be used for indexing a map,
+ ENDPOINT is a maximum index number of a map,
+ VAL and VALn is a number, nil, t, or lambda.
+
+ Valid index range of a map of type (a) is:
+ STARTPOINT <= index < STARTPOINT + map_size - 1
+ Valid index range of a map of type (b) is:
+ STARTPOINT <= index < ENDPOINT */
+
+#define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps
+ 1:ExtendedCOMMNDXXXRRRrrrXXXXX
+ 2:N-2
+ 3:SEPARATOR_1 (< 0)
+ 4:MAP-ID_1
+ 5:MAP-ID_2
+ ...
+ M:SEPARATOR_x (< 0)
+ M+1:MAP-ID_y
+ ...
+ N:SEPARATOR_z (< 0)
+ */
+
+#define MAX_MAP_SET_LEVEL 30
+
+typedef struct
+{
+ int rest_length;
+ int orig_val;
+} tr_stack;
+
+static tr_stack mapping_stack[MAX_MAP_SET_LEVEL];
+static tr_stack *mapping_stack_pointer;
+
+/* If this variable is non-zero, it indicates the stack_idx
+ of immediately called by CCL_MapMultiple. */
+static int stack_idx_of_map_multiple;
+
+#define PUSH_MAPPING_STACK(restlen, orig) \
+do \
+ { \
+ mapping_stack_pointer->rest_length = (restlen); \
+ mapping_stack_pointer->orig_val = (orig); \
+ mapping_stack_pointer++; \
+ } \
+while (0)
+
+#define POP_MAPPING_STACK(restlen, orig) \
+do \
+ { \
+ mapping_stack_pointer--; \
+ (restlen) = mapping_stack_pointer->rest_length; \
+ (orig) = mapping_stack_pointer->orig_val; \
+ } \
+while (0)
+
+#define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \
+do \
+ { \
+ struct ccl_program called_ccl; \
+ if (stack_idx >= 256 \
+ || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \
+ { \
+ if (stack_idx > 0) \
+ { \
+ ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \
+ ic = ccl_prog_stack_struct[0].ic; \
+ eof_ic = ccl_prog_stack_struct[0].eof_ic; \
+ } \
+ CCL_INVALID_CMD; \
+ } \
+ ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \
+ ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \
+ ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic; \
+ stack_idx++; \
+ ccl_prog = called_ccl.prog; \
+ ic = CCL_HEADER_MAIN; \
+ eof_ic = XFASTINT (ccl_prog[CCL_HEADER_EOF]); \
+ goto ccl_repeat; \
+ } \
+while (0)
+
+#define CCL_MapSingle 0x12 /* Map by single code conversion map
+ 1:ExtendedCOMMNDXXXRRRrrrXXXXX
+ 2:MAP-ID
+ ------------------------------
+ Map reg[rrr] by MAP-ID.
+ If some valid mapping is found,
+ set reg[rrr] to the result,
+ else
+ set reg[RRR] to -1.
+ */
+
+#define CCL_LookupIntConstTbl 0x13 /* Lookup multibyte character by
+ integer key. Afterwards R7 set
+ to 1 iff lookup succeeded.
+ 1:ExtendedCOMMNDRrrRRRXXXXXXXX
+ 2:ARGUMENT(Hash table ID) */
+
+#define CCL_LookupCharConstTbl 0x14 /* Lookup integer by multibyte
+ character key. Afterwards R7 set
+ to 1 iff lookup succeeded.
+ 1:ExtendedCOMMNDRrrRRRrrrXXXXX
+ 2:ARGUMENT(Hash table ID) */