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

Diff of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.94 by heller, Sun Nov 20 23:25:38 2005 UTC revision 1.147 by heller, Fri Aug 22 21:15:19 2008 UTC
# Line 19  Line 19 
19             #:short-message             #:short-message
20             #:condition             #:condition
21             #:severity             #:severity
22               #:with-compilation-hooks
23             #:location             #:location
24             #:location-p             #:location-p
25             #:location-buffer             #:location-buffer
# Line 29  Line 30 
30             #:quit-lisp             #:quit-lisp
31             #:references             #:references
32             #:unbound-slot-filler             #:unbound-slot-filler
33               #:declaration-arglist
34               #:type-specifier-arglist
35               ;; interrupt macro for the backend
36               #:*pending-slime-interrupts*
37               #:check-slime-interrupts
38             ;; inspector related symbols             ;; inspector related symbols
39             #:inspector             #:emacs-inspect
            #:inspect-for-emacs  
            #:raw-inspection  
            #:fancy-inspection  
40             #:label-value-line             #:label-value-line
41             #:label-value-line*             #:label-value-line*
42    
43               #:with-struct
44             ))             ))
45    
46  (defpackage :swank-mop  (defpackage :swank-mop
# Line 84  Line 89 
89     #:slot-definition-type     #:slot-definition-type
90     #:slot-definition-readers     #:slot-definition-readers
91     #:slot-definition-writers     #:slot-definition-writers
92       #:slot-boundp-using-class
93       #:slot-value-using-class
94       #:slot-makunbound-using-class
95     ;; generic function protocol     ;; generic function protocol
96     #:compute-applicable-methods-using-classes     #:compute-applicable-methods-using-classes
97     #:finalize-inheritance))     #:finalize-inheritance))
# Line 102  DEFINTERFACE adds to this list and DEFIM Line 110  DEFINTERFACE adds to this list and DEFIM
110    
111  (defmacro definterface (name args documentation &rest default-body)  (defmacro definterface (name args documentation &rest default-body)
112    "Define an interface function for the backend to implement.    "Define an interface function for the backend to implement.
113  A generic function is defined with NAME, ARGS, and DOCUMENTATION.  A function is defined with NAME, ARGS, and DOCUMENTATION.  This
114    function first looks for a function to call in NAME's property list
115  If a DEFAULT-BODY is supplied then NO-APPLICABLE-METHOD is specialized  that is indicated by 'IMPLEMENTATION; failing that, it looks for a
116  to execute the body if the backend doesn't provide a specific  function indicated by 'DEFAULT. If neither is present, an error is
117  implementation.  signaled.
118    
119    If a DEFAULT-BODY is supplied, then a function with the same body and
120    ARGS will be added to NAME's property list as the property indicated
121    by 'DEFAULT.
122    
123  Backends implement these functions using DEFIMPLEMENTATION."  Backends implement these functions using DEFIMPLEMENTATION."
124    (check-type documentation string "a documentation string")    (check-type documentation string "a documentation string")
125    (flet ((gen-default-impl ()    (assert (every #'symbolp args) ()
126             `(defmethod ,name ,args ,@default-body)))            "Complex lambda-list not supported: ~S ~S" name args)
127      `(progn (defgeneric ,name ,args (:documentation ,documentation))    (labels ((gen-default-impl ()
128              (pushnew ',name *interface-functions*)               `(setf (get ',name 'default) (lambda ,args ,@default-body)))
129              ,(if (null default-body)             (args-as-list (args)
130                   `(pushnew ',name *unimplemented-interfaces*)               (destructuring-bind (req opt key rest) (parse-lambda-list args)
131                   (gen-default-impl))                 `(,@req ,@opt
132              ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>                         ,@(loop for k in key append `(,(kw k) ,k))
133              (eval-when (:compile-toplevel :load-toplevel :execute)                         ,@(or rest '(())))))
134                (export ',name :swank-backend))             (parse-lambda-list (args)
135              ',name)))               (parse args '(&optional &key &rest)
136                        (make-array 4 :initial-element nil)))
137               (parse (args keywords vars)
138                 (cond ((null args)
139                        (reverse (map 'list #'reverse vars)))
140                       ((member (car args) keywords)
141                        (parse (cdr args) (cdr (member (car args) keywords)) vars))
142                       (t (push (car args) (aref vars (length keywords)))
143                          (parse (cdr args) keywords vars))))
144               (kw (s) (intern (string s) :keyword)))
145        `(progn
146           (defun ,name ,args
147             ,documentation
148             (let ((f (or (get ',name 'implementation)
149                          (get ',name 'default))))
150               (cond (f (apply f ,@(args-as-list args)))
151                     (t (error "~S not implementated" ',name)))))
152           (pushnew ',name *interface-functions*)
153           ,(if (null default-body)
154                `(pushnew ',name *unimplemented-interfaces*)
155                (gen-default-impl))
156           ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>
157           (eval-when (:compile-toplevel :load-toplevel :execute)
158             (export ',name :swank-backend))
159           ',name)))
160    
161  (defmacro defimplementation (name args &body body)  (defmacro defimplementation (name args &body body)
162    `(progn (defmethod ,name ,args ,@body)    (assert (every #'symbolp args) ()
163            (if (member ',name *interface-functions*)            "Complex lambda-list not supported: ~S ~S" name args)
164                (setq *unimplemented-interfaces*    `(progn
165                      (remove ',name *unimplemented-interfaces*))       (setf (get ',name 'implementation) (lambda ,args ,@body))
166                (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))       (if (member ',name *interface-functions*)
167            ',name))           (setq *unimplemented-interfaces*
168                   (remove ',name *unimplemented-interfaces*))
169             (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))
170         ',name))
171    
172  (defun warn-unimplemented-interfaces ()  (defun warn-unimplemented-interfaces ()
173    "Warn the user about unimplemented backend features.    "Warn the user about unimplemented backend features.
# Line 158  EXCEPT is a list of symbol names which s Line 197  EXCEPT is a list of symbol names which s
197  (defvar *gray-stream-symbols*  (defvar *gray-stream-symbols*
198    '(:fundamental-character-output-stream    '(:fundamental-character-output-stream
199      :stream-write-char      :stream-write-char
200        :stream-write-string
201      :stream-fresh-line      :stream-fresh-line
202      :stream-force-output      :stream-force-output
203      :stream-finish-output      :stream-finish-output
# Line 212  EXCEPT is a list of symbol names which s Line 252  EXCEPT is a list of symbol names which s
252    "Close the socket SOCKET.")    "Close the socket SOCKET.")
253    
254  (definterface accept-connection (socket &key external-format  (definterface accept-connection (socket &key external-format
255                                          buffering)                                          buffering timeout)
256     "Accept a client connection on the listening socket SOCKET.     "Accept a client connection on the listening socket SOCKET.
257  Return a stream for the new connection.")  Return a stream for the new connection.")
258    
# Line 232  Return a stream for the new connection." Line 272  Return a stream for the new connection."
272    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
273    nil)    nil)
274    
275    (definterface set-stream-timeout (stream timeout)
276      "Set the 'stream 'timeout.  The timeout is either the real number
277      specifying the timeout in seconds or 'nil for no timeout."
278      (declare (ignore stream timeout))
279      nil)
280    
281  ;;; Base condition for networking errors.  ;;; Base condition for networking errors.
282  (define-condition network-error (simple-error) ())  (define-condition network-error (simple-error) ())
283    
# Line 256  that the calling thread is the one that Line 302  that the calling thread is the one that
302  (definterface getpid ()  (definterface getpid ()
303    "Return the (Unix) process ID of this superior Lisp.")    "Return the (Unix) process ID of this superior Lisp.")
304    
305    (definterface install-sigint-handler (function)
306      "Call FUNCTION on SIGINT (instead of invoking the debugger).
307    Return old signal handler."
308      nil)
309    
310    (definterface call-with-user-break-handler (handler function)
311      "Install the break handler HANDLER while executing FUNCTION."
312      (let ((old-handler (install-sigint-handler handler)))
313        (unwind-protect (funcall function)
314          (install-sigint-handler old-handler))))
315    
316  (definterface lisp-implementation-type-name ()  (definterface lisp-implementation-type-name ()
317    "Return a short name for the Lisp implementation."    "Return a short name for the Lisp implementation."
318    (lisp-implementation-type))    (lisp-implementation-type))
# Line 292  This is used to resolve filenames withou Line 349  This is used to resolve filenames withou
349    (declare (ignore ignore))    (declare (ignore ignore))
350    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
351    
352  (definterface swank-compile-string (string &key buffer position directory)  (definterface swank-compile-string (string &key buffer position directory debug)
353    "Compile source from STRING.  During compilation, compiler    "Compile source from STRING.  During compilation, compiler
354  conditions must be trapped and resignalled as COMPILER-CONDITIONs.  conditions must be trapped and resignalled as COMPILER-CONDITIONs.
355    
# Line 303  positions reported in compiler condition Line 360  positions reported in compiler condition
360    
361  If DIRECTORY is specified it may be used by certain implementations to  If DIRECTORY is specified it may be used by certain implementations to
362  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of
363  source information.")  source information.
364    
365  (definterface operate-on-system (system-name operation-name &rest keyword-args)  If DEBUG is supplied, and non-NIL, it may be used by certain
366    "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.  implementations to compile with a debug optimization quality of its
367  The KEYWORD-ARGS are passed on to the operation.  value.
368  Example:  
369  \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"  Should return T on successfull compilation, NIL otherwise.
370    (unless (member :asdf *features*)  ")
371      (error "ASDF is not loaded."))  
372    (with-compilation-hooks ()  (definterface swank-compile-file (pathname load-p external-format)
373      (let ((operate (find-symbol "OPERATE" :asdf))     "Compile PATHNAME signalling COMPILE-CONDITIONs.
374            (operation (find-symbol operation-name :asdf)))  If LOAD-P is true, load the file after compilation.
375        (when (null operation)  EXTERNAL-FORMAT is a value returned by find-external-format or
376          (error "Couldn't find ASDF operation ~S" operation-name))  :default.
377        (apply operate operation system-name keyword-args))))  
378    Should return T on successfull compilation, NIL otherwise.")
 (definterface swank-compile-file (filename load-p &optional external-format)  
    "Compile FILENAME signalling COMPILE-CONDITIONs.  
 If LOAD-P is true, load the file after compilation.")  
379    
380  (deftype severity ()  (deftype severity ()
381    '(member :error :read-error :warning :style-warning :note))    '(member :error :read-error :warning :style-warning :note))
# Line 353  If LOAD-P is true, load the file after c Line 407  If LOAD-P is true, load the file after c
407     (location :initarg :location     (location :initarg :location
408               :accessor location)))               :accessor location)))
409    
410    (definterface parse-emacs-filename (filename)
411      "Return a PATHNAME for FILENAME. A filename in Emacs may for example
412    contain asterisks which should not be translated to wildcards."
413      (parse-namestring filename))
414    
415    (definterface find-external-format (coding-system)
416      "Return a \"external file format designator\" for CODING-SYSTEM.
417    CODING-SYSTEM is Emacs-style coding system name (a string),
418    e.g. \"latin-1-unix\"."
419      (if (equal coding-system "iso-latin-1-unix")
420          :default
421          nil))
422    
423    (definterface guess-external-format (pathname)
424      "Detect the external format for the file with name pathname.
425    Return nil if the file contains no special markers."
426      ;; Look for a Emacs-style -*- coding: ... -*- or Local Variable: section.
427      (with-open-file (s pathname :if-does-not-exist nil
428                         :external-format (or (find-external-format "latin-1-unix")
429                                              :default))
430        (if s
431            (or (let* ((line (read-line s nil))
432                       (p (search "-*-" line)))
433                  (when p
434                    (let* ((start (+ p (length "-*-")))
435                           (end (search "-*-" line :start2 start)))
436                      (when end
437                        (%search-coding line start end)))))
438                (let* ((len (file-length s))
439                       (buf (make-string (min len 3000))))
440                  (file-position s (- len (length buf)))
441                  (read-sequence buf s)
442                  (let ((start (search "Local Variables:" buf :from-end t))
443                        (end (search "End:" buf :from-end t)))
444                    (and start end (< start end)
445                         (%search-coding buf start end))))))))
446    
447    (defun %search-coding (str start end)
448      (let ((p (search "coding:" str :start2 start :end2 end)))
449        (when p
450          (incf p (length "coding:"))
451          (loop while (and (< p end)
452                           (member (aref str p) '(#\space #\tab)))
453                do (incf p))
454          (let ((end (position-if (lambda (c) (find c '(#\space #\tab #\newline)))
455                                  str :start p)))
456            (find-external-format (subseq str p end))))))
457    
458    
459  ;;;; Streams  ;;;; Streams
460    
461    (definterface make-output-stream (write-string)
462      "Return a new character output stream.
463    The stream calls WRITE-STRING when output is ready.")
464    
465    (definterface make-input-stream (read-string)
466      "Return a new character input stream.
467    The stream calls READ-STRING when input is needed.")
468    
469  (definterface make-fn-streams (input-fn output-fn)  (definterface make-fn-streams (input-fn output-fn)
470     "Return character input and output streams backended by functions.     "Return character input and output streams backended by functions.
471  When input is needed, INPUT-FN is called with no arguments to  When input is needed, INPUT-FN is called with no arguments to
# Line 367  Output should be forced to OUTPUT-FN bef Line 477  Output should be forced to OUTPUT-FN bef
477    
478  The streams are returned as two values.")  The streams are returned as two values.")
479    
 (definterface make-stream-interactive (stream)  
   "Do any necessary setup to make STREAM work interactively.  
 This is called for each stream used for interaction with the user  
 \(e.g. *standard-output*). An implementation could setup some  
 implementation-specific functions to control output flushing at the  
 like."  
   (declare (ignore stream))  
   nil)  
   
480    
481  ;;;; Documentation  ;;;; Documentation
482    
# Line 383  like." Line 484  like."
484     "Return the lambda list for the symbol NAME. NAME can also be     "Return the lambda list for the symbol NAME. NAME can also be
485  a lisp function object, on lisps which support this.  a lisp function object, on lisps which support this.
486    
487  The result can be a list or the :not-available if the arglist  The result can be a list or the :not-available keyword if the
488  cannot be determined."  arglist cannot be determined."
489     (declare (ignore name))     (declare (ignore name))
490     :not-available)     :not-available)
491    
492    (defgeneric declaration-arglist (decl-identifier)
493      (:documentation
494       "Return the argument list of the declaration specifier belonging to the
495    declaration identifier DECL-IDENTIFIER. If the arglist cannot be determined,
496    the keyword :NOT-AVAILABLE is returned.
497    
498    The different SWANK backends can specialize this generic function to
499    include implementation-dependend declaration specifiers, or to provide
500    additional information on the specifiers defined in ANSI Common Lisp.")
501      (:method (decl-identifier)
502        (case decl-identifier
503          (dynamic-extent '(&rest vars))
504          (ignore         '(&rest vars))
505          (ignorable      '(&rest vars))
506          (special        '(&rest vars))
507          (inline         '(&rest function-names))
508          (notinline      '(&rest function-name))
509          (optimize       '(&any compilation-speed debug safety space speed))
510          (type           '(type-specifier &rest args))
511          (ftype          '(type-specifier &rest function-names))
512          (otherwise
513           (flet ((typespec-p (symbol) (member :type (describe-symbol-for-emacs symbol))))
514             (cond ((and (symbolp decl-identifier) (typespec-p decl-identifier))
515                    '(&rest vars))
516                   ((and (listp decl-identifier) (typespec-p (first decl-identifier)))
517                    '(&rest vars))
518                   (t :not-available)))))))
519    
520    (defgeneric type-specifier-arglist (typespec-operator)
521      (:documentation
522       "Return the argument list of the type specifier belonging to
523    TYPESPEC-OPERATOR.. If the arglist cannot be determined, the keyword
524    :NOT-AVAILABLE is returned.
525    
526    The different SWANK backends can specialize this generic function to
527    include implementation-dependend declaration specifiers, or to provide
528    additional information on the specifiers defined in ANSI Common Lisp.")
529      (:method (typespec-operator)
530        (declare (special *type-specifier-arglists*)) ; defined at end of file.
531        (typecase typespec-operator
532          (symbol (or (cdr (assoc typespec-operator *type-specifier-arglists*))
533                      :not-available))
534          (t :not-available))))
535    
536  (definterface function-name (function)  (definterface function-name (function)
537    "Return the name of the function object FUNCTION.    "Return the name of the function object FUNCTION.
538    
# Line 492  debug the debugger! Instead, such condit Line 637  debug the debugger! Instead, such condit
637  user without (re)entering the debugger by wrapping them as  user without (re)entering the debugger by wrapping them as
638  `sldb-condition's."))  `sldb-condition's."))
639    
640    (definterface compute-sane-restarts (condition)
641      "This is an opportunity for Lisps such as CLISP to remove
642    unwanted restarts from the output of CL:COMPUTE-RESTARTS,
643    otherwise it should simply call CL:COMPUTE-RESTARTS, which is
644    what the default implementation does."
645      (compute-restarts condition))
646    
647    ;;; The following functions in this section are supposed to be called
648    ;;; within the dynamic contour of CALL-WITH-DEBUGGING-ENVIRONMENT only.
649    
650  (definterface compute-backtrace (start end)  (definterface compute-backtrace (start end)
651     "Return a list containing a backtrace of the condition current     "Returns a backtrace of the condition currently being debugged,
652  being debugged.  The results are unspecified if this function is  that is an ordered list consisting of frames. (What constitutes a
653  called outside the dynamic contour CALL-WITH-DEBUGGING-ENVIRONMENT.  frame is implementation dependent, but PRINT-FRAME must be defined on
654    it.)
655    
656    ``Ordered list'' means that the i-th. frame is associated to the
657    frame-number i.
658    
659  START and END are zero-based indices constraining the number of frames  START and END are zero-based indices constraining the number of frames
660  returned.  Frame zero is defined as the frame which invoked the  returned.  Frame zero is defined as the frame which invoked the
# Line 506  the stack.") Line 665  the stack.")
665    "Print frame to stream.")    "Print frame to stream.")
666    
667  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
668    "Return the source location for FRAME-NUMBER.")    "Return the source location for the frame associated to FRAME-NUMBER.")
669    
670  (definterface frame-catch-tags (frame-number)  (definterface frame-catch-tags (frame-number)
671    "Return a list of XXX list of what? catch tags for a debugger    "Return a list of catch tags for being printed in a debugger stack
672  stack frame.  The results are undefined unless this is called  frame.")
 within the dynamic contour of a function defined by  
 DEFINE-DEBUGGER-HOOK.")  
673    
674  (definterface frame-locals (frame-number)  (definterface frame-locals (frame-number)
675    "Return a list of XXX local variable designators define me    "Return a list of ((&key NAME ID VALUE) ...) where each element of
676  for a debugger stack frame.  The results are undefined unless  the list represents a local variable in the stack frame associated to
677  this is called within the dynamic contour of a function defined  FRAME-NUMBER.
678  by DEFINE-DEBUGGER-HOOK.")  
679    NAME, a symbol; the name of the local variable.
680  (definterface frame-var-value (frame var)  
681    "Return the value of VAR in FRAME.  ID, an integer; used as primary key for the local variable, unique
682  FRAME is the number of the frame in the backtrace.  relatively to the frame under operation.
683  VAR is the number of the variable in the frame.")  
684    value, an object; the value of the local variable.")
685    
686    (definterface frame-var-value (frame-number var-id)
687      "Return the value of the local variable associated to VAR-ID
688    relatively to the frame associated to FRAME-NUMBER.")
689    
690  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
691    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
# Line 532  FRAME-NUMBER is a non-negative integer." Line 694  FRAME-NUMBER is a non-negative integer."
694    
695  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
696     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
697  in the debugger.  The results are undefined unless called in the  in the debugger.
 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.  
698    
699  FRAME-NUMBER must be a positive integer with 0 indicating the  FRAME-NUMBER must be a positive integer with 0 indicating the
700  frame which invoked the debugger.  frame which invoked the debugger.
# Line 559  as it was called originally.") Line 720  as it was called originally.")
720    "Format a condition for display in SLDB."    "Format a condition for display in SLDB."
721    (princ-to-string condition))    (princ-to-string condition))
722    
 (definterface condition-references (condition)  
   "Return a list of documentation references for a condition.  
 Each reference is one of:  
   (:ANSI-CL  
    {:FUNCTION | :SPECIAL-OPERATOR | :MACRO | :SECTION | :GLOSSARY }  
    symbol-or-name)  
   (:SBCL :NODE node-name)"  
   (declare (ignore condition))  
   '())  
   
723  (definterface condition-extras (condition)  (definterface condition-extras (condition)
724    "Return a list of extra for the debugger.    "Return a list of extra for the debugger.
725  The allowed elements are of the form:  The allowed elements are of the form:
726    (:SHOW-FRAME-SOURCE frame-number)"    (:SHOW-FRAME-SOURCE frame-number)
727      (:REFERENCES &rest refs)
728    "
729    (declare (ignore condition))    (declare (ignore condition))
730    '())    '())
731    
# Line 585  The allowed elements are of the form: Line 738  The allowed elements are of the form:
738  (definterface sldb-break-at-start (symbol)  (definterface sldb-break-at-start (symbol)
739    "Set a breakpoint on the beginning of the function for SYMBOL.")    "Set a breakpoint on the beginning of the function for SYMBOL.")
740    
741    (definterface sldb-stepper-condition-p (condition)
742      "Return true if SLDB was invoked due to a single-stepping condition,
743    false otherwise. "
744      (declare (ignore condition))
745      nil)
746    
747    (definterface sldb-step-into ()
748      "Step into the current single-stepper form.")
749    
750    (definterface sldb-step-next ()
751      "Step to the next form in the current function.")
752    
753    (definterface sldb-step-out ()
754      "Stop single-stepping temporarily, but resume it once the current function
755    returns.")
756    
757    
758  ;;;; Definition finding  ;;;; Definition finding
# Line 615  definition, e.g., FOO or (METHOD FOO (ST Line 783  definition, e.g., FOO or (METHOD FOO (ST
783    
784  LOCATION is the source location for the definition.")  LOCATION is the source location for the definition.")
785    
786    (definterface find-source-location (object)
787      "Returns the source location of OBJECT, or NIL.
788    
789    That is the source location of the underlying datastructure of
790    OBJECT. E.g. on a STANDARD-OBJECT, the source location of the
791    respective DEFCLASS definition is returned, on a STRUCTURE-CLASS the
792    respective DEFSTRUCT definition, and so on."
793      ;; This returns one source location and not a list of locations. It's
794      ;; supposed to return the location of the DEFGENERIC definition on
795      ;; #'SOME-GENERIC-FUNCTION.
796      )
797    
798    
799  (definterface buffer-first-change (filename)  (definterface buffer-first-change (filename)
800    "Called for effect the first time FILENAME's buffer is modified."    "Called for effect the first time FILENAME's buffer is modified."
801    (declare (ignore filename))    (declare (ignore filename))
802    nil)    nil)
803    
804    
805    
806  ;;;; XREF  ;;;; XREF
807    
# Line 706  themselves, that is, their dispatch func Line 888  themselves, that is, their dispatch func
888    
889  ;;;; Inspector  ;;;; Inspector
890    
891  (defclass inspector ()  (defgeneric emacs-inspect (object)
892    ()    (:documentation
   (:documentation "Super class of inspector objects.  
   
 Implementations should sub class in order to dispatch off of the  
 inspect-for-emacs method."))  
   
 (definterface make-default-inspector ()  
   "Return an inspector object suitable for passing to inspect-for-emacs.")  
   
 (definterface inspect-for-emacs (object inspector)  
893     "Explain to Emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
894    
895  The argument INSPECTOR is an object representing how to get at  Returns a list specifying how to render the object for inspection.
 the internals of OBJECT, it is usually an implementation specific  
 class used simply for dispatching to the proper method.  
   
 The orgument INSPECTION-MODE is an object specifying how, and  
 what, to show to the user.  
   
 Returns two values: a string which will be used as the title of  
 the inspector buffer and a list specifying how to render the  
 object for inspection.  
896    
897  Every element of the list must be either a string, which will be  Every element of the list must be either a string, which will be
898  inserted into the buffer as is, or a list of the form:  inserted into the buffer as is, or a list of the form:
# Line 739  inserted into the buffer as is, or a lis Line 903  inserted into the buffer as is, or a lis
903    
904   (:newline) - Render a \\n   (:newline) - Render a \\n
905    
906   (:action label lambda) - Render LABEL (a text string) which when   (:action label lambda &key (refresh t)) - Render LABEL (a text
907   clicked will call LAMBDA.   string) which when clicked will call LAMBDA. If REFRESH is
908     non-NIL the currently inspected object will be re-inspected
909     after calling the lambda.
910    "))
911    
912   NIL - do nothing.")  (defmethod emacs-inspect ((object t))
   
 (defmethod inspect-for-emacs ((object t) (inspector t))  
913    "Generic method for inspecting any kind of object.    "Generic method for inspecting any kind of object.
914    
915  Since we don't know how to deal with OBJECT we simply dump the  Since we don't know how to deal with OBJECT we simply dump the
916  output of CL:DESCRIBE."  output of CL:DESCRIBE."
   (declare (ignore inspector))  
   (values  
    "A value."  
917     `("Type: " (:value ,(type-of object)) (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
918       "Don't know how to inspect the object, dumping output of CL:DESCRIBE:"       "Don't know how to inspect the object, dumping output of CL:DESCRIBE:"
919       (:newline) (:newline)       (:newline) (:newline)
920       ,(with-output-to-string (desc) (describe object desc)))))       ,(with-output-to-string (desc) (describe object desc))))
921    
922  ;;; Utilities for inspector methods.  ;;; Utilities for inspector methods.
923  ;;;  ;;;
924  (defun label-value-line (label value)  (defun label-value-line (label value &key (newline t))
925    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector.
926    (list (princ-to-string label) ": " `(:value ,value) '(:newline)))  If NEWLINE is non-NIL a `(:newline)' is added to the result."
927      (list* (princ-to-string label) ": " `(:value ,value)
928             (if newline '((:newline)) nil)))
929    
930  (defmacro label-value-line* (&rest label-values)  (defmacro label-value-line* (&rest label-values)
931    ` (append ,@(loop for (label value) in label-values    ` (append ,@(loop for (label value) in label-values
# Line 778  output of CL:DESCRIBE." Line 942  output of CL:DESCRIBE."
942  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
943  ;;; implementations.  ;;; implementations.
944    
945  (definterface initialize-multiprocessing ()  (definterface initialize-multiprocessing (continuation)
946     "Initialize multiprocessing, if necessary."     "Initialize multiprocessing, if necessary and then invoke CONTINUATION.
    nil)  
947    
948  (definterface startup-idle-and-top-level-loops ()  Depending on the impleimentaion, this function may never return."
949    "This function is called directly through the listener, not in an RPC     (funcall continuation))
 from Emacs. This is to support interfaces such as CMUCL's  
 MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS which does not return like a  
 normal function."  
    nil)  
950    
951  (definterface spawn (fn &key name)  (definterface spawn (fn &key name)
952    "Create a new thread to call FN.")    "Create a new thread to call FN.")
# Line 796  normal function." Line 955  normal function."
955    "Return an Emacs-parsable object to identify THREAD.    "Return an Emacs-parsable object to identify THREAD.
956    
957  Ids should be comparable with equal, i.e.:  Ids should be comparable with equal, i.e.:
958   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)"
959      thread)
960    
961  (definterface find-thread (id)  (definterface find-thread (id)
962    "Return the thread for ID.    "Return the thread for ID.
963  ID should be an id previously obtained with THREAD-ID.  ID should be an id previously obtained with THREAD-ID.
964  Can return nil if the thread no longer exists.")  Can return nil if the thread no longer exists."
965      (current-thread))
966    
967  (definterface thread-name (thread)  (definterface thread-name (thread)
968     "Return the name of THREAD.     "Return the name of THREAD.
# Line 816  user. They do not have to be unique." Line 977  user. They do not have to be unique."
977     (declare (ignore thread))     (declare (ignore thread))
978     "")     "")
979    
980    (definterface thread-description (thread)
981      "Return a string describing THREAD."
982      (declare (ignore thread))
983      "")
984    
985    (definterface set-thread-description (thread description)
986      "Set THREAD's description to DESCRIPTION."
987      (declare (ignore thread description))
988      "")
989    
990  (definterface make-lock (&key name)  (definterface make-lock (&key name)
991     "Make a lock for thread synchronization.     "Make a lock for thread synchronization.
992  Only one thread may hold the lock (via CALL-WITH-LOCK-HELD) at a time."  Only one thread may hold the lock (via CALL-WITH-LOCK-HELD) at a time
993    but that thread may hold it more than once."
994     (declare (ignore name))     (declare (ignore name))
995     :null-lock)     :null-lock)
996    
# Line 833  Only one thread may hold the lock (via C Line 1005  Only one thread may hold the lock (via C
1005    0)    0)
1006    
1007  (definterface all-threads ()  (definterface all-threads ()
1008    "Return a list of all threads.")    "Return a fresh list of all threads.")
1009    
1010  (definterface thread-alive-p (thread)  (definterface thread-alive-p (thread)
1011    "Test if THREAD is termintated."    "Test if THREAD is termintated."
# Line 850  Only one thread may hold the lock (via C Line 1022  Only one thread may hold the lock (via C
1022  (definterface send (thread object)  (definterface send (thread object)
1023    "Send OBJECT to thread THREAD.")    "Send OBJECT to thread THREAD.")
1024    
1025  (definterface receive ()  (definterface receive (&optional timeout)
1026    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox."
1027      (receive-if (constantly t) timeout))
1028    
1029    (definterface receive-if (predicate &optional timeout)
1030      "Return the first message satisfiying PREDICATE.")
1031    
1032    (defvar *pending-slime-interrupts*)
1033    
1034    (defun check-slime-interrupts ()
1035      "Execute pending interrupts if any.
1036    This should be called periodically in operations which
1037    can take a long time to complete."
1038      (when (and (boundp '*pending-slime-interrupts*)
1039                 *pending-slime-interrupts*)
1040        (funcall (pop *pending-slime-interrupts*))))
1041    
1042  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1043    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
# Line 873  SPEC can be: Line 1059  SPEC can be:
1059  (definterface make-weak-value-hash-table (&rest args)  (definterface make-weak-value-hash-table (&rest args)
1060    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
1061    (apply #'make-hash-table args))    (apply #'make-hash-table args))
1062    
1063    (definterface hash-table-weakness (hashtable)
1064      "Return nil or one of :key :value :key-or-value :key-and-value"
1065      (declare (ignore hashtable))
1066      nil)
1067    
1068    
1069    ;;;; Character names
1070    
1071    (definterface character-completion-set (prefix matchp)
1072      "Return a list of names of characters that match PREFIX."
1073      ;; Handle the standard and semi-standard characters.
1074      (loop for name in '("Newline" "Space" "Tab" "Page" "Rubout"
1075                          "Linefeed" "Return" "Backspace")
1076         when (funcall matchp prefix name)
1077         collect name))
1078    
1079    
1080    (defparameter *type-specifier-arglists*
1081      '((and                . (&rest type-specifiers))
1082        (array              . (&optional element-type dimension-spec))
1083        (base-string        . (&optional size))
1084        (bit-vector         . (&optional size))
1085        (complex            . (&optional type-specifier))
1086        (cons               . (&optional car-typespec cdr-typespec))
1087        (double-float       . (&optional lower-limit upper-limit))
1088        (eql                . (object))
1089        (float              . (&optional lower-limit upper-limit))
1090        (function           . (&optional arg-typespec value-typespec))
1091        (integer            . (&optional lower-limit upper-limit))
1092        (long-float         . (&optional lower-limit upper-limit))
1093        (member             . (&rest eql-objects))
1094        (mod                . (n))
1095        (not                . (type-specifier))
1096        (or                 . (&rest type-specifiers))
1097        (rational           . (&optional lower-limit upper-limit))
1098        (real               . (&optional lower-limit upper-limit))
1099        (satisfies          . (predicate-symbol))
1100        (short-float        . (&optional lower-limit upper-limit))
1101        (signed-byte        . (&optional size))
1102        (simple-array       . (&optional element-type dimension-spec))
1103        (simple-base-string . (&optional size))
1104        (simple-bit-vector  . (&optional size))
1105        (simple-string      . (&optional size))
1106        (single-float       . (&optional lower-limit upper-limit))
1107        (simple-vector      . (&optional size))
1108        (string             . (&optional size))
1109        (unsigned-byte      . (&optional size))
1110        (values             . (&rest typespecs))
1111        (vector             . (&optional element-type size))
1112        ))
1113    
1114    ;;; Heap dumps
1115    
1116    (definterface save-image (filename &optional restart-function)
1117      "Save a heap image to the file FILENAME.
1118    RESTART-FUNCTION, if non-nil, should be called when the image is loaded.")
1119    
1120    
1121    

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.147

  ViewVC Help
Powered by ViewVC 1.1.5