diff options
| author | Thomas Fitzsimmons | 2018-06-08 22:41:28 -0400 |
|---|---|---|
| committer | Thomas Fitzsimmons | 2018-06-11 21:23:33 -0400 |
| commit | 1feb2e221349f26ec26bc684e0cce2acecbed3ca (patch) | |
| tree | a77fbc7bab5fe11175f181d0af4d3729c4ff3568 | |
| parent | 0626d5aba518a6d22ffacd7a1e3f4c70d7248e5f (diff) | |
| download | emacs-1feb2e221349f26ec26bc684e0cce2acecbed3ca.tar.gz emacs-1feb2e221349f26ec26bc684e0cce2acecbed3ca.zip | |
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>
| -rw-r--r-- | lisp/net/soap-client.el | 48 | ||||
| -rw-r--r-- | lisp/net/soap-inspect.el | 44 |
2 files changed, 51 insertions, 41 deletions
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el index 3996da0b554..17f83082f8d 100644 --- a/lisp/net/soap-client.el +++ b/lisp/net/soap-client.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com> | 5 | ;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com> |
| 6 | ;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org> | 6 | ;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org> |
| 7 | ;; Created: December, 2009 | 7 | ;; Created: December, 2009 |
| 8 | ;; Version: 3.1.3 | 8 | ;; Version: 3.1.4 |
| 9 | ;; Keywords: soap, web-services, comm, hypermedia | 9 | ;; Keywords: soap, web-services, comm, hypermedia |
| 10 | ;; Package: soap-client | 10 | ;; Package: soap-client |
| 11 | ;; Homepage: https://github.com/alex-hhh/emacs-soap-client | 11 | ;; Homepage: https://github.com/alex-hhh/emacs-soap-client |
| @@ -685,8 +685,17 @@ This is a specialization of `soap-decode-type' for | |||
| 685 | (anyType (soap-decode-any-type node)) | 685 | (anyType (soap-decode-any-type node)) |
| 686 | (Array (soap-decode-array node)))))) | 686 | (Array (soap-decode-array node)))))) |
| 687 | 687 | ||
| 688 | (defun soap-type-of (element) | ||
| 689 | "Return the type of ELEMENT." | ||
| 690 | ;; Support Emacs < 26 byte-code running in Emacs >= 26 sessions | ||
| 691 | ;; (Bug#31742). | ||
| 692 | (let ((type (type-of element))) | ||
| 693 | (if (eq type 'vector) | ||
| 694 | (aref element 0) ; For Emacs 25 and earlier. | ||
| 695 | type))) | ||
| 696 | |||
| 688 | ;; Register methods for `soap-xs-basic-type' | 697 | ;; Register methods for `soap-xs-basic-type' |
| 689 | (let ((tag (aref (make-soap-xs-basic-type) 0))) | 698 | (let ((tag (soap-type-of (make-soap-xs-basic-type)))) |
| 690 | (put tag 'soap-attribute-encoder #'soap-encode-xs-basic-type-attributes) | 699 | (put tag 'soap-attribute-encoder #'soap-encode-xs-basic-type-attributes) |
| 691 | (put tag 'soap-encoder #'soap-encode-xs-basic-type) | 700 | (put tag 'soap-encoder #'soap-encode-xs-basic-type) |
| 692 | (put tag 'soap-decoder #'soap-decode-xs-basic-type)) | 701 | (put tag 'soap-decoder #'soap-decode-xs-basic-type)) |
| @@ -915,7 +924,7 @@ This is a specialization of `soap-decode-type' for | |||
| 915 | (soap-decode-type type node))) | 924 | (soap-decode-type type node))) |
| 916 | 925 | ||
| 917 | ;; Register methods for `soap-xs-element' | 926 | ;; Register methods for `soap-xs-element' |
| 918 | (let ((tag (aref (make-soap-xs-element) 0))) | 927 | (let ((tag (soap-type-of (make-soap-xs-element)))) |
| 919 | (put tag 'soap-resolve-references #'soap-resolve-references-for-xs-element) | 928 | (put tag 'soap-resolve-references #'soap-resolve-references-for-xs-element) |
| 920 | (put tag 'soap-attribute-encoder #'soap-encode-xs-element-attributes) | 929 | (put tag 'soap-attribute-encoder #'soap-encode-xs-element-attributes) |
| 921 | (put tag 'soap-encoder #'soap-encode-xs-element) | 930 | (put tag 'soap-encoder #'soap-encode-xs-element) |
| @@ -1011,7 +1020,7 @@ See also `soap-wsdl-resolve-references'." | |||
| 1011 | (setf (soap-xs-attribute-reference attribute) | 1020 | (setf (soap-xs-attribute-reference attribute) |
| 1012 | (soap-wsdl-get reference wsdl predicate))))) | 1021 | (soap-wsdl-get reference wsdl predicate))))) |
| 1013 | 1022 | ||
| 1014 | (put (aref (make-soap-xs-attribute) 0) | 1023 | (put (soap-type-of (make-soap-xs-attribute)) |
| 1015 | 'soap-resolve-references #'soap-resolve-references-for-xs-attribute) | 1024 | 'soap-resolve-references #'soap-resolve-references-for-xs-attribute) |
| 1016 | 1025 | ||
| 1017 | (defun soap-resolve-references-for-xs-attribute-group (attribute-group wsdl) | 1026 | (defun soap-resolve-references-for-xs-attribute-group (attribute-group wsdl) |
| @@ -1036,7 +1045,7 @@ See also `soap-wsdl-resolve-references'." | |||
| 1036 | (setf (soap-xs-attribute-group-attribute-groups attribute-group) | 1045 | (setf (soap-xs-attribute-group-attribute-groups attribute-group) |
| 1037 | (soap-xs-attribute-group-attribute-groups resolved)))))) | 1046 | (soap-xs-attribute-group-attribute-groups resolved)))))) |
| 1038 | 1047 | ||
| 1039 | (put (aref (make-soap-xs-attribute-group) 0) | 1048 | (put (soap-type-of (make-soap-xs-attribute-group)) |
| 1040 | 'soap-resolve-references #'soap-resolve-references-for-xs-attribute-group) | 1049 | 'soap-resolve-references #'soap-resolve-references-for-xs-attribute-group) |
| 1041 | 1050 | ||
| 1042 | ;;;;; soap-xs-simple-type | 1051 | ;;;;; soap-xs-simple-type |
| @@ -1374,7 +1383,7 @@ This is a specialization of `soap-decode-type' for | |||
| 1374 | (soap-validate-xs-simple-type value type)))) | 1383 | (soap-validate-xs-simple-type value type)))) |
| 1375 | 1384 | ||
| 1376 | ;; Register methods for `soap-xs-simple-type' | 1385 | ;; Register methods for `soap-xs-simple-type' |
| 1377 | (let ((tag (aref (make-soap-xs-simple-type) 0))) | 1386 | (let ((tag (soap-type-of (make-soap-xs-simple-type)))) |
| 1378 | (put tag 'soap-resolve-references | 1387 | (put tag 'soap-resolve-references |
| 1379 | #'soap-resolve-references-for-xs-simple-type) | 1388 | #'soap-resolve-references-for-xs-simple-type) |
| 1380 | (put tag 'soap-attribute-encoder #'soap-encode-xs-simple-type-attributes) | 1389 | (put tag 'soap-attribute-encoder #'soap-encode-xs-simple-type-attributes) |
| @@ -1927,7 +1936,7 @@ This is a specialization of `soap-decode-type' for | |||
| 1927 | (soap-xs-complex-type-indicator type))))) | 1936 | (soap-xs-complex-type-indicator type))))) |
| 1928 | 1937 | ||
| 1929 | ;; Register methods for `soap-xs-complex-type' | 1938 | ;; Register methods for `soap-xs-complex-type' |
| 1930 | (let ((tag (aref (make-soap-xs-complex-type) 0))) | 1939 | (let ((tag (soap-type-of (make-soap-xs-complex-type)))) |
| 1931 | (put tag 'soap-resolve-references | 1940 | (put tag 'soap-resolve-references |
| 1932 | #'soap-resolve-references-for-xs-complex-type) | 1941 | #'soap-resolve-references-for-xs-complex-type) |
| 1933 | (put tag 'soap-attribute-encoder #'soap-encode-xs-complex-type-attributes) | 1942 | (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 | |||
| 2147 | function depending on the type of the ELEMENT. | 2156 | function depending on the type of the ELEMENT. |
| 2148 | 2157 | ||
| 2149 | If ELEMENT has no resolver function, it is silently ignored." | 2158 | If ELEMENT has no resolver function, it is silently ignored." |
| 2150 | (let ((resolver (get (aref element 0) 'soap-resolve-references))) | 2159 | (let ((resolver (get (soap-type-of element) 'soap-resolve-references))) |
| 2151 | (when resolver | 2160 | (when resolver |
| 2152 | (funcall resolver element wsdl)))) | 2161 | (funcall resolver element wsdl)))) |
| 2153 | 2162 | ||
| @@ -2272,13 +2281,13 @@ See also `soap-wsdl-resolve-references'." | |||
| 2272 | 2281 | ||
| 2273 | ;; Install resolvers for our types | 2282 | ;; Install resolvers for our types |
| 2274 | (progn | 2283 | (progn |
| 2275 | (put (aref (make-soap-message) 0) 'soap-resolve-references | 2284 | (put (soap-type-of (make-soap-message)) 'soap-resolve-references |
| 2276 | 'soap-resolve-references-for-message) | 2285 | 'soap-resolve-references-for-message) |
| 2277 | (put (aref (make-soap-operation) 0) 'soap-resolve-references | 2286 | (put (soap-type-of (make-soap-operation)) 'soap-resolve-references |
| 2278 | 'soap-resolve-references-for-operation) | 2287 | 'soap-resolve-references-for-operation) |
| 2279 | (put (aref (make-soap-binding) 0) 'soap-resolve-references | 2288 | (put (soap-type-of (make-soap-binding)) 'soap-resolve-references |
| 2280 | 'soap-resolve-references-for-binding) | 2289 | 'soap-resolve-references-for-binding) |
| 2281 | (put (aref (make-soap-port) 0) 'soap-resolve-references | 2290 | (put (soap-type-of (make-soap-port)) 'soap-resolve-references |
| 2282 | 'soap-resolve-references-for-port)) | 2291 | 'soap-resolve-references-for-port)) |
| 2283 | 2292 | ||
| 2284 | (defun soap-wsdl-resolve-references (wsdl) | 2293 | (defun soap-wsdl-resolve-references (wsdl) |
| @@ -2685,16 +2694,17 @@ decode function to perform the actual decoding." | |||
| 2685 | (cond ((listp type) | 2694 | (cond ((listp type) |
| 2686 | (catch 'done | 2695 | (catch 'done |
| 2687 | (dolist (union-member type) | 2696 | (dolist (union-member type) |
| 2688 | (let* ((decoder (get (aref union-member 0) | 2697 | (let* ((decoder (get (soap-type-of union-member) |
| 2689 | 'soap-decoder)) | 2698 | 'soap-decoder)) |
| 2690 | (result (ignore-errors | 2699 | (result (ignore-errors |
| 2691 | (funcall decoder | 2700 | (funcall decoder |
| 2692 | union-member node)))) | 2701 | union-member node)))) |
| 2693 | (when result (throw 'done result)))))) | 2702 | (when result (throw 'done result)))))) |
| 2694 | (t | 2703 | (t |
| 2695 | (let ((decoder (get (aref type 0) 'soap-decoder))) | 2704 | (let ((decoder (get (soap-type-of type) 'soap-decoder))) |
| 2696 | (cl-assert decoder nil | 2705 | (cl-assert decoder nil |
| 2697 | "no soap-decoder for %s type" (aref type 0)) | 2706 | "no soap-decoder for %s type" |
| 2707 | (soap-type-of type)) | ||
| 2698 | (funcall decoder type node)))))))))) | 2708 | (funcall decoder type node)))))))))) |
| 2699 | 2709 | ||
| 2700 | (defun soap-decode-any-type (node) | 2710 | (defun soap-decode-any-type (node) |
| @@ -2878,9 +2888,9 @@ for the type and calls that specialized function to do the work. | |||
| 2878 | 2888 | ||
| 2879 | Attributes are inserted in the current buffer at the current | 2889 | Attributes are inserted in the current buffer at the current |
| 2880 | position." | 2890 | position." |
| 2881 | (let ((attribute-encoder (get (aref type 0) 'soap-attribute-encoder))) | 2891 | (let ((attribute-encoder (get (soap-type-of type) 'soap-attribute-encoder))) |
| 2882 | (cl-assert attribute-encoder nil | 2892 | (cl-assert attribute-encoder nil |
| 2883 | "no soap-attribute-encoder for %s type" (aref type 0)) | 2893 | "no soap-attribute-encoder for %s type" (soap-type-of type)) |
| 2884 | (funcall attribute-encoder value type))) | 2894 | (funcall attribute-encoder value type))) |
| 2885 | 2895 | ||
| 2886 | (defun soap-encode-value (value type) | 2896 | (defun soap-encode-value (value type) |
| @@ -2892,8 +2902,8 @@ TYPE is one of the soap-*-type structures which defines how VALUE | |||
| 2892 | is to be encoded. This is a generic function which finds an | 2902 | is to be encoded. This is a generic function which finds an |
| 2893 | encoder function based on TYPE and calls that encoder to do the | 2903 | encoder function based on TYPE and calls that encoder to do the |
| 2894 | work." | 2904 | work." |
| 2895 | (let ((encoder (get (aref type 0) 'soap-encoder))) | 2905 | (let ((encoder (get (soap-type-of type) 'soap-encoder))) |
| 2896 | (cl-assert encoder nil "no soap-encoder for %s type" (aref type 0)) | 2906 | (cl-assert encoder nil "no soap-encoder for %s type" (soap-type-of type)) |
| 2897 | (funcall encoder value type)) | 2907 | (funcall encoder value type)) |
| 2898 | (when (soap-element-namespace-tag type) | 2908 | (when (soap-element-namespace-tag type) |
| 2899 | (add-to-list 'soap-encoded-namespaces (soap-element-namespace-tag type)))) | 2909 | (add-to-list 'soap-encoded-namespaces (soap-element-namespace-tag type)))) |
diff --git a/lisp/net/soap-inspect.el b/lisp/net/soap-inspect.el index 050be453db3..252b1f35ff5 100644 --- a/lisp/net/soap-inspect.el +++ b/lisp/net/soap-inspect.el | |||
| @@ -49,10 +49,10 @@ for encoding it using TYPE when making SOAP requests. | |||
| 49 | 49 | ||
| 50 | This is a generic function, depending on TYPE a specific function | 50 | This is a generic function, depending on TYPE a specific function |
| 51 | will be called." | 51 | will be called." |
| 52 | (let ((sample-value (get (aref type 0) 'soap-sample-value))) | 52 | (let ((sample-value (get (soap-type-of type) 'soap-sample-value))) |
| 53 | (if sample-value | 53 | (if sample-value |
| 54 | (funcall sample-value type) | 54 | (funcall sample-value type) |
| 55 | (error "Cannot provide sample value for type %s" (aref type 0))))) | 55 | (error "Cannot provide sample value for type %s" (soap-type-of type))))) |
| 56 | 56 | ||
| 57 | (defun soap-sample-value-for-xs-basic-type (type) | 57 | (defun soap-sample-value-for-xs-basic-type (type) |
| 58 | "Provide a sample value for TYPE, an xs-basic-type. | 58 | "Provide a sample value for TYPE, an xs-basic-type. |
| @@ -174,31 +174,31 @@ This is a specialization of `soap-sample-value' for | |||
| 174 | 174 | ||
| 175 | (progn | 175 | (progn |
| 176 | ;; Install soap-sample-value methods for our types | 176 | ;; Install soap-sample-value methods for our types |
| 177 | (put (aref (make-soap-xs-basic-type) 0) | 177 | (put (soap-type-of (make-soap-xs-basic-type)) |
| 178 | 'soap-sample-value | 178 | 'soap-sample-value |
| 179 | 'soap-sample-value-for-xs-basic-type) | 179 | 'soap-sample-value-for-xs-basic-type) |
| 180 | 180 | ||
| 181 | (put (aref (make-soap-xs-element) 0) | 181 | (put (soap-type-of (make-soap-xs-element)) |
| 182 | 'soap-sample-value | 182 | 'soap-sample-value |
| 183 | 'soap-sample-value-for-xs-element) | 183 | 'soap-sample-value-for-xs-element) |
| 184 | 184 | ||
| 185 | (put (aref (make-soap-xs-attribute) 0) | 185 | (put (soap-type-of (make-soap-xs-attribute)) |
| 186 | 'soap-sample-value | 186 | 'soap-sample-value |
| 187 | 'soap-sample-value-for-xs-attribute) | 187 | 'soap-sample-value-for-xs-attribute) |
| 188 | 188 | ||
| 189 | (put (aref (make-soap-xs-attribute) 0) | 189 | (put (soap-type-of (make-soap-xs-attribute)) |
| 190 | 'soap-sample-value | 190 | 'soap-sample-value |
| 191 | 'soap-sample-value-for-xs-attribute-group) | 191 | 'soap-sample-value-for-xs-attribute-group) |
| 192 | 192 | ||
| 193 | (put (aref (make-soap-xs-simple-type) 0) | 193 | (put (soap-type-of (make-soap-xs-simple-type)) |
| 194 | 'soap-sample-value | 194 | 'soap-sample-value |
| 195 | 'soap-sample-value-for-xs-simple-type) | 195 | 'soap-sample-value-for-xs-simple-type) |
| 196 | 196 | ||
| 197 | (put (aref (make-soap-xs-complex-type) 0) | 197 | (put (soap-type-of (make-soap-xs-complex-type)) |
| 198 | 'soap-sample-value | 198 | 'soap-sample-value |
| 199 | 'soap-sample-value-for-xs-complex-type) | 199 | 'soap-sample-value-for-xs-complex-type) |
| 200 | 200 | ||
| 201 | (put (aref (make-soap-message) 0) | 201 | (put (soap-type-of (make-soap-message)) |
| 202 | 'soap-sample-value | 202 | 'soap-sample-value |
| 203 | 'soap-sample-value-for-message)) | 203 | 'soap-sample-value-for-message)) |
| 204 | 204 | ||
| @@ -222,7 +222,7 @@ Used to implement the BACK button.") | |||
| 222 | The buffer is populated with information about ELEMENT with links | 222 | The buffer is populated with information about ELEMENT with links |
| 223 | to its sub elements. If ELEMENT is the WSDL document itself, the | 223 | to its sub elements. If ELEMENT is the WSDL document itself, the |
| 224 | entire WSDL can be inspected." | 224 | entire WSDL can be inspected." |
| 225 | (let ((inspect (get (aref element 0) 'soap-inspect))) | 225 | (let ((inspect (get (soap-type-of element) 'soap-inspect))) |
| 226 | (unless inspect | 226 | (unless inspect |
| 227 | (error "Soap-inspect: no inspector for element")) | 227 | (error "Soap-inspect: no inspector for element")) |
| 228 | 228 | ||
| @@ -507,39 +507,39 @@ TYPE is a `soap-xs-complex-type'" | |||
| 507 | (progn | 507 | (progn |
| 508 | ;; Install the soap-inspect methods for our types | 508 | ;; Install the soap-inspect methods for our types |
| 509 | 509 | ||
| 510 | (put (aref (make-soap-xs-basic-type) 0) 'soap-inspect | 510 | (put (soap-type-of (make-soap-xs-basic-type)) 'soap-inspect |
| 511 | 'soap-inspect-xs-basic-type) | 511 | 'soap-inspect-xs-basic-type) |
| 512 | 512 | ||
| 513 | (put (aref (make-soap-xs-element) 0) 'soap-inspect | 513 | (put (soap-type-of (make-soap-xs-element)) 'soap-inspect |
| 514 | 'soap-inspect-xs-element) | 514 | 'soap-inspect-xs-element) |
| 515 | 515 | ||
| 516 | (put (aref (make-soap-xs-simple-type) 0) 'soap-inspect | 516 | (put (soap-type-of (make-soap-xs-simple-type)) 'soap-inspect |
| 517 | 'soap-inspect-xs-simple-type) | 517 | 'soap-inspect-xs-simple-type) |
| 518 | 518 | ||
| 519 | (put (aref (make-soap-xs-complex-type) 0) 'soap-inspect | 519 | (put (soap-type-of (make-soap-xs-complex-type)) 'soap-inspect |
| 520 | 'soap-inspect-xs-complex-type) | 520 | 'soap-inspect-xs-complex-type) |
| 521 | 521 | ||
| 522 | (put (aref (make-soap-xs-attribute) 0) 'soap-inspect | 522 | (put (soap-type-of (make-soap-xs-attribute)) 'soap-inspect |
| 523 | 'soap-inspect-xs-attribute) | 523 | 'soap-inspect-xs-attribute) |
| 524 | 524 | ||
| 525 | (put (aref (make-soap-xs-attribute-group) 0) 'soap-inspect | 525 | (put (soap-type-of (make-soap-xs-attribute-group)) 'soap-inspect |
| 526 | 'soap-inspect-xs-attribute-group) | 526 | 'soap-inspect-xs-attribute-group) |
| 527 | 527 | ||
| 528 | (put (aref (make-soap-message) 0) 'soap-inspect | 528 | (put (soap-type-of (make-soap-message)) 'soap-inspect |
| 529 | 'soap-inspect-message) | 529 | 'soap-inspect-message) |
| 530 | (put (aref (make-soap-operation) 0) 'soap-inspect | 530 | (put (soap-type-of (make-soap-operation)) 'soap-inspect |
| 531 | 'soap-inspect-operation) | 531 | 'soap-inspect-operation) |
| 532 | 532 | ||
| 533 | (put (aref (make-soap-port-type) 0) 'soap-inspect | 533 | (put (soap-type-of (make-soap-port-type)) 'soap-inspect |
| 534 | 'soap-inspect-port-type) | 534 | 'soap-inspect-port-type) |
| 535 | 535 | ||
| 536 | (put (aref (make-soap-binding) 0) 'soap-inspect | 536 | (put (soap-type-of (make-soap-binding)) 'soap-inspect |
| 537 | 'soap-inspect-binding) | 537 | 'soap-inspect-binding) |
| 538 | 538 | ||
| 539 | (put (aref (make-soap-port) 0) 'soap-inspect | 539 | (put (soap-type-of (make-soap-port)) 'soap-inspect |
| 540 | 'soap-inspect-port) | 540 | 'soap-inspect-port) |
| 541 | 541 | ||
| 542 | (put (aref (soap-make-wsdl "origin") 0) 'soap-inspect | 542 | (put (soap-type-of (soap-make-wsdl "origin")) 'soap-inspect |
| 543 | 'soap-inspect-wsdl)) | 543 | 'soap-inspect-wsdl)) |
| 544 | 544 | ||
| 545 | (provide 'soap-inspect) | 545 | (provide 'soap-inspect) |