diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-08-02 14:18:11 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-08-03 14:29:26 +0000 |
commit | 26d6ef0c8f359b3bc29e2f68238e28f86e9448c5 (patch) | |
tree | b8202883a6af7b4435dfd4cc05f1728efbc683e2 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | |
parent | 711515d089574cdc8be63c65d6b01863aadba141 (diff) |
shiboken: Implement template inheritance for fields
Add the fields to the typedef'ed class specializing the type
similar to the functions.
Task-number: PYSIDE-725
Change-Id: I2daae9bd3c8a73fbd868f495cfc3a2dfba703103
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index cbe33ae22..bcd447023 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -2922,6 +2922,26 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass, subclass->addFunction(f.take()); } + const AbstractMetaFieldList &subClassFields = subclass->fields(); + const AbstractMetaFieldList &templateClassFields = templateClass->fields(); + for (const AbstractMetaField *field : templateClassFields) { + // If the field is modified or the instantiation has a field named + // the same as an existing field we have shadowing, so we need to skip it. + if (field->isModifiedRemoved(TypeSystem::All) + || field->attributes().testFlag(AbstractMetaAttributes::Static) + || AbstractMetaField::find(subClassFields, field->name()) != nullptr) { + continue; + } + + QScopedPointer<AbstractMetaField> f(field->copy()); + f->setEnclosingClass(subclass); + AbstractMetaType *fieldType = inheritTemplateType(templateTypes, field->type()); + if (!fieldType) + continue; + f->replaceType(fieldType); + subclass->addField(f.take()); + } + subclass->setTemplateBaseClass(templateClass); subclass->setTemplateBaseClassInstantiations(templateTypes); subclass->setInterfaces(templateClass->interfaces()); |