Define js:FOO as a macrosymbol to (%js-vref "<symbolname>")
authorDavid Vázquez <davazp@gmail.com>
Wed, 24 Apr 2013 21:43:21 +0000 (22:43 +0100)
committerDavid Vázquez <davazp@gmail.com>
Wed, 24 Apr 2013 21:43:21 +0000 (22:43 +0100)
ecmalisp.lisp

index a0fbca1..45214ee 100644 (file)
                 (when (eq package *keyword-package*)
                   (oset symbol "value" symbol)
                   (export (list symbol) package))
-               (when (eq package (find-package "JS"))
+               (when (eq package *js-package*)
                  (let ((sym-name (symbol-name symbol))
                         (args (gensym)))
                     ;; Generate a trampoline to call the JS function
                    (fset symbol
                           (eval `(lambda (&rest ,args)
                                    (let ((,args (list-to-vector ,args)))
-                                     (%js-call (%js-vref ,sym-name) ,args)))))))
+                                     (%js-call (%js-vref ,sym-name) ,args)))))
+                    ;; Define it as a symbol macro to access to the
+                    ;; Javascript variable literally.
+                    (%define-symbol-macro symbol `(%js-vref ,(string symbol)))))
                 (oset symbols name symbol)
                 (values symbol nil)))))))