Inserts ktexttemplate ported idl files parser
This commit is contained in:
10 files changed
+217
-38
No files matched your search
@@ -14,9 +14,9 @@ endif()
|
||||
|
||||
FIND_PACKAGE(RTI)
|
||||
|
||||
# Grantlee5 is Qt5-based and optional for Qt6 migration
|
||||
# KTextTemplate is Qt6-compatible replacement for Grantlee5
|
||||
IF(BUILD_GRANTLEE)
|
||||
FIND_PACKAGE(Grantlee5 REQUIRED COMPONENTS Templates)
|
||||
FIND_PACKAGE(KF6TextTemplate REQUIRED)
|
||||
ENDIF()
|
||||
|
||||
NGL_ADD_LIBRARY2(ALL codegen_base SHARED
|
||||
@@ -57,8 +57,8 @@ else()
|
||||
endif()
|
||||
NGL_INSTALL_TARGET(codegen_base)
|
||||
|
||||
# Grantlee5 is Qt5-based and optional for Qt6 migration
|
||||
IF(BUILD_GRANTLEE AND TARGET Grantlee5::Templates)
|
||||
# KTextTemplate is Qt6-compatible replacement for Grantlee5
|
||||
IF(BUILD_GRANTLEE AND TARGET KF6::TextTemplate)
|
||||
NGL_ADD_LIBRARY(ALL codegen_grantlee STATIC
|
||||
CppTopicGeneratorGrantlee.cpp
|
||||
CppTopicGeneratorGrantlee.h
|
||||
@@ -114,7 +114,7 @@ IF(BUILD_GRANTLEE AND TARGET Grantlee5::Templates)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(codegen_grantlee
|
||||
PRIVATE
|
||||
Grantlee5::Templates
|
||||
KF6::TextTemplate
|
||||
NGLLogger
|
||||
ProjectConfig
|
||||
PUBLIC
|
||||
@@ -135,7 +135,7 @@ IF(BUILD_GRANTLEE AND TARGET Grantlee5::Templates)
|
||||
endif()
|
||||
|
||||
add_executable(grantlee_parser_smoke tests/GrantleeParserSmoke.cpp)
|
||||
target_link_libraries(grantlee_parser_smoke PRIVATE Grantlee5::Templates ${QTCORE_TARGET})
|
||||
target_link_libraries(grantlee_parser_smoke PRIVATE KF6::TextTemplate ${QTCORE_TARGET})
|
||||
add_test(NAME GrantleeParserSmoke COMMAND grantlee_parser_smoke ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
NGL_ADD_EXECUTABLE(ALL ngl_codegen
|
||||
@@ -162,7 +162,7 @@ if(QT6_GUI_AVAILABLE)
|
||||
LtsCommandLineParser
|
||||
nglapplication
|
||||
${Qt6_Widgets}
|
||||
Grantlee5::Templates
|
||||
KF6::TextTemplate
|
||||
)
|
||||
endif()
|
||||
ELSE()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <grantlee/context.h>
|
||||
#include <ktexttemplate/context.h>
|
||||
|
||||
#ifdef RTI_HEADER_AVAILABLE
|
||||
#include <dds/core/xtypes/EnumType.hpp>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "StructBuilder.h"
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <grantlee/context.h>
|
||||
#include <ktexttemplate/context.h>
|
||||
|
||||
using namespace CodeGen;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "StructBuilder.h"
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <grantlee/context.h>
|
||||
#include <ktexttemplate/context.h>
|
||||
|
||||
using namespace CodeGen;
|
||||
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <grantlee/context.h>
|
||||
#include <grantlee/engine.h>
|
||||
|
||||
using namespace CodeGen;
|
||||
|
||||
GeneratorGrantleeBase::GeneratorGrantleeBase(const char* loggerName)
|
||||
: m_engine(new Grantlee::Engine)
|
||||
, m_ctx(new Grantlee::Context)
|
||||
: m_engine(new KTextTemplate::Engine)
|
||||
, m_ctx(new KTextTemplate::Context)
|
||||
, m_structBuilder(nullptr)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName))
|
||||
{
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "XmlReader.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include <ktexttemplate/template.h>
|
||||
#include <ktexttemplate/context.h>
|
||||
#include <ktexttemplate/engine.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace Grantlee
|
||||
{
|
||||
class Context;
|
||||
class Engine;
|
||||
class TemplateImpl;
|
||||
using Template = QSharedPointer<TemplateImpl>;
|
||||
} // namespace Grantlee
|
||||
|
||||
namespace CodeGen
|
||||
{
|
||||
class StructBuilder;
|
||||
@@ -45,9 +39,9 @@ class GeneratorGrantleeBase : public QObject
|
||||
void exportUsedServices(const XmlReader* reader);
|
||||
|
||||
protected:
|
||||
Grantlee::Engine* m_engine;
|
||||
Grantlee::Context* m_ctx;
|
||||
Grantlee::Template m_template;
|
||||
KTextTemplate::Engine* m_engine;
|
||||
KTextTemplate::Context* m_ctx;
|
||||
KTextTemplate::Template m_template;
|
||||
StructBuilder* m_structBuilder;
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <grantlee/engine.h>
|
||||
#include <nglapplication/nglapplication.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: QMainWindow(parent), m_xmlReader(nullptr), m_structBuilder(nullptr),
|
||||
m_generator(new CodeGen::CppTopicGeneratorGrantlee), m_engine(new Grantlee::Engine), m_ui(new Ui_MainGrantleeGui)
|
||||
m_generator(new CodeGen::CppTopicGeneratorGrantlee), m_engine(new KTextTemplate::Engine), m_ui(new Ui_MainGrantleeGui)
|
||||
{
|
||||
m_idlServiceInfoFile = QStringLiteral("/home/chehrlic/TDS/TDS-build-product-clang/service_idl_files.txt");
|
||||
m_ui->setupUi(this);
|
||||
|
||||
@@ -11,7 +11,7 @@ class StructBuilder;
|
||||
class GeneratorGrantleeBase;
|
||||
} // namespace CodeGen
|
||||
|
||||
namespace Grantlee
|
||||
namespace KTextTemplate
|
||||
{
|
||||
class Engine;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class MainWindow : public QMainWindow
|
||||
CodeGen::XmlReader* m_xmlReader;
|
||||
CodeGen::StructBuilder* m_structBuilder;
|
||||
CodeGen::GeneratorGrantleeBase* m_generator;
|
||||
Grantlee::Engine* m_engine;
|
||||
KTextTemplate::Engine* m_engine;
|
||||
QString m_idlServiceInfoFile;
|
||||
QString m_templateFile;
|
||||
Ui_MainGrantleeGui* m_ui;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <grantlee/engine.h>
|
||||
#include <grantlee/templateloader.h>
|
||||
#include <ktexttemplate/engine.h>
|
||||
#include <ktexttemplate/templateloader.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@@ -14,8 +14,8 @@ int main(int argc, char** argv)
|
||||
templatesDir = QString::fromLocal8Bit(argv[1]);
|
||||
}
|
||||
|
||||
Grantlee::Engine engine;
|
||||
auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>::create();
|
||||
KTextTemplate::Engine engine;
|
||||
auto loader = QSharedPointer<KTextTemplate::FileSystemTemplateLoader>::create();
|
||||
loader->setTemplateDirs(QStringList() << templatesDir);
|
||||
engine.addTemplateLoader(loader);
|
||||
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char** argv)
|
||||
bool ok = true;
|
||||
for (const QString& f : files)
|
||||
{
|
||||
Grantlee::Template t;
|
||||
KTextTemplate::Template t;
|
||||
try
|
||||
{
|
||||
t = engine.loadByName(f);
|
||||
@@ -49,14 +49,14 @@ int main(int argc, char** argv)
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
if (t->error() != Grantlee::NoError)
|
||||
if (t->error() != KTextTemplate::NoError)
|
||||
{
|
||||
qDebug() << "Parse error in" << f << ":" << t->errorString();
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
// Render with empty context to ensure rendering path also works.
|
||||
Grantlee::Context ctx;
|
||||
KTextTemplate::Context ctx;
|
||||
QString out = t->render(&ctx);
|
||||
if (out.isNull())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user