summaryrefslogtreecommitdiffstats
path: root/generator.cpp
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-08-21 18:36:37 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-08-25 16:23:16 -0300
commit2270cb2b4e57b8e3d82dd1cf692eea75a4342c45 (patch)
treec485f506155df3d5ec7a21347b9d1e8d38f85400 /generator.cpp
parent55dd77e04a8cef0e14648d6d8fb18cdc18695931 (diff)
downloadgeneratorrunner-2270cb2b4e57b8e3d82dd1cf692eea75a4342c45.tar.gz
generatorrunner-2270cb2b4e57b8e3d82dd1cf692eea75a4342c45.tar.xz
generatorrunner-2270cb2b4e57b8e3d82dd1cf692eea75a4342c45.zip
Removed QtDocGenerator dependence from BoostPythonGenerator, so a lot
of function were moved from BoostPythonGenerator to the Generator class. In other words, QtDocGenerator finally compiles and their unit test pass :-)
Diffstat (limited to 'generator.cpp')
-rw-r--r--generator.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/generator.cpp b/generator.cpp
index 3004063..80610c4 100644
--- a/generator.cpp
+++ b/generator.cpp
@@ -60,6 +60,48 @@ bool Generator::setup(const ApiExtractor& extractor, const QMap< QString, QStrin
return doSetup(args);
}
+QMap< QString, QString > Generator::options() const
+{
+ return QMap<QString, QString>();
+}
+
+AbstractMetaClassList Generator::classes() const
+{
+ return m_classes;
+}
+
+AbstractMetaFunctionList Generator::globalFunctions() const
+{
+ return m_globalFunctions;
+}
+
+AbstractMetaEnumList Generator::globalEnums() const
+{
+ return m_globalEnums;
+}
+
+QList<const PrimitiveTypeEntry*> Generator::primitiveTypes() const
+{
+ return m_primitiveTypes;
+}
+
+QList<const ContainerTypeEntry*> Generator::containerTypes() const
+{
+ return m_containerTypes;
+}
+
+/// Returns the output directory
+QString Generator::outputDirectory() const
+{
+ return m_outDir;
+}
+
+/// Set the output directory
+void Generator::setOutputDirectory(const QString &outDir)
+{
+ m_outDir = outDir;
+}
+
void Generator::generate()
{
foreach (AbstractMetaClass *cls, m_classes) {
@@ -346,3 +388,52 @@ CodeSnipList Generator::getCodeSnips(const AbstractMetaFunction *func)
return result;
}
+
+QString Generator::translateType(const AbstractMetaType *cType,
+ const AbstractMetaClass *context,
+ int option) const
+{
+ QString s;
+
+ if (context && cType &&
+ context->typeEntry()->isGenericClass() &&
+ cType->originalTemplateType()) {
+ qDebug() << "set original templateType" << cType->name();
+ cType = cType->originalTemplateType();
+ }
+
+ if (!cType) {
+ s = "void";
+ } else if (cType->isArray()) {
+ s = translateType(cType->arrayElementType(), context) + "[]";
+ } else if (cType->isEnum() || cType->isFlags()) {
+ if (option & Generator::EnumAsInts)
+ s = "int";
+ else
+ s = cType->cppSignature();
+#if 0
+ } else if (c_type->isContainer()) {
+ qDebug() << "is container" << c_type->cppSignature();
+ s = c_type->name();
+ if (!(option & SkipTemplateParameters)) {
+ s += " < ";
+ QList<AbstractMetaType *> args = c_type->instantiations();
+ for (int i = 0; i < args.size(); ++i) {
+ if (i)
+ s += ", ";
+ qDebug() << "container type: " << args.at(i)->cppSignature() << " / " << args.at(i)->instantiations().count();
+ s += translateType(args.at(i), context, option);
+ }
+ s += " > ";
+ }
+#endif
+ } else {
+ s = cType->cppSignature();
+ if (cType->isConstant() && (option & Generator::ExcludeConst))
+ s.replace("const", "");
+ if (cType->isReference() && (option & Generator::ExcludeReference))
+ s.replace("&", "");
+ }
+
+ return s;
+}