Doc: Rename and rephrase pages for QML {script|type} compiler

They describe the user facing concepts, not the actual tools. In the
case of QML script compiler there are two tools that implement it.

Clarify what qmlsc and qmlcachegen actually do and highlight the
differences.

Also, lower case all references to type compiler and script compiler.
They are not product names and therefore should not be upper cased.

Change-Id: If800d368c904bd829d88b7376b107b1c5351a1ed
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit a6f5a3886d)
This commit is contained in:
Ulf Hermann 2023-03-15 08:41:14 +01:00
parent 77d5f50f13
commit fa4e37e122
10 changed files with 75 additions and 54 deletions

View File

@ -1240,7 +1240,7 @@ function(_qt_internal_qml_add_qmltc_file_mapping_resource qrc_file target qml_fi
set(${qrc_file} ${generated_qrc_file} PARENT_SCOPE) set(${qrc_file} ${generated_qrc_file} PARENT_SCOPE)
endfunction() endfunction()
# Compile Qml files (.qml) to C++ source files with Qml Type Compiler (qmltc). # Compile Qml files (.qml) to C++ source files with QML type compiler (qmltc).
function(_qt_internal_target_enable_qmltc target) function(_qt_internal_target_enable_qmltc target)
set(args_option "") set(args_option "")
set(args_single NAMESPACE) set(args_single NAMESPACE)

View File

@ -268,7 +268,7 @@ set_target_properties(someTarget PROPERTIES
\endcode \endcode
Another important argument is \c{--direct-calls}. You can use it to enable the Another important argument is \c{--direct-calls}. You can use it to enable the
direct mode of \l{The QML Script Compiler} in case the QtQuick Compiler direct mode of \l{The QML script compiler} in case the Qt Quick Compiler
Extensions are installed. If the extensions are not installed, the argument is Extensions are installed. If the extensions are not installed, the argument is
ignored. There is a shorthand called \c {QT_QMLCACHEGEN_DIRECT_CALLS} for it. ignored. There is a shorthand called \c {QT_QMLCACHEGEN_DIRECT_CALLS} for it.
@ -312,10 +312,10 @@ See \l{qt_target_qml_sources_example}{qt_target_qml_sources()} for an example on
how to set the \c QT_QML_SINGLETON_TYPE property. how to set the \c QT_QML_SINGLETON_TYPE property.
\target qmltc-cmake \target qmltc-cmake
\section2 Compiling QML to C++ with QML Type Compiler \section2 Compiling QML to C++ with QML type compiler
If a QML module has \c{.qml} files, you can compile them to C++ using \l{QML If a QML module has \c{.qml} files, you can compile them to C++ using \l{QML
Type Compiler}{qmltc}. Unlike \l{qmlcachegen-auto}{bytecode compilation}, you type compiler}{qmltc}. Unlike \l{qmlcachegen-auto}{bytecode compilation}, you
have to explicitly enable qmltc via \l{ENABLE_TYPE_COMPILER} argument. In which have to explicitly enable qmltc via \l{ENABLE_TYPE_COMPILER} argument. In which
case, \c{.qml} files specified under \c{QML_FILES} would be compiled. Files case, \c{.qml} files specified under \c{QML_FILES} would be compiled. Files
ending with \c{.js} and \c{.mjs} are ignored as qmltc does not compile ending with \c{.js} and \c{.mjs} are ignored as qmltc does not compile
@ -511,7 +511,7 @@ class MyItem: public QQuickItem { ... };
then one has to make sure that the module containing \c QQuickItem, called then one has to make sure that the module containing \c QQuickItem, called
\c Quick, is declared as a dependency via the \c DEPENDENCIES option. Not doing \c Quick, is declared as a dependency via the \c DEPENDENCIES option. Not doing
so might result in errors during type compilation with so might result in errors during type compilation with
\l{QML Type Compiler}{qmltc} or during binding and function compilation to C++ \l{QML type compiler}{qmltc} or during binding and function compilation to C++
with \l{qmlcachegen-auto}{qmlcachegen}. with \l{qmlcachegen-auto}{qmlcachegen}.
\note Adding the module to \c DEPENDENCIES is not necessary if the module \note Adding the module to \c DEPENDENCIES is not necessary if the module
@ -686,7 +686,7 @@ work out and deploy all QML modules used by an executable target.
\target ENABLE_TYPE_COMPILER \target ENABLE_TYPE_COMPILER
\c ENABLE_TYPE_COMPILER can be used to compile \c{.qml} files to C++ source code \c ENABLE_TYPE_COMPILER can be used to compile \c{.qml} files to C++ source code
with \l{QML Type Compiler}{qmltc}. Files with the source property with \l{QML type compiler}{qmltc}. Files with the source property
\c{QT_QML_SKIP_TYPE_COMPILER} are not compiled to C++. \c{QT_QML_SKIP_TYPE_COMPILER} are not compiled to C++.
\c TYPE_COMPILER_NAMESPACE argument defines a namespace, in which the generated \c TYPE_COMPILER_NAMESPACE argument defines a namespace, in which the generated

View File

@ -319,13 +319,13 @@ the file, no matter how deeply nested.
With this pragma you can change the way type annotations on functions are With this pragma you can change the way type annotations on functions are
handled. By default the interpreter and JIT ignore type annotations, but handled. By default the interpreter and JIT ignore type annotations, but
the \l{QML Script Compiler} enforces them when compiling to C++. the \l{QML script compiler} enforces them when compiling to C++.
Specifying \c{Enforce} as value makes sure the type annotations are always Specifying \c{Enforce} as value makes sure the type annotations are always
enforced. The resulting type coercions increase the overhead of calling enforced. The resulting type coercions increase the overhead of calling
typed JavaScript functions. typed JavaScript functions.
Specifying \c{Ignore} as value makes the \l{QML Script Compiler} ignore Specifying \c{Ignore} as value makes the \l{QML script compiler} ignore
any JavaScript functions when compiling the document to C++. This means less any JavaScript functions when compiling the document to C++. This means less
code is compiled to C++ ahead of time, and more code has to be interpreted or code is compiled to C++ ahead of time, and more code has to be interpreted or
JIT-compiled. JIT-compiled.
@ -336,7 +336,7 @@ JIT-compiled.
The behavior of \l{QML Value Types} and list types differs slightly The behavior of \l{QML Value Types} and list types differs slightly
depending on whether a QML document is compiled to C++ using the depending on whether a QML document is compiled to C++ using the
\l{QML Script Compiler} or interpreted at run time. \l{QML script compiler} or interpreted at run time.
With this pragma you can change the way value types and sequences are handled With this pragma you can change the way value types and sequences are handled
when retrieved as locals from properties. By default, the interpreter and JIT when retrieved as locals from properties. By default, the interpreter and JIT
@ -344,7 +344,7 @@ treat all value types and sequences as references. This means, if you change
the local value, the original property is also changed. Furthermore, if you the local value, the original property is also changed. Furthermore, if you
write the original property explicitly, the local value is also updated. write the original property explicitly, the local value is also updated.
When compiled to C++ using the \l{QML Script Compiler}, the local value is not When compiled to C++ using the \l{QML script compiler}, the local value is not
updated when the property is written, and the property is only updated when updated when the property is written, and the property is only updated when
written directly, without retrieving it as local value before. written directly, without retrieving it as local value before.
@ -379,7 +379,7 @@ confusing.
Specifying \c{Copy} as value to the pragma makes the interpreter and JIT behave Specifying \c{Copy} as value to the pragma makes the interpreter and JIT behave
like the generated C++ code. This is the recommended way to handle the problem. like the generated C++ code. This is the recommended way to handle the problem.
Specifying \c{Reference} makes the \l{QML Script Compiler} skip any functions Specifying \c{Reference} makes the \l{QML script compiler} skip any functions
that use value types or sequences when generating C++ code. Those functions are that use value types or sequences when generating C++ code. Those functions are
then left to be interpreted or JIT-compiled with the default behavior of the then left to be interpreted or JIT-compiled with the default behavior of the
interpreter and JIT. interpreter and JIT.

View File

@ -0,0 +1,51 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtqml-qml-script-compiler.html
\title QML script compiler
\brief A tool to compile functions and expressions in QML.
\keyword qmlsc
The QML script compiler compiles functions and expressions in QML and JavaScript
files to a byte code that can be interpreted or Just-in-time compiled by the
QML engine.
In addition, it compiles some functions and expressions in QML files into C++
code, within limitations set by the nature of JavaScript. It generates C++ code
for functions that can be exhaustively analyzed. The following flow chart
explains the compilation workflow.
\image qmlsc-compilation-scheme.png
\section1 qmlsc and qmlcachegen
QML script compiler is available in two versions. One is \e qmlcachegen, which
is a part of the \l{Qt Quick Compiler}. Another one is \e qmlsc, which is a part
of the commercial-only add-on \e{Qt Quick Compiler Extensions}.
The base functionality of the QML script compiler is available in both the
\e qmlsc tool and the \e qmlcachegen tool. \e qmlsc can generate more efficient
C++ code when run in \e direct mode. It is enabled by passing \c{--direct-calls}
via \c QT_QMLCACHEGEN_ARGUMENTS to \l{qt_add_qml_module}. In direct mode
\e qmlsc expects that all C++ types used in your QML code can be made available
to the generated code by simple C++ include statements. This means you have to
link to private Qt APIs by passing Qt::QuickPrivate, Qt::QmlPrivate, etc to
link_libraries() in CMake. \e qmlcachegen does not implement direct mode and
ignores the \e{--direct-calls} option. Furthermore, \e qmlsc accepts
a \e {--static} option that you can also pass via \e QT_QMLCACHEGEN_ARGUMENTS
in \l qt_add_qml_module. In \e static mode, \e qmlsc ignores shadowing of
properties. This is dangerous if your code actually shadows properties, but
allows for more JavaScript code to be compiled to C++. \e qmlcachegen ignores
the \e {--static} option.
\section1 Limitations when compiling JavaScript to C++
Many JavaScript constructs cannot be efficiently represented in C++. The QML
script compiler skips the C++ code generation for functions that contain such
constructs and only generates byte code to be interpreted or run through the
Just-in-time compiler. Most common QML expressions are rather simple: value
lookups on QObjects, arithmetics, simple if/else or loop constructs. Those can
easily be expressed in C++, and doing so makes your application run faster.
*/

View File

@ -2,12 +2,12 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*! /*!
\page qtqml-tool-qmltc.html \page qtqml-qml-type-compiler.html
\title QML Type Compiler \title QML type compiler
\brief A tool to compile QML types to C++ ahead of time. \brief A tool to compile QML types to C++ ahead of time.
\keyword qmltc \keyword qmltc
The QML Type Compiler, \c qmltc, is a tool shipped with Qt to translate QML The QML type compiler, \c qmltc, is a tool shipped with Qt to translate QML
types into C++ types that are \e{ahead-of-time} compiled as part of the user types into C++ types that are \e{ahead-of-time} compiled as part of the user
code. Using qmltc can lead to better run-time performance due to more code. Using qmltc can lead to better run-time performance due to more
optimization opportunities available to the compiler compared to a optimization opportunities available to the compiler compared to a

View File

@ -17,17 +17,17 @@ time, rather than at run time. This allows for:
The Qt Quick Compiler consist of two components: The Qt Quick Compiler consist of two components:
\list \list
\li \l {QML Type Compiler} \li \l {QML type compiler}
\li \l {QML Script Compiler} \li \l {QML script compiler}
\endlist \endlist
\note \e qmltc, \e qmlsc and \l qmlcachegen are internal build tools. If you \note \e qmltc, \e qmlsc and \l qmlcachegen are internal build tools. If you
need to care about their invocation, you are either writing a build system, or need to care about their invocation, you are either writing a build system, or
you are doing something wrong. you are doing something wrong.
\subtitle The QML Type Compiler \subtitle The QML type compiler
The \l{QML Type Compiler}, \e(qmltc) compiles QML types to C++ classes. These C++ The \l{QML type compiler}, \e(qmltc) compiles QML types to C++ classes. These C++
classes are then added to your application and can be instantiated from other classes are then added to your application and can be instantiated from other
C++ code. This way you can avoid much of the overhead of using \l{QQmlComponent} C++ code. This way you can avoid much of the overhead of using \l{QQmlComponent}
to create instances of your QML types. In order to benefit from \l qmltc, you to create instances of your QML types. In order to benefit from \l qmltc, you
@ -38,9 +38,9 @@ structure. It will fail if an unsupported language feature is encountered.
It does not have to understand the JavaScript code in bindings and functions, It does not have to understand the JavaScript code in bindings and functions,
though. though.
\subtitle The QML Script Compiler \subtitle The QML script compiler
The \l{QML Script Compiler}, (\e qmlsc and \e qmlcachegen) compiles bindings and The \l{QML script compiler}, (\e qmlsc and \e qmlcachegen) compiles bindings and
functions to both, an efficient byte code and C++ functions. This process functions to both, an efficient byte code and C++ functions. This process
automatically happens behind the scenes if you are using \l{qt_add_qml_module} automatically happens behind the scenes if you are using \l{qt_add_qml_module}
to specify your QML modules. At compile time, for each QML or JavaScript to specify your QML modules. At compile time, for each QML or JavaScript

View File

@ -1,30 +0,0 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtqml-tool-qmlsc.html
\title QML Script Compiler
\brief A tool to compile functions and expressions in QML.
\keyword qmlsc
The QML Script Compiler, \c qmlsc will compile functions and expressions in QML
files of an application into C++ code within limitations set by the nature of
JavaScript. It replaces \e qmlcachegen, and simply generates C++ code in addition
to byte code for functions that can be exhaustively analyzed. The following flow
chart explains the compilation of \e qmlsc.
\image qmlsc-compilation-scheme.png
\section1 Limitations when compiling JavaScript
Many JavaScript constructs cannot be efficiently represented in C++. \e qmlsc
skips the C++ code generation for functions that contain such constructs and
only generates byte code to be interpreted. Although, most common QML expressions
are rather simple: value lookups on QObjects, arithmetics, simple if/else or loop
constructs. Those can easily be expressed in C++, and doing so makes your
application run faster.
\e qmlsc is available for commercial customers and some of its features are
merged into \e qmlcachegen, which continues to be available with all versions of
Qt.
*/

View File

@ -98,7 +98,7 @@ all the available options.
The Qt Quick Compiler consist of two components: The Qt Quick Compiler consist of two components:
\list \list
\li \l {QML Type Compiler} \li \l {QML type compiler}
\li \l {QML Script Compiler} \li \l {QML script compiler}
\endlist \endlist
*/ */

View File

@ -55,7 +55,7 @@ endif()
add_subdirectory(qqmlmetatype) add_subdirectory(qqmlmetatype)
if(TARGET Qt::Quick) if(TARGET Qt::Quick)
add_subdirectory(qmltc_manual) add_subdirectory(qmltc_manual)
# QML Type Compiler tests cannot be run on webOS due to missing support for multiple # QML type compiler tests cannot be run on webOS due to missing support for multiple
# consecutive window creation from a single QtWayland client # consecutive window creation from a single QtWayland client
if(NOT WEBOS) if(NOT WEBOS)
add_subdirectory(qmltc) add_subdirectory(qmltc)

View File

@ -3,7 +3,7 @@
qt_get_tool_target_name(target_name qmltc) qt_get_tool_target_name(target_name qmltc)
qt_internal_add_tool(${target_name} qt_internal_add_tool(${target_name}
TARGET_DESCRIPTION "QML Type Compiler" TARGET_DESCRIPTION "QML type compiler"
TOOLS_TARGET Qml TOOLS_TARGET Qml
SOURCES SOURCES
main.cpp main.cpp