/[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.149 by heller, Sun Aug 31 11:58:01 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
209      :stream-listen      :stream-listen
210      :stream-unread-char      :stream-unread-char
211      :stream-clear-input      :stream-clear-input
# Line 212  EXCEPT is a list of symbol names which s Line 255  EXCEPT is a list of symbol names which s
255    "Close the socket SOCKET.")    "Close the socket SOCKET.")
256    
257  (definterface accept-connection (socket &key external-format  (definterface accept-connection (socket &key external-format
258                                          buffering)                                          buffering timeout)
259     "Accept a client connection on the listening socket SOCKET.     "Accept a client connection on the listening socket SOCKET.
260  Return a stream for the new connection.")  Return a stream for the new connection.")
261    
# Line 232  Return a stream for the new connection." Line 275  Return a stream for the new connection."
275    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
276    nil)    nil)
277    
278    (definterface set-stream-timeout (stream timeout)
279      "Set the 'stream 'timeout.  The timeout is either the real number
280      specifying the timeout in seconds or 'nil for no timeout."
281      (declare (ignore stream timeout))
282      nil)
283    
284  ;;; Base condition for networking errors.  ;;; Base condition for networking errors.
285  (define-condition network-error (simple-error) ())  (define-condition network-error (simple-error) ())
286    
# Line 256  that the calling thread is the one that Line 305  that the calling thread is the one that
305  (definterface getpid ()  (definterface getpid ()
306    "Return the (Unix) process ID of this superior Lisp.")    "Return the (Unix) process ID of this superior Lisp.")
307    
308    (definterface install-sigint-handler (function)
309      "Call FUNCTION on SIGINT (instead of invoking the debugger).
310    Return old signal handler."
311      nil)
312    
313    (definterface call-with-user-break-handler (handler function)
314      "Install the break handler HANDLER while executing FUNCTION."
315      (let ((old-handler (install-sigint-handler handler)))
316        (unwind-protect (funcall function)
317          (install-sigint-handler old-handler))))
318    
319  (definterface lisp-implementation-type-name ()  (definterface lisp-implementation-type-name ()
320    "Return a short name for the Lisp implementation."    "Return a short name for the Lisp implementation."
321    (lisp-implementation-type))    (lisp-implementation-type))
# Line 292  This is used to resolve filenames withou Line 352  This is used to resolve filenames withou
352    (declare (ignore ignore))    (declare (ignore ignore))
353    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
354    
355  (definterface swank-compile-string (string &key buffer position directory)  (definterface swank-compile-string (string &key buffer position directory debug)
356    "Compile source from STRING.  During compilation, compiler    "Compile source from STRING.  During compilation, compiler
357  conditions must be trapped and resignalled as COMPILER-CONDITIONs.  conditions must be trapped and resignalled as COMPILER-CONDITIONs.
358    
# Line 303  positions reported in compiler condition Line 363  positions reported in compiler condition
363    
364  If DIRECTORY is specified it may be used by certain implementations to  If DIRECTORY is specified it may be used by certain implementations to
365  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of
366  source information.")  source information.
367    
368  (definterface operate-on-system (system-name operation-name &rest keyword-args)  If DEBUG is supplied, and non-NIL, it may be used by certain
369    "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.  implementations to compile with a debug optimization quality of its
370  The KEYWORD-ARGS are passed on to the operation.  value.
371  Example:  
372  \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"  Should return T on successfull compilation, NIL otherwise.
373    (unless (member :asdf *features*)  ")
374      (error "ASDF is not loaded."))  
375    (with-compilation-hooks ()  (definterface swank-compile-file (pathname load-p external-format)
376      (let ((operate (find-symbol "OPERATE" :asdf))     "Compile PATHNAME signalling COMPILE-CONDITIONs.
377            (operation (find-symbol operation-name :asdf)))  If LOAD-P is true, load the file after compilation.
378        (when (null operation)  EXTERNAL-FORMAT is a value returned by find-external-format or
379          (error "Couldn't find ASDF operation ~S" operation-name))  :default.
380        (apply operate operation system-name keyword-args))))  
381    Should return T on successfull compilation, NIL otherwise.")
 (definterface swank-compile-file (filename load-p &optional external-format)  
    "Compile FILENAME signalling COMPILE-CONDITIONs.  
 If LOAD-P is true, load the file after compilation.")  
382    
383  (deftype severity ()  (deftype severity ()
384    '(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 410  If LOAD-P is true, load the file after c
410     (location :initarg :location     (location :initarg :location
411               :accessor location)))               :accessor location)))
412    
413    (definterface parse-emacs-filename (filename)
414      "Return a PATHNAME for FILENAME. A filename in Emacs may for example
415    contain asterisks which should not be translated to wildcards."
416      (parse-namestring filename))
417    
418    (definterface find-external-format (coding-system)
419      "Return a \"external file format designator\" for CODING-SYSTEM.
420    CODING-SYSTEM is Emacs-style coding system name (a string),
421    e.g. \"latin-1-unix\"."
422      (if (equal coding-system "iso-latin-1-unix")
423          :default
424          nil))
425    
426    (definterface guess-external-format (pathname)
427      "Detect the external format for the file with name pathname.
428    Return nil if the file contains no special markers."
429      ;; Look for a Emacs-style -*- coding: ... -*- or Local Variable: section.
430      (with-open-file (s pathname :if-does-not-exist nil
431                         :external-format (or (find-external-format "latin-1-unix")
432                                              :default))
433        (if s
434            (or (let* ((line (read-line s nil))
435                       (p (search "-*-" line)))
436                  (when p
437                    (let* ((start (+ p (length "-*-")))
438                           (end (search "-*-" line :start2 start)))
439                      (when end
440                        (%search-coding line start end)))))
441                (let* ((len (file-length s))
442                       (buf (make-string (min len 3000))))
443                  (file-position s (- len (length buf)))
444                  (read-sequence buf s)
445                  (let ((start (search "Local Variables:" buf :from-end t))
446                        (end (search "End:" buf :from-end t)))
447                    (and start end (< start end)
448                         (%search-coding buf start end))))))))
449    
450    (defun %search-coding (str start end)
451      (let ((p (search "coding:" str :start2 start :end2 end)))
452        (when p
453          (incf p (length "coding:"))
454          (loop while (and (< p end)
455                           (member (aref str p) '(#\space #\tab)))
456                do (incf p))
457          (let ((end (position-if (lambda (c) (find c '(#\space #\tab #\newline)))
458                                  str :start p)))
459            (find-external-format (subseq str p end))))))
460    
461    
462  ;;;; Streams  ;;;; Streams
463    
464  (definterface make-fn-streams (input-fn output-fn)  (definterface make-output-stream (write-string)
465     "Return character input and output streams backended by functions.    "Return a new character output stream.
466  When input is needed, INPUT-FN is called with no arguments to  The stream calls WRITE-STRING when output is ready.")
467  return a string.  
468  When output is ready, OUTPUT-FN is called with the output as its  (definterface make-input-stream (read-string)
469  argument.    "Return a new character input stream.
470    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)  
471    
472    
473  ;;;; Documentation  ;;;; Documentation
# Line 383  like." Line 476  like."
476     "Return the lambda list for the symbol NAME. NAME can also be     "Return the lambda list for the symbol NAME. NAME can also be
477  a lisp function object, on lisps which support this.  a lisp function object, on lisps which support this.
478    
479  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
480  cannot be determined."  arglist cannot be determined."
481     (declare (ignore name))     (declare (ignore name))
482     :not-available)     :not-available)
483    
484    (defgeneric declaration-arglist (decl-identifier)
485      (:documentation
486       "Return the argument list of the declaration specifier belonging to the
487    declaration identifier DECL-IDENTIFIER. If the arglist cannot be determined,
488    the keyword :NOT-AVAILABLE is returned.
489    
490    The different SWANK backends can specialize this generic function to
491    include implementation-dependend declaration specifiers, or to provide
492    additional information on the specifiers defined in ANSI Common Lisp.")
493      (:method (decl-identifier)
494        (case decl-identifier
495          (dynamic-extent '(&rest vars))
496          (ignore         '(&rest vars))
497          (ignorable      '(&rest vars))
498          (special        '(&rest vars))
499          (inline         '(&rest function-names))
500          (notinline      '(&rest function-name))
501          (optimize       '(&any compilation-speed debug safety space speed))
502          (type           '(type-specifier &rest args))
503          (ftype          '(type-specifier &rest function-names))
504          (otherwise
505           (flet ((typespec-p (symbol) (member :type (describe-symbol-for-emacs symbol))))
506             (cond ((and (symbolp decl-identifier) (typespec-p decl-identifier))
507                    '(&rest vars))
508                   ((and (listp decl-identifier) (typespec-p (first decl-identifier)))
509                    '(&rest vars))
510                   (t :not-available)))))))
511    
512    (defgeneric type-specifier-arglist (typespec-operator)
513      (:documentation
514       "Return the argument list of the type specifier belonging to
515    TYPESPEC-OPERATOR.. If the arglist cannot be determined, the keyword
516    :NOT-AVAILABLE is returned.
517    
518    The different SWANK backends can specialize this generic function to
519    include implementation-dependend declaration specifiers, or to provide
520    additional information on the specifiers defined in ANSI Common Lisp.")
521      (:method (typespec-operator)
522        (declare (special *type-specifier-arglists*)) ; defined at end of file.
523        (typecase typespec-operator
524          (symbol (or (cdr (assoc typespec-operator *type-specifier-arglists*))
525                      :not-available))
526          (t :not-available))))
527    
528  (definterface function-name (function)  (definterface function-name (function)
529    "Return the name of the function object FUNCTION.    "Return the name of the function object FUNCTION.
530    
# Line 492  debug the debugger! Instead, such condit Line 629  debug the debugger! Instead, such condit
629  user without (re)entering the debugger by wrapping them as  user without (re)entering the debugger by wrapping them as
630  `sldb-condition's."))  `sldb-condition's."))
631    
632    (definterface compute-sane-restarts (condition)
633      "This is an opportunity for Lisps such as CLISP to remove
634    unwanted restarts from the output of CL:COMPUTE-RESTARTS,
635    otherwise it should simply call CL:COMPUTE-RESTARTS, which is
636    what the default implementation does."
637      (compute-restarts condition))
638    
639    ;;; The following functions in this section are supposed to be called
640    ;;; within the dynamic contour of CALL-WITH-DEBUGGING-ENVIRONMENT only.
641    
642  (definterface compute-backtrace (start end)  (definterface compute-backtrace (start end)
643     "Return a list containing a backtrace of the condition current     "Returns a backtrace of the condition currently being debugged,
644  being debugged.  The results are unspecified if this function is  that is an ordered list consisting of frames. (What constitutes a
645  called outside the dynamic contour CALL-WITH-DEBUGGING-ENVIRONMENT.  frame is implementation dependent, but PRINT-FRAME must be defined on
646    it.)
647    
648    ``Ordered list'' means that the i-th. frame is associated to the
649    frame-number i.
650    
651  START and END are zero-based indices constraining the number of frames  START and END are zero-based indices constraining the number of frames
652  returned.  Frame zero is defined as the frame which invoked the  returned.  Frame zero is defined as the frame which invoked the
# Line 506  the stack.") Line 657  the stack.")
657    "Print frame to stream.")    "Print frame to stream.")
658    
659  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
660    "Return the source location for FRAME-NUMBER.")    "Return the source location for the frame associated to FRAME-NUMBER.")
661    
662  (definterface frame-catch-tags (frame-number)  (definterface frame-catch-tags (frame-number)
663    "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
664  stack frame.  The results are undefined unless this is called  frame.")
 within the dynamic contour of a function defined by  
 DEFINE-DEBUGGER-HOOK.")  
665    
666  (definterface frame-locals (frame-number)  (definterface frame-locals (frame-number)
667    "Return a list of XXX local variable designators define me    "Return a list of ((&key NAME ID VALUE) ...) where each element of
668  for a debugger stack frame.  The results are undefined unless  the list represents a local variable in the stack frame associated to
669  this is called within the dynamic contour of a function defined  FRAME-NUMBER.
670  by DEFINE-DEBUGGER-HOOK.")  
671    NAME, a symbol; the name of the local variable.
672  (definterface frame-var-value (frame var)  
673    "Return the value of VAR in FRAME.  ID, an integer; used as primary key for the local variable, unique
674  FRAME is the number of the frame in the backtrace.  relatively to the frame under operation.
675  VAR is the number of the variable in the frame.")  
676    value, an object; the value of the local variable.")
677    
678    (definterface frame-var-value (frame-number var-id)
679      "Return the value of the local variable associated to VAR-ID
680    relatively to the frame associated to FRAME-NUMBER.")
681    
682  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
683    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
# Line 532  FRAME-NUMBER is a non-negative integer." Line 686  FRAME-NUMBER is a non-negative integer."
686    
687  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
688     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
689  in the debugger.  The results are undefined unless called in the  in the debugger.
 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.  
690    
691  FRAME-NUMBER must be a positive integer with 0 indicating the  FRAME-NUMBER must be a positive integer with 0 indicating the
692  frame which invoked the debugger.  frame which invoked the debugger.
# Line 559  as it was called originally.") Line 712  as it was called originally.")
712    "Format a condition for display in SLDB."    "Format a condition for display in SLDB."
713    (princ-to-string condition))    (princ-to-string condition))
714    
 (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))  
   '())  
   
715  (definterface condition-extras (condition)  (definterface condition-extras (condition)
716    "Return a list of extra for the debugger.    "Return a list of extra for the debugger.
717  The allowed elements are of the form:  The allowed elements are of the form:
718    (:SHOW-FRAME-SOURCE frame-number)"    (:SHOW-FRAME-SOURCE frame-number)
719      (:REFERENCES &rest refs)
720    "
721    (declare (ignore condition))    (declare (ignore condition))
722    '())    '())
723    
# Line 585  The allowed elements are of the form: Line 730  The allowed elements are of the form:
730  (definterface sldb-break-at-start (symbol)  (definterface sldb-break-at-start (symbol)
731    "Set a breakpoint on the beginning of the function for SYMBOL.")    "Set a breakpoint on the beginning of the function for SYMBOL.")
732    
733    (definterface sldb-stepper-condition-p (condition)
734      "Return true if SLDB was invoked due to a single-stepping condition,
735    false otherwise. "
736      (declare (ignore condition))
737      nil)
738    
739    (definterface sldb-step-into ()
740      "Step into the current single-stepper form.")
741    
742    (definterface sldb-step-next ()
743      "Step to the next form in the current function.")
744    
745    (definterface sldb-step-out ()
746      "Stop single-stepping temporarily, but resume it once the current function
747    returns.")
748    
749    
750  ;;;; Definition finding  ;;;; Definition finding
# Line 615  definition, e.g., FOO or (METHOD FOO (ST Line 775  definition, e.g., FOO or (METHOD FOO (ST
775    
776  LOCATION is the source location for the definition.")  LOCATION is the source location for the definition.")
777    
778    (definterface find-source-location (object)
779      "Returns the source location of OBJECT, or NIL.
780    
781    That is the source location of the underlying datastructure of
782    OBJECT. E.g. on a STANDARD-OBJECT, the source location of the
783    respective DEFCLASS definition is returned, on a STRUCTURE-CLASS the
784    respective DEFSTRUCT definition, and so on."
785      ;; This returns one source location and not a list of locations. It's
786      ;; supposed to return the location of the DEFGENERIC definition on
787      ;; #'SOME-GENERIC-FUNCTION.
788      )
789    
790    
791  (definterface buffer-first-change (filename)  (definterface buffer-first-change (filename)
792    "Called for effect the first time FILENAME's buffer is modified."    "Called for effect the first time FILENAME's buffer is modified."
793    (declare (ignore filename))    (declare (ignore filename))
794    nil)    nil)
795    
796    
797    
798  ;;;; XREF  ;;;; XREF
799    
# Line 706  themselves, that is, their dispatch func Line 880  themselves, that is, their dispatch func
880    
881  ;;;; Inspector  ;;;; Inspector
882    
883  (defclass inspector ()  (defgeneric emacs-inspect (object)
884    ()    (: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)  
885     "Explain to Emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
886    
887  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.  
888    
889  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
890  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 895  inserted into the buffer as is, or a lis
895    
896   (:newline) - Render a \\n   (:newline) - Render a \\n
897    
898   (:action label lambda) - Render LABEL (a text string) which when   (:action label lambda &key (refresh t)) - Render LABEL (a text
899   clicked will call LAMBDA.   string) which when clicked will call LAMBDA. If REFRESH is
900     non-NIL the currently inspected object will be re-inspected
901   NIL - do nothing.")   after calling the lambda.
902    "))
903    
904  (defmethod inspect-for-emacs ((object t) (inspector t))  (defmethod emacs-inspect ((object t))
905    "Generic method for inspecting any kind of object.    "Generic method for inspecting any kind of object.
906    
907  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
908  output of CL:DESCRIBE."  output of CL:DESCRIBE."
   (declare (ignore inspector))  
   (values  
    "A value."  
909     `("Type: " (:value ,(type-of object)) (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
910       "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:"
911       (:newline) (:newline)       (:newline) (:newline)
912       ,(with-output-to-string (desc) (describe object desc)))))       ,(with-output-to-string (desc) (describe object desc))))
913    
914  ;;; Utilities for inspector methods.  ;;; Utilities for inspector methods.
915  ;;;  ;;;
916  (defun label-value-line (label value)  (defun label-value-line (label value &key (newline t))
917    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector.
918    (list (princ-to-string label) ": " `(:value ,value) '(:newline)))  If NEWLINE is non-NIL a `(:newline)' is added to the result."
919      (list* (princ-to-string label) ": " `(:value ,value)
920             (if newline '((:newline)) nil)))
921    
922  (defmacro label-value-line* (&rest label-values)  (defmacro label-value-line* (&rest label-values)
923    ` (append ,@(loop for (label value) in label-values    ` (append ,@(loop for (label value) in label-values
# Line 778  output of CL:DESCRIBE." Line 934  output of CL:DESCRIBE."
934  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
935  ;;; implementations.  ;;; implementations.
936    
937  (definterface initialize-multiprocessing ()  (definterface initialize-multiprocessing (continuation)
938     "Initialize multiprocessing, if necessary."     "Initialize multiprocessing, if necessary and then invoke CONTINUATION.
    nil)  
939    
940  (definterface startup-idle-and-top-level-loops ()  Depending on the impleimentaion, this function may never return."
941    "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)  
942    
943  (definterface spawn (fn &key name)  (definterface spawn (fn &key name)
944    "Create a new thread to call FN.")    "Create a new thread to call FN.")
# Line 796  normal function." Line 947  normal function."
947    "Return an Emacs-parsable object to identify THREAD.    "Return an Emacs-parsable object to identify THREAD.
948    
949  Ids should be comparable with equal, i.e.:  Ids should be comparable with equal, i.e.:
950   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)"
951      thread)
952    
953  (definterface find-thread (id)  (definterface find-thread (id)
954    "Return the thread for ID.    "Return the thread for ID.
955  ID should be an id previously obtained with THREAD-ID.  ID should be an id previously obtained with THREAD-ID.
956  Can return nil if the thread no longer exists.")  Can return nil if the thread no longer exists."
957      (current-thread))
958    
959  (definterface thread-name (thread)  (definterface thread-name (thread)
960     "Return the name of THREAD.     "Return the name of THREAD.
# Line 816  user. They do not have to be unique." Line 969  user. They do not have to be unique."
969     (declare (ignore thread))     (declare (ignore thread))
970     "")     "")
971    
972    (definterface thread-description (thread)
973      "Return a string describing THREAD."
974      (declare (ignore thread))
975      "")
976    
977    (definterface set-thread-description (thread description)
978      "Set THREAD's description to DESCRIPTION."
979      (declare (ignore thread description))
980      "")
981    
982  (definterface make-lock (&key name)  (definterface make-lock (&key name)
983     "Make a lock for thread synchronization.     "Make a lock for thread synchronization.
984  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
985    but that thread may hold it more than once."
986     (declare (ignore name))     (declare (ignore name))
987     :null-lock)     :null-lock)
988    
# Line 833  Only one thread may hold the lock (via C Line 997  Only one thread may hold the lock (via C
997    0)    0)
998    
999  (definterface all-threads ()  (definterface all-threads ()
1000    "Return a list of all threads.")    "Return a fresh list of all threads.")
1001    
1002  (definterface thread-alive-p (thread)  (definterface thread-alive-p (thread)
1003    "Test if THREAD is termintated."    "Test if THREAD is termintated."
# Line 850  Only one thread may hold the lock (via C Line 1014  Only one thread may hold the lock (via C
1014  (definterface send (thread object)  (definterface send (thread object)
1015    "Send OBJECT to thread THREAD.")    "Send OBJECT to thread THREAD.")
1016    
1017  (definterface receive ()  (definterface receive (&optional timeout)
1018    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox."
1019      (receive-if (constantly t) timeout))
1020    
1021    (definterface receive-if (predicate &optional timeout)
1022      "Return the first message satisfiying PREDICATE.")
1023    
1024    (defvar *pending-slime-interrupts*)
1025    
1026    (defun check-slime-interrupts ()
1027      "Execute pending interrupts if any.
1028    This should be called periodically in operations which
1029    can take a long time to complete."
1030      (when (and (boundp '*pending-slime-interrupts*)
1031                 *pending-slime-interrupts*)
1032        (funcall (pop *pending-slime-interrupts*))))
1033    
1034  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1035    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
# Line 873  SPEC can be: Line 1051  SPEC can be:
1051  (definterface make-weak-value-hash-table (&rest args)  (definterface make-weak-value-hash-table (&rest args)
1052    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
1053    (apply #'make-hash-table args))    (apply #'make-hash-table args))
1054    
1055    (definterface hash-table-weakness (hashtable)
1056      "Return nil or one of :key :value :key-or-value :key-and-value"
1057      (declare (ignore hashtable))
1058      nil)
1059    
1060    
1061    ;;;; Character names
1062    
1063    (definterface character-completion-set (prefix matchp)
1064      "Return a list of names of characters that match PREFIX."
1065      ;; Handle the standard and semi-standard characters.
1066      (loop for name in '("Newline" "Space" "Tab" "Page" "Rubout"
1067                          "Linefeed" "Return" "Backspace")
1068         when (funcall matchp prefix name)
1069         collect name))
1070    
1071    
1072    (defparameter *type-specifier-arglists*
1073      '((and                . (&rest type-specifiers))
1074        (array              . (&optional element-type dimension-spec))
1075        (base-string        . (&optional size))
1076        (bit-vector         . (&optional size))
1077        (complex            . (&optional type-specifier))
1078        (cons               . (&optional car-typespec cdr-typespec))
1079        (double-float       . (&optional lower-limit upper-limit))
1080        (eql                . (object))
1081        (float              . (&optional lower-limit upper-limit))
1082        (function           . (&optional arg-typespec value-typespec))
1083        (integer            . (&optional lower-limit upper-limit))
1084        (long-float         . (&optional lower-limit upper-limit))
1085        (member             . (&rest eql-objects))
1086        (mod                . (n))
1087        (not                . (type-specifier))
1088        (or                 . (&rest type-specifiers))
1089        (rational           . (&optional lower-limit upper-limit))
1090        (real               . (&optional lower-limit upper-limit))
1091        (satisfies          . (predicate-symbol))
1092        (short-float        . (&optional lower-limit upper-limit))
1093        (signed-byte        . (&optional size))
1094        (simple-array       . (&optional element-type dimension-spec))
1095        (simple-base-string . (&optional size))
1096        (simple-bit-vector  . (&optional size))
1097        (simple-string      . (&optional size))
1098        (single-float       . (&optional lower-limit upper-limit))
1099        (simple-vector      . (&optional size))
1100        (string             . (&optional size))
1101        (unsigned-byte      . (&optional size))
1102        (values             . (&rest typespecs))
1103        (vector             . (&optional element-type size))
1104        ))
1105    
1106    ;;; Heap dumps
1107    
1108    (definterface save-image (filename &optional restart-function)
1109      "Save a heap image to the file FILENAME.
1110    RESTART-FUNCTION, if non-nil, should be called when the image is loaded.")
1111    
1112    
1113    

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

  ViewVC Help
Powered by ViewVC 1.1.5