Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmljsloadergenerator.cpp File Reference
#include "qqmljsloadergenerator_p.h"
#include <QByteArray>
#include <QRegularExpression>
#include <QString>
#include <QStringList>
#include <QTextStream>
#include <QVector>
#include <QtEndian>
#include <QStack>
#include <QFileInfo>
#include <QSaveFile>
#include <algorithm>
+ Include dependency graph for qqmljsloadergenerator.cpp:

Go to the source code of this file.

Functions

QT_BEGIN_NAMESPACE QString mangledIdentifier (const QString &str)
 
QString qQmlJSSymbolNamespaceForPath (const QString &relativePath)
 
static QString qtResourceNameForFile (const QString &fileName)
 
bool qQmlJSGenerateLoader (const QStringList &compiledFiles, const QString &outputFileName, const QStringList &resourceFileMappings, QString *errorString)
 

Function Documentation

◆ mangledIdentifier()

QT_BEGIN_NAMESPACE QString mangledIdentifier ( const QString str)

Mangles str to be a unique C++ identifier. Characters that are invalid for C++ identifiers are replaced by the pattern _0x<hex>_ where <hex> is the hexadecimal unicode representation of the character. As identifiers with leading underscores followed by either another underscore or a capital letter are reserved in C++, we also escape those, by escaping the first underscore, using the above method.

Note
Although C++11 allows for non-ascii (unicode) characters to be used in identifiers, many compilers forgot to read the spec and do not implement this. Some also do not implement C99 identifiers, because that is {at the implementation's discretion}. So, we are stuck with plain old boring identifiers.

Definition at line 35 of file qqmljsloadergenerator.cpp.

References QString::at(), ch, i, QString::isEmpty(), QString::number(), Q_ASSERT, QString::reserve(), QString::size(), QString::startsWith(), str, and QChar::unicode().

Referenced by qQmlJSSymbolNamespaceForPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qQmlJSGenerateLoader()

bool qQmlJSGenerateLoader ( const QStringList compiledFiles,
const QString outputFileName,
const QStringList resourceFileMappings,
QString errorString 
)

Definition at line 93 of file qqmljsloadergenerator.cpp.

References i, QString::indexOf(), QString::isEmpty(), QString::mid(), qQmlJSSymbolNamespaceForPath(), QStringLiteral, qtResourceNameForFile(), QByteArray::size(), QIODeviceBase::Truncate, QString::truncate(), and QIODeviceBase::WriteOnly.

+ Here is the call graph for this function:

◆ qQmlJSSymbolNamespaceForPath()

QString qQmlJSSymbolNamespaceForPath ( const QString relativePath)

Definition at line 67 of file qqmljsloadergenerator.cpp.

References QFileInfo::baseName(), QString::clear(), QFileInfo::completeSuffix(), fi, mangledIdentifier(), QFileInfo::path(), QString::replace(), QString::size(), and QString::startsWith().

Referenced by qQmlJSGenerateLoader(), and qSaveQmlJSUnitAsCpp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qtResourceNameForFile()

static QString qtResourceNameForFile ( const QString fileName)
static

Definition at line 83 of file qqmljsloadergenerator.cpp.

References QFileInfo::completeBaseName(), fi, QFileInfo::fileName(), fileName, and QString::replace().

Referenced by qQmlJSGenerateLoader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: