%PDF- %PDF-
Direktori : /usr/local/share/emacs/27.2/lisp/ |
Current File : //usr/local/share/emacs/27.2/lisp/jsonrpc.elc |
;ELC ;;; Compiled ;;; in Emacs version 27.2 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\307\310\311\312!\"\210\307\313\314\312!\"\210\307\315\313\"\210\316\315\317\320#\210\321\312\322\313#\323\312\324\325\326$\210\327\330\324\331\324\332%\210\327\333\324\334\324\335%\210\327\336\324\337\324\340%\210\327\341\324\342\324\343%\210\327\344\324\345\324\346%\210\327\347\324\350\324\351%\210\327\352\324\353\324\354%\210\327\355\324\356\324\357%\210\327\360\324\361\324\362%\210\327\363\324\364\324\365%\210\327\366\324\367\324\370%\210\327\371\324\372\324\373%\210\327\374\324\375\324\376%\210\327\377\324\201@ \324\201A %\210\327\201B \324\201C \324\201D %\210\327\201E \324\201F \324\201G %\210\327\201H \324\201I \324\201J %\210\327\201K \324\201L \324\201M %\207" [require cl-lib json eieio warnings pcase ert defalias jsonrpc-connection-p eieio-make-class-predicate jsonrpc-connection jsonrpc-connection--eieio-childp eieio-make-child-predicate jsonrpc-connection-child-p make-obsolete "use (cl-typep ... \\='jsonrpc-connection) instead" "25.1" define-symbol-prop cl-deftype-satisfies eieio-defclass-internal nil ((name :accessor jsonrpc-name :initarg :name :documentation "A name for the connection") (-request-dispatcher :accessor jsonrpc--request-dispatcher :initform #'ignore :initarg :request-dispatcher :documentation "Dispatcher for remotely invoked requests.") (-notification-dispatcher :accessor jsonrpc--notification-dispatcher :initform #'ignore :initarg :notification-dispatcher :documentation "Dispatcher for remotely invoked notifications.") (last-error :accessor jsonrpc-last-error :documentation "Last JSONRPC error message received from endpoint.") (-request-continuations :initform (make-hash-table) :accessor jsonrpc--request-continuations :documentation "A hash table of request ID to continuation lambdas.") (-events-buffer :accessor jsonrpc--events-buffer :documentation "A buffer pretty-printing the JSONRPC events") (-events-buffer-scrollback-size :initarg :events-buffer-scrollback-size :accessor jsonrpc--events-buffer-scrollback-size :documentation "Max size of events buffer. 0 disables, nil means infinite.") (-deferred-actions :initform (make-hash-table :test #'equal) :accessor jsonrpc--deferred-actions :documentation "Map (DEFERRED BUF) to (FN TIMER ID). FN isa saved DEFERRED `async-request' from BUF, to be sent not laterthan TIMER as ID.") (-next-request-id :initform 0 :accessor jsonrpc--next-request-id :documentation "Next number used for a request")) (:documentation "Base class representing a JSONRPC connection.\nThe following initargs are accepted:\n\n:NAME (mandatory), a string naming the connection\n\n:REQUEST-DISPATCHER (optional), a function of three\narguments (CONN METHOD PARAMS) for handling JSONRPC requests.\nCONN is a `jsonrpc-connection' object, method is a symbol, and\nPARAMS is a plist representing a JSON object. The function is\nexpected to return a JSONRPC result, a plist of (:result\nRESULT) or signal an error of type `jsonrpc-error'.\n\n:NOTIFICATION-DISPATCHER (optional), a function of three\narguments (CONN METHOD PARAMS) for handling JSONRPC\nnotifications. CONN, METHOD and PARAMS are the same as in\n:REQUEST-DISPATCHER.") cl-generic-define-method jsonrpc--next-request-id ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -next-request-id eieio-oref] 4 "Retrieve the slot `-next-request-id' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--next-request-id\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -next-request-id] 6 "\n\n(fn VALUE THIS)"] jsonrpc--deferred-actions ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -deferred-actions eieio-oref] 4 "Retrieve the slot `-deferred-actions' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--deferred-actions\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -deferred-actions] 6 "\n\n(fn VALUE THIS)"] jsonrpc--events-buffer-scrollback-size ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -events-buffer-scrollback-size eieio-oref] 4 "Retrieve the slot `-events-buffer-scrollback-size' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--events-buffer-scrollback-size\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -events-buffer-scrollback-size] 6 "\n\n(fn VALUE THIS)"] jsonrpc--events-buffer ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -events-buffer eieio-oref] 4 "Retrieve the slot `-events-buffer' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--events-buffer\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -events-buffer] 6 "\n\n(fn VALUE THIS)"] jsonrpc--request-continuations ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -request-continuations eieio-oref] 4 "Retrieve the slot `-request-continuations' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--request-continuations\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -request-continuations] 6 "\n\n(fn VALUE THIS)"] jsonrpc-last-error ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp last-error eieio-oref] 4 "Retrieve the slot `last-error' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc-last-error\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset last-error] 6 "\n\n(fn VALUE THIS)"] jsonrpc--notification-dispatcher ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -notification-dispatcher eieio-oref] 4 "Retrieve the slot `-notification-dispatcher' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--notification-dispatcher\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -notification-dispatcher] 6 "\n\n(fn VALUE THIS)"] jsonrpc--request-dispatcher ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp -request-dispatcher eieio-oref] 4 "Retrieve the slot `-request-dispatcher' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc--request-dispatcher\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset -request-dispatcher] 6 "\n\n(fn VALUE THIS)"] jsonrpc-name ((this jsonrpc-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp name eieio-oref] 4 "Retrieve the slot `name' from an object of class `jsonrpc-connection'.\n\n(fn THIS)"] \(setf\ jsonrpc-name\) (value (this jsonrpc-connection)) #[514 "\300\301#\207" [eieio-oset name] 6 "\n\n(fn VALUE THIS)"]] 7) #@75 Create a new object of class type `jsonrpc-connection'. (fn &rest SLOTS) (defalias 'jsonrpc-connection #[128 "\300\301\302#\207" [apply make-instance jsonrpc-connection] 5 (#$ . 7169)]) (byte-code "\300\301\302\303#\300\207" [function-put jsonrpc-connection compiler-macro jsonrpc-connection--anon-cmacro] 4) #@26 (fn WHOLE &rest SLOTS) (defalias 'jsonrpc-connection--anon-cmacro #[385 "\211@;\204 \207\300\301\302@@#@\303@DABB\"\207" [macroexp--warn-and-return format "Obsolete name arg %S to constructor %S" identity] 7 (#$ . 7486)]) (byte-code "\300\301\302\301\303\304#\305#\210\300\306\302\306\307\304#\310#\210\300\311\302\311\312\304#\313#\210\300\314\302\314\315\304#\316#\210\317\314\304\320\304\321%\207" [defalias jsonrpc-connection-send cl-generic-define (conn &key id method params result error) nil "Send a JSONRPC message to connection CONN.\nID, METHOD, PARAMS, RESULT and ERROR.\n\n(fn CONN &key ID METHOD PARAMS RESULT ERROR)" jsonrpc-shutdown (conn) "Shutdown the JSONRPC connection CONN.\n\n(fn CONN)" jsonrpc-running-p (conn) "Tell if the JSONRPC connection CONN is still running.\n\n(fn CONN)" jsonrpc-connection-ready-p (connection what) "Tell if CONNECTION is ready for WHAT in current buffer.\nIf it isn't, a request which was passed a value to the\n`:deferred' keyword argument will be deferred to the future.\nWHAT is whatever was passed the as the value to that argument.\n\nBy default, all connections are ready for sending all requests\nimmediately.\n\n(fn CONNECTION WHAT)" cl-generic-define-method (_s _what) #[514 "\300\207" [t] 3 "\n\n(fn S WHAT)"]] 6) #@34 (fn CL-LAMBDA-LIST &body BODY) (defalias 'jsonrpc-lambda '(macro . #[385 "\300\301!\302C\303\304\302BBDEE\207" [cl-gensym "jsonrpc-lambda-elem" lambda apply cl-function] 10 (#$ . 8774)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put jsonrpc-lambda lisp-indent-function 1 put edebug-form-spec (sexp &rest form)] 5) #@70 Get or create JSONRPC events buffer for CONNECTION. (fn CONNECTION) (defalias 'jsonrpc-events-buffer #[257 "\300!\301!\203 \211\206+ \302\303\304\305!\"!r\211q\210\306 \210\307\310!\210\311\"\266)\211\262\207" [jsonrpc--events-buffer buffer-live-p get-buffer-create format "*%s events*" jsonrpc-name buffer-disable-undo read-only-mode t \(setf\ jsonrpc--events-buffer\)] 7 (#$ . 9123)]) #@82 Stop waiting for responses from the current JSONRPC CONNECTION. (fn CONNECTION) (defalias 'jsonrpc-forget-pending-continuations #[257 "\300\301!!\207" [clrhash jsonrpc--request-continuations] 4 (#$ . 9526)]) #@163 Process MESSAGE just received from CONNECTION. This function will destructure MESSAGE and call the appropriate dispatcher in CONNECTION. (fn CONNECTION MESSAGE) (defalias 'jsonrpc-connection-receive #[514 "\211\301\302\"A@\301\303\"A@\301\304\"A@\301\305\"A@\301\306\"A@\301\307\"A@\211\203S \211@\310>\203; \211AA\262\202( \311>A@\203J \312\262\202( \313\314@\"\210\202( \210\312\315\n\n\316#\210 \317\"\266\203\301 \203\301 \205v \320 ?\3211\260 \3221\222 \306\323!\324\n!#D0\202\254 \304\325\326\327A\"\206\235 \330\331\326\332A\"\206\250 \333FD\2620\202\263 \334\262\335\336\f $\210)\210\202\203\327 \337\n!\n\324 !#\210\202\205\343 \340\341\f!\"\211\262\203\3428\211\203\364 \343!\210\210\344\341\f!\"\210\203\211A@!\210\202\211@!\210\345\n!\262\207" [debug-on-error plist-member :method :id :error :params :result :jsonrpc (:method :id :error :params :result :jsonrpc :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:method :id :error :params :result :jsonrpc)" jsonrpc--log-event server \(setf\ jsonrpc-last-error\) ert-running-test (debug error) (jsonrpc-error) jsonrpc--request-dispatcher intern :code alist-get jsonrpc-error-code -32603 :message jsonrpc-error-message "Internal error" (:error (:code -32603 :message "Internal error")) apply jsonrpc--reply jsonrpc--notification-dispatcher gethash jsonrpc--request-continuations 2 cancel-timer remhash jsonrpc--call-deferred] 18 (#$ . 9743)]) #@452 Error out with FORMAT and ARGS. If invoked inside a dispatcher function, this function is suitable for replying to the remote endpoint with an error message. ARGS can be of the form (FORMAT-STRING . MOREARGS) for replying with a -32603 error code and a message formed by formatting FORMAT-STRING with MOREARGS. Alternatively ARGS can be plist representing a JSONRPC error object, using the keywords `:code', `:message' and `:data'. (fn &rest ARGS) (defalias 'jsonrpc-error #[128 "\211@;\203 \300\301@A#\302\303\304\305B\306BE\"\207\211\307\310\"A@\307\311\"A@\307\312\"A@\211\203W \211@\313>\203@ \211AA\262\202- \314>A@\203N \315\262\202- \316\317@\"\210\202- \210\302\303\320\321!\304B\306B\322BF\"\207" [apply format-message signal jsonrpc-error jsonrpc-error-code 32603 jsonrpc-error-message plist-member :code :message :data (:code :message :data :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:code :message :data)" format "[jsonrpc] error " jsonrpc-error-data] 12 (#$ . 11258)]) #@1007 Make a request to CONNECTION, expecting a reply, return immediately. The JSONRPC request is formed by METHOD, a symbol, and PARAMS a JSON object. The caller can expect SUCCESS-FN or ERROR-FN to be called with a JSONRPC `:result' or `:error' object, respectively. If this doesn't happen after TIMEOUT seconds (defaults to `jrpc-default-request-timeout'), the caller can expect TIMEOUT-FN to be called with no arguments. The default values of SUCCESS-FN, ERROR-FN and TIMEOUT-FN simply log the events into `jsonrpc-events-buffer'. If DEFERRED is non-nil, maybe defer the request to a future time when the server is thought to be ready according to `jsonrpc-connection-ready-p' (which see). The request might never be sent at all, in case it is overridden in the meantime by a new request with identical DEFERRED and for the same buffer. However, in that situation, the original timeout is kept. Returns nil. (fn CONNECTION METHOD PARAMS &rest ARGS &key SUCCESS-FN ERROR-FN TIMEOUT-FN TIMEOUT DEFERRED) (defalias 'jsonrpc-async-request #[899 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\300\305\"A@\211\203J \211@\306>\2032 \211AA\262\202 \307>A@\203A \310\262\202 \311\312@\"\210\202 \210\313\314\n\n\n\n%\210\310\207" [plist-member :success-fn :error-fn :timeout-fn :timeout :deferred (:success-fn :error-fn :timeout-fn :timeout :deferred :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:success-fn :error-fn :timeout-fn :timeout :deferred)" apply jsonrpc--async-request-1] 15 (#$ . 12307)]) #@831 Make a request to CONNECTION, wait for a reply. Like `jsonrpc-async-request' for CONNECTION, METHOD and PARAMS, but synchronous. Except in the case of a non-nil CANCEL-ON-INPUT (explained below), this function doesn't exit until anything interesting happens (success reply, error reply, or timeout). Furthermore, it only exits locally (returning the JSONRPC result object) if the request is successful, otherwise it exits non-locally with an error of type `jsonrpc-error'. DEFERRED is passed to `jsonrpc-async-request', which see. If CANCEL-ON-INPUT is non-nil and the user inputs something while the functino is waiting, then it exits immediately, returning CANCEL-ON-INPUT-RETVAL. Any future replies (normal or error) are ignored. (fn CONNECTION METHOD PARAMS &key DEFERRED TIMEOUT CANCEL-ON-INPUT CANCEL-ON-INPUT-RETVAL) (defalias 'jsonrpc-request #[899 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\211\203D \211@\305>\203, \211AA\262\202 \306>A@\203; \307\262\202 \310\311@\"\210\202 \210\312\313!\307C\307C\314\315\316\317\320\f#\321\"\322$\2162\277 \323\f\f\f\324\314\325\326\317\320 \f\"\327\"\330\331%\332\314\325\333\317\320\"\334\"\335\336%\337\314\315\340\317\320\"\341\"\342$\301\302& \240\210\203\266 \343\344!\204\246 \211\345\240\210\346D\202\276 \347\307\344\"\210\202\266 0)\211@\310=\203\325 \350\351\352\353\242@\"AB\"\210\211A@\266\204\207" [plist-member :deferred :timeout :cancel-on-input :cancel-on-input-retval (:deferred :timeout :cancel-on-input :cancel-on-input-retval . #1=(:allow-other-keys)) :allow-other-keys nil error "Keyword argument %s not one of (:deferred :timeout :cancel-on-input :cancel-on-input-retval)" cl-gensym "jsonrpc-request-catch-tag" make-byte-code 0 "\302\242@\302\242A\211@A\303\304\300!\"\210\303\301pD\305\300!\"\210\205# \306!\266\202\207" vconcat vector [remhash jsonrpc--request-continuations jsonrpc--deferred-actions cancel-timer] 10 jsonrpc--async-request-1 :success-fn 257 "\301\242?\205\f \302\300\303D\"\207" [throw done] 5 "\n\n(fn RESULT)" :error-fn "\302\303\304\305\306\307\300\301\"\310\"\311\312%\"\207" [apply make-byte-code 128 "\302\303\"A@\302\304\"A@\302\305\"A@\211\203= \211@\306>\203&