/[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.76 by heller, Wed Nov 24 19:57:10 2004 UTC revision 1.94 by heller, Sun Nov 20 23:25:38 2005 UTC
# Line 1  Line 1 
1  ;;;; -*- Mode: lisp; indent-tabs-mode: nil; outline-regexp: ";;;;;*" -*-  ;;; -*- Mode: lisp; indent-tabs-mode: nil; outline-regexp: ";;;;;*" -*-
2  ;;;  ;;;
3  ;;; slime-backend.lisp --- SLIME backend interface.  ;;; slime-backend.lisp --- SLIME backend interface.
4  ;;;  ;;;
5  ;;; Created by James Bielman in 2003. Released into the public domain.  ;;; Created by James Bielman in 2003. Released into the public domain.
6  ;;;  ;;;
7    ;;;; Frontmatter
8    ;;;
9  ;;; This file defines the functions that must be implemented  ;;; This file defines the functions that must be implemented
10  ;;; separately for each Lisp. Each is declared as a generic function  ;;; separately for each Lisp. Each is declared as a generic function
11  ;;; for which swank-<implementation>.lisp provides methods.  ;;; for which swank-<implementation>.lisp provides methods.
# Line 81  Line 83 
83     #:slot-definition-name     #:slot-definition-name
84     #:slot-definition-type     #:slot-definition-type
85     #:slot-definition-readers     #:slot-definition-readers
86     #:slot-definition-writers))     #:slot-definition-writers
87       ;; generic function protocol
88       #:compute-applicable-methods-using-classes
89       #:finalize-inheritance))
90    
91  (in-package :swank-backend)  (in-package :swank-backend)
92    
# Line 150  EXCEPT is a list of symbol names which s Line 155  EXCEPT is a list of symbol names which s
155          (import real-symbol :swank-mop)          (import real-symbol :swank-mop)
156          (export real-symbol :swank-mop)))))          (export real-symbol :swank-mop)))))
157    
158    (defvar *gray-stream-symbols*
159      '(:fundamental-character-output-stream
160        :stream-write-char
161        :stream-fresh-line
162        :stream-force-output
163        :stream-finish-output
164        :fundamental-character-input-stream
165        :stream-read-char
166        :stream-listen
167        :stream-unread-char
168        :stream-clear-input
169        :stream-line-column
170        :stream-read-char-no-hang
171        ;; STREAM-LINE-LENGTH is an extension to gray streams that's apparently
172        ;; supported by CMUCL, OpenMCL, SBCL and SCL.
173        #+(or cmu openmcl sbcl scl)
174        :stream-line-length))
175    
176    (defun import-from (package symbol-names &optional (to-package *package*))
177      "Import the list of SYMBOL-NAMES found in the package PACKAGE."
178      (dolist (name symbol-names)
179        (multiple-value-bind (symbol found) (find-symbol (string name) package)
180          (assert found () "Symbol ~A not found in package ~A" name package)
181          (import symbol to-package))))
182    
183    
184  ;;;; Utilities  ;;;; Utilities
185    
# Line 181  EXCEPT is a list of symbol names which s Line 211  EXCEPT is a list of symbol names which s
211  (definterface close-socket (socket)  (definterface close-socket (socket)
212    "Close the socket SOCKET.")    "Close the socket SOCKET.")
213    
214  (definterface accept-connection (socket &key external-format)  (definterface accept-connection (socket &key external-format
215     "Accept a client connection on the listening socket SOCKET.  Return                                          buffering)
216  a stream for the new connection.")     "Accept a client connection on the listening socket SOCKET.
217    Return a stream for the new connection.")
218    
219  (definterface add-sigio-handler (socket fn)  (definterface add-sigio-handler (socket fn)
220    "Call FN whenever SOCKET is readable.")    "Call FN whenever SOCKET is readable.")
# Line 244  This is used to resolve filenames withou Line 275  This is used to resolve filenames withou
275    (funcall fn))    (funcall fn))
276    
277  (definterface default-readtable-alist ()  (definterface default-readtable-alist ()
278      "Return a suitable initial value for SWANK:*READTABLE-ALIST*."    "Return a suitable initial value for SWANK:*READTABLE-ALIST*."
279    '())    '())
280    
281  (definterface quit-lisp ()  (definterface quit-lisp ()
# Line 288  Example: Line 319  Example:
319          (error "Couldn't find ASDF operation ~S" operation-name))          (error "Couldn't find ASDF operation ~S" operation-name))
320        (apply operate operation system-name keyword-args))))        (apply operate operation system-name keyword-args))))
321    
322  (definterface swank-compile-file (filename load-p)  (definterface swank-compile-file (filename load-p &optional external-format)
323     "Compile FILENAME signalling COMPILE-CONDITIONs.     "Compile FILENAME signalling COMPILE-CONDITIONs.
324  If LOAD-P is true, load the file after compilation.")  If LOAD-P is true, load the file after compilation.")
325    
# Line 368  The result is either a symbol, a list, o Line 399  The result is either a symbol, a list, o
399     "Recursively expand all macros in FORM.     "Recursively expand all macros in FORM.
400  Return the resulting form.")  Return the resulting form.")
401    
402    (definterface compiler-macroexpand-1 (form &optional env)
403      "Call the compiler-macro for form.
404    If FORM is a function call for which a compiler-macro has been
405    defined, invoke the expander function using *macroexpand-hook* and
406    return the results and T.  Otherwise, return the original form and
407    NIL."
408      (let ((fun (and (consp form) (compiler-macro-function (car form)))))
409        (if fun
410            (let ((result (funcall *macroexpand-hook* fun form env)))
411              (values result (not (eq result form))))
412            (values form nil))))
413    
414    (definterface compiler-macroexpand (form &optional env)
415      "Repetitively call `compiler-macroexpand-1'."
416      (labels ((frob (form expanded)
417                 (multiple-value-bind (new-form newly-expanded)
418                     (compiler-macroexpand-1 form env)
419                   (if newly-expanded
420                       (frob new-form t)
421                       (values new-form expanded)))))
422        (frob form env)))
423    
424  (definterface describe-symbol-for-emacs (symbol)  (definterface describe-symbol-for-emacs (symbol)
425     "Return a property list describing SYMBOL.     "Return a property list describing SYMBOL.
426    
427  The property list has an entry for each interesting aspect of the  The property list has an entry for each interesting aspect of the
428  symbol. The recognised keys are:  symbol. The recognised keys are:
429    
430    :VARIABLE :FUNCTION :SETF :TYPE :CLASS :MACRO :COMPILER-MACRO    :VARIABLE :FUNCTION :SETF :SPECIAL-OPERATOR :MACRO :COMPILER-MACRO
431    :ALIEN-TYPE :ALIEN-STRUCT :ALIEN-UNION :ALIEN-ENUM    :TYPE :CLASS :ALIEN-TYPE :ALIEN-STRUCT :ALIEN-UNION :ALIEN-ENUM
432    
433  The value of each property is the corresponding documentation string,  The value of each property is the corresponding documentation string,
434  or :NOT-DOCUMENTED. It is legal to include keys not listed here.  or :NOT-DOCUMENTED. It is legal to include keys not listed here (but
435    slime-print-apropos in Emacs must know about them).
436    
437  Properties should be included if and only if they are applicable to  Properties should be included if and only if they are applicable to
438  the symbol. For example, only (and all) fbound symbols should include  the symbol. For example, only (and all) fbound symbols should include
# Line 399  Return a documentation string, or NIL if Line 453  Return a documentation string, or NIL if
453    
454  ;;;; Debugging  ;;;; Debugging
455    
456    (definterface install-debugger-globally (function)
457      "Install FUNCTION as the debugger for all threads/processes. This
458    usually involves setting *DEBUGGER-HOOK* and, if the implementation
459    permits, hooking into BREAK as well."
460      (setq *debugger-hook* function))
461    
462  (definterface call-with-debugging-environment (debugger-loop-fn)  (definterface call-with-debugging-environment (debugger-loop-fn)
463     "Call DEBUGGER-LOOP-FN in a suitable debugging environment.     "Call DEBUGGER-LOOP-FN in a suitable debugging environment.
464    
# Line 409  other debugger callbacks that will be ca Line 469  other debugger callbacks that will be ca
469  For example, this is a reasonable place to compute a backtrace, switch  For example, this is a reasonable place to compute a backtrace, switch
470  to safe reader/printer settings, and so on.")  to safe reader/printer settings, and so on.")
471    
472    (definterface call-with-debugger-hook (hook fun)
473      "Call FUN and use HOOK as debugger hook.
474    
475    HOOK should be called for both BREAK and INVOKE-DEBUGGER."
476      (let ((*debugger-hook* hook))
477        (funcall fun)))
478    
479  (define-condition sldb-condition (condition)  (define-condition sldb-condition (condition)
480    ((original-condition    ((original-condition
481      :initarg :original-condition      :initarg :original-condition
# Line 438  the stack.") Line 505  the stack.")
505  (definterface print-frame (frame stream)  (definterface print-frame (frame stream)
506    "Print frame to stream.")    "Print frame to stream.")
507    
 (definterface frame-package (frame)  
   "Return the preferred package to use when printing local variables.  
 NIL can be used if no particular package is known."  
   (declare (ignore frame))  
   nil)  
   
508  (definterface frame-source-location-for-emacs (frame-number)  (definterface frame-source-location-for-emacs (frame-number)
509    "Return the source location for FRAME-NUMBER.")    "Return the source location for FRAME-NUMBER.")
510    
# Line 467  VAR is the number of the variable in the Line 528  VAR is the number of the variable in the
528  (definterface disassemble-frame (frame-number)  (definterface disassemble-frame (frame-number)
529    "Disassemble the code for the FRAME-NUMBER.    "Disassemble the code for the FRAME-NUMBER.
530  The output should be written to standard output.  The output should be written to standard output.
531  FRAME-NUMBER is a non-negative interger.")  FRAME-NUMBER is a non-negative integer.")
532    
533  (definterface eval-in-frame (form frame-number)  (definterface eval-in-frame (form frame-number)
534     "Evaluate a Lisp form in the lexical context of a stack frame     "Evaluate a Lisp form in the lexical context of a stack frame
# Line 566  LOCATION is the source location for the Line 627  LOCATION is the source location for the
627    "Return the call sites of FUNCTION-NAME (a symbol).    "Return the call sites of FUNCTION-NAME (a symbol).
628  The results is a list ((DSPEC LOCATION) ...).")  The results is a list ((DSPEC LOCATION) ...).")
629    
630    (definterface calls-who (function-name)
631      "Return the call sites of FUNCTION-NAME (a symbol).
632    The results is a list ((DSPEC LOCATION) ...).")
633    
634  (definterface who-references (variable-name)  (definterface who-references (variable-name)
635    "Return the locations where VARIABLE-NAME (a symbol) is referenced.    "Return the locations where VARIABLE-NAME (a symbol) is referenced.
636  See WHO-CALLS for a description of the return value.")  See WHO-CALLS for a description of the return value.")
# Line 652  inspect-for-emacs method.")) Line 717  inspect-for-emacs method."))
717    "Return an inspector object suitable for passing to inspect-for-emacs.")    "Return an inspector object suitable for passing to inspect-for-emacs.")
718    
719  (definterface inspect-for-emacs (object inspector)  (definterface inspect-for-emacs (object inspector)
720     "Explain to emacs how to inspect OBJECT.     "Explain to Emacs how to inspect OBJECT.
721    
722  The argument INSPECTOR is an object representing how to get at  The argument INSPECTOR is an object representing how to get at
723  the internals of OBJECT, it is usually an implementation specific  the internals of OBJECT, it is usually an implementation specific
# Line 665  Returns two values: a string which will Line 730  Returns two values: a string which will
730  the inspector buffer and a list specifying how to render the  the inspector buffer and a list specifying how to render the
731  object for inspection.  object for inspection.
732    
733  Every elementi of the list must be either a string, which will be  Every element of the list must be either a string, which will be
734  inserted into the buffer as is, or a list of the form:  inserted into the buffer as is, or a list of the form:
735    
736   (:value object &optional format) - Render an inspectable   (:value object &optional format) - Render an inspectable
# Line 685  inserted into the buffer as is, or a lis Line 750  inserted into the buffer as is, or a lis
750  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
751  output of CL:DESCRIBE."  output of CL:DESCRIBE."
752    (declare (ignore inspector))    (declare (ignore inspector))
753    (values "A value."    (values
754            `("Type: " (:value ,(type-of object))     "A value."
755              (:newline)     `("Type: " (:value ,(type-of object)) (:newline)
756              "Don't know how to inspect the object, dumping output of CL:DESCIRBE:"       "Don't know how to inspect the object, dumping output of CL:DESCRIBE:"
757              (:newline) (:newline)       (:newline) (:newline)
758              ,(with-output-to-string (desc)       ,(with-output-to-string (desc) (describe object desc)))))
                (describe object desc)))))  
759    
760  ;;; Utilities to for inspector methods.  ;;; Utilities for inspector methods.
761  ;;;  ;;;
762  (defun label-value-line (label value)  (defun label-value-line (label value)
763    "Create a control list which prints \"LABEL: VALUE\" in the inspector."    "Create a control list which prints \"LABEL: VALUE\" in the inspector."
# Line 714  output of CL:DESCRIBE." Line 778  output of CL:DESCRIBE."
778  ;;; The default implementations are sufficient for non-multiprocessing  ;;; The default implementations are sufficient for non-multiprocessing
779  ;;; implementations.  ;;; implementations.
780    
781  (definterface startup-multiprocessing ()  (definterface initialize-multiprocessing ()
782     "Initialize multiprocessing, if necessary.     "Initialize multiprocessing, if necessary."
783       nil)
784    
785  This function is called directly through the listener, not in an RPC  (definterface startup-idle-and-top-level-loops ()
786      "This function is called directly through the listener, not in an RPC
787  from Emacs. This is to support interfaces such as CMUCL's  from Emacs. This is to support interfaces such as CMUCL's
788  MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS which does not return like a  MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS which does not return like a
789  normal function."  normal function."
# Line 786  Only one thread may hold the lock (via C Line 852  Only one thread may hold the lock (via C
852    
853  (definterface receive ()  (definterface receive ()
854    "Return the next message from current thread's mailbox.")    "Return the next message from current thread's mailbox.")
855    
856    (definterface toggle-trace (spec)
857      "Toggle tracing of the function(s) given with SPEC.
858    SPEC can be:
859     (setf NAME)                            ; a setf function
860     (:defmethod NAME QUALIFIER... (SPECIALIZER...)) ; a specific method
861     (:defgeneric NAME)                     ; a generic function with all methods
862     (:call CALLER CALLEE)                  ; trace calls from CALLER to CALLEE.
863     (:labels TOPLEVEL LOCAL)
864     (:flet TOPLEVEL LOCAL) ")
865    
866    
867    ;;;; Weak datastructures
868    
869    (definterface make-weak-key-hash-table (&rest args)
870      "Like MAKE-HASH-TABLE, but weak w.r.t. the keys."
871      (apply #'make-hash-table args))
872    
873    (definterface make-weak-value-hash-table (&rest args)
874      "Like MAKE-HASH-TABLE, but weak w.r.t. the values."
875      (apply #'make-hash-table args))

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

  ViewVC Help
Powered by ViewVC 1.1.5