/[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.142 by heller, Fri Aug 8 19:42:51 2008 UTC
# Line 19  Line 19 
19             #:short-message             #:short-message
20             #:condition             #:condition
21             #:severity             #:severity
22               #:with-compilation-hooks
23             #:location             #:location
24             #:location-p             #:location-p
25             #:location-buffer             #:location-buffer
# Line 29  Line 30 
30             #:quit-lisp             #:quit-lisp
31             #:references             #:references
32             #:unbound-slot-filler             #:unbound-slot-filler
33               #:declaration-arglist
34               #:type-specifier-arglist
35               ;; interrupt macro for the backend
36               #:*pending-slime-interrupts*
37               #:check-slime-interrupts
38             ;; inspector related symbols             ;; inspector related symbols
39             #:inspector             #:emacs-inspect
            #:inspect-for-emacs  
            #:raw-inspection  
            #:fancy-inspection  
40             #:label-value-line             #:label-value-line
41             #:label-value-line*             #:label-value-line*
42    
43               #:with-struct
44             ))             ))
45    
46  (defpackage :swank-mop  (defpackage :swank-mop
# Line 84  Line 89 
89     #:slot-definition-type     #:slot-definition-type
90     #:slot-definition-readers     #:slot-definition-readers
91     #:slot-definition-writers     #:slot-definition-writers
92       #:slot-boundp-using-class
93       #:slot-value-using-class
94       #:slot-makunbound-using-class
95     ;; generic function protocol     ;; generic function protocol
96     #:compute-applicable-methods-using-classes     #:compute-applicable-methods-using-classes
97     #:finalize-inheritance))     #:finalize-inheritance))
# Line 102  DEFINTERFACE adds to this list and DEFIM Line 110  DEFINTERFACE adds to this list and DEFIM
110    
111  (defmacro definterface (name args documentation &rest default-body)  (defmacro definterface (name args documentation &rest default-body)
112    "Define an interface function for the backend to implement.    "Define an interface function for the backend to implement.
113  A generic function is defined with NAME, ARGS, and DOCUMENTATION.  A function is defined with NAME, ARGS, and DOCUMENTATION.  This
114    function first looks for a function to call in NAME's property list
115  If a DEFAULT-BODY is supplied then NO-APPLICABLE-METHOD is specialized  that is indicated by 'IMPLEMENTATION; failing that, it looks for a
116  to execute the body if the backend doesn't provide a specific  function indicated by 'DEFAULT. If neither is present, an error is
117  implementation.  signaled.
118    
119    If a DEFAULT-BODY is supplied, then a function with the same body and
120    ARGS will be added to NAME's property list as the property indicated
121    by 'DEFAULT.
122    
123  Backends implement these functions using DEFIMPLEMENTATION."  Backends implement these functions using DEFIMPLEMENTATION."
124    (check-type documentation string "a documentation string")    (check-type documentation string "a documentation string")
125    (flet ((gen-default-impl ()    (assert (every #'symbolp args) ()
126             `(defmethod ,name ,args ,@default-body)))            "Complex lambda-list not supported: ~S ~S" name args)
127      `(progn (defgeneric ,name ,args (:documentation ,documentation))    (labels ((gen-default-impl ()
128              (pushnew ',name *interface-functions*)               `(setf (get ',name 'default) (lambda ,args ,@default-body)))
129              ,(if (null default-body)             (args-as-list (args)
130                   `(pushnew ',name *unimplemented-interfaces*)               (destructuring-bind (req opt key rest) (parse-lambda-list args)
131                   (gen-default-impl))                 `(,@req ,@opt
132              ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>                         ,@(loop for k in key append `(,(kw k) ,k))
133              (eval-when (:compile-toplevel :load-toplevel :execute)                         ,@(or rest '(())))))
134                (export ',name :swank-backend))             (parse-lambda-list (args)
135              ',name)))               (parse args '(&optional &key &rest)
136                        (make-array 4 :initial-element nil)))
137               (parse (args keywords vars)
138                 (cond ((null args)
139                        (reverse (map 'list #'reverse vars)))
140                       ((member (car args) keywords)
141                        (parse (cdr args) (cdr (member (car args) keywords)) vars))
142                       (t (push (car args) (aref vars (length keywords)))
143                          (parse (cdr args) keywords vars))))
144               (kw (s) (intern (string s) :keyword)))
145        `(progn
146           (defun ,name ,args
147             ,documentation
148             (let ((f (or (get ',name 'implementation)
149                          (get ',name 'default))))
150               (cond (f (apply f ,@(args-as-list args)))
151                     (t (error "~S not implementated" ',name)))))
152           (pushnew ',name *interface-functions*)
153           ,(if (null default-body)
154                `(pushnew ',name *unimplemented-interfaces*)
155                (gen-default-impl))
156           ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>
157           (eval-when (:compile-toplevel :load-toplevel :execute)
158             (export ',name :swank-backend))
159           ',name)))
160    
161  (defmacro defimplementation (name args &body body)  (defmacro defimplementation (name args &body body)
162    `(progn (defmethod ,name ,args ,@body)    (assert (every #'symbolp args) ()
163            (if (member ',name *interface-functions*)            "Complex lambda-list not supported: ~S ~S" name args)
164                (setq *unimplemented-interfaces*    `(progn
165                      (remove ',name *unimplemented-interfaces*))       (setf (get ',name 'implementation) (lambda ,args ,@body))
166                (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))       (if (member ',name *interface-functions*)
167            ',name))           (setq *unimplemented-interfaces*
168                   (remove ',name *unimplemented-interfaces*))
169             (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))
170         ',name))
171    
172  (defun warn-unimplemented-interfaces ()  (defun warn-unimplemented-interfaces ()
173    "Warn the user about unimplemented backend features.    "Warn the user about unimplemented backend features.
# Line 158  EXCEPT is a list of symbol names which s Line 197  EXCEPT is a list of symbol names which s
197  (defvar *gray-stream-symbols*  (defvar *gray-stream-symbols*
198    '(:fundamental-character-output-stream    '(:fundamental-character-output-stream
199      :stream-write-char      :stream-write-char
200        :stream-write-string
201      :stream-fresh-line      :stream-fresh-line
202      :stream-force-output      :stream-force-output
203      :stream-finish-output      :stream-finish-output
# Line 212  EXCEPT is a list of symbol names which s Line 252  EXCEPT is a list of symbol names which s
252    "Close the socket SOCKET.")    "Close the socket SOCKET.")
253    
254  (definterface accept-connection (socket &key external-format  (definterface accept-connection (socket &key external-format
255                                          buffering)                                          buffering timeout)
256     "Accept a client connection on the listening socket SOCKET.     "Accept a client connection on the listening socket SOCKET.
257  Return a stream for the new connection.")  Return a stream for the new connection.")
258    
# Line 232  Return a stream for the new connection." Line 272  Return a stream for the new connection."
272    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."    "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
273    nil)    nil)
274    
275    (definterface set-stream-timeout (stream timeout)
276      "Set the 'stream 'timeout.  The timeout is either the real number
277      specifying the timeout in seconds or 'nil for no timeout."
278      (declare (ignore stream timeout))
279      nil)
280    
281  ;;; Base condition for networking errors.  ;;; Base condition for networking errors.
282  (define-condition network-error (simple-error) ())  (define-condition network-error (simple-error) ())
283    
# Line 292  This is used to resolve filenames withou Line 338  This is used to resolve filenames withou
338    (declare (ignore ignore))    (declare (ignore ignore))
339    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
340    
341  (definterface swank-compile-string (string &key buffer position directory)  (definterface swank-compile-string (string &key buffer position directory debug)
342    "Compile source from STRING.  During compilation, compiler    "Compile source from STRING.  During compilation, compiler
343  conditions must be trapped and resignalled as COMPILER-CONDITIONs.  conditions must be trapped and resignalled as COMPILER-CONDITIONs.
344    
# Line 303  positions reported in compiler condition Line 349  positions reported in compiler condition
349    
350  If DIRECTORY is specified it may be used by certain implementations to  If DIRECTORY is specified it may be used by certain implementations to
351  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of  rebind *DEFAULT-PATHNAME-DEFAULTS* which may improve the recording of
352  source information.")  source information.
353    
354  (definterface operate-on-system (system-name operation-name &rest keyword-args)  If DEBUG is supplied, and non-NIL, it may be used by certain
355    "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.  implementations to compile with a debug optimization quality of its
356  The KEYWORD-ARGS are passed on to the operation.  value.
 Example:  
 \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"  
   (unless (member :asdf *features*)  
     (error "ASDF is not loaded."))  
   (with-compilation-hooks ()  
     (let ((operate (find-symbol "OPERATE" :asdf))  
           (operation (find-symbol operation-name :asdf)))  
       (when (null operation)  
         (error "Couldn't find ASDF operation ~S" operation-name))  
       (apply operate operation system-name keyword-args))))  
357    
358  (definterface swank-compile-file (filename load-p &optional external-format)  Should return T on successfull compilation, NIL otherwise.
359    ")
360    
361    (definterface swank-compile-file (filename load-p external-format)
362     "Compile FILENAME signalling COMPILE-CONDITIONs.     "Compile FILENAME signalling COMPILE-CONDITIONs.
363  If LOAD-P is true, load the file after compilation.")  If LOAD-P is true, load the file after compilation.
364    EXTERNAL-FORMAT is a value returned by find-external-format or
365    :default.
366    
367    Should return T on successfull compilation, NIL otherwise.")
368    
369  (deftype severity ()  (deftype severity ()
370    '(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 396  If LOAD-P is true, load the file after c
396     (location :initarg :location     (location :initarg :location
397               :accessor location)))               :accessor location)))
398    
399    (definterface find-external-format (coding-system)
400      "Return a \"external file format designator\" for CODING-SYSTEM.
401    CODING-SYSTEM is Emacs-style coding system name (a string),
402    e.g. \"latin-1-unix\"."
403      (if (equal coding-system "iso-latin-1-unix")
404          :default
405          nil))
406    
407    (definterface guess-external-format (filename)
408      "Detect the external format for the file with name FILENAME.
409    Return nil if the file contains no special markers."
410      ;; Look for a Emacs-style -*- coding: ... -*- or Local Variable: section.
411      (with-open-file (s filename :if-does-not-exist nil
412                         :external-format (or (find-external-format "latin-1-unix")
413                                              :default))
414        (if s
415            (or (let* ((line (read-line s nil))
416                       (p (search "-*-" line)))
417                  (when p
418                    (let* ((start (+ p (length "-*-")))
419                           (end (search "-*-" line :start2 start)))
420                      (when end
421                        (%search-coding line start end)))))
422                (let* ((len (file-length s))
423                       (buf (make-string (min len 3000))))
424                  (file-position s (- len (length buf)))
425                  (read-sequence buf s)
426                  (let ((start (search "Local Variables:" buf :from-end t))
427                        (end (search "End:" buf :from-end t)))
428                    (and start end (< start end)
429                         (%search-coding buf start end))))))))
430    
431    (defun %search-coding (str start end)
432      (let ((p (search "coding:" str :start2 start :end2 end)))
433        (when p
434          (incf p (length "coding:"))
435          (loop while (and (< p end)
436                           (member (aref str p) '(#\space #\tab)))
437                do (incf p))
438          (let ((end (position-if (lambda (c) (find c '(#\space #\tab #\newline)))
439                                  str :start p)))
440            (find-external-format (subseq str p end))))))
441    
442    
443  ;;;; Streams  ;;;; Streams
444    
# Line 367  Output should be forced to OUTPUT-FN bef Line 453  Output should be forced to OUTPUT-FN bef
453    
454  The streams are returned as two values.")  The streams are returned as two values.")
455    
 (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)  
   
456    
457  ;;;; Documentation  ;;;; Documentation
458    
# Line 383  like." Line 460  like."
460     "Return the lambda list for the symbol NAME. NAME can also be     "Return the lambda list for the symbol NAME. NAME can also be
461  a lisp function object, on lisps which support this.  a lisp function object, on lisps which support this.
462    
463  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
464  cannot be determined."  arglist cannot be determined."
465     (declare (ignore name))     (declare (ignore name))
466     :not-available)     :not-available)
467    
468    (defgeneric declaration-arglist (decl-identifier)
469      (:documentation
470       "Return the argument list of the declaration specifier belonging to the
471    declaration identifier DECL-IDENTIFIER. If the arglist cannot be determined,
472    the keyword :NOT-AVAILABLE is returned.
473    
474    The different SWANK backends can specialize this generic function to
475    include implementation-dependend declaration specifiers, or to provide
476    additional information on the specifiers defined in ANSI Common Lisp.")
477      (:method (decl-identifier)
478        (case decl-identifier
479          (dynamic-extent '(&rest vars))
480          (ignore         '(&rest vars))
481          (ignorable      '(&rest vars))
482          (special        '(&rest vars))
483          (inline         '(&rest function-names))
484          (notinline      '(&rest function-name))
485          (optimize       '(&any compilation-speed debug safety space speed))
486          (type           '(type-specifier &rest args))
487          (ftype          '(type-specifier &rest function-names))
488          (otherwise
489           (flet ((typespec-p (symbol) (member :type (describe-symbol-for-emacs symbol))))
490             (cond ((and (symbolp decl-identifier) (typespec-p decl-identifier))
491                    '(&rest vars))
492                   ((and (listp decl-identifier) (typespec-p (first decl-identifier)))
493                    '(&rest vars))
494                   (t :not-available)))))))
495    
496    (defgeneric type-specifier-arglist (typespec-operator)
497      (:documentation
498       "Return the argument list of the type specifier belonging to
499    TYPESPEC-OPERATOR.. If the arglist cannot be determined, the keyword
500    :NOT-AVAILABLE is returned.
501    
502    The different SWANK backends can specialize this generic function to
503    include implementation-dependend declaration specifiers, or to provide
504    additional information on the specifiers defined in ANSI Common Lisp.")
505      (:method (typespec-operator)
506        (declare (special *type-specifier-arglists*)) ; defined at end of file.
507        (typecase typespec-operator
508          (symbol (or (cdr (assoc typespec-operator *type-specifier-arglists*))
509                      :not-available))
510          (t :not-available))))
511    
512  (definterface function-name (function)  (definterface function-name (function)
513    "Return the name of the function object FUNCTION.    "Return the name of the function object FUNCTION.
514    
# Line 492  debug the debugger! Instead, such condit Line 613  debug the debugger! Instead, such condit
613  user without (re)entering the debugger by wrapping them as  user without (re)entering the debugger by wrapping them as
614  `sldb-condition's."))  `sldb-condition's."))
615    
616    (definterface compute-sane-restarts (condition)
617      "This is an opportunity for Lisps such as CLISP to remove
618    unwanted restarts from the output of CL:COMPUTE-RESTARTS,
619    otherwise it should simply call CL:COMPUTE-RESTARTS, which is
620    what the default implementation does."
621      (compute-restarts condition))
622    
623    ;;; The following functions in this section are supposed to be called
624    ;;; within the dynamic contour of CALL-WITH-DEBUGGING-ENVIRONMENT only.
625    
626  (definterface compute-backtrace (start end)  (definterface compute-backtrace (start end)
627     "Return a list containing a backtrace of the condition current     "Returns a backtrace of the condition currently being debugged,
628  being debugged.  The results are unspecified if this function is  that is an ordered list consisting of frames. (What constitutes a
629  called outside the dynamic contour CALL-WITH-DEBUGGING-ENVIRONMENT.  frame is implementation dependent, but PRINT-FRAME must be defined on
630    it.)
631    
632    ``Ordered list'' means that the i-th. frame is associated to the
633    frame-number i.
634    
635  START and END are zero-based indices constraining the number of frames  START and END are zero-based indices constraining the number of frames
636  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 641  the stack.")
641    "Print frame to stream.")    "Print frame to stream.")
642    
643  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
644    "Return the source location for FRAME-NUMBER.")    "Return the source location for the frame associated to FRAME-NUMBER.")
645    
646  (definterface frame-catch-tags (frame-number)  (definterface frame-catch-tags (frame-number)
647    "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
648  stack frame.  The results are undefined unless this is called  frame.")
 within the dynamic contour of a function defined by  
 DEFINE-DEBUGGER-HOOK.")  
649    
650  (definterface frame-locals (frame-number)  (definterface frame-locals (frame-number)
651    "Return a list of XXX local variable designators define me    "Return a list of ((&key NAME ID VALUE) ...) where each element of
652  for a debugger stack frame.  The results are undefined unless  the list represents a local variable in the stack frame associated to
653  this is called within the dynamic contour of a function defined  FRAME-NUMBER.
654  by DEFINE-DEBUGGER-HOOK.")  
655    NAME, a symbol; the name of the local variable.
656  (definterface frame-var-value (frame var)  
657    "Return the value of VAR in FRAME.  ID, an integer; used as primary key for the local variable, unique
658  FRAME is the number of the frame in the backtrace.  relatively to the frame under operation.
659  VAR is the number of the variable in the frame.")  
660    value, an object; the value of the local variable.")
661    
662    (definterface frame-var-value (frame-number var-id)
663      "Return the value of the local variable associated to VAR-ID
664    relatively to the frame associated to FRAME-NUMBER.")
665    
666  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
667    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
# Line 532  FRAME-NUMBER is a non-negative integer." Line 670  FRAME-NUMBER is a non-negative integer."
670    
671  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
672     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
673  in the debugger.  The results are undefined unless called in the  in the debugger.
 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.  
674    
675  FRAME-NUMBER must be a positive integer with 0 indicating the  FRAME-NUMBER must be a positive integer with 0 indicating the
676  frame which invoked the debugger.  frame which invoked the debugger.
# Line 559  as it was called originally.") Line 696  as it was called originally.")
696    "Format a condition for display in SLDB."    "Format a condition for display in SLDB."
697    (princ-to-string condition))    (princ-to-string condition))
698    
 (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))  
   '())  
   
699  (definterface condition-extras (condition)  (definterface condition-extras (condition)
700    "Return a list of extra for the debugger.    "Return a list of extra for the debugger.
701  The allowed elements are of the form:  The allowed elements are of the form:
702    (:SHOW-FRAME-SOURCE frame-number)"    (:SHOW-FRAME-SOURCE frame-number)
703      (:REFERENCES &rest refs)
704    "
705    (declare (ignore condition))    (declare (ignore condition))
706    '())    '())
707    
# Line 585  The allowed elements are of the form: Line 714  The allowed elements are of the form:
714  (definterface sldb-break-at-start (symbol)  (definterface sldb-break-at-start (symbol)
715    "Set a breakpoint on the beginning of the function for SYMBOL.")    "Set a breakpoint on the beginning of the function for SYMBOL.")
716    
717    (definterface sldb-stepper-condition-p (condition)
718      "Return true if SLDB was invoked due to a single-stepping condition,
719    false otherwise. "
720      (declare (ignore condition))
721      nil)
722    
723    (definterface sldb-step-into ()
724      "Step into the current single-stepper form.")
725    
726    (definterface sldb-step-next ()
727      "Step to the next form in the current function.")
728    
729    (definterface sldb-step-out ()
730      "Stop single-stepping temporarily, but resume it once the current function
731    returns.")
732    
733    
734  ;;;; Definition finding  ;;;; Definition finding
# Line 615  definition, e.g., FOO or (METHOD FOO (ST Line 759  definition, e.g., FOO or (METHOD FOO (ST
759    
760  LOCATION is the source location for the definition.")  LOCATION is the source location for the definition.")
761    
762    (definterface find-source-location (object)
763      "Returns the source location of OBJECT, or NIL.
764    
765    That is the source location of the underlying datastructure of
766    OBJECT. E.g. on a STANDARD-OBJECT, the source location of the
767    respective DEFCLASS definition is returned, on a STRUCTURE-CLASS the
768    respective DEFSTRUCT definition, and so on."
769      ;; This returns one source location and not a list of locations. It's
770      ;; supposed to return the location of the DEFGENERIC definition on
771      ;; #'SOME-GENERIC-FUNCTION.
772      )
773    
774    
775  (definterface buffer-first-change (filename)  (definterface buffer-first-change (filename)
776    "Called for effect the first time FILENAME's buffer is modified."    "Called for effect the first time FILENAME's buffer is modified."
777    (declare (ignore filename))    (declare (ignore filename))
778    nil)    nil)
779    
780    
781    
782  ;;;; XREF  ;;;; XREF
783    
# Line 706  themselves, that is, their dispatch func Line 864  themselves, that is, their dispatch func
864    
865  ;;;; Inspector  ;;;; Inspector
866    
867  (defclass inspector ()  (defgeneric emacs-inspect (object)
868    ()    (: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)  
869     "Explain to Emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
870    
871  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.  
872    
873  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
874  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 879  inserted into the buffer as is, or a lis
879    
880   (:newline) - Render a \\n   (:newline) - Render a \\n
881    
882   (:action label lambda) - Render LABEL (a text string) which when   (:action label lambda &key (refresh t)) - Render LABEL (a text
883   clicked will call LAMBDA.   string) which when clicked will call LAMBDA. If REFRESH is
884     non-NIL the currently inspected object will be re-inspected
885   NIL - do nothing.")   after calling the lambda.
886    "))
887    
888  (defmethod inspect-for-emacs ((object t) (inspector t))  (defmethod emacs-inspect ((object t))
889    "Generic method for inspecting any kind of object.    "Generic method for inspecting any kind of object.
890    
891  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
892  output of CL:DESCRIBE."  output of CL:DESCRIBE."
   (declare (ignore inspector))  
   (values  
    "A value."  
893     `("Type: " (:value ,(type-of object)) (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
894       "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:"
895       (:newline) (:newline)       (:newline) (:newline)
896       ,(with-output-to-string (desc) (describe object desc)))))       ,(with-output-to-string (desc) (describe object desc))))
897    
898  ;;; Utilities for inspector methods.  ;;; Utilities for inspector methods.
899  ;;;  ;;;
900  (defun label-value-line (label value)  (defun label-value-line (label value &key (newline t))
901    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector.
902    (list (princ-to-string label) ": " `(:value ,value) '(:newline)))  If NEWLINE is non-NIL a `(:newline)' is added to the result."
903      (list* (princ-to-string label) ": " `(:value ,value)
904             (if newline '((:newline)) nil)))
905    
906  (defmacro label-value-line* (&rest label-values)  (defmacro label-value-line* (&rest label-values)
907    ` (append ,@(loop for (label value) in label-values    ` (append ,@(loop for (label value) in label-values
# Line 778  output of CL:DESCRIBE." Line 918  output of CL:DESCRIBE."
918  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
919  ;;; implementations.  ;;; implementations.
920    
921  (definterface initialize-multiprocessing ()  (definterface initialize-multiprocessing (continuation)
922     "Initialize multiprocessing, if necessary."     "Initialize multiprocessing, if necessary and then invoke CONTINUATION.
    nil)  
923    
924  (definterface startup-idle-and-top-level-loops ()  Depending on the impleimentaion, this function may never return."
925    "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)  
926    
927  (definterface spawn (fn &key name)  (definterface spawn (fn &key name)
928    "Create a new thread to call FN.")    "Create a new thread to call FN.")
# Line 796  normal function." Line 931  normal function."
931    "Return an Emacs-parsable object to identify THREAD.    "Return an Emacs-parsable object to identify THREAD.
932    
933  Ids should be comparable with equal, i.e.:  Ids should be comparable with equal, i.e.:
934   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")   (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)"
935      thread)
936    
937  (definterface find-thread (id)  (definterface find-thread (id)
938    "Return the thread for ID.    "Return the thread for ID.
939  ID should be an id previously obtained with THREAD-ID.  ID should be an id previously obtained with THREAD-ID.
940  Can return nil if the thread no longer exists.")  Can return nil if the thread no longer exists."
941      (current-thread))
942    
943  (definterface thread-name (thread)  (definterface thread-name (thread)
944     "Return the name of THREAD.     "Return the name of THREAD.
# Line 816  user. They do not have to be unique." Line 953  user. They do not have to be unique."
953     (declare (ignore thread))     (declare (ignore thread))
954     "")     "")
955    
956    (definterface thread-description (thread)
957      "Return a string describing THREAD."
958      (declare (ignore thread))
959      "")
960    
961    (definterface set-thread-description (thread description)
962      "Set THREAD's description to DESCRIPTION."
963      (declare (ignore thread description))
964      "")
965    
966  (definterface make-lock (&key name)  (definterface make-lock (&key name)
967     "Make a lock for thread synchronization.     "Make a lock for thread synchronization.
968  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
969    but that thread may hold it more than once."
970     (declare (ignore name))     (declare (ignore name))
971     :null-lock)     :null-lock)
972    
# Line 851  Only one thread may hold the lock (via C Line 999  Only one thread may hold the lock (via C
999    "Send OBJECT to thread THREAD.")    "Send OBJECT to thread THREAD.")
1000    
1001  (definterface receive ()  (definterface receive ()
1002    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox."
1003      (receive-if (constantly t)))
1004    
1005    (definterface receive-if (predicate)
1006      "Return the first message satisfiying PREDICATE.")
1007    
1008    (defvar *pending-slime-interrupts*)
1009    
1010    (defun check-slime-interrupts ()
1011      "Execute pending interrupts if any.
1012    This should be called periodically in operations which
1013    can take a long time to complete."
1014      (when (and (boundp '*pending-slime-interrupts*)
1015                 *pending-slime-interrupts*)
1016        (funcall (pop *pending-slime-interrupts*))))
1017    
1018  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1019    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
# Line 873  SPEC can be: Line 1035  SPEC can be:
1035  (definterface make-weak-value-hash-table (&rest args)  (definterface make-weak-value-hash-table (&rest args)
1036    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."    "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
1037    (apply #'make-hash-table args))    (apply #'make-hash-table args))
1038    
1039    (definterface hash-table-weakness (hashtable)
1040      "Return nil or one of :key :value :key-or-value :key-and-value"
1041      (declare (ignore hashtable))
1042      nil)
1043    
1044    
1045    ;;;; Character names
1046    
1047    (definterface character-completion-set (prefix matchp)
1048      "Return a list of names of characters that match PREFIX."
1049      ;; Handle the standard and semi-standard characters.
1050      (loop for name in '("Newline" "Space" "Tab" "Page" "Rubout"
1051                          "Linefeed" "Return" "Backspace")
1052         when (funcall matchp prefix name)
1053         collect name))
1054    
1055    
1056    (defparameter *type-specifier-arglists*
1057      '((and                . (&rest type-specifiers))
1058        (array              . (&optional element-type dimension-spec))
1059        (base-string        . (&optional size))
1060        (bit-vector         . (&optional size))
1061        (complex            . (&optional type-specifier))
1062        (cons               . (&optional car-typespec cdr-typespec))
1063        (double-float       . (&optional lower-limit upper-limit))
1064        (eql                . (object))
1065        (float              . (&optional lower-limit upper-limit))
1066        (function           . (&optional arg-typespec value-typespec))
1067        (integer            . (&optional lower-limit upper-limit))
1068        (long-float         . (&optional lower-limit upper-limit))
1069        (member             . (&rest eql-objects))
1070        (mod                . (n))
1071        (not                . (type-specifier))
1072        (or                 . (&rest type-specifiers))
1073        (rational           . (&optional lower-limit upper-limit))
1074        (real               . (&optional lower-limit upper-limit))
1075        (satisfies          . (predicate-symbol))
1076        (short-float        . (&optional lower-limit upper-limit))
1077        (signed-byte        . (&optional size))
1078        (simple-array       . (&optional element-type dimension-spec))
1079        (simple-base-string . (&optional size))
1080        (simple-bit-vector  . (&optional size))
1081        (simple-string      . (&optional size))
1082        (single-float       . (&optional lower-limit upper-limit))
1083        (simple-vector      . (&optional size))
1084        (string             . (&optional size))
1085        (unsigned-byte      . (&optional size))
1086        (values             . (&rest typespecs))
1087        (vector             . (&optional element-type size))
1088        ))

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

  ViewVC Help
Powered by ViewVC 1.1.5