/[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.169 by heller, Sat Jan 10 12:25:16 2009 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               #:slime-interrupt-queued
39             ;; inspector related symbols             ;; inspector related symbols
40             #:inspector             #:emacs-inspect
            #:inspect-for-emacs  
            #:raw-inspection  
            #:fancy-inspection  
41             #:label-value-line             #:label-value-line
42             #:label-value-line*             #:label-value-line*
43    
44               #:with-struct
45             ))             ))
46    
47  (defpackage :swank-mop  (defpackage :swank-mop
# Line 84  Line 90 
90     #:slot-definition-type     #:slot-definition-type
91     #:slot-definition-readers     #:slot-definition-readers
92     #:slot-definition-writers     #:slot-definition-writers
93       #:slot-boundp-using-class
94       #:slot-value-using-class
95       #:slot-makunbound-using-class
96     ;; generic function protocol     ;; generic function protocol
97     #:compute-applicable-methods-using-classes     #:compute-applicable-methods-using-classes
98     #:finalize-inheritance))     #:finalize-inheritance))
# Line 102  DEFINTERFACE adds to this list and DEFIM Line 111  DEFINTERFACE adds to this list and DEFIM
111    
112  (defmacro definterface (name args documentation &rest default-body)  (defmacro definterface (name args documentation &rest default-body)
113    "Define an interface function for the backend to implement.    "Define an interface function for the backend to implement.
114  A generic function is defined with NAME, ARGS, and DOCUMENTATION.  A function is defined with NAME, ARGS, and DOCUMENTATION.  This
115    function first looks for a function to call in NAME's property list
116  If a DEFAULT-BODY is supplied then NO-APPLICABLE-METHOD is specialized  that is indicated by 'IMPLEMENTATION; failing that, it looks for a
117  to execute the body if the backend doesn't provide a specific  function indicated by 'DEFAULT. If neither is present, an error is
118  implementation.  signaled.
119    
120    If a DEFAULT-BODY is supplied, then a function with the same body and
121    ARGS will be added to NAME's property list as the property indicated
122    by 'DEFAULT.
123    
124  Backends implement these functions using DEFIMPLEMENTATION."  Backends implement these functions using DEFIMPLEMENTATION."
125    (check-type documentation string "a documentation string")    (check-type documentation string "a documentation string")
126    (flet ((gen-default-impl ()    (assert (every #'symbolp args) ()
127             `(defmethod ,name ,args ,@default-body)))            "Complex lambda-list not supported: ~S ~S" name args)
128      `(progn (defgeneric ,name ,args (:documentation ,documentation))    (labels ((gen-default-impl ()
129              (pushnew ',name *interface-functions*)               `(setf (get ',name 'default) (lambda ,args ,@default-body)))
130              ,(if (null default-body)             (args-as-list (args)
131                   `(pushnew ',name *unimplemented-interfaces*)               (destructuring-bind (req opt key rest) (parse-lambda-list args)
132                   (gen-default-impl))                 `(,@req ,@opt
133              ;; 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))
134              (eval-when (:compile-toplevel :load-toplevel :execute)                         ,@(or rest '(())))))
135                (export ',name :swank-backend))             (parse-lambda-list (args)
136              ',name)))               (parse args '(&optional &key &rest)
137                        (make-array 4 :initial-element nil)))
138               (parse (args keywords vars)
139                 (cond ((null args)
140                        (reverse (map 'list #'reverse vars)))
141                       ((member (car args) keywords)
142                        (parse (cdr args) (cdr (member (car args) keywords)) vars))
143                       (t (push (car args) (aref vars (length keywords)))
144                          (parse (cdr args) keywords vars))))
145               (kw (s) (intern (string s) :keyword)))
146        `(progn
147           (defun ,name ,args
148             ,documentation
149             (let ((f (or (get ',name 'implementation)
150                          (get ',name 'default))))
151               (cond (f (apply f ,@(args-as-list args)))
152                     (t (error "~S not implementated" ',name)))))
153           (pushnew ',name *interface-functions*)
154           ,(if (null default-body)
155                `(pushnew ',name *unimplemented-interfaces*)
156                (gen-default-impl))
157           ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>
158           (eval-when (:compile-toplevel :load-toplevel :execute)
159             (export ',name :swank-backend))
160           ',name)))
161    
162  (defmacro defimplementation (name args &body body)  (defmacro defimplementation (name args &body body)
163    `(progn (defmethod ,name ,args ,@body)    (assert (every #'symbolp args) ()
164            (if (member ',name *interface-functions*)            "Complex lambda-list not supported: ~S ~S" name args)
165                (setq *unimplemented-interfaces*    `(progn
166                      (remove ',name *unimplemented-interfaces*))       (setf (get ',name 'implementation) (lambda ,args ,@body))
167                (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))       (if (member ',name *interface-functions*)
168            ',name))           (setq *unimplemented-interfaces*
169                   (remove ',name *unimplemented-interfaces*))
170             (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))
171         ',name))
172    
173  (defun warn-unimplemented-interfaces ()  (defun warn-unimplemented-interfaces ()
174    "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 198  EXCEPT is a list of symbol names which s
198  (defvar *gray-stream-symbols*  (defvar *gray-stream-symbols*
199    '(:fundamental-character-output-stream    '(:fundamental-character-output-stream
200      :stream-write-char      :stream-write-char
201        :stream-write-string
202      :stream-fresh-line      :stream-fresh-line
203      :stream-force-output      :stream-force-output
204      :stream-finish-output      :stream-finish-output
205      :fundamental-character-input-stream      :fundamental-character-input-stream
206      :stream-read-char      :stream-read-char
207        :stream-peek-char
208        :stream-read-line
209        ;; STREAM-FILE-POSITION is not available on all implementations, or
210        ;; partially under a different name.
211        ; :stream-file-posiion
212      :stream-listen      :stream-listen
213      :stream-unread-char      :stream-unread-char
214      :stream-clear-input      :stream-clear-input
# Line 212  EXCEPT is a list of symbol names which s Line 258  EXCEPT is a list of symbol names which s
258    "Close the socket SOCKET.")    "Close the socket SOCKET.")
259    
260  (definterface accept-connection (socket &key external-format  (definterface accept-connection (socket &key external-format
261                                          buffering)                                          buffering timeout)
262     "Accept a client connection on the listening socket SOCKET.     "Accept a client connection on the listening socket SOCKET.
263  Return a stream for the new connection.")  Return a stream for the new connection.")
264    
# Line 232  Return a stream for the new connection." Line 278  Return a stream for the new connection."
278    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
279    nil)    nil)
280    
281    (definterface set-stream-timeout (stream timeout)
282      "Set the 'stream 'timeout.  The timeout is either the real number
283      specifying the timeout in seconds or 'nil for no timeout."
284      (declare (ignore stream timeout))
285      nil)
286    
287  ;;; Base condition for networking errors.  ;;; Base condition for networking errors.
288  (define-condition network-error (simple-error) ())  (define-condition network-error (simple-error) ())
289    
# Line 256  that the calling thread is the one that Line 308  that the calling thread is the one that
308  (definterface getpid ()  (definterface getpid ()
309    "Return the (Unix) process ID of this superior Lisp.")    "Return the (Unix) process ID of this superior Lisp.")
310    
311    (definterface install-sigint-handler (function)
312      "Call FUNCTION on SIGINT (instead of invoking the debugger).
313    Return old signal handler."
314      (declare (ignore function))
315      nil)
316    
317    (definterface call-with-user-break-handler (handler function)
318      "Install the break handler HANDLER while executing FUNCTION."
319      (let ((old-handler (install-sigint-handler handler)))
320        (unwind-protect (funcall function)
321          (install-sigint-handler old-handler))))
322    
323    (definterface quit-lisp ()
324      "Exit the current lisp image.")
325    
326  (definterface lisp-implementation-type-name ()  (definterface lisp-implementation-type-name ()
327    "Return a short name for the Lisp implementation."    "Return a short name for the Lisp implementation."
328    (lisp-implementation-type))    (lisp-implementation-type))
329    
330    
331    ;; pathnames are sooo useless
332    
333    (definterface filename-to-pathname (filename)
334      "Return a pathname for FILENAME.
335    A filename in Emacs may for example contain asterisks which should not
336    be translated to wildcards."
337      (parse-namestring filename))
338    
339    (definterface pathname-to-filename (pathname)
340      "Return the filename for PATHNAME."
341      (namestring pathname))
342    
343  (definterface default-directory ()  (definterface default-directory ()
344    "Return the default directory."    "Return the default directory."
345    (directory-namestring (truename *default-pathname-defaults*)))    (directory-namestring (truename *default-pathname-defaults*)))
# Line 270  This is used to resolve filenames withou Line 350  This is used to resolve filenames withou
350    (setf *default-pathname-defaults* (truename (merge-pathnames directory)))    (setf *default-pathname-defaults* (truename (merge-pathnames directory)))
351    (default-directory))    (default-directory))
352    
353    
354  (definterface call-with-syntax-hooks (fn)  (definterface call-with-syntax-hooks (fn)
355    "Call FN with hooks to handle special syntax."    "Call FN with hooks to handle special syntax."
356    (funcall fn))    (funcall fn))
# Line 278  This is used to resolve filenames withou Line 359  This is used to resolve filenames withou
359    "Return a suitable initial value for SWANK:*READTABLE-ALIST*."    "Return a suitable initial value for SWANK:*READTABLE-ALIST*."
360    '())    '())
361    
 (definterface quit-lisp ()  
   "Exit the current lisp image.")  
   
362    
363  ;;;; Compilation  ;;;; Compilation
364    
# Line 292  This is used to resolve filenames withou Line 370  This is used to resolve filenames withou
370    (declare (ignore ignore))    (declare (ignore ignore))
371    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
372    
373  (definterface swank-compile-string (string &key buffer position directory)  (definterface swank-compile-string (string &key buffer position filename
374    "Compile source from STRING.  During compilation, compiler                                             policy)
375  conditions must be trapped and resignalled as COMPILER-CONDITIONs.    "Compile source from STRING.
376    During compilation, compiler conditions must be trapped and
377    resignalled as COMPILER-CONDITIONs.
378    
379  If supplied, BUFFER and POSITION specify the source location in Emacs.  If supplied, BUFFER and POSITION specify the source location in Emacs.
380    
381  Additionally, if POSITION is supplied, it must be added to source  Additionally, if POSITION is supplied, it must be added to source
382  positions reported in compiler conditions.  positions reported in compiler conditions.
383    
384  If DIRECTORY is specified it may be used by certain implementations to  If FILENAME is specified it may be used by certain implementations to
385  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of
386  source information.")  source information.
387    
388  (definterface operate-on-system (system-name operation-name &rest keyword-args)  If POLICY is supplied, and non-NIL, it may be used by certain
389    "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.  implementations to compile with a debug optimization quality of its
390  The KEYWORD-ARGS are passed on to the operation.  value.
391  Example:  
392  \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"  Should return T on successfull compilation, NIL otherwise.
393    (unless (member :asdf *features*)  ")
394      (error "ASDF is not loaded."))  
395    (with-compilation-hooks ()  (definterface swank-compile-file (input-file output-file load-p
396      (let ((operate (find-symbol "OPERATE" :asdf))                                               external-format)
397            (operation (find-symbol operation-name :asdf)))     "Compile INPUT-FILE signalling COMPILE-CONDITIONs.
398        (when (null operation)  If LOAD-P is true, load the file after compilation.
399          (error "Couldn't find ASDF operation ~S" operation-name))  EXTERNAL-FORMAT is a value returned by find-external-format or
400        (apply operate operation system-name keyword-args))))  :default.
401    
402  (definterface swank-compile-file (filename load-p &optional external-format)  Should return OUTPUT-TRUENAME, WARNINGS-P and FAILURE-p
403     "Compile FILENAME signalling COMPILE-CONDITIONs.  like `compile-file'")
 If LOAD-P is true, load the file after compilation.")  
404    
405  (deftype severity ()  (deftype severity ()
406    '(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 432  If LOAD-P is true, load the file after c
432     (location :initarg :location     (location :initarg :location
433               :accessor location)))               :accessor location)))
434    
435    (definterface find-external-format (coding-system)
436      "Return a \"external file format designator\" for CODING-SYSTEM.
437    CODING-SYSTEM is Emacs-style coding system name (a string),
438    e.g. \"latin-1-unix\"."
439      (if (equal coding-system "iso-latin-1-unix")
440          :default
441          nil))
442    
443    (definterface guess-external-format (pathname)
444      "Detect the external format for the file with name pathname.
445    Return nil if the file contains no special markers."
446      ;; Look for a Emacs-style -*- coding: ... -*- or Local Variable: section.
447      (with-open-file (s pathname :if-does-not-exist nil
448                         :external-format (or (find-external-format "latin-1-unix")
449                                              :default))
450        (if s
451            (or (let* ((line (read-line s nil))
452                       (p (search "-*-" line)))
453                  (when p
454                    (let* ((start (+ p (length "-*-")))
455                           (end (search "-*-" line :start2 start)))
456                      (when end
457                        (%search-coding line start end)))))
458                (let* ((len (file-length s))
459                       (buf (make-string (min len 3000))))
460                  (file-position s (- len (length buf)))
461                  (read-sequence buf s)
462                  (let ((start (search "Local Variables:" buf :from-end t))
463                        (end (search "End:" buf :from-end t)))
464                    (and start end (< start end)
465                         (%search-coding buf start end))))))))
466    
467    (defun %search-coding (str start end)
468      (let ((p (search "coding:" str :start2 start :end2 end)))
469        (when p
470          (incf p (length "coding:"))
471          (loop while (and (< p end)
472                           (member (aref str p) '(#\space #\tab)))
473                do (incf p))
474          (let ((end (position-if (lambda (c) (find c '(#\space #\tab #\newline)))
475                                  str :start p)))
476            (find-external-format (subseq str p end))))))
477    
478    
479  ;;;; Streams  ;;;; Streams
480    
481  (definterface make-fn-streams (input-fn output-fn)  (definterface make-output-stream (write-string)
482     "Return character input and output streams backended by functions.    "Return a new character output stream.
483  When input is needed, INPUT-FN is called with no arguments to  The stream calls WRITE-STRING when output is ready.")
484  return a string.  
485  When output is ready, OUTPUT-FN is called with the output as its  (definterface make-input-stream (read-string)
486  argument.    "Return a new character input stream.
487    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)  
488    
489    
490  ;;;; Documentation  ;;;; Documentation
# Line 383  like." Line 493  like."
493     "Return the lambda list for the symbol NAME. NAME can also be     "Return the lambda list for the symbol NAME. NAME can also be
494  a lisp function object, on lisps which support this.  a lisp function object, on lisps which support this.
495    
496  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
497  cannot be determined."  arglist cannot be determined."
498     (declare (ignore name))     (declare (ignore name))
499     :not-available)     :not-available)
500    
501    (defgeneric declaration-arglist (decl-identifier)
502      (:documentation
503       "Return the argument list of the declaration specifier belonging to the
504    declaration identifier DECL-IDENTIFIER. If the arglist cannot be determined,
505    the keyword :NOT-AVAILABLE is returned.
506    
507    The different SWANK backends can specialize this generic function to
508    include implementation-dependend declaration specifiers, or to provide
509    additional information on the specifiers defined in ANSI Common Lisp.")
510      (:method (decl-identifier)
511        (case decl-identifier
512          (dynamic-extent '(&rest vars))
513          (ignore         '(&rest vars))
514          (ignorable      '(&rest vars))
515          (special        '(&rest vars))
516          (inline         '(&rest function-names))
517          (notinline      '(&rest function-name))
518          (optimize       '(&any compilation-speed debug safety space speed))
519          (type           '(type-specifier &rest args))
520          (ftype          '(type-specifier &rest function-names))
521          (otherwise
522           (flet ((typespec-p (symbol) (member :type (describe-symbol-for-emacs symbol))))
523             (cond ((and (symbolp decl-identifier) (typespec-p decl-identifier))
524                    '(&rest vars))
525                   ((and (listp decl-identifier) (typespec-p (first decl-identifier)))
526                    '(&rest vars))
527                   (t :not-available)))))))
528    
529    (defgeneric type-specifier-arglist (typespec-operator)
530      (:documentation
531       "Return the argument list of the type specifier belonging to
532    TYPESPEC-OPERATOR.. If the arglist cannot be determined, the keyword
533    :NOT-AVAILABLE is returned.
534    
535    The different SWANK backends can specialize this generic function to
536    include implementation-dependend declaration specifiers, or to provide
537    additional information on the specifiers defined in ANSI Common Lisp.")
538      (:method (typespec-operator)
539        (declare (special *type-specifier-arglists*)) ; defined at end of file.
540        (typecase typespec-operator
541          (symbol (or (cdr (assoc typespec-operator *type-specifier-arglists*))
542                      :not-available))
543          (t :not-available))))
544    
545  (definterface function-name (function)  (definterface function-name (function)
546    "Return the name of the function object FUNCTION.    "Return the name of the function object FUNCTION.
547    
# Line 492  debug the debugger! Instead, such condit Line 646  debug the debugger! Instead, such condit
646  user without (re)entering the debugger by wrapping them as  user without (re)entering the debugger by wrapping them as
647  `sldb-condition's."))  `sldb-condition's."))
648    
649    ;;; The following functions in this section are supposed to be called
650    ;;; within the dynamic contour of CALL-WITH-DEBUGGING-ENVIRONMENT only.
651    
652  (definterface compute-backtrace (start end)  (definterface compute-backtrace (start end)
653     "Return a list containing a backtrace of the condition current     "Returns a backtrace of the condition currently being debugged,
654  being debugged.  The results are unspecified if this function is  that is an ordered list consisting of frames. ``Ordered list''
655  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
656    backtrace.
657    
658  START and END are zero-based indices constraining the number of frames  START and END are zero-based indices constraining the number of frames
659  returned.  Frame zero is defined as the frame which invoked the  returned. Frame zero is defined as the frame which invoked the
660  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
661  the stack.")  the stack.")
662    
663  (definterface print-frame (frame stream)  (definterface print-frame (frame stream)
664    "Print frame to stream.")    "Print frame to stream.")
665    
666    (definterface frame-restartable-p (frame)
667      "Is the frame FRAME restartable?.
668    Return T if `restart-frame' can safely be called on the frame."
669      (declare (ignore frame))
670      nil)
671    
672  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
673    "Return the source location for FRAME-NUMBER.")    "Return the source location for the frame associated to FRAME-NUMBER.")
674    
675  (definterface frame-catch-tags (frame-number)  (definterface frame-catch-tags (frame-number)
676    "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
677  stack frame.  The results are undefined unless this is called  frame."
678  within the dynamic contour of a function defined by    (declare (ignore frame-number))
679  DEFINE-DEBUGGER-HOOK.")    '())
680    
681  (definterface frame-locals (frame-number)  (definterface frame-locals (frame-number)
682    "Return a list of XXX local variable designators define me    "Return a list of ((&key NAME ID VALUE) ...) where each element of
683  for a debugger stack frame.  The results are undefined unless  the list represents a local variable in the stack frame associated to
684  this is called within the dynamic contour of a function defined  FRAME-NUMBER.
685  by DEFINE-DEBUGGER-HOOK.")  
686    NAME, a symbol; the name of the local variable.
687  (definterface frame-var-value (frame var)  
688    "Return the value of VAR in FRAME.  ID, an integer; used as primary key for the local variable, unique
689  FRAME is the number of the frame in the backtrace.  relatively to the frame under operation.
690  VAR is the number of the variable in the frame.")  
691    value, an object; the value of the local variable.")
692    
693    (definterface frame-var-value (frame-number var-id)
694      "Return the value of the local variable associated to VAR-ID
695    relatively to the frame associated to FRAME-NUMBER.")
696    
697  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
698    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
# Line 532  FRAME-NUMBER is a non-negative integer." Line 701  FRAME-NUMBER is a non-negative integer."
701    
702  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
703     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
704  in the debugger.  The results are undefined unless called in the  in the debugger.
 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.  
705    
706  FRAME-NUMBER must be a positive integer with 0 indicating the  FRAME-NUMBER must be a positive integer with 0 indicating the
707  frame which invoked the debugger.  frame which invoked the debugger.
# Line 559  as it was called originally.") Line 727  as it was called originally.")
727    "Format a condition for display in SLDB."    "Format a condition for display in SLDB."
728    (princ-to-string condition))    (princ-to-string condition))
729    
 (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))  
   '())  
   
730  (definterface condition-extras (condition)  (definterface condition-extras (condition)
731    "Return a list of extra for the debugger.    "Return a list of extra for the debugger.
732  The allowed elements are of the form:  The allowed elements are of the form:
733    (:SHOW-FRAME-SOURCE frame-number)"    (:SHOW-FRAME-SOURCE frame-number)
734      (:REFERENCES &rest refs)
735    "
736    (declare (ignore condition))    (declare (ignore condition))
737    '())    '())
738    
# Line 585  The allowed elements are of the form: Line 745  The allowed elements are of the form:
745  (definterface sldb-break-at-start (symbol)  (definterface sldb-break-at-start (symbol)
746    "Set a breakpoint on the beginning of the function for SYMBOL.")    "Set a breakpoint on the beginning of the function for SYMBOL.")
747    
748    (definterface sldb-stepper-condition-p (condition)
749      "Return true if SLDB was invoked due to a single-stepping condition,
750    false otherwise. "
751      (declare (ignore condition))
752      nil)
753    
754    (definterface sldb-step-into ()
755      "Step into the current single-stepper form.")
756    
757    (definterface sldb-step-next ()
758      "Step to the next form in the current function.")
759    
760    (definterface sldb-step-out ()
761      "Stop single-stepping temporarily, but resume it once the current function
762    returns.")
763    
764    
765  ;;;; Definition finding  ;;;; Definition finding
# Line 615  definition, e.g., FOO or (METHOD FOO (ST Line 790  definition, e.g., FOO or (METHOD FOO (ST
790    
791  LOCATION is the source location for the definition.")  LOCATION is the source location for the definition.")
792    
793    (definterface find-source-location (object)
794      "Returns the source location of OBJECT, or NIL.
795    
796    That is the source location of the underlying datastructure of
797    OBJECT. E.g. on a STANDARD-OBJECT, the source location of the
798    respective DEFCLASS definition is returned, on a STRUCTURE-CLASS the
799    respective DEFSTRUCT definition, and so on."
800      ;; This returns one source location and not a list of locations. It's
801      ;; supposed to return the location of the DEFGENERIC definition on
802      ;; #'SOME-GENERIC-FUNCTION.
803      )
804    
805    
806  (definterface buffer-first-change (filename)  (definterface buffer-first-change (filename)
807    "Called for effect the first time FILENAME's buffer is modified."    "Called for effect the first time FILENAME's buffer is modified."
808    (declare (ignore filename))    (declare (ignore filename))
809    nil)    nil)
810    
811    
812    
813  ;;;; XREF  ;;;; XREF
814    
# Line 706  themselves, that is, their dispatch func Line 895  themselves, that is, their dispatch func
895    
896  ;;;; Inspector  ;;;; Inspector
897    
898  (defclass inspector ()  (defgeneric emacs-inspect (object)
899    ()    (: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)  
900     "Explain to Emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
901    
902  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.  
903    
904  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
905  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 910  inserted into the buffer as is, or a lis
910    
911   (:newline) - Render a \\n   (:newline) - Render a \\n
912    
913   (:action label lambda) - Render LABEL (a text string) which when   (:action label lambda &key (refresh t)) - Render LABEL (a text
914   clicked will call LAMBDA.   string) which when clicked will call LAMBDA. If REFRESH is
915     non-NIL the currently inspected object will be re-inspected
916     after calling the lambda.
917    "))
918    
919   NIL - do nothing.")  (defmethod emacs-inspect ((object t))
   
 (defmethod inspect-for-emacs ((object t) (inspector t))  
920    "Generic method for inspecting any kind of object.    "Generic method for inspecting any kind of object.
921    
922  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
923  output of CL:DESCRIBE."  output of CL:DESCRIBE."
   (declare (ignore inspector))  
   (values  
    "A value."  
924     `("Type: " (:value ,(type-of object)) (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
925       "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:"
926       (:newline) (:newline)       (:newline) (:newline)
927       ,(with-output-to-string (desc) (describe object desc)))))       ,(with-output-to-string (desc) (describe object desc))))
928    
929  ;;; Utilities for inspector methods.  ;;; Utilities for inspector methods.
930  ;;;  ;;;
931  (defun label-value-line (label value)  (defun label-value-line (label value &key (newline t))
932    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector.
933    (list (princ-to-string label) ": " `(:value ,value) '(:newline)))  If NEWLINE is non-NIL a `(:newline)' is added to the result."
934      (list* (princ-to-string label) ": " `(:value ,value)
935             (if newline '((:newline)) nil)))
936    
937  (defmacro label-value-line* (&rest label-values)  (defmacro label-value-line* (&rest label-values)
938    ` (append ,@(loop for (label value) in label-values    ` (append ,@(loop for (label value) in label-values
# Line 778  output of CL:DESCRIBE." Line 949  output of CL:DESCRIBE."
949  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
950  ;;; implementations.  ;;; implementations.
951    
952  (definterface initialize-multiprocessing ()  (definterface initialize-multiprocessing (continuation)
953     "Initialize multiprocessing, if necessary."     "Initialize multiprocessing, if necessary and then invoke CONTINUATION.
    nil)  
954    
955  (definterface startup-idle-and-top-level-loops ()  Depending on the impleimentaion, this function may never return."
956    "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)  
957    
958  (definterface spawn (fn &key name)  (definterface spawn (fn &key name)
959    "Create a new thread to call FN.")    "Create a new thread to call FN.")
# Line 796  normal function." Line 962  normal function."
962    "Return an Emacs-parsable object to identify THREAD.    "Return an Emacs-parsable object to identify THREAD.
963    
964  Ids should be comparable with equal, i.e.:  Ids should be comparable with equal, i.e.:
965   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)"
966      thread)
967    
968  (definterface find-thread (id)  (definterface find-thread (id)
969    "Return the thread for ID.    "Return the thread for ID.
970  ID should be an id previously obtained with THREAD-ID.  ID should be an id previously obtained with THREAD-ID.
971  Can return nil if the thread no longer exists.")  Can return nil if the thread no longer exists."
972      (declare (ignore id))
973      (current-thread))
974    
975  (definterface thread-name (thread)  (definterface thread-name (thread)
976     "Return the name of THREAD.     "Return the name of THREAD.
# Line 816  user. They do not have to be unique." Line 985  user. They do not have to be unique."
985     (declare (ignore thread))     (declare (ignore thread))
986     "")     "")
987    
988    (definterface thread-description (thread)
989      "Return a string describing THREAD."
990      (declare (ignore thread))
991      "")
992    
993    (definterface set-thread-description (thread description)
994      "Set THREAD's description to DESCRIPTION."
995      (declare (ignore thread description))
996      "")
997    
998  (definterface make-lock (&key name)  (definterface make-lock (&key name)
999     "Make a lock for thread synchronization.     "Make a lock for thread synchronization.
1000  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
1001    but that thread may hold it more than once."
1002     (declare (ignore name))     (declare (ignore name))
1003     :null-lock)     :null-lock)
1004    
# Line 833  Only one thread may hold the lock (via C Line 1013  Only one thread may hold the lock (via C
1013    0)    0)
1014    
1015  (definterface all-threads ()  (definterface all-threads ()
1016    "Return a list of all threads.")    "Return a fresh list of all threads.")
1017    
1018  (definterface thread-alive-p (thread)  (definterface thread-alive-p (thread)
1019    "Test if THREAD is termintated."    "Test if THREAD is termintated."
# Line 850  Only one thread may hold the lock (via C Line 1030  Only one thread may hold the lock (via C
1030  (definterface send (thread object)  (definterface send (thread object)
1031    "Send OBJECT to thread THREAD.")    "Send OBJECT to thread THREAD.")
1032    
1033  (definterface receive ()  (definterface receive (&optional timeout)
1034    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox."
1035      (receive-if (constantly t) timeout))
1036    
1037    (definterface receive-if (predicate &optional timeout)
1038      "Return the first message satisfiying PREDICATE.")
1039    
1040    (definterface set-default-initial-binding (var form)
1041      "Initialize special variable VAR by default with FORM.
1042    
1043    Some implementations initialize certain variables in each newly
1044    created thread.  This function sets the form which is used to produce
1045    the initial value."
1046      (set var (eval form)))
1047    
1048    ;; List of delayed interrupts.
1049    ;; This should only have thread-local bindings, so no init form.
1050    (defvar *pending-slime-interrupts*)
1051    
1052    (defun check-slime-interrupts ()
1053      "Execute pending interrupts if any.
1054    This should be called periodically in operations which
1055    can take a long time to complete.
1056    Return a boolean indicating whether any interrupts was processed."
1057      (when (and (boundp '*pending-slime-interrupts*)
1058                 *pending-slime-interrupts*)
1059        (funcall (pop *pending-slime-interrupts*))
1060        t))
1061    
1062    (define-condition slime-interrupt-queued () ()
1063      (:documentation
1064       "Non-serious condition signalled when an interrupt
1065    occurs while interrupt handling is disabled.
1066    Backends can use this to abort blocking operations."))
1067    
1068    (definterface wait-for-input (streams &optional timeout)
1069      "Wait for input on a list of streams.  Return those that are ready.
1070    STREAMS is a list of streams
1071    TIMEOUT nil, t, or real number. If TIMEOUT is t, return
1072    those streams which are ready immediately, without waiting.
1073    If TIMEOUT is a number and no streams is ready after TIMEOUT seconds,
1074    return nil.
1075    
1076    Return :interrupt if an interrupt occurs while waiting."
1077      (assert (member timeout '(nil t)))
1078      (cond #+(or)
1079            ((null (cdr streams))
1080             (wait-for-one-stream (car streams) timeout))
1081            (t
1082             (wait-for-streams streams timeout))))
1083    
1084    (defun wait-for-streams (streams timeout)
1085      (loop
1086       (when (check-slime-interrupts) (return :interrupt))
1087       (let ((ready (remove-if-not #'stream-readable-p streams)))
1088         (when ready (return ready)))
1089       (when timeout (return nil))
1090       (sleep 0.1)))
1091    
1092    ;; Note: Usually we can't interrupt PEEK-CHAR cleanly.
1093    (defun wait-for-one-stream (stream timeout)
1094      (ecase timeout
1095        ((nil)
1096         (cond ((check-slime-interrupts) :interrupt)
1097               (t (peek-char nil stream nil nil)
1098                  (list stream))))
1099        ((t)
1100         (let ((c (read-char-no-hang stream nil nil)))
1101           (cond (c
1102                  (unread-char c stream)
1103                  (list stream))
1104                 (t '()))))))
1105    
1106    (defun stream-readable-p (stream)
1107      (let ((c (read-char-no-hang stream nil :eof)))
1108        (cond ((not c) nil)
1109              ((eq c :eof) t)
1110              (t (unread-char c stream) t))))
1111    
1112  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1113    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
# Line 873  SPEC can be: Line 1129  SPEC can be:
1129  (definterface make-weak-value-hash-table (&rest args)  (definterface make-weak-value-hash-table (&rest args)
1130    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
1131    (apply #'make-hash-table args))    (apply #'make-hash-table args))
1132    
1133    (definterface hash-table-weakness (hashtable)
1134      "Return nil or one of :key :value :key-or-value :key-and-value"
1135      (declare (ignore hashtable))
1136      nil)
1137    
1138    
1139    ;;;; Character names
1140    
1141    (definterface character-completion-set (prefix matchp)
1142      "Return a list of names of characters that match PREFIX."
1143      ;; Handle the standard and semi-standard characters.
1144      (loop for name in '("Newline" "Space" "Tab" "Page" "Rubout"
1145                          "Linefeed" "Return" "Backspace")
1146         when (funcall matchp prefix name)
1147         collect name))
1148    
1149    
1150    (defparameter *type-specifier-arglists*
1151      '((and                . (&rest type-specifiers))
1152        (array              . (&optional element-type dimension-spec))
1153        (base-string        . (&optional size))
1154        (bit-vector         . (&optional size))
1155        (complex            . (&optional type-specifier))
1156        (cons               . (&optional car-typespec cdr-typespec))
1157        (double-float       . (&optional lower-limit upper-limit))
1158        (eql                . (object))
1159        (float              . (&optional lower-limit upper-limit))
1160        (function           . (&optional arg-typespec value-typespec))
1161        (integer            . (&optional lower-limit upper-limit))
1162        (long-float         . (&optional lower-limit upper-limit))
1163        (member             . (&rest eql-objects))
1164        (mod                . (n))
1165        (not                . (type-specifier))
1166        (or                 . (&rest type-specifiers))
1167        (rational           . (&optional lower-limit upper-limit))
1168        (real               . (&optional lower-limit upper-limit))
1169        (satisfies          . (predicate-symbol))
1170        (short-float        . (&optional lower-limit upper-limit))
1171        (signed-byte        . (&optional size))
1172        (simple-array       . (&optional element-type dimension-spec))
1173        (simple-base-string . (&optional size))
1174        (simple-bit-vector  . (&optional size))
1175        (simple-string      . (&optional size))
1176        (single-float       . (&optional lower-limit upper-limit))
1177        (simple-vector      . (&optional size))
1178        (string             . (&optional size))
1179        (unsigned-byte      . (&optional size))
1180        (values             . (&rest typespecs))
1181        (vector             . (&optional element-type size))
1182        ))
1183    
1184    ;;; Heap dumps
1185    
1186    (definterface save-image (filename &optional restart-function)
1187      "Save a heap image to the file FILENAME.
1188    RESTART-FUNCTION, if non-nil, should be called when the image is loaded.")
1189    
1190    
1191    

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

  ViewVC Help
Powered by ViewVC 1.1.5