;;;; soap-inspect.el -- Interactive inspector for soap WSDL structures
-;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com>
;; Created: October 2010
;; TODO: we need better sample values for more types.
(t (format "%s" (soap-basic-type-kind type)))))
+(defun soap-sample-value-for-simple-type (type)
+ "Provide a sample value for TYPE which is a simple type.
+This is a specific function which should not be called directly,
+use `soap-sample-value' instead."
+ (let ((enumeration (soap-simple-type-enumeration type)))
+ (if (> (length enumeration) 1)
+ (elt enumeration (random (length enumeration)))
+ (soap-sample-value-for-basic-type type))))
+
(defun soap-sample-value-for-seqence-type (type)
"Provide a sample value for TYPE which is a sequence type.
Values for sequence types are ALISTS of (slot-name . VALUE) for
(put (aref (make-soap-basic-type) 0) 'soap-sample-value
'soap-sample-value-for-basic-type)
+ (put (aref (make-soap-simple-type) 0) 'soap-sample-value
+ 'soap-sample-value-for-simple-type)
+
(put (aref (make-soap-sequence-type) 0) 'soap-sample-value
'soap-sample-value-for-seqence-type)
(insert "\nSample value\n")
(pp (soap-sample-value basic-type) (current-buffer)))
+(defun soap-inspect-simple-type (simple-type)
+ "Insert information about SIMPLE-TYPE into the current buffer"
+ (insert "Simple type: " (soap-element-fq-name simple-type) "\n")
+ (insert "Base: " (symbol-name (soap-basic-type-kind simple-type)) "\n")
+ (let ((enumeration (soap-simple-type-enumeration simple-type)))
+ (when (> (length enumeration) 1)
+ (insert "Valid values: ")
+ (dolist (e enumeration)
+ (insert "\"" e "\" ")))))
+
(defun soap-inspect-sequence-type (sequence)
"Insert information about SEQUENCE into the current buffer."
(insert "Sequence type: " (soap-element-fq-name sequence) "\n")
(put (aref (make-soap-basic-type) 0) 'soap-inspect
'soap-inspect-basic-type)
+ (put (aref (make-soap-simple-type) 0) 'soap-inspect
+ 'soap-inspect-simple-type)
+
(put (aref (make-soap-sequence-type) 0) 'soap-inspect
'soap-inspect-sequence-type)