aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/cppgenerator.h
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.h')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.h201
1 files changed, 102 insertions, 99 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
index 519e12b7..ae6da958 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.h
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -44,38 +44,39 @@ public:
protected:
QString fileNameSuffix() const override;
QString fileNameForContext(GeneratorContext &context) const override;
- QVector<AbstractMetaFunctionList> filterGroupedOperatorFunctions(const AbstractMetaClass* metaClass,
+ QVector<AbstractMetaFunctionList> filterGroupedOperatorFunctions(const AbstractMetaClass *metaClass,
uint query);
- void generateClass(QTextStream& s, GeneratorContext &classContext) override;
+ void generateClass(QTextStream &s, GeneratorContext &classContext) override;
bool finishGeneration() override;
private:
- void writeConstructorNative(QTextStream& s, const AbstractMetaFunction* func);
- void writeDestructorNative(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeConstructorNative(QTextStream &s, const AbstractMetaFunction *func);
+ void writeDestructorNative(QTextStream &s, const AbstractMetaClass *metaClass);
- QString getVirtualFunctionReturnTypeName(const AbstractMetaFunction* func);
- void writeVirtualMethodNative(QTextStream& s, const AbstractMetaFunction* func);
+ QString getVirtualFunctionReturnTypeName(const AbstractMetaFunction *func);
+ void writeVirtualMethodNative(QTextStream &s, const AbstractMetaFunction *func);
- void writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass* metaClass);
- void writeMetaCast(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMetaObjectMethod(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeMetaCast(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeEnumConverterFunctions(QTextStream& s, const TypeEntry* enumType);
- void writeEnumConverterFunctions(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeEnumConverterFunctions(QTextStream &s, const TypeEntry *enumType);
+ void writeEnumConverterFunctions(QTextStream &s, const AbstractMetaEnum *metaEnum);
void writeConverterFunctions(QTextStream &s, const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeCustomConverterFunctions(QTextStream& s, const CustomConversion* customConversion);
+ void writeCustomConverterFunctions(QTextStream &s, const CustomConversion *customConversion);
void writeConverterRegister(QTextStream &s, const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar);
+ void writeCustomConverterRegister(QTextStream &s, const CustomConversion *customConversion, const QString &converterVar);
- void writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType);
+ 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 writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+ void writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
+ GeneratorContext &classContext);
+ void writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
GeneratorContext &classContext);
- void writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData);
+ void writeArgumentsInitializer(QTextStream &s, OverloadData &overloadData);
void writeCppSelfAssigment(QTextStream &s, const GeneratorContext &context,
const QString &className, bool cppSelfAsReference,
bool useWrapperClass);
@@ -88,16 +89,18 @@ private:
bool hasStaticOverload = false,
bool cppSelfAsReference = false);
- void writeErrorSection(QTextStream& s, OverloadData& overloadData);
- void writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue = true);
+ void writeErrorSection(QTextStream &s, OverloadData &overloadData);
+ void writeFunctionReturnErrorCheckSection(QTextStream &s, bool hasReturnValue = true);
/// Writes the check section for the validity of wrapped C++ objects.
- void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj);
+ void writeInvalidPyObjectCheck(QTextStream &s, const QString &pyObj);
- void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber = false, QString customType = QString(), bool rejectNull = false);
- void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName);
+ void writeTypeCheck(QTextStream &s, const AbstractMetaType *argType, const QString &argumentName,
+ bool isNumber = false, const QString &customType = QString(),
+ bool rejectNull = false);
+ void writeTypeCheck(QTextStream& s, const OverloadData *overloadData, QString argumentName);
- void writeTypeDiscoveryFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeDiscoveryFunction(QTextStream &s, const AbstractMetaClass *metaClass);
void writeSetattroFunction(QTextStream &s, GeneratorContext &context);
void writeGetattroFunction(QTextStream &s, GeneratorContext &context);
@@ -115,10 +118,10 @@ private:
* \param defaultValue an optional default value to be used instead of the conversion result
* \param castArgumentAsUnused if true the converted argument is cast as unused to avoid compiler warnings
*/
- void writeArgumentConversion(QTextStream& s, const AbstractMetaType* argType,
- const QString& argName, const QString& pyArgName,
- const AbstractMetaClass* context = 0,
- const QString& defaultValue = QString(),
+ void writeArgumentConversion(QTextStream &s, const AbstractMetaType *argType,
+ const QString &argName, const QString &pyArgName,
+ const AbstractMetaClass *context = nullptr,
+ const QString &defaultValue = QString(),
bool castArgumentAsUnused = false);
/**
@@ -132,19 +135,19 @@ private:
* \param newType It is set to true if the type returned is a new object that must be deallocated.
* \return The type of the argument indicated by \p argPos.
*/
- const AbstractMetaType* getArgumentType(const AbstractMetaFunction* func, int argPos);
+ const AbstractMetaType *getArgumentType(const AbstractMetaFunction *func, int argPos);
- void writePythonToCppTypeConversion(QTextStream& s,
- const AbstractMetaType* type,
- const QString& pyIn,
- const QString& cppOut,
- const AbstractMetaClass* context = 0,
- const QString& defaultValue = QString());
+ void writePythonToCppTypeConversion(QTextStream &s,
+ const AbstractMetaType *type,
+ const QString &pyIn,
+ const QString &cppOut,
+ const AbstractMetaClass *context = nullptr,
+ const QString &defaultValue = QString());
/// Writes the conversion rule for arguments of regular and virtual methods.
- void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language);
+ void writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language);
/// Writes the conversion rule for the return value of a method.
- void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar);
+ void writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language, const QString &outputVar);
/**
* Set the Python method wrapper return value variable to Py_None if
@@ -155,7 +158,7 @@ private:
* \param thereIsReturnValue indicates if the return type of any of the other overloads
* for this function is different from 'void'
*/
- void writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue);
+ void writeNoneReturn(QTextStream &s, const AbstractMetaFunction *func, bool thereIsReturnValue);
/**
* Writes the Python function wrapper overload decisor that selects which C++
@@ -163,9 +166,9 @@ private:
* \param s text stream to write
* \param overloadData the overload data describing all the possible overloads for the function/method
*/
- void writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData);
+ void writeOverloadedFunctionDecisor(QTextStream &s, const OverloadData &overloadData);
/// Recursive auxiliar method to the other writeOverloadedFunctionDecisor.
- void writeOverloadedFunctionDecisorEngine(QTextStream& s, const OverloadData* parentOverloadData);
+ void writeOverloadedFunctionDecisorEngine(QTextStream &s, const OverloadData *parentOverloadData);
/// Writes calls to all the possible method/function overloads.
void writeFunctionCalls(QTextStream &s,
@@ -179,55 +182,55 @@ private:
GeneratorContext &context);
/// Returns the name of a C++ to Python conversion function.
- static QString cppToPythonFunctionName(const QString& sourceTypeName, QString targetTypeName = QString());
+ static QString cppToPythonFunctionName(const QString &sourceTypeName, QString targetTypeName = QString());
/// Returns the name of a Python to C++ conversion function.
- static QString pythonToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
- static QString pythonToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
- static QString pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+ static QString pythonToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName);
+ static QString pythonToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType);
+ static QString pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative, const TypeEntry *targetType);
/// Returns the name of a Python to C++ convertible check function.
- static QString convertibleToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
- static QString convertibleToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
- static QString convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+ static QString convertibleToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName);
+ static QString convertibleToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType);
+ static QString convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative, const TypeEntry *targetType);
/// Writes a C++ to Python conversion function.
- void writeCppToPythonFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, QString targetTypeName = QString());
- void writeCppToPythonFunction(QTextStream& s, const CustomConversion* customConversion);
- void writeCppToPythonFunction(QTextStream& s, const AbstractMetaType* containerType);
+ void writeCppToPythonFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, QString targetTypeName = QString());
+ void writeCppToPythonFunction(QTextStream &s, const CustomConversion *customConversion);
+ void writeCppToPythonFunction(QTextStream &s, const AbstractMetaType *containerType);
/// Writes a Python to C++ conversion function.
- void writePythonToCppFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, const QString& targetTypeName);
+ void writePythonToCppFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, const QString &targetTypeName);
/// Writes a Python to C++ convertible check function.
- void writeIsPythonConvertibleToCppFunction(QTextStream& s,
- const QString& sourceTypeName,
- const QString& targetTypeName,
- const QString& condition,
+ void writeIsPythonConvertibleToCppFunction(QTextStream &s,
+ const QString &sourceTypeName,
+ const QString &targetTypeName,
+ const QString &condition,
QString pythonToCppFuncName = QString(),
bool acceptNoneAsCppNull = false);
/// Writes a pair of Python to C++ conversion and check functions.
- void writePythonToCppConversionFunctions(QTextStream& s,
- const AbstractMetaType* sourceType,
- const AbstractMetaType* targetType,
+ void writePythonToCppConversionFunctions(QTextStream &s,
+ const AbstractMetaType *sourceType,
+ const AbstractMetaType *targetType,
QString typeCheck = QString(),
QString conversion = QString(),
- QString preConversion = QString());
+ const QString &preConversion = QString());
/// Writes a pair of Python to C++ conversion and check functions for implicit conversions.
- void writePythonToCppConversionFunctions(QTextStream& s,
- const CustomConversion::TargetToNativeConversion* toNative,
- const TypeEntry* targetType);
+ void writePythonToCppConversionFunctions(QTextStream &s,
+ const CustomConversion::TargetToNativeConversion *toNative,
+ const TypeEntry *targetType);
/// Writes a pair of Python to C++ conversion and check functions for instantiated container types.
- void writePythonToCppConversionFunctions(QTextStream& s, const AbstractMetaType* containerType);
+ void writePythonToCppConversionFunctions(QTextStream &s, const AbstractMetaType *containerType);
- void writeAddPythonToCppConversion(QTextStream& s, const QString& converterVar, const QString& pythonToCppFunc, const QString& isConvertibleFunc);
+ void writeAddPythonToCppConversion(QTextStream &s, const QString &converterVar, const QString &pythonToCppFunc, const QString &isConvertibleFunc);
- void writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs);
+ void writeNamedArgumentResolution(QTextStream &s, const AbstractMetaFunction *func, bool usePyArgs);
/// Returns a string containing the name of an argument for the given function and argument index.
- QString argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass);
+ QString argumentNameFromIndex(const AbstractMetaFunction *func, int argIndex, const AbstractMetaClass **wrappedClass);
void writeMethodCall(QTextStream &s, const AbstractMetaFunction *func,
GeneratorContext &context, int maxArgs = 0);
@@ -241,25 +244,25 @@ private:
void writeClassDefinition(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeMethodDefinitionEntry(QTextStream& s, const AbstractMetaFunctionList &overloads);
- void writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList &overloads);
+ void writeMethodDefinitionEntry(QTextStream &s, const AbstractMetaFunctionList &overloads);
+ void writeMethodDefinition(QTextStream &s, const AbstractMetaFunctionList &overloads);
void writeSignatureInfo(QTextStream &s, const AbstractMetaFunctionList &overloads);
/// Writes the implementation of all methods part of python sequence protocol
void writeSequenceMethods(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &context);
- void writeTypeAsSequenceDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsSequenceDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
/// Writes the PyMappingMethods structure for types that supports the python mapping protocol.
- void writeTypeAsMappingDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsMappingDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
void writeMappingMethods(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &context);
- void writeTypeAsNumberDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsNumberDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeTpTraverseFunction(QTextStream& s, const AbstractMetaClass* metaClass);
- void writeTpClearFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTpTraverseFunction(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeTpClearFunction(QTextStream &s, const AbstractMetaClass *metaClass);
void writeCopyFunction(QTextStream &s, GeneratorContext &context);
@@ -272,35 +275,35 @@ private:
void writeRichCompareFunction(QTextStream &s, GeneratorContext &context);
- void writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums);
- void writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeEnumsInitialization(QTextStream &s, AbstractMetaEnumList &enums);
+ void writeEnumInitialization(QTextStream &s, const AbstractMetaEnum *metaEnum);
- void writeSignalInitialization(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeSignalInitialization(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsToLong(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsNonZero(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ void writeFlagsMethods(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsToLong(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsNonZero(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsNumberMethodsDefinition(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName, const QString &cppOpName);
- void writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ void writeFlagsUnaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName, const QString &cppOpName,
bool boolResult = false);
/// Writes the function that registers the multiple inheritance information for the classes that need it.
- void writeMultipleInheritanceInitializerFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMultipleInheritanceInitializerFunction(QTextStream &s, const AbstractMetaClass *metaClass);
/// Writes the implementation of special cast functions, used when we need to cast a class with multiple inheritance.
- void writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeSpecialCastFunction(QTextStream &s, const AbstractMetaClass *metaClass);
- void writePrimitiveConverterInitialization(QTextStream& s, const CustomConversion* customConversion);
- void writeEnumConverterInitialization(QTextStream& s, const TypeEntry* enumType);
- void writeEnumConverterInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
- void writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type);
- void writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType, const QVector<const AbstractMetaClass*>& conversions);
+ void writePrimitiveConverterInitialization(QTextStream &s, const CustomConversion *customConversion);
+ void writeEnumConverterInitialization(QTextStream &s, const TypeEntry *enumType);
+ void writeEnumConverterInitialization(QTextStream &s, const AbstractMetaEnum *metaEnum);
+ void writeContainerConverterInitialization(QTextStream &s, const AbstractMetaType *type);
+ void writeExtendedConverterInitialization(QTextStream &s, const TypeEntry *externalType, const QVector<const AbstractMetaClass *>& conversions);
- void writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, bool userHeuristicForReturn);
- bool writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool userHeuristicPolicy);
- void writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self = QLatin1String("self"));
+ void writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, bool userHeuristicForReturn);
+ bool writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, int argIndex, bool userHeuristicPolicy);
+ void writeReturnValueHeuristics(QTextStream &s, const AbstractMetaFunction *func, const QString &self = QLatin1String("self"));
void writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorContext &context) const;
/**
@@ -309,34 +312,34 @@ private:
* \return name of the multiple inheritance information initializer function or
* an empty string if there is no multiple inheritance in its ancestry.
*/
- QString multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass);
+ QString multipleInheritanceInitializerFunctionName(const AbstractMetaClass *metaClass);
/// Returns a list of all classes to which the given class could be cast.
- QStringList getAncestorMultipleInheritance(const AbstractMetaClass* metaClass);
+ QStringList getAncestorMultipleInheritance(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python number protocol
- bool supportsNumberProtocol(const AbstractMetaClass* metaClass);
+ bool supportsNumberProtocol(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python sequence protocol
- bool supportsSequenceProtocol(const AbstractMetaClass* metaClass);
+ bool supportsSequenceProtocol(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python mapping protocol
- bool supportsMappingProtocol(const AbstractMetaClass* metaClass);
+ bool supportsMappingProtocol(const AbstractMetaClass *metaClass);
/// Returns true if generator should produce getters and setters for the given class.
- bool shouldGenerateGetSetList(const AbstractMetaClass* metaClass);
+ bool shouldGenerateGetSetList(const AbstractMetaClass *metaClass);
void writeHashFunction(QTextStream &s, GeneratorContext &context);
/// Write default implementations for sequence protocol
void writeStdListWrapperMethods(QTextStream &s, GeneratorContext &context);
/// Helper function for writeStdListWrapperMethods.
- void writeIndexError(QTextStream& s, const QString& errorMsg);
+ void writeIndexError(QTextStream &s, const QString &errorMsg);
QString writeReprFunction(QTextStream &s, GeneratorContext &context);
- const AbstractMetaFunction *boolCast(const AbstractMetaClass* metaClass) const;
- bool hasBoolCast(const AbstractMetaClass* metaClass) const
+ const AbstractMetaFunction *boolCast(const AbstractMetaClass *metaClass) const;
+ bool hasBoolCast(const AbstractMetaClass *metaClass) const
{ return boolCast(metaClass) != nullptr; }
// Number protocol structure members names.