fix bug introduced by automatic integer to hex string conversion (for JS)

This commit is contained in:
pls.153 2023-11-23 16:50:39 +01:00
parent 5be79e1640
commit 0b36d00d64
7 changed files with 15 additions and 23 deletions

View file

@ -45,7 +45,7 @@ void iniCLFunctions() {
DEFUN ("%qfind-children", qfind_children2, 3)
DEFUN ("qfrom-utf8", qfrom_utf8, 1)
DEFUN ("qto-utf8", qto_utf8, 1)
DEFUN ("%qinvoke-method", qinvoke_method2, 3)
DEFUN ("qinvoke-method", qinvoke_method, 4)
DEFUN ("%qload-c++", qload_cpp, 2)
DEFUN ("qload-rc", qload_rc, 1)
DEFUN ("%qlog", qlog2, 1)
@ -484,7 +484,7 @@ cl_object qnull(cl_object l_arg) {
ecl_return1(ecl_process_env(), (qobject == nullptr) ? ECL_T : ECL_NIL);
}
cl_object qinvoke_method2(cl_object l_obj, cl_object l_name, cl_object l_args) {
cl_object qinvoke_method(cl_object l_obj, cl_object l_name, cl_object l_args, cl_object l_qjs_call) {
// for internal use: this is used to call user defined JS functions, and to
// call user defined Qt/C++ plugin functions.
// Max. 10 arguments of type T, NIL, INTEGER, FLOAT, STRING, VECTOR of
@ -501,13 +501,9 @@ cl_object qinvoke_method2(cl_object l_obj, cl_object l_name, cl_object l_args) {
QGenericArgument genA[MAX];
const char* v = "QVariant";
int i = 0;
QObject* qobject = toQObjectPointer(l_obj);
const char* class_name = qobject->metaObject()->className();
const bool qjs_call = (qstrcmp("QQuick", class_name) < 0) ||
(qstrcmp("QQml", class_name) < 0);
for (cl_object l_do_list = l_args; l_do_list != ECL_NIL; l_do_list = cl_cdr(l_do_list), i++) {
cl_object l_el = cl_car(l_do_list);
if (qjs_call) {
if (l_qjs_call == ECL_T) {
// convert INTEGER to hex string, since we only have floats in JS;
// will be converted back automatically if passed with 'Lisp.call()'
if (cl_integerp(l_el) == ECL_T) {
@ -522,6 +518,7 @@ cl_object qinvoke_method2(cl_object l_obj, cl_object l_name, cl_object l_args) {
genA[i] = null;
}
QByteArray name(toCString(l_name));
QObject* qobject = toQObjectPointer(l_obj);
if ((qobject != nullptr) && !name.isEmpty()) {
QVariant ret;
QGenericReturnArgument genR(v, &ret);

View file

@ -67,7 +67,7 @@ cl_object qfind_child (cl_object, cl_object);
cl_object qfind_children2 (cl_object, cl_object, cl_object);
cl_object qfrom_utf8 (cl_object);
cl_object qto_utf8 (cl_object);
cl_object qinvoke_method2 (cl_object, cl_object, cl_object);
cl_object qinvoke_method (cl_object, cl_object, cl_object, cl_object);
cl_object qload_cpp (cl_object, cl_object);
cl_object qload_rc (cl_object);
cl_object qlog2 (cl_object);

View file

@ -7,7 +7,7 @@
#include <QtQuick/QQuickView>
#include <QDebug>
const char LQML::version[] = "23.11.1"; // November 2023
const char LQML::version[] = "23.11.2"; // November 2023
extern "C" void ini_LQML(cl_object);

View file

@ -18,7 +18,7 @@
(defun qfind-child (a b))
(defun %qfind-children (a b c))
(defun qfrom-utf8 (a))
(defun %qinvoke-method (a b c))
(defun qinvoke-method (a b c d))
(defun %qload-c++ (a b))
(defun %qlog (a))
(defun qnull (a))

View file

@ -52,7 +52,7 @@
;; usage:
;; (! "myFunction" *cpp* 1 2 3)
;; (! |myFunction| *cpp* 1 2 3)
`(qfun ,qt-object ,(if (stringp fun) fun (symbol-name fun)) ,@args))
`(qinvoke-method ,qt-object ,(if (stringp fun) fun (symbol-name fun)) (list ,@args) nil))
(defun %reference-name ()
(format nil "%~A%" (gensym)))
@ -199,11 +199,7 @@
;; (excluding non-portable hacks)
(eval `(defgeneric ,lisp-name (object &rest arguments)))
(eval `(defmethod ,lisp-name ((object qt-object) &rest arguments)
(%qinvoke-method object ,qt-name arguments)))))))))
(defun qinvoke-method (object function-name &rest arguments)
;; for internal use
(%qinvoke-method object function-name arguments))
(qinvoke-method object ,qt-name arguments nil)))))))))
(defmacro qget (object name)
`(qrun* (%qget ,object ,(if (symbolp name)
@ -365,7 +361,6 @@
(defmacro alias (s1 s2)
`(setf (fdefinition ',s1) (function ,s2)))
(alias qfun qinvoke-method)
(alias qrun qrun-on-ui-thread)
(alias qq qquit)

View file

@ -36,7 +36,6 @@
#:qexec
#:qexit
#:qfrom-utf8
#:qfun
#:qget
#:qset
#:qlater

View file

@ -210,11 +210,12 @@
N.B: Does not work with JS default arguments.
(qjs |drawLine| *canvas* (float x1) (float y1) (float x2) (float y2))
(qjs |addPlanet| *planets* (list :name \"Jupiter\" :src \"img/jupiter.png\"))"
`(qrun* (qfun (quick-item ,item/name)
,(if (symbolp function)
(symbol-name function)
function)
,@arguments)))
`(qrun* (qinvoke-method (quick-item ,item/name)
,(if (symbolp function)
(symbol-name function)
function)
(list ,@arguments)
t))) ; qjs call
;;; apropos