diff --git a/examples/M-modules/quick/9999/lisp/main.lisp b/examples/M-modules/quick/9999/lisp/main.lisp index 5f754d9..30a3fe1 100644 --- a/examples/M-modules/quick/9999/lisp/main.lisp +++ b/examples/M-modules/quick/9999/lisp/main.lisp @@ -6,8 +6,8 @@ (defvar *canvas* "canvas") (defun draw-line (x1 y1 x2 y2) - (js *canvas* "drawLine(~D, ~D, ~D, ~D)" - x1 y1 x2 y2)) + (qjs |drawLine| *canvas* + x1 y1 x2 y2)) (defun draw-number (number) (setf *number* number) diff --git a/examples/M-modules/quick/9999/lisp/qml-lisp.lisp b/examples/M-modules/quick/9999/lisp/qml-lisp.lisp index dc34fcf..4c837c4 100644 --- a/examples/M-modules/quick/9999/lisp/qml-lisp.lisp +++ b/examples/M-modules/quick/9999/lisp/qml-lisp.lisp @@ -25,6 +25,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -196,7 +197,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qrun* (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -209,6 +210,17 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + ;;; ini (defun ini-quick-view (file) diff --git a/examples/M-modules/quick/Tic-Tac-Toe/qml-lisp.lisp b/examples/M-modules/quick/Tic-Tac-Toe/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/Tic-Tac-Toe/qml-lisp.lisp +++ b/examples/M-modules/quick/Tic-Tac-Toe/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/item-model/qml-lisp.lisp b/examples/M-modules/quick/item-model/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/item-model/qml-lisp.lisp +++ b/examples/M-modules/quick/item-model/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/painted-item/qml-lisp.lisp b/examples/M-modules/quick/painted-item/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/painted-item/qml-lisp.lisp +++ b/examples/M-modules/quick/painted-item/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/palindrome-2/qml-lisp.lisp b/examples/M-modules/quick/palindrome-2/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/palindrome-2/qml-lisp.lisp +++ b/examples/M-modules/quick/palindrome-2/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/qml-lisp/qml-lisp.lisp b/examples/M-modules/quick/qml-lisp/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/qml-lisp/qml-lisp.lisp +++ b/examples/M-modules/quick/qml-lisp/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/sokoban/lisp/qml-lisp.lisp b/examples/M-modules/quick/sokoban/lisp/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/sokoban/lisp/qml-lisp.lisp +++ b/examples/M-modules/quick/sokoban/lisp/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/examples/M-modules/quick/table-view/qml-lisp.lisp b/examples/M-modules/quick/table-view/qml-lisp.lisp index 1930a75..0d1385b 100644 --- a/examples/M-modules/quick/table-view/qml-lisp.lisp +++ b/examples/M-modules/quick/table-view/qml-lisp.lisp @@ -23,6 +23,7 @@ #:q< #:q> #:q>* + #:qjs #:paint #:scale #:reload @@ -187,7 +188,7 @@ ;;; JS (defun js (item/name js-format-string &rest arguments) - "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT." + "Evaluates a JS string, with 'this' bound to either ITEM, or first object matching NAME. Arguments are passed through FORMAT. Use this function instead of the (faster) QJS if you need to evaluate generic JS code." (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)" (root-context) (quick-item item/name) @@ -200,3 +201,15 @@ (with-output-to-string (*standard-output*) (print-js-readably object))) +(defun %qjs (item/name function-name &rest arguments) + ;; QJS-CALL is defined in EQL5, function 'ecl_fun.cpp' + (eql::qjs-call (quick-item item/name) function-name arguments)) + +(defmacro qjs (function-name item/name &rest arguments) + "Fast and direct JS calls; max 10 arguments of type: T, NIL, INTEGER, FLOAT, STRING, (nested) LIST of mentioned types. + Examples: + (qjs |drawLine| *canvas* 0 0 100.0 100.0) + (qjs |drawPath| *canvas* (list (list 0 0) (list 0 10.0) (list 10.0 10.0)))" + `(%qjs ,item/name ,(symbol-name function-name) ,@arguments)) + + diff --git a/src/ecl_fun.cpp b/src/ecl_fun.cpp index 982091f..2e8c40b 100644 --- a/src/ecl_fun.cpp +++ b/src/ecl_fun.cpp @@ -978,11 +978,11 @@ static QVariantList lispToQVariantList(cl_object l_list) { l << QVariant(toQString(l_el)); } else if(l_el == ECL_T) { // true l << QVariant(true); } - else if(l_el == ECL_NIL) { // null - l << QVariant(); } + else if(l_el == ECL_NIL) { // false + l << QVariant(false); } else if(LISTP(l_el)) { // list l << QVariant::fromValue(lispToQVariantList(l_el)); } - else { // null + else { // default: undefined l << QVariant(); } l_do_list = cl_cdr(l_do_list); }} return l; } @@ -3066,11 +3066,11 @@ cl_object qjs_call(cl_object l_item, cl_object l_name, cl_object l_args) { arg[i] = QVariant(toQString(l_arg)); } else if(l_arg == ECL_T) { // true arg[i] = QVariant(true); } - else if(l_arg == ECL_NIL) { // null - arg[i] = QVariant(); } + else if(l_arg == ECL_NIL) { // false + arg[i] = QVariant(false); } else if(LISTP(l_arg)) { // list arg[i] = QVariant::fromValue(lispToQVariantList(l_arg)); } - else { // default: null + else { // default: undefined arg[i] = QVariant(); } genA[i] = QGenericArgument(v, &arg[i]); l_do_args = cl_cdr(l_do_args); } diff --git a/src/eql.cpp b/src/eql.cpp index 7e4e7f7..e7bf121 100644 --- a/src/eql.cpp +++ b/src/eql.cpp @@ -9,7 +9,7 @@ #include #include -const char EQL::version[] = "20.7.1"; // July 2020 +const char EQL::version[] = "21.3.1"; // March 2021 extern "C" void ini_EQL(cl_object);