:name "parenscript"
:author "Manuel Odendahl <manuel@bl0rg.net>"
:version "0"
- :maintainer "Edward Marco Baringer <mb@bese.it>"
+ :maintainer "Vladimir Sedach <vsedach@gmail.com>"
:licence "BSD"
:description "js - javascript compiler"
:components ((:static-file "parenscript.asd")
(:file "js-html" :depends-on ("package" "js" "utils"))
(:file "css" :depends-on ("package" "utils"))
(:file "compile-js" :depends-on ("package" "js"))
+ (:file "js-utils" :depends-on ("package" "js"))
(:module :lib
:components ((:static-file "functional.lisp")))))))
--- /dev/null
+(in-package :js)
+
+;;; Handy utilities for doing common tasks found in many web browser
+;;; JavaScript implementations
+
+(defjsmacro with-timeout ((timeout) &body body)
+ `(set-timeout (lambda () ,@body) ,timeout))
+
+;;; Arithmetic
+
+(defmacro def-js-maths (&rest mathdefs)
+ `(progn ,@(mapcar (lambda (def) (cons 'defjsmacro def)) mathdefs)))
+
+(def-js-maths
+ (min (&rest nums) `(*math.min ,@nums))
+ (max (&rest nums) `(*math.max ,@nums))
+ (ceiling (n) `(*math.ceil ,n))
+ (abs (n) `(*math.abs ,n))
+ (sin (n) `(*math.sin ,n))
+ (cos (n) `(*math.cos ,n))
+ (tan (n) `(*math.tan ,n))
+ (acos (n) `(*math.acos ,n))
+ (asin (n) `(*math.asin ,n))
+ (atan (n) `(*math.atan ,n))
+ (exp (n) `(*math.exp ,n))
+ (floor (n) `(*math.floor ,n))
+ (expt (base power) `(*math.pow ,base ,power))
+ (round (n) `(*math.round ,n))
+ (random (&optional upto) (if upto
+ `(floor (* ,upto (*math.random)))
+ '(*math.random))))