diff --git a/doc/help.htm b/doc/help.htm index daa153b..4b41a97 100644 --- a/doc/help.htm +++ b/doc/help.htm @@ -55,17 +55,18 @@ Since we only have floats in QML/JS, INTEGERs from Lisp are converted automatically to hex strings, if (1) populating an item model, or (2) passed with function QJS. - Those hex strings are automatically converted back to a 'qint64' integer when + Those hex strings are automatically converted back to a Lisp INTEGER when passed with 'Lisp.call()' or 'Lisp.apply()'. Important note: because of the automatic conversion of INTEGERs, you need to explicitly add '(float x)' in Lisp to values you don't want to be converted - to hex strings, like drawing a line in a QML Canvas, or FIXNUM integers. + to hex strings, like drawing a line in a QML Canvas, or a FIXNUM integer + which you want as number type in JS. mobile-p () - Returns T on android, iOS, SailfishOS. + On mobile returns one of :ANDROID, :IOS, :SFOS. pixel-ratio () diff --git a/src/cpp/ecl_ext.cpp b/src/cpp/ecl_ext.cpp index 395b89d..515cf4b 100644 --- a/src/cpp/ecl_ext.cpp +++ b/src/cpp/ecl_ext.cpp @@ -632,15 +632,21 @@ cl_object qquit2(cl_object l_status) { cl_object mobile_p() { /// args: () - /// Returns T on android, iOS, SailfishOS. + /// On mobile returns one of :ANDROID, :IOS, :SFOS. + STATIC_SYMBOL_PKG (s_android, "ANDROID", "KEYWORD") + STATIC_SYMBOL_PKG (s_ios, "IOS", "KEYWORD") + STATIC_SYMBOL_PKG (s_sfos, "SFOS", "KEYWORD") ecl_process_env()->nvalues = 1; + cl_object l_ret = ECL_NIL; QString platform = qGuiApp->platformName(); - if ((platform == QStringLiteral("android")) || - (platform == QStringLiteral("ios")) || - QFile::exists("/etc/sailfish-release")) { - return ECL_T; + if (platform == QStringLiteral("android")) { + l_ret = s_android; + } else if (platform == QStringLiteral("ios")) { + l_ret = s_ios; + } else if (QFile::exists("/etc/sailfish-release")) { + l_ret = s_sfos; } - return ECL_NIL; + return l_ret; } cl_object pixel_ratio() { diff --git a/src/cpp/ecl_fun_plugin.h b/src/cpp/ecl_fun_plugin.h index 7e1744a..f38ec49 100644 --- a/src/cpp/ecl_fun_plugin.h +++ b/src/cpp/ecl_fun_plugin.h @@ -250,6 +250,8 @@ QVariant toQVariant(cl_object l_arg, int type) { var = QVariant(toFloat(l_arg)); } else if (cl_stringp(l_arg) == ECL_T) { // string var = QVariant(toQString(l_arg)); + } else if (cl_symbolp(l_arg) == ECL_T) { // symbol + var = QVariant(toQString(cl_string_downcase(1, cl_symbol_name(l_arg)))); } else if (cl_characterp(l_arg) == ECL_T) { // char var = QChar(toInt(cl_char_code(l_arg))); } else if (l_arg == ECL_T) { // true diff --git a/src/cpp/marshal.cpp b/src/cpp/marshal.cpp index 1a8b963..bb4c314 100644 --- a/src/cpp/marshal.cpp +++ b/src/cpp/marshal.cpp @@ -164,6 +164,8 @@ QVariant toQVariant(cl_object l_arg, int type) { var = QVariant(toFloat(l_arg)); } else if (cl_stringp(l_arg) == ECL_T) { // string var = QVariant(toQString(l_arg)); + } else if (cl_symbolp(l_arg) == ECL_T) { // symbol + var = QVariant(toQString(cl_string_downcase(1, cl_symbol_name(l_arg)))); } else if (cl_characterp(l_arg) == ECL_T) { // char var = QChar(toInt(cl_char_code(l_arg))); } else if (l_arg == ECL_T) { // true diff --git a/src/lisp/qml.lisp b/src/lisp/qml.lisp index c6b9327..c7ae5ce 100644 --- a/src/lisp/qml.lisp +++ b/src/lisp/qml.lisp @@ -20,12 +20,13 @@ Since we only have floats in QML/JS, INTEGERs from Lisp are converted automatically to hex strings, if (1) populating an item model, or (2) passed with function QJS. - Those hex strings are automatically converted back to a 'qint64' integer when + Those hex strings are automatically converted back to a Lisp INTEGER when passed with 'Lisp.call()' or 'Lisp.apply()'. Important note: because of the automatic conversion of INTEGERs, you need to explicitly add '(float x)' in Lisp to values you don't want to be converted - to hex strings, like drawing a line in a QML Canvas, or FIXNUM integers." + to hex strings, like drawing a line in a QML Canvas, or a FIXNUM integer + which you want as number type in JS." (assert (integerp integer)) (let ((*print-base* 16)) (x:cc "#x" (princ-to-string integer))))