soap-client: Add byte-code compatibility function (Bug#31742)
* lisp/net/soap-client.el: Bump version to 3.1.4.
(soap-type-of): New function.
(soap-resolve-references, soap-decode-type)
(soap-encode-attributes, soap-encode-value): Replace aref
calls with calls to soap-type-of.
* lisp/net/soap-inspect.el (soap-sample-value, soap-inspect):
Replace aref calls with calls to soap-type-of.
Co-authored-by: Noam Postavsky <npostavs@gmail.com>
Backport: (cherry picked from commit
1feb2e2213
)
This commit is contained in:
parent
9c6f35a6b2
commit
642c11fdd1
2 changed files with 51 additions and 41 deletions
|
@ -5,7 +5,7 @@
|
||||||
;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com>
|
;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com>
|
||||||
;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
|
;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
|
||||||
;; Created: December, 2009
|
;; Created: December, 2009
|
||||||
;; Version: 3.1.3
|
;; Version: 3.1.4
|
||||||
;; Keywords: soap, web-services, comm, hypermedia
|
;; Keywords: soap, web-services, comm, hypermedia
|
||||||
;; Package: soap-client
|
;; Package: soap-client
|
||||||
;; Homepage: https://github.com/alex-hhh/emacs-soap-client
|
;; Homepage: https://github.com/alex-hhh/emacs-soap-client
|
||||||
|
@ -685,8 +685,17 @@ This is a specialization of `soap-decode-type' for
|
||||||
(anyType (soap-decode-any-type node))
|
(anyType (soap-decode-any-type node))
|
||||||
(Array (soap-decode-array node))))))
|
(Array (soap-decode-array node))))))
|
||||||
|
|
||||||
|
(defun soap-type-of (element)
|
||||||
|
"Return the type of ELEMENT."
|
||||||
|
;; Support Emacs < 26 byte-code running in Emacs >= 26 sessions
|
||||||
|
;; (Bug#31742).
|
||||||
|
(let ((type (type-of element)))
|
||||||
|
(if (eq type 'vector)
|
||||||
|
(aref element 0) ; For Emacs 25 and earlier.
|
||||||
|
type)))
|
||||||
|
|
||||||
;; Register methods for `soap-xs-basic-type'
|
;; Register methods for `soap-xs-basic-type'
|
||||||
(let ((tag (aref (make-soap-xs-basic-type) 0)))
|
(let ((tag (soap-type-of (make-soap-xs-basic-type))))
|
||||||
(put tag 'soap-attribute-encoder #'soap-encode-xs-basic-type-attributes)
|
(put tag 'soap-attribute-encoder #'soap-encode-xs-basic-type-attributes)
|
||||||
(put tag 'soap-encoder #'soap-encode-xs-basic-type)
|
(put tag 'soap-encoder #'soap-encode-xs-basic-type)
|
||||||
(put tag 'soap-decoder #'soap-decode-xs-basic-type))
|
(put tag 'soap-decoder #'soap-decode-xs-basic-type))
|
||||||
|
@ -915,7 +924,7 @@ This is a specialization of `soap-decode-type' for
|
||||||
(soap-decode-type type node)))
|
(soap-decode-type type node)))
|
||||||
|
|
||||||
;; Register methods for `soap-xs-element'
|
;; Register methods for `soap-xs-element'
|
||||||
(let ((tag (aref (make-soap-xs-element) 0)))
|
(let ((tag (soap-type-of (make-soap-xs-element))))
|
||||||
(put tag 'soap-resolve-references #'soap-resolve-references-for-xs-element)
|
(put tag 'soap-resolve-references #'soap-resolve-references-for-xs-element)
|
||||||
(put tag 'soap-attribute-encoder #'soap-encode-xs-element-attributes)
|
(put tag 'soap-attribute-encoder #'soap-encode-xs-element-attributes)
|
||||||
(put tag 'soap-encoder #'soap-encode-xs-element)
|
(put tag 'soap-encoder #'soap-encode-xs-element)
|
||||||
|
@ -1011,7 +1020,7 @@ See also `soap-wsdl-resolve-references'."
|
||||||
(setf (soap-xs-attribute-reference attribute)
|
(setf (soap-xs-attribute-reference attribute)
|
||||||
(soap-wsdl-get reference wsdl predicate)))))
|
(soap-wsdl-get reference wsdl predicate)))))
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute) 0)
|
(put (soap-type-of (make-soap-xs-attribute))
|
||||||
'soap-resolve-references #'soap-resolve-references-for-xs-attribute)
|
'soap-resolve-references #'soap-resolve-references-for-xs-attribute)
|
||||||
|
|
||||||
(defun soap-resolve-references-for-xs-attribute-group (attribute-group wsdl)
|
(defun soap-resolve-references-for-xs-attribute-group (attribute-group wsdl)
|
||||||
|
@ -1036,7 +1045,7 @@ See also `soap-wsdl-resolve-references'."
|
||||||
(setf (soap-xs-attribute-group-attribute-groups attribute-group)
|
(setf (soap-xs-attribute-group-attribute-groups attribute-group)
|
||||||
(soap-xs-attribute-group-attribute-groups resolved))))))
|
(soap-xs-attribute-group-attribute-groups resolved))))))
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute-group) 0)
|
(put (soap-type-of (make-soap-xs-attribute-group))
|
||||||
'soap-resolve-references #'soap-resolve-references-for-xs-attribute-group)
|
'soap-resolve-references #'soap-resolve-references-for-xs-attribute-group)
|
||||||
|
|
||||||
;;;;; soap-xs-simple-type
|
;;;;; soap-xs-simple-type
|
||||||
|
@ -1374,7 +1383,7 @@ This is a specialization of `soap-decode-type' for
|
||||||
(soap-validate-xs-simple-type value type))))
|
(soap-validate-xs-simple-type value type))))
|
||||||
|
|
||||||
;; Register methods for `soap-xs-simple-type'
|
;; Register methods for `soap-xs-simple-type'
|
||||||
(let ((tag (aref (make-soap-xs-simple-type) 0)))
|
(let ((tag (soap-type-of (make-soap-xs-simple-type))))
|
||||||
(put tag 'soap-resolve-references
|
(put tag 'soap-resolve-references
|
||||||
#'soap-resolve-references-for-xs-simple-type)
|
#'soap-resolve-references-for-xs-simple-type)
|
||||||
(put tag 'soap-attribute-encoder #'soap-encode-xs-simple-type-attributes)
|
(put tag 'soap-attribute-encoder #'soap-encode-xs-simple-type-attributes)
|
||||||
|
@ -1927,7 +1936,7 @@ This is a specialization of `soap-decode-type' for
|
||||||
(soap-xs-complex-type-indicator type)))))
|
(soap-xs-complex-type-indicator type)))))
|
||||||
|
|
||||||
;; Register methods for `soap-xs-complex-type'
|
;; Register methods for `soap-xs-complex-type'
|
||||||
(let ((tag (aref (make-soap-xs-complex-type) 0)))
|
(let ((tag (soap-type-of (make-soap-xs-complex-type))))
|
||||||
(put tag 'soap-resolve-references
|
(put tag 'soap-resolve-references
|
||||||
#'soap-resolve-references-for-xs-complex-type)
|
#'soap-resolve-references-for-xs-complex-type)
|
||||||
(put tag 'soap-attribute-encoder #'soap-encode-xs-complex-type-attributes)
|
(put tag 'soap-attribute-encoder #'soap-encode-xs-complex-type-attributes)
|
||||||
|
@ -2147,7 +2156,7 @@ This is a generic function which invokes a specific resolver
|
||||||
function depending on the type of the ELEMENT.
|
function depending on the type of the ELEMENT.
|
||||||
|
|
||||||
If ELEMENT has no resolver function, it is silently ignored."
|
If ELEMENT has no resolver function, it is silently ignored."
|
||||||
(let ((resolver (get (aref element 0) 'soap-resolve-references)))
|
(let ((resolver (get (soap-type-of element) 'soap-resolve-references)))
|
||||||
(when resolver
|
(when resolver
|
||||||
(funcall resolver element wsdl))))
|
(funcall resolver element wsdl))))
|
||||||
|
|
||||||
|
@ -2272,13 +2281,13 @@ See also `soap-wsdl-resolve-references'."
|
||||||
|
|
||||||
;; Install resolvers for our types
|
;; Install resolvers for our types
|
||||||
(progn
|
(progn
|
||||||
(put (aref (make-soap-message) 0) 'soap-resolve-references
|
(put (soap-type-of (make-soap-message)) 'soap-resolve-references
|
||||||
'soap-resolve-references-for-message)
|
'soap-resolve-references-for-message)
|
||||||
(put (aref (make-soap-operation) 0) 'soap-resolve-references
|
(put (soap-type-of (make-soap-operation)) 'soap-resolve-references
|
||||||
'soap-resolve-references-for-operation)
|
'soap-resolve-references-for-operation)
|
||||||
(put (aref (make-soap-binding) 0) 'soap-resolve-references
|
(put (soap-type-of (make-soap-binding)) 'soap-resolve-references
|
||||||
'soap-resolve-references-for-binding)
|
'soap-resolve-references-for-binding)
|
||||||
(put (aref (make-soap-port) 0) 'soap-resolve-references
|
(put (soap-type-of (make-soap-port)) 'soap-resolve-references
|
||||||
'soap-resolve-references-for-port))
|
'soap-resolve-references-for-port))
|
||||||
|
|
||||||
(defun soap-wsdl-resolve-references (wsdl)
|
(defun soap-wsdl-resolve-references (wsdl)
|
||||||
|
@ -2685,16 +2694,17 @@ decode function to perform the actual decoding."
|
||||||
(cond ((listp type)
|
(cond ((listp type)
|
||||||
(catch 'done
|
(catch 'done
|
||||||
(dolist (union-member type)
|
(dolist (union-member type)
|
||||||
(let* ((decoder (get (aref union-member 0)
|
(let* ((decoder (get (soap-type-of union-member)
|
||||||
'soap-decoder))
|
'soap-decoder))
|
||||||
(result (ignore-errors
|
(result (ignore-errors
|
||||||
(funcall decoder
|
(funcall decoder
|
||||||
union-member node))))
|
union-member node))))
|
||||||
(when result (throw 'done result))))))
|
(when result (throw 'done result))))))
|
||||||
(t
|
(t
|
||||||
(let ((decoder (get (aref type 0) 'soap-decoder)))
|
(let ((decoder (get (soap-type-of type) 'soap-decoder)))
|
||||||
(cl-assert decoder nil
|
(cl-assert decoder nil
|
||||||
"no soap-decoder for %s type" (aref type 0))
|
"no soap-decoder for %s type"
|
||||||
|
(soap-type-of type))
|
||||||
(funcall decoder type node))))))))))
|
(funcall decoder type node))))))))))
|
||||||
|
|
||||||
(defun soap-decode-any-type (node)
|
(defun soap-decode-any-type (node)
|
||||||
|
@ -2878,9 +2888,9 @@ for the type and calls that specialized function to do the work.
|
||||||
|
|
||||||
Attributes are inserted in the current buffer at the current
|
Attributes are inserted in the current buffer at the current
|
||||||
position."
|
position."
|
||||||
(let ((attribute-encoder (get (aref type 0) 'soap-attribute-encoder)))
|
(let ((attribute-encoder (get (soap-type-of type) 'soap-attribute-encoder)))
|
||||||
(cl-assert attribute-encoder nil
|
(cl-assert attribute-encoder nil
|
||||||
"no soap-attribute-encoder for %s type" (aref type 0))
|
"no soap-attribute-encoder for %s type" (soap-type-of type))
|
||||||
(funcall attribute-encoder value type)))
|
(funcall attribute-encoder value type)))
|
||||||
|
|
||||||
(defun soap-encode-value (value type)
|
(defun soap-encode-value (value type)
|
||||||
|
@ -2892,8 +2902,8 @@ TYPE is one of the soap-*-type structures which defines how VALUE
|
||||||
is to be encoded. This is a generic function which finds an
|
is to be encoded. This is a generic function which finds an
|
||||||
encoder function based on TYPE and calls that encoder to do the
|
encoder function based on TYPE and calls that encoder to do the
|
||||||
work."
|
work."
|
||||||
(let ((encoder (get (aref type 0) 'soap-encoder)))
|
(let ((encoder (get (soap-type-of type) 'soap-encoder)))
|
||||||
(cl-assert encoder nil "no soap-encoder for %s type" (aref type 0))
|
(cl-assert encoder nil "no soap-encoder for %s type" (soap-type-of type))
|
||||||
(funcall encoder value type))
|
(funcall encoder value type))
|
||||||
(when (soap-element-namespace-tag type)
|
(when (soap-element-namespace-tag type)
|
||||||
(add-to-list 'soap-encoded-namespaces (soap-element-namespace-tag type))))
|
(add-to-list 'soap-encoded-namespaces (soap-element-namespace-tag type))))
|
||||||
|
|
|
@ -49,10 +49,10 @@ for encoding it using TYPE when making SOAP requests.
|
||||||
|
|
||||||
This is a generic function, depending on TYPE a specific function
|
This is a generic function, depending on TYPE a specific function
|
||||||
will be called."
|
will be called."
|
||||||
(let ((sample-value (get (aref type 0) 'soap-sample-value)))
|
(let ((sample-value (get (soap-type-of type) 'soap-sample-value)))
|
||||||
(if sample-value
|
(if sample-value
|
||||||
(funcall sample-value type)
|
(funcall sample-value type)
|
||||||
(error "Cannot provide sample value for type %s" (aref type 0)))))
|
(error "Cannot provide sample value for type %s" (soap-type-of type)))))
|
||||||
|
|
||||||
(defun soap-sample-value-for-xs-basic-type (type)
|
(defun soap-sample-value-for-xs-basic-type (type)
|
||||||
"Provide a sample value for TYPE, an xs-basic-type.
|
"Provide a sample value for TYPE, an xs-basic-type.
|
||||||
|
@ -174,31 +174,31 @@ This is a specialization of `soap-sample-value' for
|
||||||
|
|
||||||
(progn
|
(progn
|
||||||
;; Install soap-sample-value methods for our types
|
;; Install soap-sample-value methods for our types
|
||||||
(put (aref (make-soap-xs-basic-type) 0)
|
(put (soap-type-of (make-soap-xs-basic-type))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-basic-type)
|
'soap-sample-value-for-xs-basic-type)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-element) 0)
|
(put (soap-type-of (make-soap-xs-element))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-element)
|
'soap-sample-value-for-xs-element)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute) 0)
|
(put (soap-type-of (make-soap-xs-attribute))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-attribute)
|
'soap-sample-value-for-xs-attribute)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute) 0)
|
(put (soap-type-of (make-soap-xs-attribute))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-attribute-group)
|
'soap-sample-value-for-xs-attribute-group)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-simple-type) 0)
|
(put (soap-type-of (make-soap-xs-simple-type))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-simple-type)
|
'soap-sample-value-for-xs-simple-type)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-complex-type) 0)
|
(put (soap-type-of (make-soap-xs-complex-type))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-xs-complex-type)
|
'soap-sample-value-for-xs-complex-type)
|
||||||
|
|
||||||
(put (aref (make-soap-message) 0)
|
(put (soap-type-of (make-soap-message))
|
||||||
'soap-sample-value
|
'soap-sample-value
|
||||||
'soap-sample-value-for-message))
|
'soap-sample-value-for-message))
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ Used to implement the BACK button.")
|
||||||
The buffer is populated with information about ELEMENT with links
|
The buffer is populated with information about ELEMENT with links
|
||||||
to its sub elements. If ELEMENT is the WSDL document itself, the
|
to its sub elements. If ELEMENT is the WSDL document itself, the
|
||||||
entire WSDL can be inspected."
|
entire WSDL can be inspected."
|
||||||
(let ((inspect (get (aref element 0) 'soap-inspect)))
|
(let ((inspect (get (soap-type-of element) 'soap-inspect)))
|
||||||
(unless inspect
|
(unless inspect
|
||||||
(error "Soap-inspect: no inspector for element"))
|
(error "Soap-inspect: no inspector for element"))
|
||||||
|
|
||||||
|
@ -507,39 +507,39 @@ TYPE is a `soap-xs-complex-type'"
|
||||||
(progn
|
(progn
|
||||||
;; Install the soap-inspect methods for our types
|
;; Install the soap-inspect methods for our types
|
||||||
|
|
||||||
(put (aref (make-soap-xs-basic-type) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-basic-type)) 'soap-inspect
|
||||||
'soap-inspect-xs-basic-type)
|
'soap-inspect-xs-basic-type)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-element) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-element)) 'soap-inspect
|
||||||
'soap-inspect-xs-element)
|
'soap-inspect-xs-element)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-simple-type) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-simple-type)) 'soap-inspect
|
||||||
'soap-inspect-xs-simple-type)
|
'soap-inspect-xs-simple-type)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-complex-type) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-complex-type)) 'soap-inspect
|
||||||
'soap-inspect-xs-complex-type)
|
'soap-inspect-xs-complex-type)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-attribute)) 'soap-inspect
|
||||||
'soap-inspect-xs-attribute)
|
'soap-inspect-xs-attribute)
|
||||||
|
|
||||||
(put (aref (make-soap-xs-attribute-group) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-xs-attribute-group)) 'soap-inspect
|
||||||
'soap-inspect-xs-attribute-group)
|
'soap-inspect-xs-attribute-group)
|
||||||
|
|
||||||
(put (aref (make-soap-message) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-message)) 'soap-inspect
|
||||||
'soap-inspect-message)
|
'soap-inspect-message)
|
||||||
(put (aref (make-soap-operation) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-operation)) 'soap-inspect
|
||||||
'soap-inspect-operation)
|
'soap-inspect-operation)
|
||||||
|
|
||||||
(put (aref (make-soap-port-type) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-port-type)) 'soap-inspect
|
||||||
'soap-inspect-port-type)
|
'soap-inspect-port-type)
|
||||||
|
|
||||||
(put (aref (make-soap-binding) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-binding)) 'soap-inspect
|
||||||
'soap-inspect-binding)
|
'soap-inspect-binding)
|
||||||
|
|
||||||
(put (aref (make-soap-port) 0) 'soap-inspect
|
(put (soap-type-of (make-soap-port)) 'soap-inspect
|
||||||
'soap-inspect-port)
|
'soap-inspect-port)
|
||||||
|
|
||||||
(put (aref (soap-make-wsdl "origin") 0) 'soap-inspect
|
(put (soap-type-of (soap-make-wsdl "origin")) 'soap-inspect
|
||||||
'soap-inspect-wsdl))
|
'soap-inspect-wsdl))
|
||||||
|
|
||||||
(provide 'soap-inspect)
|
(provide 'soap-inspect)
|
||||||
|
|
Loading…
Add table
Reference in a new issue