diff options
| author | Dave Love | 2002-07-05 18:54:22 +0000 |
|---|---|---|
| committer | Dave Love | 2002-07-05 18:54:22 +0000 |
| commit | d80dc57e0d13d64fff21608a91b95701faf75a1e (patch) | |
| tree | 22b392eff2a3c1a49d3817a7cb9cca1a67e73afb | |
| parent | e431fcda805ccc6b2442ddf5b7f2fcac29ab7d85 (diff) | |
| download | emacs-d80dc57e0d13d64fff21608a91b95701faf75a1e.tar.gz emacs-d80dc57e0d13d64fff21608a91b95701faf75a1e.zip | |
(Vtranslation_hash_table_vector, GET_HASH_TABLE)
(HASH_VALUE, CCL_LookupIntConstTbl, CCL_LookupCharConstTbl): New.
(ccl_driver): Add cases for CCL_LookupIntConstTbl,
CCL_LookupCharConstTbl.
(syms_of_ccl): Defvar translation-hash-table-vector.
| -rw-r--r-- | src/ccl.c | 74 |
1 files changed, 73 insertions, 1 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | /* CCL (Code Conversion Language) interpreter. | 1 | /* CCL (Code Conversion Language) interpreter. |
| 2 | Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. | 2 | Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. |
| 3 | Copyright (C) 2001 Free Software Foundation, Inc. | 3 | Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
| 4 | Licensed to the Free Software Foundation. | 4 | Licensed to the Free Software Foundation. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| @@ -65,6 +65,15 @@ Lisp_Object Qccl_program_idx; | |||
| 65 | already resolved to index numbers or not. */ | 65 | already resolved to index numbers or not. */ |
| 66 | Lisp_Object Vccl_program_table; | 66 | Lisp_Object Vccl_program_table; |
| 67 | 67 | ||
| 68 | /* Vector of registered hash tables for translation. */ | ||
| 69 | Lisp_Object Vtranslation_hash_table_vector; | ||
| 70 | |||
| 71 | /* Return a hash table of id number ID. */ | ||
| 72 | #define GET_HASH_TABLE(id) \ | ||
| 73 | (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)]))) | ||
| 74 | /* Copied from fns.c. */ | ||
| 75 | #define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1) | ||
| 76 | |||
| 68 | /* CCL (Code Conversion Language) is a simple language which has | 77 | /* CCL (Code Conversion Language) is a simple language which has |
| 69 | operations on one input buffer, one output buffer, and 7 registers. | 78 | operations on one input buffer, one output buffer, and 7 registers. |
| 70 | The syntax of CCL is described in `ccl.el'. Emacs Lisp function | 79 | The syntax of CCL is described in `ccl.el'. Emacs Lisp function |
| @@ -652,6 +661,18 @@ while (0) | |||
| 652 | set reg[RRR] to -1. | 661 | set reg[RRR] to -1. |
| 653 | */ | 662 | */ |
| 654 | 663 | ||
| 664 | #define CCL_LookupIntConstTbl 0x13 /* Lookup multibyte character by | ||
| 665 | integer key. Afterwards R7 set | ||
| 666 | to 1 iff lookup succeeded. | ||
| 667 | 1:ExtendedCOMMNDRrrRRRXXXXXXXX | ||
| 668 | 2:ARGUMENT(Hash table ID) */ | ||
| 669 | |||
| 670 | #define CCL_LookupCharConstTbl 0x14 /* Lookup integer by multibyte | ||
| 671 | character key. Afterwards R7 set | ||
| 672 | to 1 iff lookup succeeded. | ||
| 673 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX | ||
| 674 | 2:ARGUMENT(Hash table ID) */ | ||
| 675 | |||
| 655 | /* CCL arithmetic/logical operators. */ | 676 | /* CCL arithmetic/logical operators. */ |
| 656 | #define CCL_PLUS 0x00 /* X = Y + Z */ | 677 | #define CCL_PLUS 0x00 /* X = Y + Z */ |
| 657 | #define CCL_MINUS 0x01 /* X = Y - Z */ | 678 | #define CCL_MINUS 0x01 /* X = Y - Z */ |
| @@ -1406,6 +1427,50 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1406 | reg[rrr] = i; | 1427 | reg[rrr] = i; |
| 1407 | break; | 1428 | break; |
| 1408 | 1429 | ||
| 1430 | case CCL_LookupIntConstTbl: | ||
| 1431 | op = XINT (ccl_prog[ic]); /* table */ | ||
| 1432 | ic++; | ||
| 1433 | { | ||
| 1434 | struct Lisp_Hash_Table *h = GET_HASH_TABLE (op); | ||
| 1435 | |||
| 1436 | op = hash_lookup (h, make_number (reg[RRR]), NULL); | ||
| 1437 | if (op >= 0) | ||
| 1438 | { | ||
| 1439 | op = HASH_VALUE (h, op); | ||
| 1440 | if (!CHAR_VALID_P (op, 0)) | ||
| 1441 | CCL_INVALID_CMD; | ||
| 1442 | SPLIT_CHAR (XINT (op), reg[RRR], i, j); | ||
| 1443 | if (j != -1) | ||
| 1444 | i = (i << 7) | j; | ||
| 1445 | reg[rrr] = i; | ||
| 1446 | reg[7] = 1; /* r7 true for success */ | ||
| 1447 | } | ||
| 1448 | else | ||
| 1449 | reg[7] = 0; | ||
| 1450 | } | ||
| 1451 | break; | ||
| 1452 | |||
| 1453 | case CCL_LookupCharConstTbl: | ||
| 1454 | op = XINT (ccl_prog[ic]); /* table */ | ||
| 1455 | ic++; | ||
| 1456 | CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); | ||
| 1457 | { | ||
| 1458 | struct Lisp_Hash_Table *h = GET_HASH_TABLE (op); | ||
| 1459 | |||
| 1460 | op = hash_lookup (h, make_number (i), NULL); | ||
| 1461 | if (op >= 0) | ||
| 1462 | { | ||
| 1463 | op = HASH_VALUE (h, op); | ||
| 1464 | if (!INTEGERP (op)) | ||
| 1465 | CCL_INVALID_CMD; | ||
| 1466 | reg[RRR] = XINT (op); | ||
| 1467 | reg[7] = 1; /* r7 true for success */ | ||
| 1468 | } | ||
| 1469 | else | ||
| 1470 | reg[7] = 0; | ||
| 1471 | } | ||
| 1472 | break; | ||
| 1473 | |||
| 1409 | case CCL_IterateMultipleMap: | 1474 | case CCL_IterateMultipleMap: |
| 1410 | { | 1475 | { |
| 1411 | Lisp_Object map, content, attrib, value; | 1476 | Lisp_Object map, content, attrib, value; |
| @@ -2336,6 +2401,13 @@ The code point in the font is set in CCL registers R1 and R2 | |||
| 2336 | If the font is single-byte font, the register R2 is not used. */); | 2401 | If the font is single-byte font, the register R2 is not used. */); |
| 2337 | Vfont_ccl_encoder_alist = Qnil; | 2402 | Vfont_ccl_encoder_alist = Qnil; |
| 2338 | 2403 | ||
| 2404 | DEFVAR_LISP ("translation-hash-table-vector", &Vtranslation_hash_table_vector, | ||
| 2405 | doc: /* Vector containing all translation hash tables ever defined. | ||
| 2406 | Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls | ||
| 2407 | to `define-translation-hash-table'. The vector is indexed by the table id | ||
| 2408 | used by CCL. */); | ||
| 2409 | Vtranslation_hash_table_vector = Qnil; | ||
| 2410 | |||
| 2339 | defsubr (&Sccl_program_p); | 2411 | defsubr (&Sccl_program_p); |
| 2340 | defsubr (&Sccl_execute); | 2412 | defsubr (&Sccl_execute); |
| 2341 | defsubr (&Sccl_execute_on_string); | 2413 | defsubr (&Sccl_execute_on_string); |