From f1194ffa7df1f7a58b77c3e0754d49cd55393433 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Jun 2018 14:11:40 +0200 Subject: shiboken: Remove unused code from the generators Change-Id: I88c4148000acba2ba1e2013fe587e7f5fbe6c2ca Reviewed-by: Christian Tismer --- .../shiboken2/generator/shiboken2/cppgenerator.cpp | 9 -- .../shiboken2/generator/shiboken2/cppgenerator.h | 3 - .../generator/shiboken2/shibokengenerator.cpp | 97 ---------------------- .../generator/shiboken2/shibokengenerator.h | 27 ------ 4 files changed, 136 deletions(-) (limited to 'sources/shiboken2/generator/shiboken2') diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index badb6a4cd..568b5fd27 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -1446,15 +1446,6 @@ void CppGenerator::writeCustomConverterRegister(QTextStream& s, const CustomConv } } -void CppGenerator::writeContainerConverterRegister(QTextStream& s, const AbstractMetaType* container, const QString& converterVar) -{ - s << INDENT << "// Add user defined container conversion to type converter." << endl; - QString typeName = fixedCppTypeName(container); - QString toCpp = pythonToCppFunctionName(typeName, typeName); - QString isConv = convertibleToCppFunctionName(typeName, typeName); - writeAddPythonToCppConversion(s, converterVar, toCpp, isConv); -} - void CppGenerator::writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType) { writeCppToPythonFunction(s, containerType); diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h index 4dbd31828..1b59bcda7 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.h +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h @@ -64,14 +64,12 @@ private: void writeConverterRegister(QTextStream &s, const AbstractMetaClass *metaClass, GeneratorContext &classContext); void writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar); - void writeContainerConverterRegister(QTextStream& s, const AbstractMetaType* container, const QString& converterVar); void writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType); void writeMethodWrapperPreamble(QTextStream &s, OverloadData &overloadData, GeneratorContext &context); void writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList overloads, GeneratorContext &classContext); - void writeDestructorWrapper(QTextStream& s, const AbstractMetaClass* metaClass); void writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads, GeneratorContext &classContext); void writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData); @@ -266,7 +264,6 @@ private: GeneratorContext &context); void writeRichCompareFunction(QTextStream &s, GeneratorContext &context); - void writeToPythonFunction(QTextStream& s, const AbstractMetaClass* metaClass); void writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums); void writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum); diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 315f10fcb..80096cbf2 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -639,14 +639,6 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry* type, QString arg + QLatin1String(", reinterpret_cast(") + argName + QLatin1String(")))"); } -QString ShibokenGenerator::getFunctionReturnType(const AbstractMetaFunction* func, Options) const -{ - if (func->ownerClass() && func->isConstructor()) - return func->ownerClass()->qualifiedCppName() + QLatin1Char('*'); - - return translateTypeForWrapperMethod(func->type(), func->implementingClass()); -} - void ShibokenGenerator::writeToPythonConversion(QTextStream & s, const AbstractMetaType* type, const AbstractMetaClass * /* context */, const QString& argumentName) @@ -876,17 +868,6 @@ static QString msgUnknownOperator(const AbstractMetaFunction* func) static inline QString unknownOperator() { return QStringLiteral("__UNKNOWN_OPERATOR__"); } -QString ShibokenGenerator::cpythonOperatorFunctionName(const AbstractMetaFunction* func) -{ - if (!func->isOperatorOverload()) - return QString(); - const QString pythonOp = pythonOperatorFunctionName(func->originalName()); - if (pythonOp == unknownOperator()) - qCWarning(lcShiboken).noquote().nospace() << msgUnknownOperator(func); - return QLatin1String("Sbk") + func->ownerClass()->name() - + QLatin1Char('_') + pythonOp; -} - QString ShibokenGenerator::fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative) { if (toNative->sourceType()) @@ -1014,12 +995,6 @@ bool ShibokenGenerator::isPyInt(const AbstractMetaType* type) return isPyInt(type->typeEntry()); } -bool ShibokenGenerator::isPairContainer(const AbstractMetaType* type) -{ - return type->isContainer() - && static_cast(type->typeEntry())->type() == ContainerTypeEntry::PairContainer; -} - bool ShibokenGenerator::isWrapperType(const TypeEntry* type) { if (type->isComplex()) @@ -1238,18 +1213,6 @@ QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type, Abstra return type + QLatin1String("_Check"); } -QString ShibokenGenerator::guessCPythonIsConvertible(const QString& type) -{ - if (type == QLatin1String("PyTypeObject")) - return QLatin1String("PyType_Check"); - - AbstractMetaType* metaType = buildAbstractMetaTypeFromString(type); - if (metaType && !metaType->typeEntry()->isCustom()) - return cpythonIsConvertibleFunction(metaType); - - return type + QLatin1String("_Check"); -} - QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry* type, bool /* genericNumberType */, bool /* checkExact */) @@ -2096,16 +2059,6 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa code.replace(rep.first, rep.second); } -bool ShibokenGenerator::injectedCodeUsesCppSelf(const AbstractMetaFunction* func) -{ - CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode); - for (const CodeSnip &snip : qAsConst(snips)) { - if (snip.code().contains(QLatin1String("%CPPSELF"))) - return true; - } - return false; -} - bool ShibokenGenerator::injectedCodeUsesPySelf(const AbstractMetaFunction* func) { CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::NativeCode); @@ -2296,20 +2249,6 @@ QString ShibokenGenerator::getModuleHeaderFileName(const QString& moduleName) co return result.toLower() + QLatin1String("_python.h"); } -QString ShibokenGenerator::extendedIsConvertibleFunctionName(const TypeEntry* targetType) const -{ - QString p = targetType->targetLangPackage(); - p.replace(QLatin1Char('.'), QLatin1Char('_')); - return QStringLiteral("ExtendedIsConvertible_%1_%2").arg(p, targetType->name()); -} - -QString ShibokenGenerator::extendedToCppFunctionName(const TypeEntry* targetType) const -{ - QString p = targetType->targetLangPackage(); - p.replace(QLatin1Char('.'), QLatin1Char('_')); - return QStringLiteral("ExtendedToCpp_%1_%2").arg(p, targetType->name()); -} - bool ShibokenGenerator::isCopyable(const AbstractMetaClass *metaClass) { @@ -2549,25 +2488,6 @@ AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractM return results; } -QPair< int, int > ShibokenGenerator::getMinMaxArguments(const AbstractMetaFunction* metaFunction) -{ - AbstractMetaFunctionList overloads = getFunctionOverloads(metaFunction->ownerClass(), metaFunction->name()); - - int minArgs = std::numeric_limits::max(); - int maxArgs = 0; - for (const AbstractMetaFunction* func : qAsConst(overloads)) { - int numArgs = 0; - const AbstractMetaArgumentList &arguments = func->arguments(); - for (const AbstractMetaArgument *arg : arguments) { - if (!func->argumentRemoved(arg->argumentIndex() + 1)) - numArgs++; - } - maxArgs = std::max(maxArgs, numArgs); - minArgs = std::min(minArgs, numArgs); - } - return qMakePair(minArgs, maxArgs); -} - Generator::OptionDescriptions ShibokenGenerator::options() const { return OptionDescriptions() @@ -2769,23 +2689,6 @@ bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadD || overloadData.hasArgumentWithDefaultValue(); } -Generator::Options ShibokenGenerator::getConverterOptions(const AbstractMetaType* metaType) -{ - // exclude const on Objects - Options flags; - const TypeEntry* type = metaType->typeEntry(); - bool isCStr = isCString(metaType); - if (metaType->indirections() && !isCStr) { - flags = ExcludeConst; - } else if (metaType->isContainer() - || (type->isPrimitive() && !isCStr) - // const refs become just the value, but pure refs must remain pure. - || (type->isValue() && metaType->isConstant() && metaType->referenceType() == LValueReference)) { - flags = ExcludeConst | ExcludeReference; - } - return flags; -} - QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg) { if (!arg->defaultValueExpression().isEmpty()) diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index 3271d741d..cb1bdd11f 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -105,11 +105,6 @@ public: * \param functionName the function name. */ AbstractMetaFunctionList getFunctionOverloads(const AbstractMetaClass* scope, const QString& functionName); - /** - * Returns the minimun and maximun number of arguments which this function and all overloads - * can accept. Arguments removed by typesystem are considered as well. - */ - QPair getMinMaxArguments(const AbstractMetaFunction* metaFunction); /** * Write a function argument in the C++ in the text stream \p s. * This function just call \code s << argumentString(); \endcode @@ -196,14 +191,6 @@ public: replaceConverterTypeSystemVariable(TypeSystemCheckFunction, code); } - /** - * Verifies if any of the function's code injections of the "target" - * type needs the type system variable "%CPPSELF". - * \param func the function to check - * \return true if the function's target code snippets use "%CPPSELF" - */ - bool injectedCodeUsesCppSelf(const AbstractMetaFunction* func); - /** * Verifies if any of the function's code injections of the "native" * type needs the type system variable "%PYSELF". @@ -310,8 +297,6 @@ public: static QString pythonRichCompareOperatorId(QString cppOpFuncName); static QString pythonRichCompareOperatorId(const AbstractMetaFunction* func); - static QString cpythonOperatorFunctionName(const AbstractMetaFunction* func); - static QString fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative); static QString fixedCppTypeName(const AbstractMetaType* type); static QString fixedCppTypeName(const TypeEntry* type, QString typeName = QString()); @@ -321,7 +306,6 @@ public: static bool isNumber(const AbstractMetaType* type); static bool isPyInt(const TypeEntry* type); static bool isPyInt(const AbstractMetaType* type); - static bool isPairContainer(const AbstractMetaType* type); /** * Returns true if the type passed has a Python wrapper for it. @@ -391,7 +375,6 @@ public: QString cpythonIsConvertibleFunction(const TypeEntry* type, bool genericNumberType = false, bool checkExact = false); QString cpythonIsConvertibleFunction(const AbstractMetaType* metaType, bool genericNumberType = false); QString cpythonIsConvertibleFunction(const AbstractMetaArgument* metaArg, bool genericNumberType = false); - QString guessCPythonIsConvertible(const QString& type); QString cpythonToCppConversionFunction(const AbstractMetaClass* metaClass); QString cpythonToCppConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0); @@ -425,15 +408,11 @@ public: /// Returns the special cast function name, the function used to proper cast class with multiple inheritance. QString cpythonSpecialCastFunctionName(const AbstractMetaClass* metaClass); - QString getFunctionReturnType(const AbstractMetaFunction* func, Options options = NoOption) const; QString getFormatUnitString(const AbstractMetaFunction* func, bool incRef = false) const; /// Returns the file name for the module global header. If no module name is provided the current will be used. QString getModuleHeaderFileName(const QString& moduleName = QString()) const; - QString extendedIsConvertibleFunctionName(const TypeEntry* targetType) const; - QString extendedToCppFunctionName(const TypeEntry* targetType) const; - OptionDescriptions options() const override; /// Returns true if the user enabled the so called "parent constructor heuristic". @@ -478,12 +457,6 @@ public: void writeMinimalConstructorExpression(QTextStream& s, const AbstractMetaType* type, const QString& defaultCtor = QString()); void writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor = QString()); - /** - * Helper function to return the flags to be used by a meta type when - * it needs to write some converter code. - */ - static Options getConverterOptions(const AbstractMetaType* metaType); - /** * Helper function to find for argument default value */ -- cgit v1.2.3