/[slime]/slime/swank-lispworks.lisp
ViewVC logotype

Contents of /slime/swank-lispworks.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.142 - (hide annotations)
Thu Nov 3 18:31:19 2011 UTC (2 years, 5 months ago) by heller
Branch: MAIN
CVS Tags: SLIME-2-3, byte-stream, FAIRLY-STABLE
Changes since 1.141: +225 -22 lines
Remove dependecy on FLEXI-STREAMS for Lispworks.

* swank-lispworks.lisp (make-flexi-stream): Deleted.
(utf8-stream): New class to do the transcoding.
(accept-connection): Use it.
1 heller 1.74 ;;; -*- indent-tabs-mode: nil -*-
2 heller 1.1 ;;;
3     ;;; swank-lispworks.lisp --- LispWorks specific code for SLIME.
4     ;;;
5     ;;; Created 2003, Helmut Eller
6     ;;;
7     ;;; This code has been placed in the Public Domain. All warranties
8     ;;; are disclaimed.
9     ;;;
10    
11 heller 1.30 (in-package :swank-backend)
12 heller 1.1
13     (eval-when (:compile-toplevel :load-toplevel :execute)
14 heller 1.79 (require "comm")
15     (import-from :stream *gray-stream-symbols* :swank-backend))
16 heller 1.1
17 heller 1.62 (import-swank-mop-symbols :clos '(:slot-definition-documentation
18 msimmons 1.129 :slot-boundp-using-class
19     :slot-value-using-class
20     :slot-makunbound-using-class
21 heller 1.62 :eql-specializer
22 heller 1.65 :eql-specializer-object
23     :compute-applicable-methods-using-classes))
24 msimmons 1.57
25     (defun swank-mop:slot-definition-documentation (slot)
26     (documentation slot t))
27 mbaringer 1.59
28 msimmons 1.129 (defun swank-mop:slot-boundp-using-class (class object slotd)
29     (clos:slot-boundp-using-class class object
30     (clos:slot-definition-name slotd)))
31    
32     (defun swank-mop:slot-value-using-class (class object slotd)
33     (clos:slot-value-using-class class object
34     (clos:slot-definition-name slotd)))
35    
36     (defun (setf swank-mop:slot-value-using-class) (value class object slotd)
37     (setf (clos:slot-value-using-class class object
38     (clos:slot-definition-name slotd))
39     value))
40    
41     (defun swank-mop:slot-makunbound-using-class (class object slotd)
42     (clos:slot-makunbound-using-class class object
43     (clos:slot-definition-name slotd)))
44    
45 heller 1.65 (defun swank-mop:compute-applicable-methods-using-classes (gf classes)
46     (clos::compute-applicable-methods-from-classes gf classes))
47    
48     ;; lispworks doesn't have the eql-specializer class, it represents
49     ;; them as a list of `(EQL ,OBJECT)
50 mbaringer 1.59 (deftype swank-mop:eql-specializer () 'cons)
51    
52     (defun swank-mop:eql-specializer-object (eql-spec)
53     (second eql-spec))
54 msimmons 1.57
55 heller 1.111 (eval-when (:compile-toplevel :execute :load-toplevel)
56     (defvar *original-defimplementation* (macro-function 'defimplementation))
57     (defmacro defimplementation (&whole whole name args &body body
58     &environment env)
59     (declare (ignore args body))
60     `(progn
61     (dspec:record-definition '(defun ,name) (dspec:location)
62     :check-redefinition-p nil)
63     ,(funcall *original-defimplementation* whole env))))
64 heller 1.49
65 heller 1.13 ;;; TCP server
66 lgorrie 1.12
67 heller 1.30 (defimplementation preferred-communication-style ()
68     :spawn)
69 heller 1.18
70 heller 1.13 (defun socket-fd (socket)
71     (etypecase socket
72     (fixnum socket)
73     (comm:socket-stream (comm:socket-stream-socket socket))))
74    
75 heller 1.22 (defimplementation create-socket (host port)
76 heller 1.13 (multiple-value-bind (socket where errno)
77 msimmons 1.64 #-(or lispworks4.1 (and macosx lispworks4.3))
78     (comm::create-tcp-socket-for-service port :address host)
79     #+(or lispworks4.1 (and macosx lispworks4.3))
80     (comm::create-tcp-socket-for-service port)
81 heller 1.13 (cond (socket socket)
82 heller 1.14 (t (error 'network-error
83 heller 1.13 :format-control "~A failed: ~A (~D)"
84     :format-arguments (list where
85     (list #+unix (lw:get-unix-error errno))
86 heller 1.14 errno))))))
87 heller 1.13
88 lgorrie 1.17 (defimplementation local-port (socket)
89 heller 1.13 (nth-value 1 (comm:get-socket-address (socket-fd socket))))
90    
91 lgorrie 1.17 (defimplementation close-socket (socket)
92 heller 1.13 (comm::close-socket (socket-fd socket)))
93    
94 heller 1.63 (defimplementation accept-connection (socket
95 heller 1.85 &key external-format buffering timeout)
96 heller 1.118 (declare (ignore buffering))
97 heller 1.61 (let* ((fd (comm::get-fd-from-socket socket)))
98 heller 1.13 (assert (/= fd -1))
99 heller 1.118 (assert (valid-external-format-p external-format))
100     (cond ((member (first external-format) '(:latin-1 :ascii))
101     (make-instance 'comm:socket-stream
102     :socket fd
103     :direction :io
104     :read-timeout timeout
105     :element-type 'base-char))
106     (t
107 heller 1.142 (assert (member (first external-format) '(:utf-8)))
108     (make-instance 'utf8-stream
109     :byte-stream
110     (make-instance 'comm:socket-stream
111     :socket fd
112     :direction :io
113     :read-timeout timeout
114     :element-type '(unsigned-byte 8)))))))
115    
116     (defclass utf8-stream (stream:fundamental-character-input-stream
117     stream:fundamental-character-output-stream)
118     ((byte-stream :type comm:socket-stream
119     :initform nil
120     :initarg :byte-stream
121     :accessor utf8-stream-byte-stream)))
122    
123     ;; Helper function. Decode the next N bytes starting from INDEX.
124     ;; Return the decoded char and the new index.
125     (defun utf8-decode-aux (buffer index limit byte0 n)
126     (declare (simple-string buffer) (fixnum index limit byte0 n))
127     (if (< (- limit index) n)
128     (values nil index)
129     (do ((i 0 (1+ i))
130     (code byte0 (let ((byte (char-code (schar buffer (+ index i)))))
131     (cond ((= (ldb (byte 2 6) byte) #b10)
132     (+ (ash code 6) (ldb (byte 6 0) byte)))
133     (t
134     (error "Invalid encoding"))))))
135     ((= i n)
136     (values (cond ((<= code #xff) (code-char code))
137     ((<= #xdc00 code #xdbff)
138     (error "Invalid Unicode code point: #x~x" code))
139     ((< code char-code-limit)
140     (code-char code))
141     (t
142     (error
143     "Can't represent code point: #x~x ~
144     (char-code-limit is #x~x)"
145     code char-code-limit)))
146     (+ index n))))))
147    
148     ;; Decode one character in BUFFER starting at INDEX.
149     ;; Return 2 values: the character and the new index.
150     ;; If there aren't enough bytes between INDEX and LIMIT return nil.
151     (defun utf8-decode (buffer index limit)
152     (declare (simple-string buffer) (fixnum index limit))
153     (if (= index limit)
154     (values nil index)
155     (let ((b (char-code (schar buffer index))))
156     (if (<= b #x7f)
157     (values (code-char b) (1+ index))
158     (macrolet ((try (marker else)
159     (let* ((l (integer-length marker))
160     (n (- l 2)))
161     `(if (= (ldb (byte ,l ,(- 8 l)) b) ,marker)
162     (utf8-decode-aux buffer (1+ index) limit
163     (ldb (byte ,(- 8 l) 0) b)
164     ,n)
165     ,else))))
166     (try #b110
167     (try #b1110
168     (try #b11110
169     (try #b111110
170     (try #b1111110
171     (error "Invalid encoding")))))))))))
172    
173     ;; Decode characters from BUFFER and write them to STRING.
174     ;; Return 2 values: LASTINDEX and LASTSTART where
175     ;; LASTINDEX is the last index in BUFFER that was not decoded
176     ;; and LASTSTART is the last index in STRING not written.
177     (defun utf8-decode-into (buffer index limit string start end)
178     (declare (string string) (fixnum index limit start end))
179     (loop
180     (cond ((= start end)
181     (return (values index start)))
182     (t
183     (multiple-value-bind (c i) (utf8-decode buffer index limit)
184     (cond (c
185     (setf (aref string start) c)
186     (setq index i)
187     (setq start (1+ start)))
188     (t
189     (return (values index start)))))))))
190    
191     (defmacro utf8-encode-aux (code buffer start end n)
192     `(cond ((< (- ,end ,start) ,n)
193     ,start)
194     (t
195     (setf (schar ,buffer ,start)
196     (code-char
197     (dpb (ldb (byte ,(- 7 n) ,(* 6 (1- n))) ,code)
198     (byte ,(- 7 n) 0)
199     ,(dpb 0 (byte 1 (- 7 n)) #xff))))
200     ,@(loop for i from 0 upto (- n 2) collect
201     `(setf (schar ,buffer (+ ,start ,(- n 1 i)))
202     (code-char
203     (dpb (ldb (byte 6 ,(* 6 i)) ,code)
204     (byte 6 0)
205     #b10111111))))
206     (+ ,start ,n))))
207    
208     (defun utf8-encode (char buffer start end)
209     (declare (fixnum start end))
210     (let ((code (char-code char)))
211     (cond ((<= code #x7f)
212     (cond ((< start end)
213     (setf (schar buffer start) char)
214     (1+ start))
215     (t start)))
216     ((<= code #x7ff) (utf8-encode-aux code buffer start end 2))
217     ((<= #xd800 code #xdfff)
218     (error "Invalid Unicode code point (surrogate): #x~x" code))
219     ((<= code #xffff) (utf8-encode-aux code buffer start end 3))
220     ((<= code #x1fffff) (utf8-encode-aux code buffer start end 4))
221     ((<= code #x3ffffff) (utf8-encode-aux code buffer start end 5))
222     ((<= code #x7fffffff) (utf8-encode-aux code buffer start end 6))
223     (t (error "Can't encode ~s (~x)" char code)))))
224    
225     (defun utf8-encode-into (string start end buffer index limit)
226     (loop
227     (cond ((= start end)
228     (return (values start index)))
229     ((= index limit)
230     (return (values start index)))
231     (t
232     (let ((i2 (utf8-encode (char string start) buffer index limit)))
233     (cond ((= i2 index)
234     (return (values start index)))
235     (t
236     (setq index i2)
237     (incf start))))))))
238    
239     (defun utf8-stream-read-char (stream no-hang)
240     (with-slots (byte-stream) stream
241     (loop
242     (stream:with-stream-input-buffer (b i l) byte-stream
243     (multiple-value-bind (c i2) (utf8-decode b i l)
244     (cond (c
245     (setf i i2)
246     (return c))
247     ((and no-hang
248     (not (sys:wait-for-input-streams-returning-first
249     (list byte-stream) :timeout 0)))
250     (return nil))
251     ((stream:stream-fill-buffer byte-stream)
252     #| next iteration |# )
253     (t
254     (return :eof))))))))
255    
256     (defmethod stream:stream-read-char ((stream utf8-stream))
257     (utf8-stream-read-char stream nil))
258    
259     (defmethod stream:stream-read-char-no-hang ((stream utf8-stream))
260     (utf8-stream-read-char stream t))
261    
262     (defmethod stream:stream-read-sequence ((stream utf8-stream) (string string)
263     start end)
264     (with-slots (byte-stream) stream
265     (loop
266     (stream:with-stream-input-buffer (b i l) byte-stream
267     (multiple-value-bind (i2 s2) (utf8-decode-into b i l string start end)
268     (setq i i2)
269     (setq start s2)
270     (cond ((= start end)
271     (return start))
272     ((stream:stream-fill-buffer byte-stream)
273     #| next iteration |# )
274     (t
275     (return start))))))))
276    
277     (defmethod stream:stream-unread-char ((stream utf8-stream) (c character))
278     (with-slots (byte-stream) stream
279     (stream:with-stream-input-buffer (b i l) byte-stream
280     (declare (ignorable l))
281     (let* ((bytes (ef:encode-lisp-string (string c) :utf-8))
282     (len (length bytes))
283     (i2 (- i len)))
284     (assert (equal (utf8-decode b i2 i) c))
285     (setq i i2)
286     nil))))
287    
288     (defmethod stream:stream-write-char ((stream utf8-stream) (char character))
289     (with-slots (byte-stream) stream
290     (loop
291     (stream:with-stream-output-buffer (b i l) byte-stream
292     (let ((i2 (utf8-encode char b i l)))
293     (cond ((< i i2)
294     (setf i i2)
295     (return char))
296     ((stream:stream-flush-buffer byte-stream)
297     )
298     (t
299     (error "Can't flush buffer"))))))))
300    
301     (defmethod stream:stream-write-string ((stream utf8-stream)
302     (string string)
303     &optional (start 0)
304     (end (length string)))
305     (with-slots (byte-stream) stream
306     (loop
307     (stream:with-stream-output-buffer (b i l) byte-stream
308     (multiple-value-bind (s2 i2) (utf8-encode-into string start end
309     b i l)
310     (setf i i2)
311     (setf start s2)
312     (cond ((= start end)
313     (return string))
314     ((stream:stream-flush-buffer byte-stream)
315     )
316     (t
317     (error "Can't flush buffer"))))))))
318    
319     (defmethod stream:stream-write-sequence ((stream utf8-stream)
320     seq start end)
321     (stream:stream-write-string seq start end))
322    
323     (defmethod stream:stream-force-output ((stream utf8-stream))
324     (with-slots (byte-stream) stream (force-output byte-stream)))
325    
326     (defmethod stream:stream-finish-output ((stream utf8-stream))
327     (with-slots (byte-stream) stream (finish-output byte-stream)))
328 heller 1.13
329 heller 1.88 ;;; Coding Systems
330    
331 heller 1.118 (defun valid-external-format-p (external-format)
332     (member external-format *external-format-to-coding-system*
333     :test #'equal :key #'car))
334    
335 heller 1.88 (defvar *external-format-to-coding-system*
336     '(((:latin-1 :eol-style :lf)
337     "latin-1-unix" "iso-latin-1-unix" "iso-8859-1-unix")
338 heller 1.142 ;;((:latin-1) "latin-1" "iso-latin-1" "iso-8859-1")
339     ;;((:utf-8) "utf-8")
340 heller 1.88 ((:utf-8 :eol-style :lf) "utf-8-unix")
341 heller 1.142 ;;((:euc-jp) "euc-jp")
342 heller 1.88 ((:euc-jp :eol-style :lf) "euc-jp-unix")
343 heller 1.142 ;;((:ascii) "us-ascii")
344 heller 1.88 ((:ascii :eol-style :lf) "us-ascii-unix")))
345    
346     (defimplementation find-external-format (coding-system)
347     (car (rassoc-if (lambda (x) (member coding-system x :test #'equal))
348     *external-format-to-coding-system*)))
349    
350 heller 1.15 ;;; Unix signals
351    
352 heller 1.18 (defun sigint-handler ()
353 heller 1.16 (with-simple-restart (continue "Continue from SIGINT handler.")
354     (invoke-debugger "SIGINT")))
355 heller 1.1
356 heller 1.18 (defun make-sigint-handler (process)
357     (lambda (&rest args)
358     (declare (ignore args))
359     (mp:process-interrupt process #'sigint-handler)))
360    
361 heller 1.125 (defun set-sigint-handler ()
362     ;; Set SIGINT handler on Swank request handler thread.
363     #-win32
364     (sys::set-signal-handler +sigint+
365     (make-sigint-handler mp:*current-process*)))
366    
367     #-win32
368     (defimplementation install-sigint-handler (handler)
369     (sys::set-signal-handler +sigint+
370     (let ((self mp:*current-process*))
371     (lambda (&rest args)
372     (declare (ignore args))
373     (mp:process-interrupt self handler)))))
374    
375 heller 1.29 (defimplementation getpid ()
376     #+win32 (win32:get-current-process-id)
377     #-win32 (system::getpid))
378 heller 1.1
379 heller 1.23 (defimplementation lisp-implementation-type-name ()
380     "lispworks")
381    
382 heller 1.36 (defimplementation set-default-directory (directory)
383     (namestring (hcl:change-directory directory)))
384 heller 1.40
385     ;;;; Documentation
386 heller 1.36
387 sboukarev 1.133 (defun map-list (function list)
388     "Map over proper and not proper lists."
389     (loop for (car . cdr) on list
390     collect (funcall function car) into result
391     when (null cdr) return result
392     when (atom cdr) return (nconc result (funcall function cdr))))
393    
394 sboukarev 1.132 (defun replace-strings-with-symbols (tree)
395 sboukarev 1.133 (map-list
396     (lambda (x)
397     (typecase x
398     (list
399     (replace-strings-with-symbols x))
400     (symbol
401     x)
402     (string
403     (intern x))
404     (t
405     (intern (write-to-string x)))))
406     tree))
407 sboukarev 1.132
408 msimmons 1.57 (defimplementation arglist (symbol-or-function)
409     (let ((arglist (lw:function-lambda-list symbol-or-function)))
410 heller 1.30 (etypecase arglist
411 heller 1.39 ((member :dont-know)
412     :not-available)
413     (list
414 sboukarev 1.132 (replace-strings-with-symbols arglist)))))
415 msimmons 1.57
416     (defimplementation function-name (function)
417     (nth-value 2 (function-lambda-expression function)))
418 heller 1.1
419 lgorrie 1.17 (defimplementation macroexpand-all (form)
420 heller 1.1 (walker:walk-form form))
421    
422 heller 1.37 (defun generic-function-p (object)
423 heller 1.36 (typep object 'generic-function))
424    
425 lgorrie 1.17 (defimplementation describe-symbol-for-emacs (symbol)
426 heller 1.1 "Return a plist describing SYMBOL.
427     Return NIL if the symbol is unbound."
428     (let ((result '()))
429     (labels ((first-line (string)
430     (let ((pos (position #\newline string)))
431     (if (null pos) string (subseq string 0 pos))))
432     (doc (kind &optional (sym symbol))
433 heller 1.116 (let ((string (or (documentation sym kind))))
434 heller 1.1 (if string
435     (first-line string)
436     :not-documented)))
437     (maybe-push (property value)
438     (when value
439     (setf result (list* property value result)))))
440     (maybe-push
441     :variable (when (boundp symbol)
442     (doc 'variable)))
443     (maybe-push
444 heller 1.36 :generic-function (if (and (fboundp symbol)
445 heller 1.37 (generic-function-p (fdefinition symbol)))
446 heller 1.36 (doc 'function)))
447     (maybe-push
448     :function (if (and (fboundp symbol)
449 heller 1.37 (not (generic-function-p (fdefinition symbol))))
450 heller 1.1 (doc 'function)))
451     (maybe-push
452 heller 1.49 :setf (let ((setf-name (sys:underlying-setf-name `(setf ,symbol))))
453     (if (fboundp setf-name)
454     (doc 'setf))))
455     (maybe-push
456 heller 1.1 :class (if (find-class symbol nil)
457     (doc 'class)))
458 heller 1.30 result)))
459 heller 1.1
460 heller 1.30 (defimplementation describe-definition (symbol type)
461     (ecase type
462     (:variable (describe-symbol symbol))
463     (:class (describe (find-class symbol)))
464 heller 1.49 ((:function :generic-function) (describe-function symbol))
465     (:setf (describe-function (sys:underlying-setf-name `(setf ,symbol))))))
466 heller 1.30
467     (defun describe-function (symbol)
468     (cond ((fboundp symbol)
469 heller 1.123 (format t "(~A ~/pprint-fill/)~%~%~:[(not documented)~;~:*~A~]~%"
470     symbol
471     (lispworks:function-lambda-list symbol)
472 heller 1.30 (documentation symbol 'function))
473 heller 1.38 (describe (fdefinition symbol)))
474 heller 1.30 (t (format t "~S is not fbound" symbol))))
475 heller 1.4
476 heller 1.30 (defun describe-symbol (sym)
477 heller 1.1 (format t "~A is a symbol in package ~A." sym (symbol-package sym))
478     (when (boundp sym)
479     (format t "~%~%Value: ~A" (symbol-value sym)))
480     (let ((doc (documentation sym 'variable)))
481     (when doc
482     (format t "~%~%Variable documentation:~%~A" doc)))
483     (when (fboundp sym)
484 heller 1.30 (describe-function sym)))
485 heller 1.1
486     ;;; Debugging
487    
488 heller 1.66 (defclass slime-env (env:environment)
489     ((debugger-hook :initarg :debugger-hoook)))
490    
491     (defun slime-env (hook io-bindings)
492     (make-instance 'slime-env :name "SLIME Environment"
493     :io-bindings io-bindings
494     :debugger-hoook hook))
495    
496 heller 1.111 (defmethod env-internals:environment-display-notifier
497 heller 1.66 ((env slime-env) &key restarts condition)
498 heller 1.111 (declare (ignore restarts condition))
499 heller 1.113 (funcall (swank-sym :swank-debugger-hook) condition *debugger-hook*)
500     ;; nil
501 heller 1.111 )
502 heller 1.66
503     (defmethod env-internals:environment-display-debugger ((env slime-env))
504     *debug-io*)
505    
506 heller 1.111 (defmethod env-internals:confirm-p ((e slime-env) &optional msg &rest args)
507     (apply (swank-sym :y-or-n-p-in-emacs) msg args))
508    
509 heller 1.110 (defimplementation call-with-debugger-hook (hook fun)
510     (let ((*debugger-hook* hook))
511     (env:with-environment ((slime-env hook '()))
512     (funcall fun))))
513 heller 1.66
514 msimmons 1.100 (defimplementation install-debugger-globally (function)
515     (setq *debugger-hook* function)
516     (setf (env:environment) (slime-env function '())))
517    
518 heller 1.26 (defvar *sldb-top-frame*)
519 heller 1.1
520     (defun interesting-frame-p (frame)
521 heller 1.36 (cond ((or (dbg::call-frame-p frame)
522     (dbg::derived-call-frame-p frame)
523     (dbg::foreign-frame-p frame)
524     (dbg::interpreted-call-frame-p frame))
525     t)
526     ((dbg::catch-frame-p frame) dbg:*print-catch-frames*)
527     ((dbg::binding-frame-p frame) dbg:*print-binding-frames*)
528     ((dbg::handler-frame-p frame) dbg:*print-handler-frames*)
529     ((dbg::restart-frame-p frame) dbg:*print-restart-frames*)
530     (t nil)))
531 heller 1.1
532 heller 1.41 (defun nth-next-frame (frame n)
533     "Unwind FRAME N times."
534     (do ((frame frame (dbg::frame-next frame))
535     (i n (if (interesting-frame-p frame) (1- i) i)))
536 heller 1.48 ((or (not frame)
537     (and (interesting-frame-p frame) (zerop i)))
538     frame)))
539 heller 1.41
540     (defun nth-frame (index)
541     (nth-next-frame *sldb-top-frame* index))
542 heller 1.139
543 heller 1.41 (defun find-top-frame ()
544     "Return the most suitable top-frame for the debugger."
545 mbaringer 1.69 (or (do ((frame (dbg::debugger-stack-current-frame dbg::*debugger-stack*)
546     (nth-next-frame frame 1)))
547     ((or (null frame) ; no frame found!
548     (and (dbg::call-frame-p frame)
549     (eq (dbg::call-frame-function-name frame)
550     'invoke-debugger)))
551     (nth-next-frame frame 1)))
552     ;; if we can't find a invoke-debugger frame, take any old frame at the top
553     (dbg::debugger-stack-current-frame dbg::*debugger-stack*)))
554 heller 1.41
555     (defimplementation call-with-debugging-environment (fn)
556     (dbg::with-debugger-stack ()
557     (let ((*sldb-top-frame* (find-top-frame)))
558     (funcall fn))))
559 heller 1.1
560 heller 1.30 (defimplementation compute-backtrace (start end)
561 heller 1.1 (let ((end (or end most-positive-fixnum))
562     (backtrace '()))
563     (do ((frame (nth-frame start) (dbg::frame-next frame))
564     (i start))
565     ((or (not frame) (= i end)) (nreverse backtrace))
566     (when (interesting-frame-p frame)
567     (incf i)
568 heller 1.121 (push frame backtrace)))))
569 heller 1.1
570 heller 1.36 (defun frame-actual-args (frame)
571 msimmons 1.141 (let ((*break-on-signals* nil)
572     (kind nil))
573     (loop for arg in (dbg::call-frame-arglist frame)
574     if (eq kind '&rest)
575     nconc (handler-case
576     (dbg::dbg-eval arg frame)
577     (error (e) (list (format nil "<~A>" arg))))
578     and do (loop-finish)
579     else
580     if (member arg '(&rest &optional &key))
581     do (setq kind arg)
582     else
583     nconc
584     (handler-case
585     (nconc (and (eq kind '&key)
586     (list (cond ((symbolp arg)
587     (intern (symbol-name arg) :keyword))
588     ((and (consp arg) (symbolp (car arg)))
589     (intern (symbol-name (car arg)) :keyword))
590     (t (caar arg)))))
591     (list (dbg::dbg-eval
592     (cond ((symbolp arg) arg)
593     ((and (consp arg) (symbolp (car arg)))
594     (car arg))
595     (t (cadar arg)))
596     frame)))
597     (error (e) (list (format nil "<~A>" arg)))))))
598 heller 1.36
599 heller 1.121 (defimplementation print-frame (frame stream)
600     (cond ((dbg::call-frame-p frame)
601 msimmons 1.141 (prin1 (cons (dbg::call-frame-function-name frame)
602     (frame-actual-args frame))
603     stream))
604 heller 1.121 (t (princ frame stream))))
605 heller 1.1
606 heller 1.47 (defun frame-vars (frame)
607     (first (dbg::frame-locals-format-list frame #'list 75 0)))
608    
609 lgorrie 1.17 (defimplementation frame-locals (n)
610 heller 1.29 (let ((frame (nth-frame n)))
611 heller 1.1 (if (dbg::call-frame-p frame)
612 heller 1.47 (mapcar (lambda (var)
613     (destructuring-bind (name value symbol location) var
614     (declare (ignore name location))
615     (list :name symbol :id 0
616     :value value)))
617     (frame-vars frame)))))
618    
619     (defimplementation frame-var-value (frame var)
620     (let ((frame (nth-frame frame)))
621     (destructuring-bind (_n value _s _l) (nth var (frame-vars frame))
622     (declare (ignore _n _s _l))
623     value)))
624 heller 1.1
625 heller 1.130 (defimplementation frame-source-location (frame)
626 heller 1.60 (let ((frame (nth-frame frame))
627     (callee (if (plusp frame) (nth-frame (1- frame)))))
628 heller 1.1 (if (dbg::call-frame-p frame)
629 heller 1.60 (let ((dspec (dbg::call-frame-function-name frame))
630     (cname (and (dbg::call-frame-p callee)
631 heller 1.139 (dbg::call-frame-function-name callee)))
632     (path (and (dbg::call-frame-p frame)
633     (dbg::call-frame-edit-path frame))))
634 heller 1.60 (if dspec
635 heller 1.139 (frame-location dspec cname path))))))
636 heller 1.26
637     (defimplementation eval-in-frame (form frame-number)
638     (let ((frame (nth-frame frame-number)))
639     (dbg::dbg-eval form frame)))
640    
641     (defimplementation return-from-frame (frame-number form)
642     (let* ((frame (nth-frame frame-number))
643 heller 1.30 (return-frame (dbg::find-frame-for-return frame)))
644 heller 1.26 (dbg::dbg-return-from-call-frame frame form return-frame
645     dbg::*debugger-stack*)))
646    
647     (defimplementation restart-frame (frame-number)
648     (let ((frame (nth-frame frame-number)))
649     (dbg::restart-frame frame :same-args t)))
650 heller 1.1
651 heller 1.109 (defimplementation disassemble-frame (frame-number)
652     (let* ((frame (nth-frame frame-number)))
653     (when (dbg::call-frame-p frame)
654     (let ((function (dbg::get-call-frame-function frame)))
655     (disassemble function)))))
656    
657 heller 1.18 ;;; Definition finding
658    
659 heller 1.139 (defun frame-location (dspec callee-name edit-path)
660 heller 1.60 (let ((infos (dspec:find-dspec-locations dspec)))
661     (cond (infos
662     (destructuring-bind ((rdspec location) &rest _) infos
663     (declare (ignore _))
664     (let ((name (and callee-name (symbolp callee-name)
665 heller 1.139 (string callee-name)))
666     (path (edit-path-to-cmucl-source-path edit-path)))
667     (make-dspec-location rdspec location
668     `(:call-site ,name :edit-path ,path)))))
669 heller 1.60 (t
670     (list :error (format nil "Source location not available for: ~S"
671     dspec))))))
672 heller 1.4
673 heller 1.139 ;; dbg::call-frame-edit-path is not documented but lets assume the
674     ;; binary representation of the integer EDIT-PATH should be
675     ;; interpreted as a sequence of CAR or CDR. #b1111010 is roughly the
676     ;; same as cadadddr. Something is odd with the highest bit.
677     (defun edit-path-to-cmucl-source-path (edit-path)
678     (and edit-path
679     (cons 0
680     (let ((n -1))
681     (loop for i from (1- (integer-length edit-path)) downto 0
682     if (logbitp i edit-path) do (incf n)
683     else collect (prog1 n (setq n 0)))))))
684    
685     ;; (edit-path-to-cmucl-source-path #b1111010) => (0 3 1)
686    
687 heller 1.33 (defimplementation find-definitions (name)
688 heller 1.26 (let ((locations (dspec:find-name-locations dspec:*dspec-classes* name)))
689 heller 1.33 (loop for (dspec location) in locations
690     collect (list dspec (make-dspec-location dspec location)))))
691 heller 1.6
692 msimmons 1.56
693 heller 1.18 ;;; Compilation
694    
695 msimmons 1.42 (defmacro with-swank-compilation-unit ((location &rest options) &body body)
696     (lw:rebinding (location)
697     `(let ((compiler::*error-database* '()))
698     (with-compilation-unit ,options
699 heller 1.120 (multiple-value-prog1 (progn ,@body)
700     (signal-error-data-base compiler::*error-database*
701     ,location)
702     (signal-undefined-functions compiler::*unknown-functions*
703     ,location))))))
704 msimmons 1.42
705 heller 1.128 (defimplementation swank-compile-file (input-file output-file
706 sboukarev 1.136 load-p external-format
707     &key policy)
708     (declare (ignore policy))
709 heller 1.128 (with-swank-compilation-unit (input-file)
710     (compile-file input-file
711     :output-file output-file
712     :load load-p
713 heller 1.119 :external-format external-format)))
714 msimmons 1.56
715 eweitz 1.70 (defvar *within-call-with-compilation-hooks* nil
716     "Whether COMPILE-FILE was called from within CALL-WITH-COMPILATION-HOOKS.")
717    
718     (defvar *undefined-functions-hash* nil
719     "Hash table to map info about undefined functions to pathnames.")
720    
721     (lw:defadvice (compile-file compile-file-and-collect-notes :around)
722     (pathname &rest rest)
723 msimmons 1.75 (multiple-value-prog1 (apply #'lw:call-next-advice pathname rest)
724 eweitz 1.70 (when *within-call-with-compilation-hooks*
725     (maphash (lambda (unfun dspecs)
726     (dolist (dspec dspecs)
727     (let ((unfun-info (list unfun dspec)))
728     (unless (gethash unfun-info *undefined-functions-hash*)
729     (setf (gethash unfun-info *undefined-functions-hash*)
730     pathname)))))
731     compiler::*unknown-functions*))))
732    
733 msimmons 1.56 (defimplementation call-with-compilation-hooks (function)
734 eweitz 1.70 (let ((compiler::*error-database* '())
735     (*undefined-functions-hash* (make-hash-table :test 'equal))
736     (*within-call-with-compilation-hooks* t))
737     (with-compilation-unit ()
738     (prog1 (funcall function)
739     (signal-error-data-base compiler::*error-database*)
740     (signal-undefined-functions compiler::*unknown-functions*)))))
741 heller 1.1
742     (defun map-error-database (database fn)
743     (loop for (filename . defs) in database do
744     (loop for (dspec . conditions) in defs do
745 heller 1.140 (dolist (c conditions)
746     (multiple-value-bind (condition path)
747     (if (consp c) (values (car c) (cdr c)) (values c nil))
748     (funcall fn filename dspec condition path))))))
749 heller 1.1
750     (defun lispworks-severity (condition)
751     (cond ((not condition) :warning)
752     (t (etypecase condition
753 heller 1.6 (error :error)
754 heller 1.1 (style-warning :warning)
755     (warning :warning)))))
756    
757     (defun signal-compiler-condition (message location condition)
758     (check-type message string)
759     (signal
760     (make-instance 'compiler-condition :message message
761     :severity (lispworks-severity condition)
762     :location location
763     :original-condition condition)))
764    
765 heller 1.118 (defvar *temp-file-format* '(:utf-8 :eol-style :lf))
766    
767 heller 1.1 (defun compile-from-temp-file (string filename)
768     (unwind-protect
769     (progn
770 heller 1.118 (with-open-file (s filename :direction :output
771     :if-exists :supersede
772     :external-format *temp-file-format*)
773    
774 heller 1.1 (write-string string s)
775     (finish-output s))
776 heller 1.120 (multiple-value-bind (binary-filename warnings? failure?)
777     (compile-file filename :load t
778     :external-format *temp-file-format*)
779     (declare (ignore warnings?))
780 heller 1.6 (when binary-filename
781 heller 1.120 (delete-file binary-filename))
782     (not failure?)))
783 heller 1.1 (delete-file filename)))
784    
785 heller 1.117 (defun dspec-function-name-position (dspec fallback)
786 heller 1.34 (etypecase dspec
787     (cons (let ((name (dspec:dspec-primary-name dspec)))
788 heller 1.37 (typecase name
789 heller 1.34 ((or symbol string)
790     (list :function-name (string name)))
791 heller 1.117 (t fallback))))
792     (null fallback)
793 heller 1.34 (symbol (list :function-name (string dspec)))))
794 heller 1.18
795 lgorrie 1.45 (defmacro with-fairly-standard-io-syntax (&body body)
796     "Like WITH-STANDARD-IO-SYNTAX but preserve *PACKAGE* and *READTABLE*."
797     (let ((package (gensym))
798     (readtable (gensym)))
799     `(let ((,package *package*)
800     (,readtable *readtable*))
801     (with-standard-io-syntax
802     (let ((*package* ,package)
803     (*readtable* ,readtable))
804     ,@body)))))
805    
806 heller 1.117 (defun skip-comments (stream)
807     (let ((pos0 (file-position stream)))
808     (cond ((equal (ignore-errors (list (read-delimited-list #\( stream)))
809     '(()))
810     (file-position stream (1- (file-position stream))))
811     (t (file-position stream pos0)))))
812    
813 heller 1.52 #-(or lispworks4.1 lispworks4.2) ; no dspec:parse-form-dspec prior to 4.3
814 msimmons 1.42 (defun dspec-stream-position (stream dspec)
815 lgorrie 1.45 (with-fairly-standard-io-syntax
816 heller 1.117 (loop (let* ((pos (progn (skip-comments stream) (file-position stream)))
817 lgorrie 1.44 (form (read stream nil '#1=#:eof)))
818     (when (eq form '#1#)
819     (return nil))
820     (labels ((check-dspec (form)
821     (when (consp form)
822     (let ((operator (car form)))
823     (case operator
824     ((progn)
825     (mapcar #'check-dspec
826     (cdr form)))
827     ((eval-when locally macrolet symbol-macrolet)
828     (mapcar #'check-dspec
829     (cddr form)))
830     ((in-package)
831     (let ((package (find-package (second form))))
832     (when package
833     (setq *package* package))))
834     (otherwise
835     (let ((form-dspec (dspec:parse-form-dspec form)))
836     (when (dspec:dspec-equal dspec form-dspec)
837     (return pos)))))))))
838     (check-dspec form))))))
839 msimmons 1.42
840 heller 1.52 (defun dspec-file-position (file dspec)
841 mbaringer 1.90 (let* ((*compile-file-pathname* (pathname file))
842     (*compile-file-truename* (truename *compile-file-pathname*))
843     (*load-pathname* *compile-file-pathname*)
844     (*load-truename* *compile-file-truename*))
845     (with-open-file (stream file)
846     (let ((pos
847     #-(or lispworks4.1 lispworks4.2)
848     (dspec-stream-position stream dspec)))
849     (if pos
850 heller 1.117 (list :position (1+ pos))
851     (dspec-function-name-position dspec `(:position 1)))))))
852 heller 1.52
853 heller 1.25 (defun emacs-buffer-location-p (location)
854     (and (consp location)
855     (eq (car location) :emacs-buffer)))
856    
857 heller 1.60 (defun make-dspec-location (dspec location &optional hints)
858 heller 1.52 (etypecase location
859     ((or pathname string)
860     (multiple-value-bind (file err)
861     (ignore-errors (namestring (truename location)))
862     (if err
863     (list :error (princ-to-string err))
864     (make-location `(:file ,file)
865 heller 1.60 (dspec-file-position file dspec)
866     hints))))
867 heller 1.52 (symbol
868     `(:error ,(format nil "Cannot resolve location: ~S" location)))
869     ((satisfies emacs-buffer-location-p)
870     (destructuring-bind (_ buffer offset string) location
871     (declare (ignore _ string))
872     (make-location `(:buffer ,buffer)
873 heller 1.117 (dspec-function-name-position dspec `(:offset ,offset 0))
874 heller 1.60 hints)))))
875 heller 1.1
876 heller 1.140 (defun make-dspec-progenitor-location (dspec location edit-path)
877 msimmons 1.42 (let ((canon-dspec (dspec:canonicalize-dspec dspec)))
878     (make-dspec-location
879     (if canon-dspec
880     (if (dspec:local-dspec-p canon-dspec)
881     (dspec:dspec-progenitor canon-dspec)
882 heller 1.140 canon-dspec)
883     nil)
884     location
885     (if edit-path
886     (list :edit-path (edit-path-to-cmucl-source-path edit-path))))))
887 msimmons 1.42
888 eweitz 1.70 (defun signal-error-data-base (database &optional location)
889 heller 1.1 (map-error-database
890     database
891 heller 1.140 (lambda (filename dspec condition edit-path)
892 heller 1.1 (signal-compiler-condition
893     (format nil "~A" condition)
894 heller 1.140 (make-dspec-progenitor-location dspec (or location filename) edit-path)
895 heller 1.1 condition))))
896    
897 eweitz 1.71 (defun unmangle-unfun (symbol)
898     "Converts symbols like 'SETF::|\"CL-USER\" \"GET\"| to
899     function names like \(SETF GET)."
900 heller 1.93 (cond ((sys::setf-symbol-p symbol)
901     (sys::setf-pair-from-underlying-name symbol))
902     (t symbol)))
903    
904 eweitz 1.70 (defun signal-undefined-functions (htab &optional filename)
905 heller 1.1 (maphash (lambda (unfun dspecs)
906     (dolist (dspec dspecs)
907     (signal-compiler-condition
908 eweitz 1.71 (format nil "Undefined function ~A" (unmangle-unfun unfun))
909 heller 1.140 (make-dspec-progenitor-location
910     dspec
911     (or filename
912     (gethash (list unfun dspec) *undefined-functions-hash*))
913     nil)
914 heller 1.1 nil)))
915     htab))
916 heller 1.2
917 heller 1.126 (defimplementation swank-compile-string (string &key buffer position filename
918     policy)
919     (declare (ignore filename policy))
920 heller 1.1 (assert buffer)
921     (assert position)
922 heller 1.30 (let* ((location (list :emacs-buffer buffer position string))
923 heller 1.26 (tmpname (hcl:make-temp-file nil "lisp")))
924 msimmons 1.42 (with-swank-compilation-unit (location)
925 heller 1.26 (compile-from-temp-file
926 heller 1.68 (with-output-to-string (s)
927     (let ((*print-radix* t))
928     (print `(eval-when (:compile-toplevel)
929     (setq dspec::*location* (list ,@location)))
930     s))
931     (write-string string s))
932 msimmons 1.42 tmpname))))
933 heller 1.1
934 heller 1.3 ;;; xref
935    
936 heller 1.31 (defmacro defxref (name function)
937     `(defimplementation ,name (name)
938     (xref-results (,function name))))
939    
940     (defxref who-calls hcl:who-calls)
941 msimmons 1.42 (defxref who-macroexpands hcl:who-calls) ; macros are in the calls table too
942 heller 1.67 (defxref calls-who hcl:calls-who)
943 msimmons 1.42 (defxref list-callers list-callers-internal)
944 sboukarev 1.137 (defxref list-callees list-callees-internal)
945 msimmons 1.42
946     (defun list-callers-internal (name)
947     (let ((callers (make-array 100
948     :fill-pointer 0
949     :adjustable t)))
950     (hcl:sweep-all-objects
951     #'(lambda (object)
952     (when (and #+Harlequin-PC-Lisp (low:compiled-code-p object)
953 msimmons 1.138 #+Harlequin-Unix-Lisp (sys:callablep object)
954     #-(or Harlequin-PC-Lisp Harlequin-Unix-Lisp) (sys:compiled-code-p object)
955 msimmons 1.42 (system::find-constant$funcallable name object))
956     (vector-push-extend object callers))))
957     ;; Delay dspec:object-dspec until after sweep-all-objects
958     ;; to reduce allocation problems.
959     (loop for object across callers
960     collect (if (symbolp object)
961     (list 'function object)
962 heller 1.63 (or (dspec:object-dspec object) object)))))
963 heller 1.36
964 sboukarev 1.137 (defun list-callees-internal (name)
965 msimmons 1.138 (let ((callees '()))
966     (system::find-constant$funcallable
967     'junk name
968     :test #'(lambda (junk constant)
969     (declare (ignore junk))
970     (when (and (symbolp constant)
971     (fboundp constant))
972     (pushnew (list 'function constant) callees :test 'equal))
973     ;; Return nil so we iterate over all constants.
974     nil))
975     callees))
976 sboukarev 1.137
977 heller 1.37 ;; only for lispworks 4.2 and above
978     #-lispworks4.1
979     (progn
980     (defxref who-references hcl:who-references)
981     (defxref who-binds hcl:who-binds)
982     (defxref who-sets hcl:who-sets))
983    
984 heller 1.36 (defimplementation who-specializes (classname)
985     (let ((methods (clos:class-direct-methods (find-class classname))))
986     (xref-results (mapcar #'dspec:object-dspec methods))))
987 heller 1.31
988     (defun xref-results (dspecs)
989 heller 1.63 (flet ((frob-locs (dspec locs)
990     (cond (locs
991     (loop for (name loc) in locs
992     collect (list name (make-dspec-location name loc))))
993     (t `((,dspec (:error "Source location not available")))))))
994     (loop for dspec in dspecs
995     append (frob-locs dspec (dspec:dspec-definition-locations dspec)))))
996 heller 1.66
997 heller 1.25 ;;; Inspector
998 mbaringer 1.58
999 heller 1.95 (defmethod emacs-inspect ((o t))
1000 heller 1.60 (lispworks-inspect o))
1001    
1002 heller 1.95 (defmethod emacs-inspect ((o function))
1003 heller 1.60 (lispworks-inspect o))
1004    
1005 heller 1.82 ;; FIXME: slot-boundp-using-class in LW works with names so we can't
1006     ;; use our method in swank.lisp.
1007 heller 1.95 (defmethod emacs-inspect ((o standard-object))
1008 heller 1.82 (lispworks-inspect o))
1009    
1010 heller 1.60 (defun lispworks-inspect (o)
1011 heller 1.25 (multiple-value-bind (names values _getter _setter type)
1012     (lw:get-inspector-values o nil)
1013     (declare (ignore _getter _setter))
1014 heller 1.60 (append
1015     (label-value-line "Type" type)
1016 msimmons 1.91 (loop for name in names
1017     for value in values
1018 heller 1.96 append (label-value-line name value)))))
1019 heller 1.25
1020 lgorrie 1.46 ;;; Miscellaneous
1021    
1022     (defimplementation quit-lisp ()
1023     (lispworks:quit))
1024    
1025 heller 1.66 ;;; Tracing
1026    
1027     (defun parse-fspec (fspec)
1028     "Return a dspec for FSPEC."
1029     (ecase (car fspec)
1030 heller 1.67 ((:defmethod) `(method ,(cdr fspec)))))
1031 heller 1.66
1032     (defun tracedp (dspec)
1033     (member dspec (eval '(trace)) :test #'equal))
1034    
1035 heller 1.67 (defun toggle-trace-aux (dspec)
1036 heller 1.66 (cond ((tracedp dspec)
1037     (eval `(untrace ,dspec))
1038     (format nil "~S is now untraced." dspec))
1039     (t
1040     (eval `(trace (,dspec)))
1041     (format nil "~S is now traced." dspec))))
1042    
1043 heller 1.67 (defimplementation toggle-trace (fspec)
1044     (toggle-trace-aux (parse-fspec fspec)))
1045 heller 1.66
1046 heller 1.16 ;;; Multithreading
1047    
1048 mbaringer 1.86 (defimplementation initialize-multiprocessing (continuation)
1049 heller 1.87 (cond ((not mp::*multiprocessing*)
1050     (push (list "Initialize SLIME" '() continuation)
1051     mp:*initial-processes*)
1052     (mp:initialize-multiprocessing))
1053     (t (funcall continuation))))
1054 heller 1.16
1055 heller 1.18 (defimplementation spawn (fn &key name)
1056 heller 1.127 (mp:process-run-function name () fn))
1057 heller 1.48
1058     (defvar *id-lock* (mp:make-lock))
1059     (defvar *thread-id-counter* 0)
1060    
1061     (defimplementation thread-id (thread)
1062     (mp:with-lock (*id-lock*)
1063     (or (getf (mp:process-plist thread) 'id)
1064     (setf (getf (mp:process-plist thread) 'id)
1065     (incf *thread-id-counter*)))))
1066    
1067     (defimplementation find-thread (id)
1068     (find id (mp:list-all-processes)
1069     :key (lambda (p) (getf (mp:process-plist p) 'id))))
1070 heller 1.16
1071 heller 1.21 (defimplementation thread-name (thread)
1072     (mp:process-name thread))
1073 heller 1.16
1074 heller 1.21 (defimplementation thread-status (thread)
1075     (format nil "~A ~D"
1076     (mp:process-whostate thread)
1077     (mp:process-priority thread)))
1078 heller 1.16
1079 heller 1.18 (defimplementation make-lock (&key name)
1080 heller 1.16 (mp:make-lock :name name))
1081    
1082 heller 1.18 (defimplementation call-with-lock-held (lock function)
1083 heller 1.16 (mp:with-lock (lock) (funcall function)))
1084 heller 1.20
1085     (defimplementation current-thread ()
1086     mp:*current-process*)
1087 heller 1.21
1088     (defimplementation all-threads ()
1089     (mp:list-all-processes))
1090 heller 1.20
1091     (defimplementation interrupt-thread (thread fn)
1092     (mp:process-interrupt thread fn))
1093 heller 1.25
1094     (defimplementation kill-thread (thread)
1095     (mp:process-kill thread))
1096 heller 1.27
1097     (defimplementation thread-alive-p (thread)
1098     (mp:process-alive-p thread))
1099 heller 1.20
1100 heller 1.102 (defstruct (mailbox (:conc-name mailbox.))
1101     (mutex (mp:make-lock :name "thread mailbox"))
1102     (queue '() :type list))
1103    
1104 heller 1.20 (defvar *mailbox-lock* (mp:make-lock))
1105    
1106     (defun mailbox (thread)
1107     (mp:with-lock (*mailbox-lock*)
1108     (or (getf (mp:process-plist thread) 'mailbox)
1109     (setf (getf (mp:process-plist thread) 'mailbox)
1110 heller 1.102 (make-mailbox)))))
1111 heller 1.20
1112 heller 1.112 (defimplementation receive-if (test &optional timeout)
1113 heller 1.102 (let* ((mbox (mailbox mp:*current-process*))
1114     (lock (mailbox.mutex mbox)))
1115 heller 1.112 (assert (or (not timeout) (eq timeout t)))
1116 heller 1.102 (loop
1117 heller 1.106 (check-slime-interrupts)
1118     (mp:with-lock (lock "receive-if/try")
1119     (let* ((q (mailbox.queue mbox))
1120     (tail (member-if test q)))
1121     (when tail
1122     (setf (mailbox.queue mbox) (nconc (ldiff q tail) (cdr tail)))
1123     (return (car tail)))))
1124 heller 1.112 (when (eq timeout t) (return (values nil t)))
1125 heller 1.106 (mp:process-wait-with-timeout
1126 heller 1.125 "receive-if" 0.3 (lambda () (some test (mailbox.queue mbox)))))))
1127 heller 1.102
1128     (defimplementation send (thread message)
1129     (let ((mbox (mailbox thread)))
1130 heller 1.106 (mp:with-lock ((mailbox.mutex mbox))
1131     (setf (mailbox.queue mbox)
1132     (nconc (mailbox.queue mbox) (list message))))))
1133 heller 1.3
1134 heller 1.127 (defimplementation set-default-initial-binding (var form)
1135     (setq mp:*process-initial-bindings*
1136     (acons var `(eval (quote ,form))
1137     mp:*process-initial-bindings* )))
1138    
1139 heller 1.131 (defimplementation thread-attributes (thread)
1140     (list :priority (mp:process-priority thread)
1141     :idle (mp:process-idle-time thread)))
1142    
1143 heller 1.66 ;;; Some intergration with the lispworks environment
1144    
1145 heller 1.74 (defun swank-sym (name) (find-symbol (string name) :swank))
1146 mkoeppe 1.77
1147 eweitz 1.89
1148     ;;;; Weak hashtables
1149    
1150     (defimplementation make-weak-key-hash-table (&rest args)
1151     (apply #'make-hash-table :weak-kind :key args))
1152    
1153     (defimplementation make-weak-value-hash-table (&rest args)
1154     (apply #'make-hash-table :weak-kind :value args))

  ViewVC Help
Powered by ViewVC 1.1.5