diff options
| author | Kenichi Handa | 2005-05-27 11:27:50 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2005-05-27 11:27:50 +0000 |
| commit | 2a69c66e3ab906db41a40bbe452db563335cb6ab (patch) | |
| tree | 8e3273c0604ce619caaf328320be65dab89832a7 /src | |
| parent | 968786fd0ed183f9d8d651e740822c021a1e96ec (diff) | |
| download | emacs-2a69c66e3ab906db41a40bbe452db563335cb6ab.tar.gz emacs-2a69c66e3ab906db41a40bbe452db563335cb6ab.zip | |
Now an element of Vccl_program_table is a vector of
length 4, not 3.
(ccl_get_compiled_code): New arg idx. Caller changed. Adjusted
for the change of Vccl_program_table.
(setup_ccl_program): Adjusted for the change of
Vccl_program_table.
(check_ccl_update): New function.
(Fregister_ccl_program): Use ASET to set an element of a vector.
Adjusted for the change of Vccl_program_table.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 72 |
1 files changed, 56 insertions, 16 deletions
| @@ -49,10 +49,12 @@ Lisp_Object Qcode_conversion_map_id; | |||
| 49 | Lisp_Object Qccl_program_idx; | 49 | Lisp_Object Qccl_program_idx; |
| 50 | 50 | ||
| 51 | /* Table of registered CCL programs. Each element is a vector of | 51 | /* Table of registered CCL programs. Each element is a vector of |
| 52 | NAME, CCL_PROG, and RESOLVEDP where NAME (symbol) is the name of | 52 | NAME, CCL_PROG, RESOLVEDP, and UPDATEDP, where NAME (symbol) is the |
| 53 | the program, CCL_PROG (vector) is the compiled code of the program, | 53 | name of the program, CCL_PROG (vector) is the compiled code of the |
| 54 | RESOLVEDP (t or nil) is the flag to tell if symbols in CCL_PROG is | 54 | program, RESOLVEDP (t or nil) is the flag to tell if symbols in |
| 55 | already resolved to index numbers or not. */ | 55 | CCL_PROG is already resolved to index numbers or not, UPDATEDP (t |
| 56 | or nil) is the flat to tell if the CCL program is updated after it | ||
| 57 | was once used. */ | ||
| 56 | Lisp_Object Vccl_program_table; | 58 | Lisp_Object Vccl_program_table; |
| 57 | 59 | ||
| 58 | /* Vector of registered hash tables for translation. */ | 60 | /* Vector of registered hash tables for translation. */ |
| @@ -2028,14 +2030,16 @@ resolve_symbol_ccl_program (ccl) | |||
| 2028 | symbols, return Qnil. */ | 2030 | symbols, return Qnil. */ |
| 2029 | 2031 | ||
| 2030 | static Lisp_Object | 2032 | static Lisp_Object |
| 2031 | ccl_get_compiled_code (ccl_prog) | 2033 | ccl_get_compiled_code (ccl_prog, idx) |
| 2032 | Lisp_Object ccl_prog; | 2034 | Lisp_Object ccl_prog; |
| 2035 | int *idx; | ||
| 2033 | { | 2036 | { |
| 2034 | Lisp_Object val, slot; | 2037 | Lisp_Object val, slot; |
| 2035 | 2038 | ||
| 2036 | if (VECTORP (ccl_prog)) | 2039 | if (VECTORP (ccl_prog)) |
| 2037 | { | 2040 | { |
| 2038 | val = resolve_symbol_ccl_program (ccl_prog); | 2041 | val = resolve_symbol_ccl_program (ccl_prog); |
| 2042 | *idx = -1; | ||
| 2039 | return (VECTORP (val) ? val : Qnil); | 2043 | return (VECTORP (val) ? val : Qnil); |
| 2040 | } | 2044 | } |
| 2041 | if (!SYMBOLP (ccl_prog)) | 2045 | if (!SYMBOLP (ccl_prog)) |
| @@ -2047,9 +2051,10 @@ ccl_get_compiled_code (ccl_prog) | |||
| 2047 | return Qnil; | 2051 | return Qnil; |
| 2048 | slot = AREF (Vccl_program_table, XINT (val)); | 2052 | slot = AREF (Vccl_program_table, XINT (val)); |
| 2049 | if (! VECTORP (slot) | 2053 | if (! VECTORP (slot) |
| 2050 | || ASIZE (slot) != 3 | 2054 | || ASIZE (slot) != 4 |
| 2051 | || ! VECTORP (AREF (slot, 1))) | 2055 | || ! VECTORP (AREF (slot, 1))) |
| 2052 | return Qnil; | 2056 | return Qnil; |
| 2057 | *idx = XINT (val); | ||
| 2053 | if (NILP (AREF (slot, 2))) | 2058 | if (NILP (AREF (slot, 2))) |
| 2054 | { | 2059 | { |
| 2055 | val = resolve_symbol_ccl_program (AREF (slot, 1)); | 2060 | val = resolve_symbol_ccl_program (AREF (slot, 1)); |
| @@ -2078,7 +2083,7 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 2078 | { | 2083 | { |
| 2079 | struct Lisp_Vector *vp; | 2084 | struct Lisp_Vector *vp; |
| 2080 | 2085 | ||
| 2081 | ccl_prog = ccl_get_compiled_code (ccl_prog); | 2086 | ccl_prog = ccl_get_compiled_code (ccl_prog, &ccl->idx); |
| 2082 | if (! VECTORP (ccl_prog)) | 2087 | if (! VECTORP (ccl_prog)) |
| 2083 | return -1; | 2088 | return -1; |
| 2084 | vp = XVECTOR (ccl_prog); | 2089 | vp = XVECTOR (ccl_prog); |
| @@ -2086,6 +2091,13 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 2086 | ccl->prog = vp->contents; | 2091 | ccl->prog = vp->contents; |
| 2087 | ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]); | 2092 | ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]); |
| 2088 | ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]); | 2093 | ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]); |
| 2094 | if (ccl->idx >= 0) | ||
| 2095 | { | ||
| 2096 | Lisp_Object slot; | ||
| 2097 | |||
| 2098 | slot = AREF (Vccl_program_table, ccl->idx); | ||
| 2099 | ASET (slot, 3, Qnil); | ||
| 2100 | } | ||
| 2089 | } | 2101 | } |
| 2090 | ccl->ic = CCL_HEADER_MAIN; | 2102 | ccl->ic = CCL_HEADER_MAIN; |
| 2091 | for (i = 0; i < 8; i++) | 2103 | for (i = 0; i < 8; i++) |
| @@ -2100,6 +2112,33 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 2100 | return 0; | 2112 | return 0; |
| 2101 | } | 2113 | } |
| 2102 | 2114 | ||
| 2115 | |||
| 2116 | /* Check if CCL is updated or not. If not, re-setup members of CCL. */ | ||
| 2117 | |||
| 2118 | int | ||
| 2119 | check_ccl_update (ccl) | ||
| 2120 | struct ccl_program *ccl; | ||
| 2121 | { | ||
| 2122 | struct Lisp_Vector *vp; | ||
| 2123 | Lisp_Object slot, ccl_prog; | ||
| 2124 | |||
| 2125 | if (ccl->idx < 0) | ||
| 2126 | return 0; | ||
| 2127 | slot = AREF (Vccl_program_table, ccl->idx); | ||
| 2128 | if (NILP (AREF (slot, 3))) | ||
| 2129 | return 0; | ||
| 2130 | ccl_prog = ccl_get_compiled_code (AREF (slot, 0), &ccl->idx); | ||
| 2131 | if (! VECTORP (ccl_prog)) | ||
| 2132 | return -1; | ||
| 2133 | ccl->size = ASIZE (ccl_prog); | ||
| 2134 | ccl->prog = XVECTOR (ccl_prog)->contents; | ||
| 2135 | ccl->eof_ic = XINT (AREF (ccl_prog, CCL_HEADER_EOF)); | ||
| 2136 | ccl->buf_magnification = XINT (AREF (ccl_prog, CCL_HEADER_BUF_MAG)); | ||
| 2137 | ASET (slot, 3, Qnil); | ||
| 2138 | return 0; | ||
| 2139 | } | ||
| 2140 | |||
| 2141 | |||
| 2103 | DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, | 2142 | DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, |
| 2104 | doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. | 2143 | doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. |
| 2105 | See the documentation of `define-ccl-program' for the detail of CCL program. */) | 2144 | See the documentation of `define-ccl-program' for the detail of CCL program. */) |
| @@ -2298,8 +2337,9 @@ Return index number of the registered CCL program. */) | |||
| 2298 | if (EQ (name, AREF (slot, 0))) | 2337 | if (EQ (name, AREF (slot, 0))) |
| 2299 | { | 2338 | { |
| 2300 | /* Update this slot. */ | 2339 | /* Update this slot. */ |
| 2301 | AREF (slot, 1) = ccl_prog; | 2340 | ASET (slot, 1, ccl_prog); |
| 2302 | AREF (slot, 2) = resolved; | 2341 | ASET (slot, 2, resolved); |
| 2342 | ASET (slot, 3, Qt); | ||
| 2303 | return make_number (idx); | 2343 | return make_number (idx); |
| 2304 | } | 2344 | } |
| 2305 | } | 2345 | } |
| @@ -2312,19 +2352,19 @@ Return index number of the registered CCL program. */) | |||
| 2312 | 2352 | ||
| 2313 | new_table = Fmake_vector (make_number (len * 2), Qnil); | 2353 | new_table = Fmake_vector (make_number (len * 2), Qnil); |
| 2314 | for (j = 0; j < len; j++) | 2354 | for (j = 0; j < len; j++) |
| 2315 | AREF (new_table, j) | 2355 | ASET (new_table, j, AREF (Vccl_program_table, j)); |
| 2316 | = AREF (Vccl_program_table, j); | ||
| 2317 | Vccl_program_table = new_table; | 2356 | Vccl_program_table = new_table; |
| 2318 | } | 2357 | } |
| 2319 | 2358 | ||
| 2320 | { | 2359 | { |
| 2321 | Lisp_Object elt; | 2360 | Lisp_Object elt; |
| 2322 | 2361 | ||
| 2323 | elt = Fmake_vector (make_number (3), Qnil); | 2362 | elt = Fmake_vector (make_number (4), Qnil); |
| 2324 | AREF (elt, 0) = name; | 2363 | ASET (elt, 0, name); |
| 2325 | AREF (elt, 1) = ccl_prog; | 2364 | ASET (elt, 1, ccl_prog); |
| 2326 | AREF (elt, 2) = resolved; | 2365 | ASET (elt, 2, resolved); |
| 2327 | AREF (Vccl_program_table, idx) = elt; | 2366 | ASET (elt, 3, Qt); |
| 2367 | ASET (Vccl_program_table, idx, elt); | ||
| 2328 | } | 2368 | } |
| 2329 | 2369 | ||
| 2330 | Fput (name, Qccl_program_idx, make_number (idx)); | 2370 | Fput (name, Qccl_program_idx, make_number (idx)); |