/[emacs]/emacs/src/ccl.c
ViewVC logotype

Diff of /emacs/src/ccl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.76.2.2 by handa, Fri Jul 26 04:05:16 2002 UTC revision 1.76.2.3 by fx, Tue Jul 30 11:31:54 2002 UTC
# Line 23  along with GNU Emacs; see the file COPYI Line 23  along with GNU Emacs; see the file COPYI
23  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  Boston, MA 02111-1307, USA.  */  Boston, MA 02111-1307, USA.  */
25    
 #ifdef emacs  
26  #include <config.h>  #include <config.h>
 #endif  
27    
28  #include <stdio.h>  #include <stdio.h>
29    
 #ifdef emacs  
   
30  #include "lisp.h"  #include "lisp.h"
31  #include "character.h"  #include "character.h"
32  #include "charset.h"  #include "charset.h"
33  #include "ccl.h"  #include "ccl.h"
34  #include "coding.h"  #include "coding.h"
35    
 #else  /* not emacs */  
   
 #include "mulelib.h"  
   
 #endif /* not emacs */  
   
36  Lisp_Object Qccl, Qcclp;  Lisp_Object Qccl, Qcclp;
37    
38  /* This contains all code conversion map available to CCL.  */  /* This contains all code conversion map available to CCL.  */
# Line 71  Lisp_Object Qccl_program_idx; Line 61  Lisp_Object Qccl_program_idx;
61     already resolved to index numbers or not.  */     already resolved to index numbers or not.  */
62  Lisp_Object Vccl_program_table;  Lisp_Object Vccl_program_table;
63    
64    /* Vector of registered hash tables for translation.  */
65    Lisp_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    
73    extern int charset_unicode;
74    
75  /* CCL (Code Conversion Language) is a simple language which has  /* CCL (Code Conversion Language) is a simple language which has
76     operations on one input buffer, one output buffer, and 7 registers.     operations on one input buffer, one output buffer, and 7 registers.
77     The syntax of CCL is described in `ccl.el'.  Emacs Lisp function     The syntax of CCL is described in `ccl.el'.  Emacs Lisp function
# Line 658  while (0) Line 659  while (0)
659                                            set reg[RRR] to -1.                                            set reg[RRR] to -1.
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    
674  /* CCL arithmetic/logical operators. */  /* CCL arithmetic/logical operators. */
675  #define CCL_PLUS        0x00    /* X = Y + Z */  #define CCL_PLUS        0x00    /* X = Y + Z */
676  #define CCL_MINUS       0x01    /* X = Y - Z */  #define CCL_MINUS       0x01    /* X = Y - Z */
# Line 1214  ccl_driver (ccl, source, destination, sr Line 1227  ccl_driver (ccl, source, destination, sr
1227                reg[rrr] = ENCODE_CHAR (charset, op);                reg[rrr] = ENCODE_CHAR (charset, op);
1228                break;                break;
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    
1275              case CCL_IterateMultipleMap:              case CCL_IterateMultipleMap:
1276                {                {
1277                  Lisp_Object map, content, attrib, value;                  Lisp_Object map, content, attrib, value;
# Line 1795  setup_ccl_program (ccl, ccl_prog) Line 1853  setup_ccl_program (ccl, ccl_prog)
1853    return 0;    return 0;
1854  }  }
1855    
 #ifdef emacs  
   
1856  DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0,  DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0,
1857         doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code.         doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code.
1858  See the documentation of  `define-ccl-program' for the detail of CCL program.  */)  See the documentation of  `define-ccl-program' for the detail of CCL program.  */)
# Line 2186  The code point in the font is set in CCL Line 2242  The code point in the font is set in CCL
2242   If the font is single-byte font, the register R2 is not used.  */);   If the font is single-byte font, the register R2 is not used.  */);
2243    Vfont_ccl_encoder_alist = Qnil;    Vfont_ccl_encoder_alist = Qnil;
2244    
2245      DEFVAR_LISP ("translation-hash-table-vector", &Vtranslation_hash_table_vector,
2246        doc: /* Vector containing all translation hash tables ever defined.
2247    Comprises pairs (SYMBOL . TABLE) where SYMBOL and TABLE were set up by calls
2248    to `define-translation-hash-table'.  The vector is indexed by the table id
2249    used by CCL.  */);
2250        Vtranslation_hash_table_vector = Qnil;
2251    
2252    defsubr (&Sccl_program_p);    defsubr (&Sccl_program_p);
2253    defsubr (&Sccl_execute);    defsubr (&Sccl_execute);
2254    defsubr (&Sccl_execute_on_string);    defsubr (&Sccl_execute_on_string);
2255    defsubr (&Sregister_ccl_program);    defsubr (&Sregister_ccl_program);
2256    defsubr (&Sregister_code_conversion_map);    defsubr (&Sregister_code_conversion_map);
2257  }  }
   
 #endif  /* emacs */  

Legend:
Removed from v.1.76.2.2  
changed lines
  Added in v.1.76.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26