Better handling of parsing integer and float values

This commit is contained in:
David Botton 2024-02-06 20:00:42 -05:00
parent f631a43059
commit d07b41dd73
10 changed files with 155 additions and 132 deletions

View file

@ -198,19 +198,19 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(let ((f (ppcre:split ":" data)))
(list
:event-type :mouse
:x (parse-integer (nth 0 f) :junk-allowed t)
:y (parse-integer (nth 1 f) :junk-allowed t)
:screen-x (parse-integer (nth 2 f) :junk-allowed t)
:screen-y (parse-integer (nth 3 f) :junk-allowed t)
:which-button (parse-integer (nth 4 f) :junk-allowed t)
:x (js-to-integer (nth 0 f))
:y (js-to-integer (nth 1 f))
:screen-x (js-to-integer (nth 2 f))
:screen-y (js-to-integer (nth 3 f))
:which-button (js-to-integer (nth 4 f))
:alt-key (js-true-p (nth 5 f))
:ctrl-key (js-true-p (nth 6 f))
:shift-key (js-true-p (nth 7 f))
:meta-key (js-true-p (nth 8 f))
:client-x (parse-integer (nth 9 f) :junk-allowed t)
:client-Y (parse-integer (nth 10 f) :junk-allowed t)
:page-x (parse-integer (nth 11 f) :junk-allowed t)
:page-Y (parse-integer (nth 12 f) :junk-allowed t))))
:client-x (js-to-integer (nth 9 f))
:client-Y (js-to-integer (nth 10 f))
:page-x (js-to-integer (nth 11 f))
:page-Y (js-to-integer (nth 12 f)))))
;;;;;;;;;;;;;;;;;;;;;;;
;; parse-touch-event ;;
@ -236,19 +236,19 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(let ((f (ppcre:split ":" data)))
(list
:event-type :touch
:x (parse-integer (nth 0 f) :junk-allowed t)
:y (parse-integer (nth 1 f) :junk-allowed t)
:screen-x (parse-integer (nth 2 f) :junk-allowed t)
:screen-y (parse-integer (nth 3 f) :junk-allowed t)
:number-fingers (parse-integer (nth 4 f) :junk-allowed t)
:x (js-to-integer (nth 0 f))
:y (js-to-integer (nth 1 f))
:screen-x (js-to-integer (nth 2 f))
:screen-y (js-to-integer (nth 3 f))
:number-fingers (js-to-integer (nth 4 f))
:alt-key (js-true-p (nth 5 f))
:ctrl-key (js-true-p (nth 6 f))
:shift-key (js-true-p (nth 7 f))
:meta-key (js-true-p (nth 8 f))
:client-x (parse-integer (nth 9 f) :junk-allowed t)
:client-Y (parse-integer (nth 10 f) :junk-allowed t)
:page-x (parse-integer (nth 11 f) :junk-allowed t)
:page-Y (parse-integer (nth 12 f) :junk-allowed t))))
:client-x (js-to-integer (nth 9 f))
:client-Y (js-to-integer (nth 10 f))
:page-x (js-to-integer (nth 11 f))
:page-Y (js-to-integer (nth 12 f)))))
;;;;;;;;;;;;;;;;;;;;;;;;;
;; parse-pointer-event ;;
@ -266,19 +266,19 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(let ((f (ppcre:split ":" data)))
(list
:event-type :pointer
:x (parse-integer (nth 0 f) :junk-allowed t)
:y (parse-integer (nth 1 f) :junk-allowed t)
:screen-x (parse-integer (nth 2 f) :junk-allowed t)
:screen-y (parse-integer (nth 3 f) :junk-allowed t)
:which-button (parse-integer (nth 4 f) :junk-allowed t)
:x (js-to-integer (nth 0 f))
:y (js-to-integer (nth 1 f))
:screen-x (js-to-integer (nth 2 f))
:screen-y (js-to-integer (nth 3 f))
:which-button (js-to-integer (nth 4 f))
:alt-key (js-true-p (nth 5 f))
:ctrl-key (js-true-p (nth 6 f))
:shift-key (js-true-p (nth 7 f))
:meta-key (js-true-p (nth 8 f))
:client-x (parse-integer (nth 9 f) :junk-allowed t)
:client-Y (parse-integer (nth 10 f) :junk-allowed t)
:page-x (parse-integer (nth 11 f) :junk-allowed t)
:page-Y (parse-integer (nth 12 f) :junk-allowed t))))
:client-x (js-to-integer (nth 9 f))
:client-Y (js-to-integer (nth 10 f))
:page-x (js-to-integer (nth 11 f))
:page-Y (js-to-integer (nth 12 f)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; parse-keyboard-event ;;
@ -294,8 +294,8 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(let ((f (ppcre:split ":" data)))
(list
:event-type :keyboard
:key-code (parse-integer (nth 0 f) :junk-allowed t)
:char-code (parse-integer (nth 1 f) :junk-allowed t)
:key-code (js-to-integer (nth 0 f))
:char-code (js-to-integer (nth 1 f))
:alt-key (js-true-p (nth 2 f))
:ctrl-key (js-true-p (nth 3 f))
:shift-key (js-true-p (nth 4 f))
@ -319,9 +319,9 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(let ((f (ppcre:split ":" data)))
(list
:event-type :drop
:x (parse-integer (nth 0 f) :junk-allowed t)
:y (parse-integer (nth 1 f) :junk-allowed t)
:which-button (parse-integer (nth 2 f) :junk-allowed t)
:x (js-to-integer (nth 0 f))
:y (js-to-integer (nth 1 f))
:which-button (js-to-integer (nth 2 f))
:alt-key (js-true-p (nth 3 f))
:ctrl-key (js-true-p (nth 4 f))
:shift-key (js-true-p (nth 5 f))
@ -398,7 +398,7 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(:documentation "Get/Setf html height in pixels."))
(defmethod height ((obj clog-obj))
(parse-integer (jquery-query obj "height()" :default-answer 0) :junk-allowed t))
(js-to-integer (jquery-query obj "height()")))
(defgeneric (setf height) (value clog-obj)
(:documentation "Set height VALUE for CLOG-OBJ"))
@ -415,7 +415,7 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(:documentation "Get/Setf html width in pixels."))
(defmethod width ((obj clog-obj))
(parse-integer (jquery-query obj "width()" :default-answer 0) :junk-allowed t))
(js-to-integer (jquery-query obj "width()")))
(defgeneric (setf width) (value clog-obj)
(:documentation "Set width VALUE for CLOG-OBJ"))