aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Love2002-07-30 11:31:54 +0000
committerDave Love2002-07-30 11:31:54 +0000
commitd325055a00e658a38c1721fcc63ed1775dd8ccb3 (patch)
treee0ab05c42f7c7b08c7a3c4f9a00765c464222140 /src
parentd7e78a446a9483c05fda98c2e461b256c62af41e (diff)
downloademacs-d325055a00e658a38c1721fcc63ed1775dd8ccb3.tar.gz
emacs-d325055a00e658a38c1721fcc63ed1775dd8ccb3.zip
Remove `emacs' conditional. Include hash table stuff
from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ccl.c89
1 files changed, 75 insertions, 14 deletions
diff --git a/src/ccl.c b/src/ccl.c
index fd535acfe82..f6a8a3ab668 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -23,26 +23,16 @@ along with GNU Emacs; see the file COPYING. If not, write to
23the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24Boston, MA 02111-1307, USA. */ 24Boston, MA 02111-1307, USA. */
25 25
26#ifdef emacs
27#include <config.h> 26#include <config.h>
28#endif
29 27
30#include <stdio.h> 28#include <stdio.h>
31 29
32#ifdef emacs
33
34#include "lisp.h" 30#include "lisp.h"
35#include "character.h" 31#include "character.h"
36#include "charset.h" 32#include "charset.h"
37#include "ccl.h" 33#include "ccl.h"
38#include "coding.h" 34#include "coding.h"
39 35
40#else /* not emacs */
41
42#include "mulelib.h"
43
44#endif /* not emacs */
45
46Lisp_Object Qccl, Qcclp; 36Lisp_Object Qccl, Qcclp;
47 37
48/* This contains all code conversion map available to CCL. */ 38/* This contains all code conversion map available to CCL. */
@@ -71,6 +61,17 @@ Lisp_Object Qccl_program_idx;
71 already resolved to index numbers or not. */ 61 already resolved to index numbers or not. */
72Lisp_Object Vccl_program_table; 62Lisp_Object Vccl_program_table;
73 63
64/* Vector of registered hash tables for translation. */
65Lisp_Object Vtranslation_hash_table_vector;
66
67/* Return a hash table of id number ID. */
68#define GET_HASH_TABLE(id) \
69 (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
70/* Copied from fns.c. */
71#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
72
73extern int charset_unicode;
74
74/* CCL (Code Conversion Language) is a simple language which has 75/* CCL (Code Conversion Language) is a simple language which has
75 operations on one input buffer, one output buffer, and 7 registers. 76 operations on one input buffer, one output buffer, and 7 registers.
76 The syntax of CCL is described in `ccl.el'. Emacs Lisp function 77 The syntax of CCL is described in `ccl.el'. Emacs Lisp function
@@ -658,6 +659,18 @@ while (0)
658 set reg[RRR] to -1. 659 set reg[RRR] to -1.
659 */ 660 */
660 661
662#define CCL_LookupIntConstTbl 0x13 /* Lookup multibyte character by
663 integer key. Afterwards R7 set
664 to 1 iff lookup succeeded.
665 1:ExtendedCOMMNDRrrRRRXXXXXXXX
666 2:ARGUMENT(Hash table ID) */
667
668#define CCL_LookupCharConstTbl 0x14 /* Lookup integer by multibyte
669 character key. Afterwards R7 set
670 to 1 iff lookup succeeded.
671 1:ExtendedCOMMNDRrrRRRrrrXXXXX
672 2:ARGUMENT(Hash table ID) */
673
661/* CCL arithmetic/logical operators. */ 674/* CCL arithmetic/logical operators. */
662#define CCL_PLUS 0x00 /* X = Y + Z */ 675#define CCL_PLUS 0x00 /* X = Y + Z */
663#define CCL_MINUS 0x01 /* X = Y - Z */ 676#define CCL_MINUS 0x01 /* X = Y - Z */
@@ -1214,6 +1227,51 @@ ccl_driver (ccl, source, destination, src_size, dst_size)
1214 reg[rrr] = ENCODE_CHAR (charset, op); 1227 reg[rrr] = ENCODE_CHAR (charset, op);
1215 break; 1228 break;
1216 1229
1230 case CCL_LookupIntConstTbl:
1231 op = XINT (ccl_prog[ic]); /* table */
1232 ic++;
1233 {
1234 struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
1235
1236 op = hash_lookup (h, make_number (reg[RRR]), NULL);
1237 if (op >= 0)
1238 {
1239 Lisp_Object opl;
1240 opl = HASH_VALUE (h, op);
1241 if (!CHARACTERP (opl))
1242 CCL_INVALID_CMD;
1243 reg[rrr] = ENCODE_CHAR (CHAR_CHARSET (charset_unicode),
1244 op);
1245 reg[7] = 1; /* r7 true for success */
1246 }
1247 else
1248 reg[7] = 0;
1249 }
1250 break;
1251
1252 case CCL_LookupCharConstTbl:
1253 op = XINT (ccl_prog[ic]); /* table */
1254 ic++;
1255 charset = CHARSET_FROM_ID (reg[RRR]);
1256 i = DECODE_CHAR (charset, reg[rrr]);
1257 {
1258 struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
1259
1260 op = hash_lookup (h, make_number (i), NULL);
1261 if (op >= 0)
1262 {
1263 Lisp_Object opl;
1264 opl = HASH_VALUE (h, op);
1265 if (!INTEGERP (opl))
1266 CCL_INVALID_CMD;
1267 reg[RRR] = XINT (opl);
1268 reg[7] = 1; /* r7 true for success */
1269 }
1270 else
1271 reg[7] = 0;
1272 }
1273 break;
1274
1217 case CCL_IterateMultipleMap: 1275 case CCL_IterateMultipleMap:
1218 { 1276 {
1219 Lisp_Object map, content, attrib, value; 1277 Lisp_Object map, content, attrib, value;
@@ -1795,8 +1853,6 @@ setup_ccl_program (ccl, ccl_prog)
1795 return 0; 1853 return 0;
1796} 1854}
1797 1855
1798#ifdef emacs
1799
1800DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, 1856DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0,
1801 doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. 1857 doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code.
1802See the documentation of `define-ccl-program' for the detail of CCL program. */) 1858See the documentation of `define-ccl-program' for the detail of CCL program. */)
@@ -2186,11 +2242,16 @@ The code point in the font is set in CCL registers R1 and R2
2186 If the font is single-byte font, the register R2 is not used. */); 2242 If the font is single-byte font, the register R2 is not used. */);
2187 Vfont_ccl_encoder_alist = Qnil; 2243 Vfont_ccl_encoder_alist = Qnil;
2188 2244
2245 DEFVAR_LISP ("translation-hash-table-vector", &Vtranslation_hash_table_vector,
2246 doc: /* Vector containing all translation hash tables ever defined.
2247Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls
2248to `define-translation-hash-table'. The vector is indexed by the table id
2249used by CCL. */);
2250 Vtranslation_hash_table_vector = Qnil;
2251
2189 defsubr (&Sccl_program_p); 2252 defsubr (&Sccl_program_p);
2190 defsubr (&Sccl_execute); 2253 defsubr (&Sccl_execute);
2191 defsubr (&Sccl_execute_on_string); 2254 defsubr (&Sccl_execute_on_string);
2192 defsubr (&Sregister_ccl_program); 2255 defsubr (&Sregister_ccl_program);
2193 defsubr (&Sregister_code_conversion_map); 2256 defsubr (&Sregister_code_conversion_map);
2194} 2257}
2195
2196#endif /* emacs */