add fast, direct (low-level) JS function calls for QML
This commit is contained in:
parent
bfdc227b21
commit
8d3bc5234f
11 changed files with 120 additions and 17 deletions
|
|
@ -6,8 +6,8 @@
|
||||||
(defvar *canvas* "canvas")
|
(defvar *canvas* "canvas")
|
||||||
|
|
||||||
(defun draw-line (x1 y1 x2 y2)
|
(defun draw-line (x1 y1 x2 y2)
|
||||||
(js *canvas* "drawLine(~D, ~D, ~D, ~D)"
|
(qjs |drawLine| *canvas*
|
||||||
x1 y1 x2 y2))
|
x1 y1 x2 y2))
|
||||||
|
|
||||||
(defun draw-number (number)
|
(defun draw-number (number)
|
||||||
(setf *number* number)
|
(setf *number* number)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -196,7 +197,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qrun* (qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -209,6 +210,17 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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
|
;;; ini
|
||||||
|
|
||||||
(defun ini-quick-view (file)
|
(defun ini-quick-view (file)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:q<
|
#:q<
|
||||||
#:q>
|
#:q>
|
||||||
#:q>*
|
#:q>*
|
||||||
|
#:qjs
|
||||||
#:paint
|
#:paint
|
||||||
#:scale
|
#:scale
|
||||||
#:reload
|
#:reload
|
||||||
|
|
@ -187,7 +188,7 @@
|
||||||
;;; JS
|
;;; JS
|
||||||
|
|
||||||
(defun js (item/name js-format-string &rest arguments)
|
(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)"
|
(qlet ((qml-exp "QQmlExpression(QQmlContext*,QObject*,QString)"
|
||||||
(root-context)
|
(root-context)
|
||||||
(quick-item item/name)
|
(quick-item item/name)
|
||||||
|
|
@ -200,3 +201,15 @@
|
||||||
(with-output-to-string (*standard-output*)
|
(with-output-to-string (*standard-output*)
|
||||||
(print-js-readably object)))
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -978,11 +978,11 @@ static QVariantList lispToQVariantList(cl_object l_list) {
|
||||||
l << QVariant(toQString(l_el)); }
|
l << QVariant(toQString(l_el)); }
|
||||||
else if(l_el == ECL_T) { // true
|
else if(l_el == ECL_T) { // true
|
||||||
l << QVariant(true); }
|
l << QVariant(true); }
|
||||||
else if(l_el == ECL_NIL) { // null
|
else if(l_el == ECL_NIL) { // false
|
||||||
l << QVariant(); }
|
l << QVariant(false); }
|
||||||
else if(LISTP(l_el)) { // list
|
else if(LISTP(l_el)) { // list
|
||||||
l << QVariant::fromValue(lispToQVariantList(l_el)); }
|
l << QVariant::fromValue(lispToQVariantList(l_el)); }
|
||||||
else { // null
|
else { // default: undefined
|
||||||
l << QVariant(); }
|
l << QVariant(); }
|
||||||
l_do_list = cl_cdr(l_do_list); }}
|
l_do_list = cl_cdr(l_do_list); }}
|
||||||
return l; }
|
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)); }
|
arg[i] = QVariant(toQString(l_arg)); }
|
||||||
else if(l_arg == ECL_T) { // true
|
else if(l_arg == ECL_T) { // true
|
||||||
arg[i] = QVariant(true); }
|
arg[i] = QVariant(true); }
|
||||||
else if(l_arg == ECL_NIL) { // null
|
else if(l_arg == ECL_NIL) { // false
|
||||||
arg[i] = QVariant(); }
|
arg[i] = QVariant(false); }
|
||||||
else if(LISTP(l_arg)) { // list
|
else if(LISTP(l_arg)) { // list
|
||||||
arg[i] = QVariant::fromValue(lispToQVariantList(l_arg)); }
|
arg[i] = QVariant::fromValue(lispToQVariantList(l_arg)); }
|
||||||
else { // default: null
|
else { // default: undefined
|
||||||
arg[i] = QVariant(); }
|
arg[i] = QVariant(); }
|
||||||
genA[i] = QGenericArgument(v, &arg[i]);
|
genA[i] = QGenericArgument(v, &arg[i]);
|
||||||
l_do_args = cl_cdr(l_do_args); }
|
l_do_args = cl_cdr(l_do_args); }
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
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);
|
extern "C" void ini_EQL(cl_object);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue