1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef BUILDMESSAGE_H
5#define BUILDMESSAGE_H
6
7#include <QtCore/qobject.h>
8#include <QtCore/qdebug.h>
9#include <QtQml/qqmlregistration.h>
10#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
11
12QT_BEGIN_NAMESPACE
13
14struct BuildMessage
15{
16 using Status = QtQuick3DEditorHelpers::ShaderBaker::Status;
17 QString message;
18 QString identifier;
19 qint64 line = -1;
20 qint64 column = -1;
21 Status status = Status::Success;
22
23 friend QDebug operator<<(QDebug stream, const BuildMessage &err)
24 {
25 stream << err.message;
26 if (err.line != -1)
27 stream << "at line: " << err.line;
28 return stream;
29 }
30};
31
32class ShaderBuildMessage
33{
34 Q_GADGET
35 Q_PROPERTY(QString filename READ filename)
36 Q_PROPERTY(QString message READ message)
37 Q_PROPERTY(QString identifier READ identifier)
38 Q_PROPERTY(qint64 line READ line)
39 Q_PROPERTY(Status status READ status)
40 Q_PROPERTY(Stage stage READ stage)
41 QML_VALUE_TYPE(shaderStatus)
42public:
43 enum class Status
44 {
45 Success,
46 Error
47 };
48 Q_ENUM(Status)
49 enum class Stage
50 {
51 Vertex,
52 Fragment
53 };
54 Q_ENUM(Stage)
55
56 ShaderBuildMessage() = default;
57 ShaderBuildMessage(const BuildMessage &data, const QString &filename, Stage stage);
58 const QString &filename() const { return m_filename; }
59 const QString &message() const { return m_message.message; }
60 const QString &identifier() const { return m_message.identifier; }
61 qint64 line() const { return m_message.line; }
62 Status status() const { return static_cast<Status>(m_message.status); }
63 Stage stage() const { return m_stage; }
64
65private:
66 BuildMessage m_message;
67 QString m_filename;
68 Stage m_stage;
69};
70
71// To prevent the same type from being exported twice into qmltypes
72// (for value type and for the enums)
73struct ShaderBuildMessageDerived : public ShaderBuildMessage
74{
75 Q_GADGET
76};
77
78namespace ShaderEnums {
79Q_NAMESPACE
80QML_FOREIGN_NAMESPACE(ShaderBuildMessageDerived)
81QML_NAMED_ELEMENT(ShaderConstants)
82}
83
84QT_END_NAMESPACE
85
86#endif // BUILDMESSAGE_H
87

source code of qtquick3d/tools/materialeditor/buildmessage.h