aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-08-22 14:35:06 +0000
committerChong Yidong2009-08-22 14:35:06 +0000
commit18ac3e1edd392421e0d6696973cb8620beddb7eb (patch)
tree87fcb7ff2785d63d1b1891d6666a24c3312e0649
parentf88099c0e054dcf58415313e186b664b49f17121 (diff)
downloademacs-18ac3e1edd392421e0d6696973cb8620beddb7eb.tar.gz
emacs-18ac3e1edd392421e0d6696973cb8620beddb7eb.zip
Simplified version of Emacs/XEmacs compatibility code from upstream.
Declare eieio-defgeneric-form. Add defvars for bytecomp-outbuffer and defvar bytecomp-filename to silence compiler.
-rw-r--r--lisp/eieio/eieio-comp.el90
1 files changed, 67 insertions, 23 deletions
diff --git a/lisp/eieio/eieio-comp.el b/lisp/eieio/eieio-comp.el
index 652d3e9163b..8c75aee313a 100644
--- a/lisp/eieio/eieio-comp.el
+++ b/lisp/eieio/eieio-comp.el
@@ -32,6 +32,67 @@
32 32
33;;; Code: 33;;; Code:
34 34
35(eval-and-compile
36 (if (featurep 'xemacs)
37 (progn
38 ;; XEmacs compatibility settings.
39 (if (not (fboundp 'byte-compile-compiled-obj-to-list))
40 (defun byte-compile-compiled-obj-to-list (moose) nil))
41 (if (not (boundp 'byte-compile-outbuffer))
42 (defvar byte-compile-outbuffer nil))
43 (defmacro eieio-byte-compile-princ-code (code outbuffer)
44 `(progn (if (atom ,code)
45 (princ "#[" ,outbuffer)
46 (princ "'(" ,outbuffer))
47 (let ((codelist (if (byte-code-function-p ,code)
48 (byte-compile-compiled-obj-to-list ,code)
49 (append ,code nil))))
50 (while codelist
51 (eieio-prin1 (car codelist) ,outbuffer)
52 (princ " " ,outbuffer)
53 (setq codelist (cdr codelist))))
54 (if (atom ,code)
55 (princ "]" ,outbuffer)
56 (princ ")" ,outbuffer))))
57 (defun eieio-prin1 (code outbuffer)
58 (cond ((byte-code-function-p code)
59 (let ((codelist (byte-compile-compiled-obj-to-list code)))
60 (princ "#[" outbuffer)
61 (while codelist
62 (eieio-prin1 (car codelist) outbuffer)
63 (princ " " outbuffer)
64 (setq codelist (cdr codelist)))
65 (princ "]" outbuffer)))
66 ((vectorp code)
67 (let ((i 0) (ln (length code)))
68 (princ "[" outbuffer)
69 (while (< i ln)
70 (eieio-prin1 (aref code i) outbuffer)
71 (princ " " outbuffer)
72 (setq i (1+ i)))
73 (princ "]" outbuffer)))
74 (t (prin1 code outbuffer)))))
75 ;; Emacs:
76 (defmacro eieio-byte-compile-princ-code (code outbuffer)
77 (list 'prin1 code outbuffer))
78 ;; Dynamically bound in byte-compile-from-buffer.
79 (defvar bytecomp-outbuffer)
80 (defvar bytecomp-filename)))
81
82(declare-function eieio-defgeneric-form "eieio" (method doc-string))
83
84(defun byte-compile-defmethod-param-convert (paramlist)
85 "Convert method params into the params used by the defmethod thingy.
86Argument PARAMLIST is the paramter list to convert."
87 (let ((argfix nil))
88 (while paramlist
89 (setq argfix (cons (if (listp (car paramlist))
90 (car (car paramlist))
91 (car paramlist))
92 argfix))
93 (setq paramlist (cdr paramlist)))
94 (nreverse argfix)))
95
35;; This teaches the byte compiler how to do this sort of thing. 96;; This teaches the byte compiler how to do this sort of thing.
36(put 'defmethod 'byte-hunk-handler 'byte-compile-file-form-defmethod) 97(put 'defmethod 'byte-hunk-handler 'byte-compile-file-form-defmethod)
37 98
@@ -65,19 +126,14 @@ that is called but rarely. Argument FORM is the body of the method."
65 (lamparams (byte-compile-defmethod-param-convert params)) 126 (lamparams (byte-compile-defmethod-param-convert params))
66 (arg1 (car params)) 127 (arg1 (car params))
67 (class (if (listp arg1) (nth 1 arg1) nil)) 128 (class (if (listp arg1) (nth 1 arg1) nil))
68 (my-outbuffer (if (eval-when-compile 129 (my-outbuffer (if (featurep 'xemacs)
69 (string-match "XEmacs" emacs-version))
70 byte-compile-outbuffer 130 byte-compile-outbuffer
71 (condition-case nil 131 bytecomp-outbuffer)))
72 bytecomp-outbuffer
73 (error outbuffer))))
74 )
75 (let ((name (format "%s::%s" (or class "#<generic>") meth))) 132 (let ((name (format "%s::%s" (or class "#<generic>") meth)))
76 (if byte-compile-verbose 133 (if byte-compile-verbose
77 ;; #### filename used free 134 ;; bytecomp-filename is from byte-compile-from-buffer.
78 (message "Compiling %s... (%s)" (or filename "") name)) 135 (message "Compiling %s... (%s)" (or bytecomp-filename "") name))
79 (setq byte-compile-current-form name) ; for warnings 136 (setq byte-compile-current-form name)) ; for warnings
80 )
81 ;; Flush any pending output 137 ;; Flush any pending output
82 (byte-compile-flush-pending) 138 (byte-compile-flush-pending)
83 ;; Byte compile the body. For the byte compiled forms, add the 139 ;; Byte compile the body. For the byte compiled forms, add the
@@ -93,7 +149,7 @@ that is called but rarely. Argument FORM is the body of the method."
93 (princ key my-outbuffer) 149 (princ key my-outbuffer)
94 (prin1 params my-outbuffer) 150 (prin1 params my-outbuffer)
95 (princ " " my-outbuffer) 151 (princ " " my-outbuffer)
96 (prin1 code my-outbuffer) 152 (eieio-byte-compile-princ-code code my-outbuffer)
97 (princ "))" my-outbuffer)) 153 (princ "))" my-outbuffer))
98 ;; Now add this function to the list of known functions. 154 ;; Now add this function to the list of known functions.
99 ;; Don't bother with a doc string. Not relevant here. 155 ;; Don't bother with a doc string. Not relevant here.
@@ -109,18 +165,6 @@ that is called but rarely. Argument FORM is the body of the method."
109 ;; nil prevents cruft from appearing in the output buffer. 165 ;; nil prevents cruft from appearing in the output buffer.
110 nil)) 166 nil))
111 167
112(defun byte-compile-defmethod-param-convert (paramlist)
113 "Convert method params into the params used by the defmethod thingy.
114Argument PARAMLIST is the paramter list to convert."
115 (let ((argfix nil))
116 (while paramlist
117 (setq argfix (cons (if (listp (car paramlist))
118 (car (car paramlist))
119 (car paramlist))
120 argfix))
121 (setq paramlist (cdr paramlist)))
122 (nreverse argfix)))
123
124(provide 'eieio-comp) 168(provide 'eieio-comp)
125 169
126;;; eieio-comp.el ends here 170;;; eieio-comp.el ends here