/[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.162 by heller, Sun Oct 19 20:03:49 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
204      :fundamental-character-input-stream      :fundamental-character-input-stream
205      :stream-read-char      :stream-read-char
206        :stream-peek-char
207        :stream-read-line
208        ;; STREAM-FILE-POSITION is not available on all implementations, or
209        ;; partially under a different name.
210        ; :stream-file-posiion
211      :stream-listen      :stream-listen
212      :stream-unread-char      :stream-unread-char
213      :stream-clear-input      :stream-clear-input
# Line 212  EXCEPT is a list of symbol names which s Line 257  EXCEPT is a list of symbol names which s
257    "Close the socket SOCKET.")    "Close the socket SOCKET.")
258    
259  (definterface accept-connection (socket &key external-format  (definterface accept-connection (socket &key external-format
260                                          buffering)                                          buffering timeout)
261     "Accept a client connection on the listening socket SOCKET.     "Accept a client connection on the listening socket SOCKET.
262  Return a stream for the new connection.")  Return a stream for the new connection.")
263    
# Line 232  Return a stream for the new connection." Line 277  Return a stream for the new connection."
277    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
278    nil)    nil)
279    
280    (definterface set-stream-timeout (stream timeout)
281      "Set the 'stream 'timeout.  The timeout is either the real number
282      specifying the timeout in seconds or 'nil for no timeout."
283      (declare (ignore stream timeout))
284      nil)
285    
286  ;;; Base condition for networking errors.  ;;; Base condition for networking errors.
287  (define-condition network-error (simple-error) ())  (define-condition network-error (simple-error) ())
288    
# Line 256  that the calling thread is the one that Line 307  that the calling thread is the one that
307  (definterface getpid ()  (definterface getpid ()
308    "Return the (Unix) process ID of this superior Lisp.")    "Return the (Unix) process ID of this superior Lisp.")
309    
310    (definterface install-sigint-handler (function)
311      "Call FUNCTION on SIGINT (instead of invoking the debugger).
312    Return old signal handler."
313      (declare (ignore function))
314      nil)
315    
316    (definterface call-with-user-break-handler (handler function)
317      "Install the break handler HANDLER while executing FUNCTION."
318      (let ((old-handler (install-sigint-handler handler)))
319        (unwind-protect (funcall function)
320          (install-sigint-handler old-handler))))
321    
322    (definterface quit-lisp ()
323      "Exit the current lisp image.")
324    
325  (definterface lisp-implementation-type-name ()  (definterface lisp-implementation-type-name ()
326    "Return a short name for the Lisp implementation."    "Return a short name for the Lisp implementation."
327    (lisp-implementation-type))    (lisp-implementation-type))
328    
329    
330    ;; pathnames are sooo useless
331    
332    (definterface filename-to-pathname (filename)
333      "Return a pathname for FILENAME.
334    A filename in Emacs may for example contain asterisks which should not
335    be translated to wildcards."
336      (parse-namestring filename))
337    
338    (definterface pathname-to-filename (pathname)
339      "Return the filename for PATHNAME."
340      (namestring pathname))
341    
342  (definterface default-directory ()  (definterface default-directory ()
343    "Return the default directory."    "Return the default directory."
344    (directory-namestring (truename *default-pathname-defaults*)))    (directory-namestring (truename *default-pathname-defaults*)))
# Line 270  This is used to resolve filenames withou Line 349  This is used to resolve filenames withou
349    (setf *default-pathname-defaults* (truename (merge-pathnames directory)))    (setf *default-pathname-defaults* (truename (merge-pathnames directory)))
350    (default-directory))    (default-directory))
351    
352    
353  (definterface call-with-syntax-hooks (fn)  (definterface call-with-syntax-hooks (fn)
354    "Call FN with hooks to handle special syntax."    "Call FN with hooks to handle special syntax."
355    (funcall fn))    (funcall fn))
# Line 278  This is used to resolve filenames withou Line 358  This is used to resolve filenames withou
358    "Return a suitable initial value for SWANK:*READTABLE-ALIST*."    "Return a suitable initial value for SWANK:*READTABLE-ALIST*."
359    '())    '())
360    
 (definterface quit-lisp ()  
   "Exit the current lisp image.")  
   
