/* SPDX-FileCopyrightText: 2018 Eike Hein SPDX-FileCopyrightText: 2021 Volker Krause SPDX-License-Identifier: MIT */ #include "kquicksyntaxhighlightingplugin.h" #include "kquicksyntaxhighlighter.h" #include #include #include #include using namespace KSyntaxHighlighting; Repository *defaultRepository() { static std::unique_ptr s_instance; if (!s_instance) { s_instance = std::make_unique(); } return s_instance.get(); } void KQuickSyntaxHighlightingPlugin::registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.syntaxhighlighting")); qRegisterMetaType(); qRegisterMetaType>(); qRegisterMetaType(); qRegisterMetaType>(); qmlRegisterType(uri, 1, 0, "SyntaxHighlighter"); qmlRegisterUncreatableMetaObject(Definition::staticMetaObject, uri, 1, 0, "Definition", {}); qmlRegisterUncreatableMetaObject(Theme::staticMetaObject, uri, 1, 0, "Theme", {}); qmlRegisterSingletonType(uri, 1, 0, "Repository", [](auto engine, auto scriptEngine) { (void)engine; auto repo = defaultRepository(); scriptEngine->setObjectOwnership(repo, QJSEngine::CppOwnership); return defaultRepository(); }); } #include "moc_kquicksyntaxhighlightingplugin.cpp"