/* CCL (Code Conversion Language) interpreter.
Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Licensed to the Free Software Foundation.
This file is part of GNU Emacs.
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifdef emacs
#include <config.h>
-#endif
#include <stdio.h>
-#ifdef emacs
-
#include "lisp.h"
#include "charset.h"
#include "ccl.h"
#include "coding.h"
-#else /* not emacs */
-
-#include "mulelib.h"
-
-#endif /* not emacs */
-
/* This contains all code conversion map available to CCL. */
Lisp_Object Vcode_conversion_map_vector;
already resolved to index numbers or not. */
Lisp_Object Vccl_program_table;
+/* Vector of registered hash tables for translation. */
+Lisp_Object Vtranslation_hash_table_vector;
+
+/* Return a hash table of id number ID. */
+#define GET_HASH_TABLE(id) \
+ (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
+
/* CCL (Code Conversion Language) is a simple language which has
operations on one input buffer, one output buffer, and 7 registers.
The syntax of CCL is described in `ccl.el'. Emacs Lisp function
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) */
+
/* CCL arithmetic/logical operators. */
#define CCL_PLUS 0x00 /* X = Y + Z */
#define CCL_MINUS 0x01 /* X = Y - Z */
#ifdef CCL_DEBUG
#define CCL_DEBUG_BACKTRACE_LEN 256
-int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
+int ccl_backtrace_table[CCL_DEBUG_BACKTRACE_LEN];
int ccl_backtrace_idx;
#endif
reg[rrr] = i;
break;
+ case CCL_LookupIntConstTbl:
+ op = XINT (ccl_prog[ic]); /* table */
+ ic++;
+ {
+ struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
+
+ op = hash_lookup (h, make_number (reg[RRR]), NULL);
+ if (op >= 0)
+ {
+ Lisp_Object opl;
+ opl = HASH_VALUE (h, op);
+ if (!CHAR_VALID_P (XINT (opl), 0))
+ CCL_INVALID_CMD;
+ SPLIT_CHAR (XINT (opl), reg[RRR], i, j);
+ if (j != -1)
+ i = (i << 7) | j;
+ reg[rrr] = i;
+ reg[7] = 1; /* r7 true for success */
+ }
+ else
+ reg[7] = 0;
+ }
+ break;
+
+ case CCL_LookupCharConstTbl:
+ op = XINT (ccl_prog[ic]); /* table */
+ ic++;
+ CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
+ {
+ struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
+
+ op = hash_lookup (h, make_number (i), NULL);
+ if (op >= 0)
+ {
+ Lisp_Object opl;
+ opl = HASH_VALUE (h, op);
+ if (!INTEGERP (opl))
+ CCL_INVALID_CMD;
+ reg[RRR] = XINT (opl);
+ reg[7] = 1; /* r7 true for success */
+ }
+ else
+ reg[7] = 0;
+ }
+ break;
+
case CCL_IterateMultipleMap:
{
Lisp_Object map, content, attrib, value;
return 0;
}
-#ifdef emacs
-
DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0,
doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code.
See the documentation of `define-ccl-program' for the detail of CCL program. */)
if (ccl.ic < i && i < ccl.size)
ccl.ic = i;
}
- outbufsize = STRING_BYTES (XSTRING (str)) * ccl.buf_magnification + 256;
+ outbufsize = SBYTES (str) * ccl.buf_magnification + 256;
outbuf = (char *) xmalloc (outbufsize);
ccl.last_block = NILP (contin);
ccl.multibyte = STRING_MULTIBYTE (str);
- produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf,
- STRING_BYTES (XSTRING (str)), outbufsize, (int *) 0);
+ produced = ccl_driver (&ccl, SDATA (str), outbuf,
+ SBYTES (str), outbufsize, (int *) 0);
for (i = 0; i < 8; i++)
XSET (AREF (status, i), Lisp_Int, ccl.reg[i]);
XSETINT (AREF (status, 8), ccl.ic);
If the font is single-byte font, the register R2 is not used. */);
Vfont_ccl_encoder_alist = Qnil;
+ DEFVAR_LISP ("translation-hash-table-vector", &Vtranslation_hash_table_vector,
+ doc: /* Vector containing all translation hash tables ever defined.
+Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls
+to `define-translation-hash-table'. The vector is indexed by the table id
+used by CCL. */);
+ Vtranslation_hash_table_vector = Qnil;
+
defsubr (&Sccl_program_p);
defsubr (&Sccl_execute);
defsubr (&Sccl_execute_on_string);
defsubr (&Sregister_ccl_program);
defsubr (&Sregister_code_conversion_map);
}
-
-#endif /* emacs */