changeset 88925:aa33304a3bb8

Remove `emacs' conditional. Include hash table stuff from trunk.
author Dave Love <fx@gnu.org>
date Tue, 30 Jul 2002 11:31:54 +0000
parents 6ab7bfc7590d
children f026b7e4fc61
files src/ccl.c
diffstat 1 files changed, 75 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/ccl.c	Tue Jul 30 11:30:32 2002 +0000
+++ b/src/ccl.c	Tue Jul 30 11:31:54 2002 +0000
@@ -23,26 +23,16 @@
 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 "character.h"
 #include "charset.h"
 #include "ccl.h"
 #include "coding.h"
 
-#else  /* not emacs */
-
-#include "mulelib.h"
-
-#endif /* not emacs */
-
 Lisp_Object Qccl, Qcclp;
 
 /* This contains all code conversion map available to CCL.  */
@@ -71,6 +61,17 @@
    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)])))
+/* Copied from fns.c.  */
+#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
+
+extern int charset_unicode;
+
 /* 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
@@ -658,6 +659,18 @@
 					  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 */
@@ -1214,6 +1227,51 @@
 	      reg[rrr] = ENCODE_CHAR (charset, op);
 	      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 (!CHARACTERP (opl))
+		      CCL_INVALID_CMD;
+		    reg[rrr] = ENCODE_CHAR (CHAR_CHARSET (charset_unicode),
+					    op);
+		    reg[7] = 1; /* r7 true for success */
+		  }
+		else
+		  reg[7] = 0;
+	      }
+	      break;
+
+	    case CCL_LookupCharConstTbl:
+	      op = XINT (ccl_prog[ic]); /* table */
+	      ic++;
+	      charset = CHARSET_FROM_ID (reg[RRR]);
+	      i = DECODE_CHAR (charset, reg[rrr]);
+	      {		
+		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;
@@ -1795,8 +1853,6 @@
   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.  */)
@@ -2186,11 +2242,16 @@
  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 */