| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2018 Eike Hein <hein@kde.org> |
| 3 | SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: MIT |
| 6 | */ |
| 7 | |
| 8 | #include "types.h" |
| 9 | |
| 10 | #include <QJSEngine> |
| 11 | |
| 12 | KSyntaxHighlighting::Repository *defaultRepository() // also used by KQuickSyntaxHighlighter |
| 13 | { |
| 14 | static std::unique_ptr<KSyntaxHighlighting::Repository> s_instance; |
| 15 | if (!s_instance) { |
| 16 | s_instance = std::make_unique<KSyntaxHighlighting::Repository>(); |
| 17 | } |
| 18 | return s_instance.get(); |
| 19 | } |
| 20 | |
| 21 | KSyntaxHighlighting::Repository *RepositoryForeign::create([[maybe_unused]] QQmlEngine *engine, QJSEngine *scriptEngine) |
| 22 | { |
| 23 | auto repo = defaultRepository(); |
| 24 | scriptEngine->setObjectOwnership(repo, QJSEngine::CppOwnership); |
| 25 | return repo; |
| 26 | } |
| 27 | |
| 28 | #include "moc_types.cpp" |
| 29 | |