| 1 | /* Header for CCL (Code Conversion Language) interpreter. |
| 2 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 3 | 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
| 4 | National Institute of Advanced Industrial Science and Technology (AIST) |
| 5 | Registration Number H14PRO021 |
| 6 | Copyright (C) 2003 |
| 7 | National Institute of Advanced Industrial Science and Technology (AIST) |
| 8 | Registration Number H13PRO009 |
| 9 | |
| 10 | This file is part of GNU Emacs. |
| 11 | |
| 12 | GNU Emacs is free software: you can redistribute it and/or modify |
| 13 | it under the terms of the GNU General Public License as published by |
| 14 | the Free Software Foundation, either version 3 of the License, or |
| 15 | (at your option) any later version. |
| 16 | |
| 17 | GNU Emacs is distributed in the hope that it will be useful, |
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License |
| 23 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 24 | |
| 25 | |
| 26 | #ifndef EMACS_CCL_H |
| 27 | #define EMACS_CCL_H |
| 28 | |
| 29 | #include "character.h" /* For MAX_MULTIBYTE_LENGTH */ |
| 30 | |
| 31 | /* Macros for exit status of CCL program. */ |
| 32 | #define CCL_STAT_SUCCESS 0 /* Terminated successfully. */ |
| 33 | #define CCL_STAT_SUSPEND_BY_SRC 1 /* Terminated by empty input. */ |
| 34 | #define CCL_STAT_SUSPEND_BY_DST 2 /* Terminated by output buffer full. */ |
| 35 | #define CCL_STAT_INVALID_CMD 3 /* Terminated because of invalid |
| 36 | command. */ |
| 37 | #define CCL_STAT_QUIT 4 /* Terminated because of quit. */ |
| 38 | |
| 39 | /* Structure to hold information about running CCL code. Read |
| 40 | comments in the file ccl.c for the detail of each field. */ |
| 41 | struct ccl_program { |
| 42 | ptrdiff_t idx; /* Index number of the CCL program. |
| 43 | -1 means that the program was given |
| 44 | by a vector, not by a program |
| 45 | name. */ |
| 46 | int size; /* Size of the compiled code. */ |
| 47 | Lisp_Object *prog; /* Pointer into the compiled code. */ |
| 48 | int ic; /* Instruction Counter (index for PROG). */ |
| 49 | int eof_ic; /* Instruction Counter for end-of-file |
| 50 | processing code. */ |
| 51 | int reg[8]; /* CCL registers, reg[7] is used for |
| 52 | condition flag of relational |
| 53 | operations. */ |
| 54 | int status; /* Exit status of the CCL program. */ |
| 55 | int buf_magnification; /* Output buffer magnification. How |
| 56 | many times bigger the output buffer |
| 57 | should be than the input buffer. */ |
| 58 | int stack_idx; /* How deep the call of CCL_Call is nested. */ |
| 59 | int consumed; |
| 60 | int produced; |
| 61 | bool_bf last_block : 1; /* Set to true while processing the last |
| 62 | block. */ |
| 63 | bool_bf quit_silently : 1; /* If true, don't append "CCL: |
| 64 | Quitted" to the generated text when |
| 65 | CCL program is quitted. */ |
| 66 | }; |
| 67 | |
| 68 | /* This data type is used for the spec field of the structure |
| 69 | coding_system. */ |
| 70 | |
| 71 | struct ccl_spec { |
| 72 | struct ccl_program ccl; |
| 73 | }; |
| 74 | |
| 75 | #define CODING_SPEC_CCL_PROGRAM(coding) ((coding)->spec.ccl.ccl) |
| 76 | |
| 77 | /* Setup fields of the structure pointed by CCL appropriately for the |
| 78 | execution of ccl program CCL_PROG (symbol or vector). */ |
| 79 | extern bool setup_ccl_program (struct ccl_program *, Lisp_Object); |
| 80 | |
| 81 | extern void ccl_driver (struct ccl_program *, int *, int *, int, int, |
| 82 | Lisp_Object); |
| 83 | |
| 84 | extern Lisp_Object Qccl, Qcclp; |
| 85 | |
| 86 | #define CHECK_CCL_PROGRAM(x) \ |
| 87 | do { \ |
| 88 | if (NILP (Fccl_program_p (x))) \ |
| 89 | wrong_type_argument (Qcclp, (x)); \ |
| 90 | } while (false); |
| 91 | |
| 92 | #endif /* EMACS_CCL_H */ |