(error "~S is not an array." array))
(if (eq (oget array "stringp") 1)
'character
- (oget array "type")))
+ (let ((type (oget array "type")))
+ (and (not (undefined type))
+ type))))
(defun array-dimensions (array)
(unless (arrayp array)
(error "~S is not an array." array))
- (oget array "dimensions"))
+ (let ((dimensions (oget array "dimensions")))
+ (and (not (undefined dimensions))
+ dimensions)))
;; TODO: Error checking
(defun array-dimension (array axis)
(/debug "loading ffi.lisp!")
+;; for FFI
+(defconstant false 'false)
+(%js-vset "falseSymbol" false)
+(defconstant undefined 'undefined)
+(%js-vset "undefinedSymbol" undefined)
+
+(defun false (x)
+ (eq x false))
+
+(defun undefined (x)
+ (eq x undefined))
+
(define-setf-expander oget (object key &rest keys)
(let* ((keys (cons key keys))
(g!object (gensym))
(if foundp
(values symbol foundp)
(let ((symbols (%package-symbols package)))
- (oget symbols name)
(let ((symbol (make-symbol name)))
(setf (oget symbol "package") package)
(when (eq package *keyword-package*)
(defun symbol-package (symbol)
(unless (symbolp symbol)
(error "`~S' is not a symbol." symbol))
- (oget symbol "package"))
+ (let ((package (oget symbol "package")))
+ (and (not (undefined package))
+ package)))
(defun export (symbols &optional (package *package*))
(let ((exports (%package-external-symbols package)))
var window = this;
var t;
var nil;
+var falseSymbol;
+var undefinedSymbol;
var lisp = {};
return null;
else if (x === t)
return true;
+ else if (x === falseSymbol)
+ return false;
+ else if (x === undefinedSymbol)
+ return undefined;
else if (typeof x == 'object' && 'length' in x && x.stringp == 1)
return xstring(x);
else if (typeof x == 'function'){
}
function js_to_lisp (x) {
- if (x === null || x === undefined || x === false)
+ if (x === null)
return nil;
else if (x === true)
return t;
+ else if (x === false)
+ return falseSymbol;
+ else if (x === undefined)
+ return undefinedSymbol;
else if (typeof x == 'string')
return make_lisp_string(x);
else if (typeof x == 'function'){