aboutsummaryrefslogtreecommitdiffstats
path: root/include/qdotnetstatic.h
blob: adb39689633dcbb27339cc66f9a225e8810799ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/***************************************************************************************************
 Copyright (C) 2024 The Qt Company Ltd.
 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/

#pragma once

#include "qdotnetinterface.h"
#include "qdotnetobject.h"
#include "iqqmlengine.h"

#include <functional>

class QDotNetStatic : public QDotNetInterface
{
public:
    static inline const QString &AssemblyQualifiedName =
        QStringLiteral("Qt.DotNet.Adapter+IStatic, Qt.DotNet.Adapter");

    QDotNetStatic(const void *objectRef) : QDotNetInterface(objectRef) {}

    QDotNetStatic() : QDotNetInterface(AssemblyQualifiedName, nullptr)
    {
#ifdef QT_QUICK_LIB
        IQQmlEngine::staticInit(this);
#endif
    }
};

inline static bool ctor_static = std::invoke([]()
    {
        QDotNetAdapter::ctor_staticInterface = []()
            {
                auto *staticObject = new QDotNetStatic();
                auto setStatic = QDotNetType::staticMethod<void, QDotNetStatic>(
                    "Qt.DotNet.Adapter, Qt.DotNet.Adapter", "set_Static");
                setStatic(*staticObject);
                return staticObject;
            };
        return true;
    });

inline static bool dtor_static = std::invoke([]()
    {
        QDotNetAdapter::dtor_staticInterface = [](void *that)
            {
                delete reinterpret_cast<QDotNetStatic *>(that);
            };
        return true;
    });