From b07152d7d4ecc57c42e98abb83e45b2990f0ec64 Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Sun, 8 Oct 2023 15:46:12 +0200 Subject: [PATCH] prepare for SailfishOS (Qt5.15 libs & qt-runner) --- .../advanced-qml-auto-reload/lisp/curl.lisp | 2 +- .../advanced-qml-auto-reload/lisp/main.lisp | 2 +- examples/advanced-qml-auto-reload/make.lisp | 5 +++- examples/app-template/make.lisp | 5 +++- examples/camera/make.lisp | 5 +++- examples/cl-repl/lisp/curl.lisp | 2 +- examples/cl-repl/lisp/dialogs.lisp | 4 +-- examples/cl-repl/lisp/ini.lisp | 6 ++-- examples/cl-repl/lisp/main.lisp | 2 +- examples/cl-repl/lisp/upload-download.lisp | 4 +-- examples/cl-repl/make-lib.lisp | 5 +++- examples/cl-repl/make.lisp | 5 +++- examples/cl-repl/qml/ext/FileBrowser.qml | 4 +-- examples/cl-repl/qml/ext/dialogs/Dialogs.qml | 6 ++-- examples/clog-demo/make.lisp | 5 +++- examples/swank-server/lisp/curl.lisp | 2 +- examples/swank-server/make.lisp | 5 +++- examples/wear-os-gps/make.lisp | 5 +++- src/cpp/ecl_ext.cpp | 30 ++++++++++++++----- src/cpp/ecl_ext.h | 1 + src/cpp/ecl_fun_plugin.h | 10 +++---- src/cpp/lqml.cpp | 4 +-- src/cpp/main.cpp | 8 ++--- src/cpp/main.h | 6 ++-- src/cpp/marshal.cpp | 8 ++--- src/cpp/qt_ecl.cpp | 8 ++--- src/lisp/package.lisp | 1 + src/make.lisp | 8 +++-- 28 files changed, 99 insertions(+), 59 deletions(-) diff --git a/examples/advanced-qml-auto-reload/lisp/curl.lisp b/examples/advanced-qml-auto-reload/lisp/curl.lisp index ae7a5e5..921f6b3 100644 --- a/examples/advanced-qml-auto-reload/lisp/curl.lisp +++ b/examples/advanced-qml-auto-reload/lisp/curl.lisp @@ -1,6 +1,6 @@ (in-package :qml) -#-mobile +#-(or android ios) (require :ecl-curl) (defun curl (url) diff --git a/examples/advanced-qml-auto-reload/lisp/main.lisp b/examples/advanced-qml-auto-reload/lisp/main.lisp index bd8eeba..a38aae8 100644 --- a/examples/advanced-qml-auto-reload/lisp/main.lisp +++ b/examples/advanced-qml-auto-reload/lisp/main.lisp @@ -1,5 +1,5 @@ (in-package :app) -#+mobile +#+(or android ios) (when qml::*remote-ip* (qsingle-shot 1000 'auto-reload-qml)) diff --git a/examples/advanced-qml-auto-reload/make.lisp b/examples/advanced-qml-auto-reload/make.lisp index 0c15289..1522a11 100644 --- a/examples/advanced-qml-auto-reload/make.lisp +++ b/examples/advanced-qml-auto-reload/make.lisp @@ -7,7 +7,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; copy Swank and ECL contrib files (mobile only) diff --git a/examples/app-template/make.lisp b/examples/app-template/make.lisp index ee374af..adff0ff 100644 --- a/examples/app-template/make.lisp +++ b/examples/app-template/make.lisp @@ -6,7 +6,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) (require :asdf) diff --git a/examples/camera/make.lisp b/examples/camera/make.lisp index 8a24552..2fb1253 100644 --- a/examples/camera/make.lisp +++ b/examples/camera/make.lisp @@ -7,7 +7,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; copy ECL '*.doc' and 'encodings/' (mobile only) diff --git a/examples/cl-repl/lisp/curl.lisp b/examples/cl-repl/lisp/curl.lisp index ae7a5e5..921f6b3 100644 --- a/examples/cl-repl/lisp/curl.lisp +++ b/examples/cl-repl/lisp/curl.lisp @@ -1,6 +1,6 @@ (in-package :qml) -#-mobile +#-(or android ios) (require :ecl-curl) (defun curl (url) diff --git a/examples/cl-repl/lisp/dialogs.lisp b/examples/cl-repl/lisp/dialogs.lisp index af94bfe..7bb21a9 100644 --- a/examples/cl-repl/lisp/dialogs.lisp +++ b/examples/cl-repl/lisp/dialogs.lisp @@ -123,11 +123,11 @@ (defun location (name) (cond ((string= ":data" name) - #+mobile + #+(or android ios) (progn #+android "/sdcard/Documents/" #+ios (namestring (truename (merge-pathnames "../Documents/")))) - #-mobile + #-(or android ios) (namestring (merge-pathnames "Documents/" (user-homedir-pathname)))) ((string= ":home" name) (namestring *default-pathname-defaults*)))) diff --git a/examples/cl-repl/lisp/ini.lisp b/examples/cl-repl/lisp/ini.lisp index 252715a..962d8fa 100644 --- a/examples/cl-repl/lisp/ini.lisp +++ b/examples/cl-repl/lisp/ini.lisp @@ -29,7 +29,7 @@ ;;; create default '.eclrc' -#+mobile +#+(or android ios) (let ((ecl-rc (merge-pathnames ".eclrc"))) (unless (probe-file ecl-rc) (with-open-file (s ecl-rc :direction :output) @@ -41,10 +41,10 @@ ;;; check version -#+mobile +#+(or android ios) (defconstant +version+ 6) -#+mobile +#+(or android ios) (let ((.version (merge-pathnames ".version"))) (when (or (not (probe-file .version)) (> +version+ diff --git a/examples/cl-repl/lisp/main.lisp b/examples/cl-repl/lisp/main.lisp index 2ccc01b..76a7c06 100644 --- a/examples/cl-repl/lisp/main.lisp +++ b/examples/cl-repl/lisp/main.lisp @@ -1,5 +1,5 @@ (in-package :editor) -#+mobile +#+(or android ios) (when qml::*remote-ip* (qsingle-shot 1000 'auto-reload-qml)) diff --git a/examples/cl-repl/lisp/upload-download.lisp b/examples/cl-repl/lisp/upload-download.lisp index 389427a..c0d6f06 100644 --- a/examples/cl-repl/lisp/upload-download.lisp +++ b/examples/cl-repl/lisp/upload-download.lisp @@ -88,8 +88,8 @@ it saves uploaded files on the server." (start-server *web-server*) (when ini (register-context-handler *web-server* "/" 'static-resource/upload-handler - :arguments (list #+mobile *default-pathname-defaults* - #-mobile (merge-pathnames "www/"))))) + :arguments (list #+(or android ios) *default-pathname-defaults* + #-(or android ios) (merge-pathnames "www/"))))) (x:when-it (qml:my-ip) (format nil "http://~A:1701/" x:it))) diff --git a/examples/cl-repl/make-lib.lisp b/examples/cl-repl/make-lib.lisp index 03e3efc..e77084e 100644 --- a/examples/cl-repl/make-lib.lisp +++ b/examples/cl-repl/make-lib.lisp @@ -9,7 +9,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; compile ASDF system diff --git a/examples/cl-repl/make.lisp b/examples/cl-repl/make.lisp index bc45ec2..48d6542 100644 --- a/examples/cl-repl/make.lisp +++ b/examples/cl-repl/make.lisp @@ -9,7 +9,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; copy Swank and ECL contrib files (mobile only) diff --git a/examples/cl-repl/qml/ext/FileBrowser.qml b/examples/cl-repl/qml/ext/FileBrowser.qml index 4d5dae5..c31921b 100644 --- a/examples/cl-repl/qml/ext/FileBrowser.qml +++ b/examples/cl-repl/qml/ext/FileBrowser.qml @@ -120,9 +120,7 @@ Rectangle { y: main.small ? 7 : 10 anchors.horizontalCenter: parent.horizontalCenter spacing: 20 - visible: ((Qt.platform.os === "android") || - (Qt.platform.os === "ios")) - ? path.focus : false + visible: Lisp.call("qml:mobile-p") ? path.focus : false // cursor back Ext.ArrowButton { diff --git a/examples/cl-repl/qml/ext/dialogs/Dialogs.qml b/examples/cl-repl/qml/ext/dialogs/Dialogs.qml index 41ebf84..f048bfe 100644 --- a/examples/cl-repl/qml/ext/dialogs/Dialogs.qml +++ b/examples/cl-repl/qml/ext/dialogs/Dialogs.qml @@ -11,8 +11,7 @@ Item { } function message(text) { - if ((Qt.platform.os === "android") || - (Qt.platform.os === "ios")) { + if (Lisp.call("qml:mobile-p")) { loader.source = "MessageMobile.qml" } else { loader.source = "Message.qml" @@ -23,8 +22,7 @@ Item { } function confirm(title, text, callback) { - if ((Qt.platform.os === "android") || - (Qt.platform.os === "ios")) { + if (Lisp.call("qml:mobile-p")) { loader.source = "ConfirmMobile.qml" } else { loader.source = "Confirm.qml" diff --git a/examples/clog-demo/make.lisp b/examples/clog-demo/make.lisp index 0827dbc..927276f 100644 --- a/examples/clog-demo/make.lisp +++ b/examples/clog-demo/make.lisp @@ -7,7 +7,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; copy Swank and ECL contrib files (mobile only) diff --git a/examples/swank-server/lisp/curl.lisp b/examples/swank-server/lisp/curl.lisp index ae7a5e5..921f6b3 100644 --- a/examples/swank-server/lisp/curl.lisp +++ b/examples/swank-server/lisp/curl.lisp @@ -1,6 +1,6 @@ (in-package :qml) -#-mobile +#-(or android ios) (require :ecl-curl) (defun curl (url) diff --git a/examples/swank-server/make.lisp b/examples/swank-server/make.lisp index 0c15289..1522a11 100644 --- a/examples/swank-server/make.lisp +++ b/examples/swank-server/make.lisp @@ -7,7 +7,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; copy Swank and ECL contrib files (mobile only) diff --git a/examples/wear-os-gps/make.lisp b/examples/wear-os-gps/make.lisp index c85a3e6..dd41bb2 100644 --- a/examples/wear-os-gps/make.lisp +++ b/examples/wear-os-gps/make.lisp @@ -6,7 +6,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) (require :asdf) diff --git a/src/cpp/ecl_ext.cpp b/src/cpp/ecl_ext.cpp index 1267fb8..395b89d 100644 --- a/src/cpp/ecl_ext.cpp +++ b/src/cpp/ecl_ext.cpp @@ -5,16 +5,16 @@ #include #include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef Q_OS_ANDROID #include @@ -32,6 +32,7 @@ void iniCLFunctions() { DEFUN ("%disable-clipboard-menu", disable_clipboard_menu2, 1) DEFUN ("%ensure-permissions", ensure_permissions2, 1) DEFUN ("%js", js2, 2) + DEFUN ("mobile-p", mobile_p, 0) DEFUN ("pixel-ratio", pixel_ratio, 0) DEFUN ("%qapropos", qapropos2, 3) DEFUN ("qchildren", qchildren, 1) @@ -502,7 +503,7 @@ cl_object qinvoke_method2(cl_object l_obj, cl_object l_name, cl_object l_args) { 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) { - // convert INTEGER to hex string, since we only have floats in JS + // 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) { l_el = cl_funcall(2, s_hex, l_el); @@ -629,6 +630,19 @@ cl_object qquit2(cl_object l_status) { return ECL_NIL; } +cl_object mobile_p() { + /// args: () + /// Returns T on android, iOS, SailfishOS. + ecl_process_env()->nvalues = 1; + QString platform = qGuiApp->platformName(); + if ((platform == QStringLiteral("android")) || + (platform == QStringLiteral("ios")) || + QFile::exists("/etc/sailfish-release")) { + return ECL_T; + } + return ECL_NIL; +} + cl_object pixel_ratio() { /// args: () /// Returns the effective device pixel ratio. diff --git a/src/cpp/ecl_ext.h b/src/cpp/ecl_ext.h index cf348c1..1b03d40 100644 --- a/src/cpp/ecl_ext.h +++ b/src/cpp/ecl_ext.h @@ -54,6 +54,7 @@ cl_object clipboard_text (); cl_object disable_clipboard_menu2 (cl_object); cl_object ensure_permissions2 (cl_object); cl_object js2 (cl_object, cl_object); +cl_object mobile_p (); cl_object pixel_ratio (); cl_object qapropos2 (cl_object, cl_object, cl_object); cl_object qchildren (cl_object); diff --git a/src/cpp/ecl_fun_plugin.h b/src/cpp/ecl_fun_plugin.h index cef4606..7e1744a 100644 --- a/src/cpp/ecl_fun_plugin.h +++ b/src/cpp/ecl_fun_plugin.h @@ -321,7 +321,7 @@ cl_object from_cstring(const QByteArray& s) { cl_object from_qbytearray(const QByteArray& ba) { STATIC_SYMBOL_PKG (s_make_byte_vector, "%MAKE-BYTE-VECTOR", "QML") // see 'ini.lisp' - cl_object l_list = Cnil; + cl_object l_list = ECL_NIL; for (int i = 0; i < ba.size(); i++) { l_list = CONS(ecl_make_fixnum(static_cast(ba.at(i))), l_list); } @@ -409,7 +409,7 @@ cl_object from_qvariant(const QVariant& var) { QHash lisp_functions; cl_object lisp_apply(cl_object l_fun, cl_object l_args) { - cl_object l_ret = Cnil; + cl_object l_ret = ECL_NIL; const cl_env_ptr l_env = ecl_process_env(); CL_CATCH_ALL_BEGIN(l_env) { CL_UNWIND_PROTECT_BEGIN(l_env) { @@ -469,17 +469,17 @@ QVariant ecl_fun(const QByteArray& pkgFun, QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p); QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1); cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData())); - if (l_pkg != Cnil) { + if (l_pkg != ECL_NIL) { cl_object l_sym = cl_find_symbol(2, make_constant_base_string(fun.toUpper().constData()), l_pkg); - if (cl_fboundp(l_sym) != Cnil) { + if (cl_fboundp(l_sym) != ECL_NIL) { symbol = l_sym; lisp_functions[pkgFun] = symbol; } } } - cl_object l_args = Cnil; + cl_object l_args = ECL_NIL; if (!a1.isNull()) { PUSH_ARG(a1); if (!a2.isNull()) { PUSH_ARG(a2); if (!a3.isNull()) { PUSH_ARG(a3); diff --git a/src/cpp/lqml.cpp b/src/cpp/lqml.cpp index 35c6aae..d2c2c34 100644 --- a/src/cpp/lqml.cpp +++ b/src/cpp/lqml.cpp @@ -4,10 +4,10 @@ #include #include #include -#include +#include #include -const char LQML::version[] = "23.10.1"; // October 2023 +const char LQML::version[] = "23.10.2"; // October 2023 extern "C" void ini_LQML(cl_object); diff --git a/src/cpp/main.cpp b/src/cpp/main.cpp index d2afbd1..2dcd8c4 100644 --- a/src/cpp/main.cpp +++ b/src/cpp/main.cpp @@ -4,11 +4,11 @@ #include #include #include -#include -#include -#include #include #include +#include +#include +#include #include #ifdef INI_WEBVIEW @@ -58,7 +58,7 @@ cl_object do_ini_app() { #ifdef BACKGROUND_INI_LISP ecl_init_module(NULL, ini_app); #endif - return Cnil; + return ECL_NIL; } int main(int argc, char* argv[]) { diff --git a/src/cpp/main.h b/src/cpp/main.h index ceec05e..7618d5f 100644 --- a/src/cpp/main.h +++ b/src/cpp/main.h @@ -3,9 +3,9 @@ #undef SLOT #include -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/cpp/marshal.cpp b/src/cpp/marshal.cpp index edf1275..1a8b963 100644 --- a/src/cpp/marshal.cpp +++ b/src/cpp/marshal.cpp @@ -1,10 +1,10 @@ #include "marshal.h" -#include #include #include #include #include -#include +#include +#include QT_BEGIN_NAMESPACE @@ -220,7 +220,7 @@ QVariant toQVariantMap(cl_object l_list) { cl_object l_keyword = cl_first(l_do_args); if (cl_keywordp(l_keyword) == ECL_T) { cl_object l_value = cl_second(l_do_args); - // convert INTEGER to hex string, since we only have floats in JS + // 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_value) == ECL_T) { l_value = cl_funcall(2, s_hex, l_value); @@ -258,7 +258,7 @@ cl_object from_cstring(const QByteArray& s) { cl_object from_qbytearray(const QByteArray& ba) { STATIC_SYMBOL_PKG (s_make_byte_vector, "%MAKE-BYTE-VECTOR", "QML") // see 'ini.lisp' - cl_object l_list = Cnil; + cl_object l_list = ECL_NIL; for (int i = 0; i < ba.size(); i++) { l_list = CONS(ecl_make_fixnum(static_cast(ba.at(i))), l_list); } diff --git a/src/cpp/qt_ecl.cpp b/src/cpp/qt_ecl.cpp index 8122703..ad4b800 100644 --- a/src/cpp/qt_ecl.cpp +++ b/src/cpp/qt_ecl.cpp @@ -8,7 +8,7 @@ QT_BEGIN_NAMESPACE static QHash lisp_functions; static cl_object lisp_apply(cl_object l_fun, cl_object l_args) { - cl_object l_ret = Cnil; + cl_object l_ret = ECL_NIL; const cl_env_ptr l_env = ecl_process_env(); CL_CATCH_ALL_BEGIN(l_env) { CL_UNWIND_PROTECT_BEGIN(l_env) { @@ -46,17 +46,17 @@ QVariant ecl_fun(const QByteArray& pkgFun, QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p); QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1); cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData())); - if (l_pkg != Cnil) { + if (l_pkg != ECL_NIL) { cl_object l_sym = cl_find_symbol(2, make_constant_base_string(fun.toUpper().constData()), l_pkg); - if (cl_fboundp(l_sym) != Cnil) { + if (cl_fboundp(l_sym) != ECL_NIL) { symbol = l_sym; lisp_functions[pkgFun] = symbol; } } } - cl_object l_args = Cnil; + cl_object l_args = ECL_NIL; if (!a1.isNull()) { PUSH_ARG(a1); if (!a2.isNull()) { PUSH_ARG(a2); if (!a3.isNull()) { PUSH_ARG(a3); diff --git a/src/lisp/package.lisp b/src/lisp/package.lisp index c992f66..c19d494 100644 --- a/src/lisp/package.lisp +++ b/src/lisp/package.lisp @@ -14,6 +14,7 @@ #:ensure-permissions #:find-quick-item #:hex + #:mobile-p #:pixel-ratio #:qapropos #:qapropos* diff --git a/src/make.lisp b/src/make.lisp index b15db30..f546f68 100644 --- a/src/make.lisp +++ b/src/make.lisp @@ -7,7 +7,10 @@ (list "/ecl-android" "/ecl-ios") (list :android :ios))) -#+(or android ios) +(when (probe-file "/etc/sailfish-release") + (pushnew :sailfish *features*)) + +#+(or android ios sailfish) (pushnew :mobile *features*) ;;; compile ASDF system @@ -53,7 +56,8 @@ #-msvc "a")) (to #+msvc "lisp.lib" #-msvc (format nil "liblisp~A.a" - (if (<= most-positive-fixnum (expt 2 32)) "32" ""))) + #+android (if (<= most-positive-fixnum (expt 2 32)) "32" "") + #-android "")) (to* (format nil "platforms/~A/lib/~A" #+(and linux (not android)) "linux" #+(and darwin (not ios)) "macos"