Index: iedoc.lisp
===================================================================
RCS file: /project/cl-selenium/cvsroot/cl-selenium/iedoc.lisp,v
retrieving revision 1.2
diff -r1.2 iedoc.lisp
9c9,11
< 	    :accessor iedoc-function-comment)))
---
> 	    :accessor iedoc-function-comment)
>    (return-type :initarg :return-type
>                 :accessor iedoc-return-type)))
33c35,38
< 		   :comment (make-iedoc-comment (elt (dom:get-elements-by-tag-name e "comment") 0)))))
---
> 		   :comment (make-iedoc-comment (elt (dom:get-elements-by-tag-name e "comment") 0))
>                    :return-type (let ((return-elements (dom:get-elements-by-tag-name e "return")))
>                                   (when (plusp (length return-elements))
>                                     (make-iedoc-return-type (elt return-elements 0)))))))
50a56,64
> (defun make-iedoc-return-type (e)
>   (let ((type (dom:get-attribute e "type")))
>     (cond
>       ((string-equal type "string") 'string)
>       ((string-equal type "boolean") 'boolean)
>       ((string-equal type "number") 'number)
>       ((string-equal type "string[]") 'list))))
> 
> 
107,111c121,151
< (defun convert-result (s)
<   (cond
<     ((string= s "true") t)
<     ((string= s "false") nil)
<     (t s)))
---
> (defun convert-result (s return-type)
>   (ecase return-type
>     ((number string) s)
>     (boolean (cond
>                ((string= s "true") t)
>                ((string= s "false") nil)))
>     (list (convert-string-array s))
>     ((nil) nil)))
> 
> ;;; Shamelessly copied from selenium.rb in selenium-ruby-client-driver
> (defun convert-string-array (s)
>   (flet ((new-string ()
>            (make-array 0 :element-type 'character :fill-pointer 0 :adjustable t)))
>     (let ((result nil)
>           (escape-p nil)
>           (token (new-string)))
>       (loop
>          for char across s
>          do (cond
>               (escape-p
>                (vector-push-extend char token)
>                (setf escape-p nil))
>               ((eql char #\\)
>                (setf escape-p t))
>               ((eql char #\,)
>                (push token result)
>                (setf token (new-string)))
>               (t
>                (vector-push-extend char token)))
>          finally (push token result))
>       (nreverse result))))
133c173
< (defun execute (url)
---
> (defun execute (url &optional return-type)
139,144c179,184
<     (let ((results (split-sequence:split-sequence #\, reply)))
<       (cond
<         ((starts-with (first results) "OK") (convert-result (second results)))
<         ((starts-with (first results) "ERROR:")
<          (let ((err (second (split-sequence:split-sequence #\: (first results)))))
<            (error 'execution-error :description err)))))))
---
>     (cond
>       ((starts-with reply "OK")
>        (convert-result (subseq reply (min 3 (length reply))) return-type))
>       ((starts-with reply "ERROR:")
>        (let ((err (second (split-sequence:split-sequence #\: reply))))
>          (error 'execution-error :description err))))))
156c196,197
<                                    *selenium-driver-url*))))))
---
>                                    *selenium-driver-url*)
>                   ',(iedoc-return-type iedoc-function))))))
Index: selenium.lisp
===================================================================
RCS file: /project/cl-selenium/cvsroot/cl-selenium/selenium.lisp,v
retrieving revision 1.2
diff -r1.2 selenium.lisp
18,19c18,20
<   (execute  (puri:merge-uris (make-instance 'puri:uri :query (marshall-request "getNewBrowserSession" browser url))
<                              *selenium-driver-url*)))
---
>   (execute (puri:merge-uris (make-instance 'puri:uri :query (marshall-request "getNewBrowserSession" browser url))
>                              *selenium-driver-url*)
>            'string))
