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

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

  ViewVC Help
Powered by ViewVC 1.1.5