fixed.
[elisp/apel.git] / pccl-om.el
1 ;;; pccl-om.el --- Portable CCL utility for Mule 1.* and Mule 2.*
2
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
4 ;; Copyright (C) 1998 Tanaka Akira
5
6 ;; Author: Tanaka Akira <akr@jaist.ac.jp>
7 ;;         Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
8 ;; Keywords: emulation, compatibility, Mule
9
10 ;; This file is part of APEL (A Portable Emacs Library).
11
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
16
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; 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; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Code:
28
29 (require 'poem)
30
31 (eval-when-compile (require 'ccl))
32
33 (defconst ccl-use-symbol-as-program nil
34   "t if CCL related builtins accept symbol as CCL program.
35 (20.2 with ExCCL, 20.3 or later)
36 Otherwise nil (20.2 without ExCCL or former).
37
38 Because emu provides functions accepting symbol as CCL program,
39 user programs should not refer this variable.")
40
41 (defun make-ccl-coding-system
42   (coding-system mnemonic doc-string decoder encoder)
43   "Define a new CODING-SYSTEM (symbol) by CCL programs
44 DECODER (symbol) and ENCODER (symbol)."
45   (setq decoder (symbol-value decoder)
46         encoder (symbol-value encoder))
47   (make-coding-system coding-system 4 mnemonic doc-string
48                       nil ; Mule takes one more optional argument: EOL-TYPE.
49                       (cons decoder encoder)))
50
51 (eval-when-compile
52   (define-ccl-program test-ccl-eof-block
53     '(1
54       (read r0)
55       (write "[EOF]")))
56
57   (make-ccl-coding-system
58    'test-ccl-eof-block-cs ?T "CCL_EOF_BLOCK tester"
59    'test-ccl-eof-block 'test-ccl-eof-block)
60   )
61
62 (defconst ccl-encoder-eof-block-is-broken
63   (eval-when-compile
64     (not (equal (encode-coding-string "" 'test-ccl-eof-block-cs)
65                 "[EOF]")))
66   "t if CCL_EOF_BLOCK is not executed when coding system encounts EOF on
67 encoding.")
68
69 (defconst ccl-decoder-eof-block-is-broken
70   (eval-when-compile
71     (not (equal (decode-coding-string "" 'test-ccl-eof-block-cs)
72                 "[EOF]")))
73   "t if CCL_EOF_BLOCK is not executed when coding system encounts EOF on
74 decoding.")
75
76 (defconst ccl-eof-block-is-broken
77   (or ccl-encoder-eof-block-is-broken
78       ccl-decoder-eof-block-is-broken))
79
80 (defun ccl-execute (ccl-prog reg)
81   "Execute CCL-PROG with registers initialized by REGISTERS.
82 If CCL-PROG is symbol, it is dereferenced.
83 \[Emacs 20.3 emulating function]"
84   (exec-ccl
85    (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
86    reg))
87
88 (defun ccl-execute-on-string (ccl-prog status string &optional contin)
89   "Execute CCL-PROG with initial STATUS on STRING.
90 If CCL-PROG is symbol, it is dereferenced.
91 \[Emacs 20.3 emulating function]"
92   (exec-ccl-string
93    (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
94    status string))
95
96
97 ;;; @ end
98 ;;;
99
100 (provide 'pccl-om)
101
102 ;;; pccl-om.el ends here