361    
362  ;;;; Compilation  ;;;; Compilation
363    
# Line 292  This is used to resolve filenames withou Line 369  This is used to resolve filenames withou
369    (declare (ignore ignore))    (declare (ignore ignore))
370    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
371    
372  (definterface swank-compile-string (string &key buffer position directory)  (definterface swank-compile-string (string &key buffer position directory
373    "Compile source from STRING.  During compilation, compiler                                             debug)
374  conditions must be trapped and resignalled as COMPILER-CONDITIONs.    "Compile source from STRING.
375    During compilation, compiler conditions must be trapped and
376    resignalled as COMPILER-CONDITIONs.
377    
378  If supplied, BUFFER and POSITION specify the source location in Emacs.  If supplied, BUFFER and POSITION specify the source location in Emacs.
379    
# Line 303  positions reported in compiler condition Line 382  positions reported in compiler condition
382    
383  If DIRECTORY is specified it may be used by certain implementations to  If DIRECTORY is specified it may be used by certain implementations to
384  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of
385  source information.")  source information.
386    
387  (definterface operate-on-system (system-name operation-name &rest keyword-args)  If DEBUG is supplied, and non-NIL, it may be used by certain
388    "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.  implementations to compile with a debug optimization quality of its
389  The KEYWORD-ARGS are passed on to the operation.  value.
390  Example:  
391  \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"  Should return T on successfull compilation, NIL otherwise.
392    (unless (member :asdf *features*)  ")
393      (error "ASDF is not loaded."))  
394    (with-compilation-hooks ()  (definterface swank-compile-file (pathname load-p external-format)
395      (let ((operate (find-symbol "OPERATE" :asdf))     "Compile PATHNAME signalling COMPILE-CONDITIONs.
396            (operation (find-symbol operation-name :asdf)))  If LOAD-P is true, load the file after compilation.
397        (when (null operation)  EXTERNAL-FORMAT is a value returned by find-external-format or
398          (error "Couldn't find ASDF operation ~S" operation-name))  :default.
399        (apply operate operation system-name keyword-args))))  
400    Should return OUTPUT-TRUENAME, WARNINGS-P and FAILURE-p
401  (definterface swank-compile-file (filename load-p &optional external-format)  like `compile-file'")
    "Compile FILENAME signalling COMPILE-CONDITIONs.  
 If LOAD-P is true, load the file after compilation.")  
402    
403  (deftype severity ()  (deftype severity ()
404    '(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 430  If LOAD-P is true, load the file after c
430     (location :initarg :location     (location :initarg :location
431               :accessor location)))               :accessor location)))
432    
433    (definterface find-external-format (coding-system)
434      "Return a \"external file format designator\" for CODING-SYSTEM.
435    CODING-SYSTEM is Emacs-style coding system name (a string),
436    e.g. \"latin-1-unix\"."
437      (if (equal coding-system "iso-latin-1-unix")
438          :default
439          nil))
440    
441    (definterface guess-external-format (pathname)
442      "Detect the external format for the file with name pathname.
443    Return nil if the file contains no special markers."
444      ;; Look for a Emacs-style -*- coding: ... -*- or Local Variable: section.
445      (with-open-file (s pathname :if-does-not-exist nil
446                         :external-format (or (find-external-format "latin-1-unix")
447                                              :default))
448        (if s
449            (or (let* ((line (read-line s nil))
450                       (p (search "-*-" line)))
451                  (when p
452                    (let* ((start (+ p (length "-*-")))
453                           (end (search "-*-" line :start2 start)))
454                      (when end
455                        (%search-coding line start end)))))
456                (let* ((len (file-length s))
457                       (buf (make-string (min len 3000))))
458                  (file-position s (- len (length buf)))
459                  (read-sequence buf s)
460                  (let ((start (search "Local Variables:" buf :from-end t))
461                        (end (search "End:" buf :from-end t)))
462                    (and start end (< start end)
463                         (%search-coding buf start end))))))))
464    
465    (defun %search-coding (str start end)
466      (let ((p (search "coding:" str :start2 start :end2 end)))
467        (when p
468          (incf p (length "coding:"))
469          (loop while (and (< p end)
470                           (member (aref str p) '(#\space #\tab)))
471                do (incf p))
472          (let ((end (position-if (lambda (c) (find c '(#\space #\tab #\newline)))
473                                  str :start p)))
474            (find-external-format (subseq str p end))))))
475    
476    
477  ;;;; Streams  ;;;; Streams
478    
479  (definterface make-fn-streams (input-fn output-fn)  (definterface make-output-stream (write-string)
480     "Return character input and output streams backended by functions.    "Return a new character output stream.
481  When input is needed, INPUT-FN is called with no arguments to  The stream calls WRITE-STRING when output is ready.")
482  return a string.  
483  When output is ready, OUTPUT-FN is called with the output as its  (definterface make-input-stream (read-string)
484  argument.    "Return a new character input stream.
485    The stream calls READ-STRING when input is needed.")
 Output should be forced to OUTPUT-FN before calling INPUT-FN.  
   
 The streams are returned as two values.")  
   
 (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)  
486    
487    
488  ;;;; Documentation  ;;;; Documentation
# Line 383  like." Line 491  like."
491     "Return the lambda list for the symbol NAME. NAME can also be     "Return the lambda list for the symbol NAME. NAME can also be
492  a lisp function object, on lisps which support this.  a lisp function object, on lisps which support this.
493    
494  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
495  cannot be determined."  arglist cannot be determined."
496     (declare (ignore name))     (declare (ignore name))
497     :not-available)     :not-available)
498    
499    (defgeneric declaration-arglist (decl-identifier)
500      (:documentation
501       "Return the argument list of the declaration specifier belonging to the
502    declaration identifier DECL-IDENTIFIER. If the arglist cannot be determined,
503    the keyword :NOT-AVAILABLE is returned.
504    
505    The different SWANK backends can specialize this generic function to
506    include implementation-dependend declaration specifiers, or to provide
507    additional information on the specifiers defined in ANSI Common Lisp.")
508      (:method (decl-identifier)
509        (case decl-identifier
510          (dynamic-extent '(&rest vars))
511          (ignore         '(&rest vars))
512          (ignorable      '(&rest vars))
513          (special        '(&rest vars))
514          (inline         '(&rest function-names))
515          (notinline      '(&rest function-name))
516          (optimize       '(&any compilation-speed debug safety space speed))
517          (type           '(type-specifier &rest args))
518          (ftype          '(type-specifier &rest function-names))
519          (otherwise
520           (flet ((typespec-p (symbol) (member :type (describe-symbol-for-emacs symbol))))
521             (cond ((and (symbolp decl-identifier) (typespec-p decl-identifier))
522                    '(&rest vars))
523                   ((and (listp decl-identifier) (typespec-p (first decl-identifier)))
524                    '(&rest vars))
525                   (t :not-available)))))))
526    
527    (defgeneric type-specifier-arglist (typespec-operator)
528      (:documentation
529       "Return the argument list of the type specifier belonging to
530    TYPESPEC-OPERATOR.. If the arglist cannot be determined, the keyword
531    :NOT-AVAILABLE is returned.
532    
533    The different SWANK backends can specialize this generic function to
534    include implementation-dependend declaration specifiers, or to provide
535    additional information on the specifiers defined in ANSI Common Lisp.")
536      (:method (typespec-operator)
537        (declare (special *type-specifier-arglists*)) ; defined at end of file.
538        (typecase typespec-operator
539          (symbol (or (cdr (assoc typespec-operator *type-specifier-arglists*))
540                      :not-available))
541          (t :not-available))))
542    
543  (definterface function-name (function)  (definterface function-name (function)
544    "Return the name of the function object FUNCTION.    "Return the name of the function object FUNCTION.
545    
# Line 492  debug the debugger! Instead, such condit Line 644  debug the debugger! Instead, such condit
644  user without (re)entering the debugger by wrapping them as  user without (re)entering the debugger by wrapping them as
645  `sldb-condition's."))  `sldb-condition's."))
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. ``Ordered list''
653  called outside the dynamic contour CALL-WITH-DEBUGGING-ENVIRONMENT.  means that an integer I can be mapped back to the i-th frame of this
654    backtrace.
655    
656  START and END are zero-based indices constraining the number of frames  START and END are zero-based indices constraining the number of frames
657  returned.  Frame zero is defined as the frame which invoked the  returned. Frame zero is defined as the frame which invoked the
658  debugger.  If END is nil, return the frames from START to the end of  debugger. If END is nil, return the frames from START to the end of
659  the stack.")  the stack.")
660    
661  (definterface print-frame (frame stream)  (definterface print-frame (frame stream)
662    "Print frame to stream.")    "Print frame to stream.")
663    
664    (definterface frame-restartable-p (frame)
665      "Is the frame FRAME restartable?.
666    Return T if `restart-frame' can safely be called on the frame."
667      (declare (ignore frame))
668      nil)
669    
670  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
671    "Return the source location for FRAME-NUMBER.")    "Return the source location for the frame associated to FRAME-NUMBER.")
672    
673  (definterface frame-catch-tags (frame-number)  (definterface frame-catch-tags (frame-number)
674    "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
675  stack frame.  The results are undefined unless this is called  frame."
676  within the dynamic contour of a function defined by    (declare (ignore frame-number))
677  DEFINE-DEBUGGER-HOOK.")    '())
678    
679  (definterface frame-locals (frame-number)  (definterface frame-locals (frame-number)
680    "Return a list of XXX local variable designators define me    "Return a list of ((&key NAME ID VALUE) ...) where each element of
681  for a debugger stack frame.  The results are undefined unless  the list represents a local variable in the stack frame associated to
682  this is called within the dynamic contour of a function defined  FRAME-NUMBER.
683  by DEFINE-DEBUGGER-HOOK.")  
684    NAME, a symbol; the name of the local variable.
685  (definterface frame-var-value (frame var)  
686    "Return the value of VAR in FRAME.  ID, an integer; used as primary key for the local variable, unique
687  FRAME is the number of the frame in the backtrace.  relatively to the frame under operation.
688  VAR is the number of the variable in the frame.")  
689    value, an object; the value of the local variable.")
690    
691    (definterface frame-var-value (frame-number var-id)
692      "Return the value of the local variable associated to VAR-ID
693    relatively to the frame associated to FRAME-NUMBER.")
694    
695  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
696    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
# Line 532  FRAME-NUMBER is a non-negative integer." Line 699  FRAME-NUMBER is a non-negative integer."
699    
700  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
701     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
702  in the debugger.  The results are undefined unless called in the  in the debugger.
 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.  
703    
704  FRAME-NUMBER must be a positive integer with 0 indicating the  FRAME-NUMBER must be a positive integer with 0 indicating the
705  frame which invoked the debugger.  frame which invoked the debugger.
# Line 559  as it was called originally.") Line 725  as it was called originally.")
725    "Format a condition for display in SLDB."    "Format a condition for display in SLDB."
726    (princ-to-string condition))    (princ-to-string condition))
727    
 (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))  
   '())  
   
728  (definterface condition-extras (condition)  (definterface condition-extras (condition)
729    "Return a list of extra for the debugger.    "Return a list of extra for the debugger.
730  The allowed elements are of the form:  The allowed elements are of the form:
731    (:SHOW-FRAME-SOURCE frame-number)"    (:SHOW-FRAME-SOURCE frame-number)
732      (:REFERENCES &rest refs)
733    "
734    (declare (ignore condition))    (declare (ignore condition))
735    '())    '())
736    
# Line 585  The allowed elements are of the form: Line 743  The allowed elements are of the form:
743  (definterface sldb-break-at-start (symbol)  (definterface sldb-break-at-start (symbol)
744    "Set a breakpoint on the beginning of the function for SYMBOL.")    "Set a breakpoint on the beginning of the function for SYMBOL.")
745    
746    (definterface sldb-stepper-condition-p (condition)
747      "Return true if SLDB was invoked due to a single-stepping condition,
748    false otherwise. "
749      (declare (ignore condition))
750      nil)
751    
752    (definterface sldb-step-into ()
753      "Step into the current single-stepper form.")
754    
755    (definterface sldb-step-next ()
756      "Step to the next form in the current function.")
757    
758    (definterface sldb-step-out ()
759      "Stop single-stepping temporarily, but resume it once the current function
760    returns.")
761    
762    
763  ;;;; Definition finding  ;;;; Definition finding
# Line 615  definition, e.g., FOO or (METHOD FOO (ST Line 788  definition, e.g., FOO or (METHOD FOO (ST
788    
789  LOCATION is the source location for the definition.")  LOCATION is the source location for the definition.")
790    
791    (definterface find-source-location (object)
792      "Returns the source location of OBJECT, or NIL.
793    
794    That is the source location of the underlying datastructure of
795    OBJECT. E.g. on a STANDARD-OBJECT, the source location of the
796    respective DEFCLASS definition is returned, on a STRUCTURE-CLASS the
797    respective DEFSTRUCT definition, and so on."
798      ;; This returns one source location and not a list of locations. It's
799      ;; supposed to return the location of the DEFGENERIC definition on
800      ;; #'SOME-GENERIC-FUNCTION.
801      )
802    
803    
804  (definterface buffer-first-change (filename)  (definterface buffer-first-change (filename)
805    "Called for effect the first time FILENAME's buffer is modified."    "Called for effect the first time FILENAME's buffer is modified."
806    (declare (ignore filename))    (declare (ignore filename))
807    nil)    nil)
808    
809    
810    
811  ;;;; XREF  ;;;; XREF
812    
# Line 706  themselves, that is, their dispatch func Line 893  themselves, that is, their dispatch func
893    
894  ;;;; Inspector  ;;;; Inspector
895    
896  (defclass inspector ()  (defgeneric emacs-inspect (object)
897    ()    (: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)  
898     "Explain to Emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
899    
900  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.  
901    
902  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
903  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 908  inserted into the buffer as is, or a lis
908    
909   (:newline) - Render a \\n   (:newline) - Render a \\n
910    
911   (:action label lambda) - Render LABEL (a text string) which when   (:action label lambda &key (refresh t)) - Render LABEL (a text
912   clicked will call LAMBDA.   string) which when clicked will call LAMBDA. If REFRESH is
913     non-NIL the currently inspected object will be re-inspected
914     after calling the lambda.
915    "))
916    
917   NIL - do nothing.")  (defmethod emacs-inspect ((object t))
   
 (defmethod inspect-for-emacs ((object t) (inspector t))  
918    "Generic method for inspecting any kind of object.    "Generic method for inspecting any kind of object.
919    
920  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
921  output of CL:DESCRIBE."  output of CL:DESCRIBE."
   (declare (ignore inspector))  
   (values  
    "A value."  
922     `("Type: " (:value ,(type-of object)) (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
923       "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:"
924       (:newline) (:newline)       (:newline) (:newline)
925       ,(with-output-to-string (desc) (describe object desc)))))       ,(with-output-to-string (desc) (describe object desc))))
926    
927  ;;; Utilities for inspector methods.  ;;; Utilities for inspector methods.
928  ;;;  ;;;
929  (defun label-value-line (label value)  (defun label-value-line (label value &key (newline t))
930    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector.
931    (list (princ-to-string label) ": " `(:value ,value) '(:newline)))  If NEWLINE is non-NIL a `(:newline)' is added to the result."
932      (list* (princ-to-string label) ": " `(:value ,value)
933             (if newline '((:newline)) nil)))
934    
935  (defmacro label-value-line* (&rest label-values)  (defmacro label-value-line* (&rest label-values)
936    ` (append ,@(loop for (label value) in label-values    ` (append ,@(loop for (label value) in label-values
# Line 778  output of CL:DESCRIBE." Line 947  output of CL:DESCRIBE."
947  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
948  ;;; implementations.  ;;; implementations.
949    
950  (definterface initialize-multiprocessing ()  (definterface initialize-multiprocessing (continuation)
951     "Initialize multiprocessing, if necessary."     "Initialize multiprocessing, if necessary and then invoke CONTINUATION.
    nil)  
952    
953  (definterface startup-idle-and-top-level-loops ()  Depending on the impleimentaion, this function may never return."
954    "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)  
955    
956  (definterface spawn (fn &key name)  (definterface spawn (fn &key name)
957    "Create a new thread to call FN.")    "Create a new thread to call FN.")
# Line 796  normal function." Line 960  normal function."
960    "Return an Emacs-parsable object to identify THREAD.    "Return an Emacs-parsable object to identify THREAD.
961    
962  Ids should be comparable with equal, i.e.:  Ids should be comparable with equal, i.e.:
963   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)"
964      thread)
965    
966  (definterface find-thread (id)  (definterface find-thread (id)
967    "Return the thread for ID.    "Return the thread for ID.
968  ID should be an id previously obtained with THREAD-ID.  ID should be an id previously obtained with THREAD-ID.
969  Can return nil if the thread no longer exists.")  Can return nil if the thread no longer exists."
970      (declare (ignore id))
971      (current-thread))
972    
973  (definterface thread-name (thread)  (definterface thread-name (thread)
974     "Return the name of THREAD.     "Return the name of THREAD.
# Line 816  user. They do not have to be unique." Line 983  user. They do not have to be unique."
983     (declare (ignore thread))     (declare (ignore thread))
984     "")     "")
985    
986    (definterface thread-description (thread)
987      "Return a string describing THREAD."
988      (declare (ignore thread))
989      "")
990    
991    (definterface set-thread-description (thread description)
992      "Set THREAD's description to DESCRIPTION."
993      (declare (ignore thread description))
994      "")
995    
996  (definterface make-lock (&key name)  (definterface make-lock (&key name)
997     "Make a lock for thread synchronization.     "Make a lock for thread synchronization.
998  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
999    but that thread may hold it more than once."
1000     (declare (ignore name))     (declare (ignore name))
1001     :null-lock)     :null-lock)
1002    
# Line 833  Only one thread may hold the lock (via C Line 1011  Only one thread may hold the lock (via C
1011    0)    0)
1012    
1013  (definterface all-threads ()  (definterface all-threads ()
1014    "Return a list of all threads.")    "Return a fresh list of all threads.")
1015    
1016  (definterface thread-alive-p (thread)  (definterface thread-alive-p (thread)
1017    "Test if THREAD is termintated."    "Test if THREAD is termintated."
# Line 850  Only one thread may hold the lock (via C Line 1028  Only one thread may hold the lock (via C
1028  (definterface send (thread object)  (definterface send (thread object)
1029    "Send OBJECT to thread THREAD.")    "Send OBJECT to thread THREAD.")
1030    
1031  (definterface receive ()  (definterface receive (&optional timeout)
1032    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox."
1033      (receive-if (constantly t) timeout))
1034    
1035    (definterface receive-if (predicate &optional timeout)
1036      "Return the first message satisfiying PREDICATE.")
1037    
1038    ;; List of delayed interrupts.
1039    ;; This should only have thread-local bindings, so no init form.
1040    (defvar *pending-slime-interrupts*)
1041    
1042    (defun check-slime-interrupts ()
1043      "Execute pending interrupts if any.
1044    This should be called periodically in operations which
1045    can take a long time to complete.
1046    Return a boolean indicating whether any interrupts was processed."
1047      (when (and (boundp '*pending-slime-interrupts*)
1048                 *pending-slime-interrupts*)
1049        (funcall (pop *pending-slime-interrupts*))
1050        t))
1051    
1052    (definterface wait-for-input (streams &optional timeout)
1053      "Wait for input on a list of streams.  Return those that are ready.
1054    STREAMS is a list of streams
1055    TIMEOUT nil, t, or real number. If TIMEOUT is t, return
1056    those streams which are ready immediately, without waiting.
1057    If TIMEOUT is a number and no streams is ready after TIMEOUT seconds,
1058    return nil.
1059    
1060    Return :interrupt if an interrupt occurs while waiting."
1061      (assert (= (length streams) 1))
1062      (let ((stream (car streams)))
1063        (case timeout
1064          ((nil)
1065           (cond ((check-slime-interrupts) :interrupt)
1066                 (t (peek-char nil stream nil nil)
1067                    streams)))
1068          ((t)
1069           (let ((c (read-char-no-hang stream nil nil)))
1070             (cond (c
1071                    (unread-char c stream)
1072                    streams)
1073                   (t '()))))
1074          (t
1075           (loop
1076            (if (check-slime-interrupts) (return :interrupt))
1077            (when (wait-for-input streams t) (return streams))
1078            (sleep 0.1)
1079            (when (<= (decf timeout 0.1) 0) (return nil)))))))
1080    
1081  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1082    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
# Line 873  SPEC can be: Line 1098  SPEC can be:
1098  (definterface make-weak-value-hash-table (&rest args)  (definterface make-weak-value-hash-table (&rest args)
1099    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
1100    (apply #'make-hash-table args))    (apply #'make-hash-table args))
1101    
1102    (definterface hash-table-weakness (hashtable)
1103      "Return nil or one of :key :value :key-or-value :key-and-value"
1104      (declare (ignore hashtable))
1105      nil)
1106    
1107    
1108    ;;;; Character names
1109    
1110    (definterface character-completion-set (prefix matchp)
1111      "Return a list of names of characters that match PREFIX."
1112      ;; Handle the standard and semi-standard characters.
1113      (loop for name in '("Newline" "Space" "Tab" "Page" "Rubout"
1114                          "Linefeed" "Return" "Backspace")
1115         when (funcall matchp prefix name)
1116         collect name))
1117    
1118    
1119    (defparameter *type-specifier-arglists*
1120      '((and                . (&rest type-specifiers))
1121        (array              . (&optional element-type dimension-spec))
1122        (base-string        . (&optional size))
1123        (bit-vector         . (&optional size))
1124        (complex            . (&optional type-specifier))
1125        (cons               . (&optional car-typespec cdr-typespec))
1126        (double-float       . (&optional lower-limit upper-limit))
1127        (eql                . (object))
1128        (float              . (&optional lower-limit upper-limit))
1129        (function           . (&optional arg-typespec value-typespec))
1130        (integer            . (&optional lower-limit upper-limit))
1131        (long-float         . (&optional lower-limit upper-limit))
1132        (member             . (&rest eql-objects))
1133        (mod                . (n))
1134        (not                . (type-specifier))
1135        (or                 . (&rest type-specifiers))
1136        (rational           . (&optional lower-limit upper-limit))
1137        (real               . (&optional lower-limit upper-limit))
1138        (satisfies          . (predicate-symbol))
1139        (short-float        . (&optional lower-limit upper-limit))
1140        (signed-byte        . (&optional size))
1141        (simple-array       . (&optional element-type dimension-spec))
1142        (simple-base-string . (&optional size))
1143        (simple-bit-vector  . (&optional size))
1144        (simple-string      . (&optional size))
1145        (single-float       . (&optional lower-limit upper-limit))
1146        (simple-vector      . (&optional size))
1147        (string             . (&optional size))
1148        (unsigned-byte      . (&optional size))
1149        (values             . (&rest typespecs))
1150        (vector             . (&optional element-type size))
1151        ))
1152    
1153    ;;; Heap dumps
1154    
1155    (definterface save-image (filename &optional restart-function)
1156      "Save a heap image to the file FILENAME.
1157    RESTART-FUNCTION, if non-nil, should be called when the image is loaded.")
1158    
1159    
1160    

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

  ViewVC Help
Powered by ViewVC 1.1.5