/[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.12 by heller, Fri Jan 9 19:42:25 2004 UTC revision 1.13 by lgorrie, Mon Jan 12 00:51:32 2004 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-impl.lisp --- Slime interface reference implementation.  ;;; slime-backend.lisp --- SLIME backend interface.
4  ;;;  ;;;
5  ;;; Copyright (C) 2003, James Bielman  <jamesjb@jamesjb.com>  ;;; Created by James Bielman in 2003. Released into the public domain.
 ;;; Released into the public domain.  
6  ;;;  ;;;
7  ;;;   $Id$  ;;; This file defines the functions that must be implemented
8  ;;;  ;;; separately for each Lisp. Each is declared as a generic function
9    ;;; for which swank-<implementation>.lisp provides methods.
 ;; This is a skeletal implementation of the Slime internals interface.  
 ;;  
 ;; The idea is to create a de-facto standard interface that can be  
 ;; used by editor <-> CL integration software, such as Slime.  Vendors  
 ;; are encouraged to comment on this interface.  
10    
11  (defpackage :swank  (defpackage :swank
12    (:use :common-lisp)    (:use :common-lisp)
# Line 25  Line 19 
19             #:call-with-conversation-lock             #:call-with-conversation-lock
20             #:compiler-notes-for-emacs             #:compiler-notes-for-emacs
21             #:completions             #:completions
22               #:create-server
23             #:create-swank-server             #:create-swank-server
24             #:describe-alien-enum             #:describe-alien-enum
25             #:describe-alien-struct             #:describe-alien-struct
# Line 98  Line 93 
93  (in-package :swank)  (in-package :swank)
94    
95    
96  ;;;; Conditions and Error Handling  ;;;; TCP server
97    
98  ;; XXX need to specify restart behavior for errors/warnings?  (defgeneric create-socket-server (init-fn &key announce-fn port
99                                              accept-background handle-background loop)
100      (:documentation
101       "Create a callback-driven TCP server.
102    Initially a TCP listen socket is opened, and then ANNOUNCE-FN is
103    called with its port number for its argument.
104    
105  (define-condition not-implemented-error (error)  When a client connects, first a two-way stream is created for I/O
106    ())  on the socket, and then INIT-FN is called with the stream for its
107    argument. INIT-FN returns another function, HANDLER-FN, to be
108    called with no arguments each time the stream becomes readable.
109    
110  (deftype severity () '(member :error :warning :style-warning :note))  If LOOP is true (the default), the server continues accepting
111    clients until CLOSE-SOCKET-SERVER is called. Otherwise the server
112    is closed after a single client has connected.
113    
114  ;; Base condition type for compiler errors, warnings and notes.  If BACKGROUND-ACCEPT is true (the default), this function
115  (define-condition compiler-condition (condition)  immediately after creating the socket, and accepts connections
116    ((original-condition  asynchronously.
117      ;; The original condition thrown by the compiler if appropriate.  
118      ;; May be NIL if a compiler does not report using conditions.  If BACKGROUND-HANDLE is true (the default), the... FIXME."))
119      :initarg :original-condition  
120      :accessor original-condition)  ;;; Base condition for networking errors.
121    (define-condition network-error (error) ())
122    
123    (defgeneric emacs-connected ()
124      (:documentation
125       "Hook called when the first connection from Emacs is established.
126    Called from the INIT-FN of the socket server that accepts the
127    connection.
128    
129     (severity  This is intended for setting up extra context, e.g. to discover
130      :type severity  that the calling thread is the one that interacts with Emacs."))
131      :initarg :severity  
132      :accessor severity)  (defmethod no-applicable-method ((m (eql #'emacs-connected)) &rest _)
133      (declare (ignore _))
134     (message    nil)
     :initarg :message  
     :accessor message)  
   
    (location  
     :initarg :location  
     :accessor location)))  
135    
136    
137  ;;;; Compilation  ;;;; Compilation
# Line 134  Line 139 
139  (defgeneric call-with-compilation-hooks (func)  (defgeneric call-with-compilation-hooks (func)
140    (:documentation    (:documentation
141     "Call FUNC with hooks to trigger SLDB on compiler errors."))     "Call FUNC with hooks to trigger SLDB on compiler errors."))
142  (defmacro with-compilation-hooks ((&rest _) &body body)  
143    (defmacro with-compilation-hooks (() &body body)
144    `(call-with-compilation-hooks (lambda () (progn ,@body))))    `(call-with-compilation-hooks (lambda () (progn ,@body))))
145    
146  (defgeneric compile-string-for-emacs (string &key buffer position)  (defgeneric compile-string-for-emacs (string &key buffer position)
# Line 152  positions reported in compiler condition Line 158  positions reported in compiler condition
158     "Compile FILENAME signalling COMPILE-CONDITIONs.     "Compile FILENAME signalling COMPILE-CONDITIONs.
159  If LOAD-P is true, load the file after compilation."))  If LOAD-P is true, load the file after compilation."))
160    
161    ;;;;; Compiler conditions
162    
163    (deftype severity () '(member :error :warning :style-warning :note))
164    
165    ;; Base condition type for compiler errors, warnings and notes.
166    (define-condition compiler-condition (condition)
167      ((original-condition
168        ;; The original condition thrown by the compiler if appropriate.
169        ;; May be NIL if a compiler does not report using conditions.
170        :type (or null condition)
171        :initarg :original-condition
172        :accessor original-condition)
173    
174       (severity :type severity
175                 :initarg :severity
176                 :accessor severity)
177    
178       (message :initarg :message
179                :accessor message)
180    
181       (location :initarg :location
182                 :accessor location)))
183    
184    ;;;
185    ;;;; Streams
186    
187    (defgeneric make-fn-streams (input-fn output-fn)
188      (:documentation
189       "Return character input and output streams backended by functions.
190    When input is needed, INPUT-FN is called with no arguments to
191    return a string.
192    When output is ready, OUTPUT-FN is called with the output as its
193    argument.
194    
195    Output should be forced to OUTPUT-FN before calling INPUT-FN.
196    
197    The streams are returned as two values."))
198    
199    
200  ;;;; Documentation  ;;;; Documentation
201    
# Line 412  WAIT-GOAHEAD. Line 456  WAIT-GOAHEAD.
456    
457  Systems that do not support multiprocessing always signal an error."))  Systems that do not support multiprocessing always signal an error."))
458    
459    
460  ;;;;; Default implementation for non-MP systems  ;;;;; Default implementation for non-MP systems
461    
462  ;;; Using NO-APPLICABLE-METHOD to supply a default implementation that  ;;; Using NO-APPLICABLE-METHOD to supply a default implementation that
463  ;;; works in systems that don't have multiprocessing.  ;;; works in systems that don't have multiprocessing.
464  ;;; (Good or bad idea? -luke)  ;;; (Good or bad idea? -luke)
465    
 (defvar _ nil                           ; Good or bad idea? -luke  
   "Null variable -- can be used for ignored arguments.  
 Declared special, so no IGNORE declarations are necessary.")  
   
466  (defmethod no-applicable-method ((m (eql #'startup-multiprocessing)) &rest _)  (defmethod no-applicable-method ((m (eql #'startup-multiprocessing)) &rest _)
467      (declare (ignore _))
468    nil)    nil)
469  (defmethod no-applicable-method ((m (eql #'thread-id)) &rest _)  (defmethod no-applicable-method ((m (eql #'thread-id)) &rest _)
470      (declare (ignore _))
471    nil)    nil)
472  (defmethod no-applicable-method ((m (eql #'thread-name)) &rest _)  (defmethod no-applicable-method ((m (eql #'thread-name)) &rest _)
473      (declare (ignore _))
474    "The One True Thread")    "The One True Thread")
475  (defmethod no-applicable-method ((m (eql #'call-with-I/O-lock))  (defmethod no-applicable-method ((m (eql #'call-with-I/O-lock))
476                                   &rest args)                                   &rest args)
# Line 435  Declared special, so no IGNORE declarati Line 479  Declared special, so no IGNORE declarati
479                                   &rest args)                                   &rest args)
480    (funcall (first args)))    (funcall (first args)))
481  (defmethod no-applicable-method ((m (eql #'wait-goahead)) &rest _)  (defmethod no-applicable-method ((m (eql #'wait-goahead)) &rest _)
482      (declare (ignore _))
483    t)    t)
484  (defmethod no-applicable-method ((m (eql #'give-goahead)) &rest _)  (defmethod no-applicable-method ((m (eql #'give-goahead)) &rest _)
485      (declare (ignore _))
486    (error "SLIME multiprocessing not available"))    (error "SLIME multiprocessing not available"))
487    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.5