summaryrefslogtreecommitdiffstats
path: root/generators/boostpython
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-08-21 18:13:34 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-08-25 16:23:16 -0300
commit55dd77e04a8cef0e14648d6d8fb18cdc18695931 (patch)
treed6533b9b8e741050a6c6ccd9c5abab561767739d /generators/boostpython
parent9682566c558674609a77540978e36db3dd174303 (diff)
downloadgeneratorrunner-55dd77e04a8cef0e14648d6d8fb18cdc18695931.tar.gz
generatorrunner-55dd77e04a8cef0e14648d6d8fb18cdc18695931.tar.xz
generatorrunner-55dd77e04a8cef0e14648d6d8fb18cdc18695931.zip
- QtDocGenerator is now a GeneratorRunner plugin.
- A lot of methods moved from boostpythongenerator to the generator class.
Diffstat (limited to 'generators/boostpython')
-rw-r--r--generators/boostpython/CMakeLists.txt8
-rw-r--r--generators/boostpython/boostpythongenerator.cpp206
-rw-r--r--generators/boostpython/boostpythongenerator.h10
3 files changed, 4 insertions, 220 deletions
diff --git a/generators/boostpython/CMakeLists.txt b/generators/boostpython/CMakeLists.txt
index 1e47cac..c4bb296 100644
--- a/generators/boostpython/CMakeLists.txt
+++ b/generators/boostpython/CMakeLists.txt
@@ -1,6 +1,6 @@
project(boostpython)
-set(boostpython_SRC
+set(boostpython_generator_SRC
boostpythongenerator.cpp
convertergenerator.cpp
cppgenerator.cpp
@@ -8,7 +8,7 @@ hppgenerator.cpp
boostpython.cpp
)
-add_library(boostpython SHARED ${boostpython_SRC})
-target_link_libraries(boostpython ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} generator)
+add_library(boostpython_generator SHARED ${boostpython_generator_SRC})
+target_link_libraries(boostpython_generator ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} generator)
-install(TARGETS boostpython DESTINATION lib)
+install(TARGETS boostpython_generator DESTINATION ${LIB_INSTALL_DIR})
diff --git a/generators/boostpython/boostpythongenerator.cpp b/generators/boostpython/boostpythongenerator.cpp
index d5fd5e6..b799f4d 100644
--- a/generators/boostpython/boostpythongenerator.cpp
+++ b/generators/boostpython/boostpythongenerator.cpp
@@ -36,92 +36,6 @@
static Indentor INDENT;
static void dump_function(AbstractMetaFunctionList lst);
-static QString formattedCodeHelper(QTextStream &s, Indentor &indentor, QStringList &lines)
-{
- bool multilineComment = false;
- bool lastEmpty = true;
- QString lastLine;
- while (!lines.isEmpty()) {
- const QString line = lines.takeFirst().trimmed();
- if (line.isEmpty()) {
- if (!lastEmpty)
- s << endl;
- lastEmpty = true;
- continue;
- } else
- lastEmpty = false;
-
- if (line.startsWith("/*"))
- multilineComment = true;
-
- if (multilineComment) {
- s << indentor;
- if (line.startsWith("*"))
- s << " ";
- s << line << endl;
- if (line.endsWith("*/"))
- multilineComment = false;
- } else if (line.startsWith("}"))
- return line;
- else if (line.endsWith("")) {
- s << indentor << line << endl;
- return 0;
- } else if (line.endsWith("{")) {
- s << indentor << line << endl;
- QString tmp;
- {
- Indentation indent(indentor);
- tmp = formattedCodeHelper(s, indentor, lines);
- }
- if (!tmp.isNull())
- s << indentor << tmp << endl;
-
- lastLine = tmp;
- continue;
- } else {
- s << indentor;
- if (!lastLine.isEmpty() &&
- !lastLine.endsWith(";") &&
- !line.startsWith("@") &&
- !line.startsWith("//") &&
- !lastLine.startsWith("//") &&
- !lastLine.endsWith("}") &&
- !line.startsWith("{"))
- s << " ";
- s << line << endl;
- }
- lastLine = line;
- }
- return 0;
-}
-
-QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
-{
- QStringList lst(code.split("\n"));
- while (!lst.isEmpty()) {
- QString tmp = formattedCodeHelper(s, indentor, lst);
- if (!tmp.isNull())
- s << indentor << tmp << endl;
-
- }
- s.flush();
- return s;
-}
-
-FunctionModificationList BoostPythonGenerator::functionModifications(const AbstractMetaFunction *metaFunction)
-{
- FunctionModificationList mods;
- const AbstractMetaClass *cls = metaFunction->implementingClass();
- while (cls) {
- mods += metaFunction->modifications(cls);
-
- if (cls == cls->baseClass())
- break;
- cls = cls->baseClass();
- }
- return mods;
-}
-
QString BoostPythonGenerator::translateType(const AbstractMetaType *cType,
const AbstractMetaClass *context,
int option) const
@@ -343,77 +257,6 @@ void BoostPythonGenerator::writeArgumentNames(QTextStream &s,
}
}
-AbstractMetaFunctionList BoostPythonGenerator::queryGlobalOperators(const AbstractMetaClass *cppClass)
-{
- AbstractMetaFunctionList result;
-
- foreach (AbstractMetaFunction *func, cppClass->functions()) {
- if (func->isInGlobalScope() && func->isOperatorOverload())
- result.append(func);
- }
- return result;
-}
-
-AbstractMetaFunctionList BoostPythonGenerator::sortContructor(AbstractMetaFunctionList list)
-{
- AbstractMetaFunctionList result;
-
- foreach (AbstractMetaFunction *func, list) {
- bool inserted = false;
- foreach (AbstractMetaArgument *arg, func->arguments()) {
- if (arg->type()->isFlags() || arg->type()->isEnum()) {
- result.push_back(func);
- inserted = true;
- break;
- }
- }
- if (!inserted)
- result.push_front(func);
- }
-
- return result;
-}
-
-AbstractMetaFunctionList BoostPythonGenerator::queryFunctions(const AbstractMetaClass *cppClass, bool allFunctions)
-{
- AbstractMetaFunctionList result;
-
- if (allFunctions) {
- int default_flags = AbstractMetaClass::NormalFunctions | AbstractMetaClass::Visible;
- default_flags |= cppClass->isInterface() ? 0 : AbstractMetaClass::ClassImplements;
-
- // Constructors
- result = cppClass->queryFunctions(AbstractMetaClass::Constructors |
- default_flags);
-
- // put enum constructor first to avoid conflict with int contructor
- result = sortContructor(result);
-
- // Final functions
- result += cppClass->queryFunctions(AbstractMetaClass::FinalInTargetLangFunctions |
- AbstractMetaClass::NonStaticFunctions |
- default_flags);
-
- //virtual
- result += cppClass->queryFunctions(AbstractMetaClass::VirtualInTargetLangFunctions |
- AbstractMetaClass::NonStaticFunctions |
- default_flags);
-
- // Static functions
- result += cppClass->queryFunctions(AbstractMetaClass::StaticFunctions | default_flags);
-
- // Empty, private functions, since they aren't caught by the other ones
- result += cppClass->queryFunctions(AbstractMetaClass::Empty |
- AbstractMetaClass::Invisible | default_flags);
- // Signals
- result += cppClass->queryFunctions(AbstractMetaClass::Signals | default_flags);
- } else {
- result = cppClass->functionsInTargetLang();
- }
-
- return result;
-}
-
void BoostPythonGenerator::writeFunctionCall(QTextStream &s,
const AbstractMetaFunction* func,
uint options)
@@ -427,55 +270,6 @@ void BoostPythonGenerator::writeFunctionCall(QTextStream &s,
s << ')';
}
-AbstractMetaFunctionList BoostPythonGenerator::filterFunctions(const AbstractMetaClass *cppClass)
-{
- AbstractMetaFunctionList lst = queryFunctions(cppClass, true);
- foreach (AbstractMetaFunction *func, lst) {
- //skip signals
- if (func->isSignal() ||
- func->isDestructor() ||
- (func->isModifiedRemoved() && !func->isAbstract())) {
- lst.removeOne(func);
- }
- }
-
- //virtual not implemented in current class
- AbstractMetaFunctionList virtual_lst = cppClass->queryFunctions(AbstractMetaClass::VirtualFunctions);
- foreach (AbstractMetaFunction *func, virtual_lst) {
- if ((func->implementingClass() != cppClass) &&
- !lst.contains(func)) {
- lst.append(func);
- }
- }
-
- //append global operators
- foreach (AbstractMetaFunction *func , queryGlobalOperators(cppClass)) {
- if (!lst.contains(func))
- lst.append(func);
- }
-
- return lst;
- //return cpp_class->functions();
-}
-
-CodeSnipList BoostPythonGenerator::getCodeSnips(const AbstractMetaFunction *func)
-{
- CodeSnipList result;
- const AbstractMetaClass *cppClass = func->implementingClass();
- while (cppClass) {
- foreach (FunctionModification mod, func->modifications(cppClass)) {
- if (mod.isCodeInjection())
- result << mod.snips;
- }
-
- if (cppClass == cppClass->baseClass())
- break;
- cppClass = cppClass->baseClass();
- }
-
- return result;
-}
-
void BoostPythonGenerator::writeCodeSnips(QTextStream &s,
const CodeSnipList &codeSnips,
CodeSnip::Position position,
diff --git a/generators/boostpython/boostpythongenerator.h b/generators/boostpython/boostpythongenerator.h
index 709612e..254ea95 100644
--- a/generators/boostpython/boostpythongenerator.h
+++ b/generators/boostpython/boostpythongenerator.h
@@ -29,8 +29,6 @@
class DocParser;
-QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor);
-
/**
* Abstract generator that contains common methods used in CppGenerator and HppGenerator.
*/
@@ -98,8 +96,6 @@ public:
CodeSnip::Position position,
TypeSystem::Language language,
const AbstractMetaFunction *cpp_function = 0);
- /// returns the code snips of a function
- CodeSnipList getCodeSnips(const AbstractMetaFunction *func);
static bool canCreateWrapperFor(const AbstractMetaClass* cppClass);
/**
* Function witch parse the metafunction information
@@ -135,13 +131,7 @@ protected:
// verify if the class is copyalbe
bool isCopyable(const AbstractMetaClass *cpp_class);
- static FunctionModificationList functionModifications(const AbstractMetaFunction *meta_function);
- AbstractMetaFunctionList queryFunctions(const AbstractMetaClass *cpp_class, bool all_function = false);
void writeFunctionCall(QTextStream &s, const AbstractMetaFunction *cpp_func, uint options = 0);
-
- AbstractMetaFunctionList filterFunctions(const AbstractMetaClass *cpp_class);
- AbstractMetaFunctionList queryGlobalOperators(const AbstractMetaClass *cpp_class);
- AbstractMetaFunctionList sortContructor(AbstractMetaFunctionList list);
};