jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp
https://jscl-project.github.io
GNU General Public License v3.0
874 stars 108 forks source link

Path 1120 2022 #461

Closed vlad-km closed 1 year ago

vlad-km commented 1 year ago

Closed issue #392

Added global declaration (declaim (clos override)), after declaring which, you can override existing classes. Unsafe mode. While the integrity of already existing classes is not reviewed. The mode is canceled by declaration (declaim (clos non-override))

Details see at tests\clos.lisp If you use this mode, you know what you are doing.

Closes #392 Closes #458 Closes #459

Experimental FFI feature

Added fi functions: (jscl::get-js-null) => js:null (jscl::get-js-undefined) => js:undefined

JSCL version 0.8.2 built on 30 November 2022

CL-USER> 
CL-USER> 
CL-USER> (jscl::get-js-null)
<js-null>
CL-USER> (jscl::get-js-undefined)
<JS-UNDEFINED>
CL-USER> (jscl::js-null-p (jscl::get-js-null))
T
CL-USER> (jscl::js-undefined-p (jscl::get-js-undefined))
T
CL-USER> 

Now JS values, such as null and undefined, are available in the Lisp environment.

;;; Important:
    (defconstant +v-null+  (jscl::get-js-null))   OR
    (defvar *v-null* (jscl::get-js-null))
;;;                BUT!
    (defconstant +v-undef+ (jscl::get-js-undefined)) 
;;; other details see at  tests\ffi.lisp
    (setq alu (make-list 5 ::initial-element  +v-null+))
    (setq ara (make-new #j:Array 1000))
    (setf (aref ara 2) 123)
    (setf (oget ara "issue") 392)
    (aref ara 2) 
    (typecase (aref ara 900) (jscl::js-null :null) (jscl::js-undefined :undef) (t :damn))
;;;    ... etc 

Have fun, @vlad-km

vlad-km commented 1 year ago

File std-object i'll clean it up later, it has a lot of redundant comments, and the code is very old in places. There will be changes.

vlad-km commented 1 year ago

File std-object i'll clean it up later, it has a lot of redundant comments, and the code is very old in places. There will be changes.

This will be the next PR. With this PR it's all over. @David, thanks for review

vlad-km commented 1 year ago

I close it. The idea is good, but it needs more work.