aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-05-25 16:13:19 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:03 -0300
commit6ddb2e91990b119017819c6290ca6de6c6b6ea21 (patch)
tree4fd524331337d4ea6de141cc7b36c753a2abb570
parent73d7cfa75642672e4fe2ccd52eae872a16953dba (diff)
Implemented support to flag "since" on typesystem.
With this flag you can specify after which version the tag became valid.
-rw-r--r--abstractmetabuilder.cpp45
-rw-r--r--abstractmetabuilder.h3
-rw-r--r--abstractmetalang.cpp2
-rw-r--r--apiextractor.cpp5
-rw-r--r--apiextractor.h2
-rw-r--r--typedatabase.cpp5
-rw-r--r--typedatabase.h14
-rw-r--r--typesystem.cpp88
-rw-r--r--typesystem.h145
9 files changed, 210 insertions, 99 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 85cbc6e8b..12ace950f 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -385,10 +385,16 @@ bool AbstractMetaBuilder::build(QIODevice* input)
foreach (FunctionModelItem func, m_dom->functions()) {
if (func->accessPolicy() != CodeModel::Public || func->name().startsWith("operator"))
continue;
+
FunctionTypeEntry* funcEntry = types->findFunctionType(func->name());
if (!funcEntry || !funcEntry->generateCode())
continue;
+ if (!types->supportedApiVersion(funcEntry->version())) {
+ m_rejectedFunctions.insert(func->name(), ApiIncompatible);
+ continue;
+ }
+
AbstractMetaFunction* metaFunc = traverseFunction(func);
if (!metaFunc)
continue;
@@ -432,7 +438,7 @@ bool AbstractMetaBuilder::build(QIODevice* input)
cls->typeEntry()->setLookupName(cls->typeEntry()->targetLangName() + "$ConcreteWrapper");
}
- QList<TypeEntry*> entries = TypeDatabase::instance()->entries().values();
+ QList<TypeEntry*> entries = types->entries().values();
ReportHandler::setProgressReference(entries);
foreach (const TypeEntry *entry, entries) {
ReportHandler::progress("Detecting inconsistencies in typesystem for %s", qPrintable(entry->name()));
@@ -440,6 +446,11 @@ bool AbstractMetaBuilder::build(QIODevice* input)
if (entry->isPrimitive())
continue;
+ if (!types->supportedApiVersion(entry->version())) {
+ m_rejectedClasses.insert(entry->name(), ApiIncompatible);
+ continue;
+ }
+
if ((entry->isValue() || entry->isObject())
&& !entry->isString()
&& !entry->isChar()
@@ -546,6 +557,10 @@ bool AbstractMetaBuilder::build(QIODevice* input)
// Functions added to the module on the type system.
foreach (AddedFunction addedFunc, types->globalUserFunctions()) {
+ if (!types->supportedApiVersion(addedFunc.version())) {
+ m_rejectedFunctions.insert(addedFunc.name(), ApiIncompatible);
+ continue;
+ }
AbstractMetaFunction* metaFunc = traverseFunction(addedFunc);
metaFunc->setFunctionType(AbstractMetaFunction::NormalFunction);
m_globalFunctions << metaFunc;
@@ -868,6 +883,12 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst
return 0;
}
+ // Skipping api incompatible
+ if (!TypeDatabase::instance()->supportedApiVersion(typeEntry->version())) {
+ m_rejectedEnums.insert(qualifiedName, ApiIncompatible);
+ return 0;
+ }
+
AbstractMetaEnum* metaEnum = createMetaEnum();
if (enumsDeclarations.contains(qualifiedName)
|| enumsDeclarations.contains(enumName)) {
@@ -919,7 +940,7 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst
name += "::";
}
name += e->name();
- EnumValueTypeEntry* enumValue = new EnumValueTypeEntry(name, e->value(), static_cast<EnumTypeEntry*>(typeEntry));
+ EnumValueTypeEntry* enumValue = new EnumValueTypeEntry(name, e->value(), static_cast<EnumTypeEntry*>(typeEntry), typeEntry->version());
typeDb->addType(enumValue);
}
@@ -948,6 +969,7 @@ AbstractMetaClass* AbstractMetaBuilder::traverseTypeAlias(TypeAliasModelItem typ
return 0;
}
+
// If we haven't specified anything for the typedef, then we don't care
ComplexTypeEntry* type = types->findComplexType(fullClassName);
if (!type)
@@ -1004,7 +1026,6 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
} else if (type->codeGeneration() == TypeEntry::GenerateNothing) {
reason = GenerationDisabled;
}
-
if (reason != NoReason) {
m_rejectedClasses.insert(fullClassName, reason);
return 0;
@@ -1033,7 +1054,7 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
template_args.clear();
for (int i = 0; i < template_parameters.size(); ++i) {
const TemplateParameterModelItem &param = template_parameters.at(i);
- TemplateArgumentEntry *param_type = new TemplateArgumentEntry(param->name());
+ TemplateArgumentEntry *param_type = new TemplateArgumentEntry(param->name(), type->version());
param_type->setOrdinal(i);
template_args.append(param_type);
}
@@ -1447,7 +1468,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
metaFunction->setUserAdded(true);
AbstractMetaAttributes::Attribute isStatic = addedFunc.isStatic() ? AbstractMetaFunction::Static : AbstractMetaFunction::None;
metaFunction->setAttributes(metaFunction->attributes() | AbstractMetaAttributes::Final | isStatic);
- metaFunction->setType(translateType(addedFunc.returnType()));
+ metaFunction->setType(translateType(addedFunc.version(), addedFunc.returnType()));
QList<AddedFunction::TypeInfo> args = addedFunc.arguments();
AbstractMetaArgumentList metaArguments;
@@ -1455,7 +1476,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
for (int i = 0; i < args.count(); ++i) {
AddedFunction::TypeInfo& typeInfo = args[i];
AbstractMetaArgument* metaArg = createMetaArgument();
- AbstractMetaType* type = translateType(typeInfo);
+ AbstractMetaType* type = translateType(addedFunc.version(), typeInfo);
decideUsagePattern(type);
metaArg->setType(type);
metaArg->setArgumentIndex(i);
@@ -1504,6 +1525,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
return 0;
}
+
Q_ASSERT(functionItem->functionType() == CodeModel::Normal
|| functionItem->functionType() == CodeModel::Signal
|| functionItem->functionType() == CodeModel::Slot);
@@ -1572,6 +1594,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
metaFunction->setInvalid(true);
return metaFunction;
}
+
metaFunction->setType(type);
if (functionItem->functionType() == CodeModel::Signal)
@@ -1661,7 +1684,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
return metaFunction;
}
-AbstractMetaType* AbstractMetaBuilder::translateType(const AddedFunction::TypeInfo& typeInfo)
+AbstractMetaType* AbstractMetaBuilder::translateType(double vr, const AddedFunction::TypeInfo& typeInfo)
{
Q_ASSERT(!typeInfo.name.isEmpty());
AbstractMetaType* metaType = createMetaType();
@@ -1673,7 +1696,7 @@ AbstractMetaType* AbstractMetaBuilder::translateType(const AddedFunction::TypeIn
type = typeDb->findType(typeInfo.name);
if (!type)
- type = new TypeEntry(typeInfo.name, TypeEntry::CustomType);
+ type = new TypeEntry(typeInfo.name, TypeEntry::CustomType, vr);
metaType->setTypeEntry(type);
metaType->setIndirections(typeInfo.indirections);
@@ -1757,7 +1780,7 @@ AbstractMetaType* AbstractMetaBuilder::translateType(const TypeInfo& _typei, boo
AbstractMetaType* arrayType = createMetaType();
arrayType->setArrayElementCount(elems);
arrayType->setArrayElementType(elementType);
- arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry()));
+ arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry() , elementType->typeEntry()->version()));
decideUsagePattern(arrayType);
elementType = arrayType;
@@ -2445,6 +2468,10 @@ static void writeRejectLogFile(const QString &name,
s << "Unmatched argument type";
break;
+ case AbstractMetaBuilder::ApiIncompatible:
+ s << "Incompatible API";
+ break;
+
default:
s << "unknown reason";
break;
diff --git a/abstractmetabuilder.h b/abstractmetabuilder.h
index e676f1217..0d554b9af 100644
--- a/abstractmetabuilder.h
+++ b/abstractmetabuilder.h
@@ -43,6 +43,7 @@ public:
RedefinedToNotClass,
UnmatchedArgumentType,
UnmatchedReturnType,
+ ApiIncompatible,
NoReason
};
@@ -137,7 +138,7 @@ public:
QString fixDefaultValue(ArgumentModelItem item, AbstractMetaType *type,
AbstractMetaFunction *fnc, AbstractMetaClass *,
int argumentIndex);
- AbstractMetaType* translateType(const AddedFunction::TypeInfo& typeInfo);
+ AbstractMetaType* translateType(double vr, const AddedFunction::TypeInfo& typeInfo);
AbstractMetaType *translateType(const TypeInfo &type, bool *ok, bool resolveType = true, bool resolveScope = true);
void decideUsagePattern(AbstractMetaType *type);
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index cc9d7715a..8d25a2319 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -712,7 +712,7 @@ CodeSnipList AbstractMetaFunction::injectedCodeSnips(CodeSnip::Position position
{
CodeSnipList result;
foreach (const FunctionModification mod, modifications(ownerClass())) {
- if (mod.isCodeInjection()) {
+ if (mod.isCodeInjection() && TypeDatabase::instance()->supportedApiVersion(mod.version())) {
QList<CodeSnip>::const_iterator it = mod.snips.constBegin();
for (;it != mod.snips.constEnd(); ++it) {
if ((it->language & language) && (it->position == position || position == CodeSnip::Any))
diff --git a/apiextractor.cpp b/apiextractor.cpp
index 00734de8d..2a44d56b3 100644
--- a/apiextractor.cpp
+++ b/apiextractor.cpp
@@ -104,6 +104,11 @@ void ApiExtractor::setSilent ( bool value )
ReportHandler::setSilent(value);
}
+void ApiExtractor::setApiVersion(double version)
+{
+ TypeDatabase::instance()->setApiVersion(version);
+}
+
AbstractMetaEnumList ApiExtractor::globalEnums() const
{
Q_ASSERT(m_builder);
diff --git a/apiextractor.h b/apiextractor.h
index 1c729cf6f..dddc362ad 100644
--- a/apiextractor.h
+++ b/apiextractor.h
@@ -47,8 +47,8 @@ public:
void addTypesystemSearchPath(const QStringList& paths);
void addIncludePath(const QString& path);
void addIncludePath(const QStringList& paths);
-
void setLogDirectory(const QString& logDir);
+ void setApiVersion(double version);
AbstractMetaEnumList globalEnums() const;
AbstractMetaFunctionList globalFunctions() const;
diff --git a/typedatabase.cpp b/typedatabase.cpp
index c4266a83e..debc97865 100644
--- a/typedatabase.cpp
+++ b/typedatabase.cpp
@@ -396,3 +396,8 @@ NamespaceTypeEntry* TypeDatabase::findNamespaceType(const QString& name) const
return 0;
}
+bool TypeDatabase::supportedApiVersion(double version) const
+{
+ return version <= m_apiVersion;
+}
+
diff --git a/typedatabase.h b/typedatabase.h
index 10be28d15..94de75565 100644
--- a/typedatabase.h
+++ b/typedatabase.h
@@ -168,6 +168,18 @@ public:
bool parseFile(const QString &filename, bool generate = true);
bool parseFile(QIODevice* device, bool generate = true);
+ double apiVersion() const
+ {
+ return m_apiVersion;
+ }
+
+ void setApiVersion(double version)
+ {
+ m_apiVersion = version;
+ }
+
+ bool supportedApiVersion(double version) const;
+
private:
bool m_suppressWarnings;
TypeEntryHash m_entries;
@@ -185,6 +197,8 @@ private:
QList<TypeRejection> m_rejections;
QStringList m_rebuildClasses;
+
+ double m_apiVersion;
};
#endif
diff --git a/typesystem.cpp b/typesystem.cpp
index 4d4bdaca5..d5f127476 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -353,6 +353,7 @@ bool Handler::startElement(const QString &, const QString &n,
QHash<QString, QString> attributes;
attributes["name"] = QString();
+ attributes["since"] = QString("0");
switch (element->type) {
case StackElement::PrimitiveTypeEntry:
@@ -370,9 +371,7 @@ bool Handler::startElement(const QString &, const QString &n,
attributes["lower-bound"] = QString();
attributes["force-integer"] = "no";
attributes["extensible"] = "no";
-
break;
-
case StackElement::ObjectTypeEntry:
case StackElement::ValueTypeEntry:
attributes["force-abstract"] = QString("no");
@@ -405,8 +404,9 @@ bool Handler::startElement(const QString &, const QString &n,
};
fetchAttributeValues(tagName, atts, &attributes);
-
QString name = attributes["name"];
+ double since = attributes["since"].toDouble();
+
// The top level tag 'function' has only the 'signature' tag
// and we should extract the 'name' value from it.
if (element->type == StackElement::FunctionTypeEntry) {
@@ -440,7 +440,7 @@ bool Handler::startElement(const QString &, const QString &n,
if (targetLangApiName.isEmpty())
targetLangApiName = name;
- PrimitiveTypeEntry *type = new PrimitiveTypeEntry(name);
+ PrimitiveTypeEntry *type = new PrimitiveTypeEntry(name, since);
type->setCodeGeneration(m_generate);
type->setTargetLangName(targetLangName);
type->setTargetLangApiName(targetLangApiName);
@@ -468,7 +468,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- ContainerTypeEntry *type = new ContainerTypeEntry(name, containerType);
+ ContainerTypeEntry *type = new ContainerTypeEntry(name, containerType, since);
type->setCodeGeneration(m_generate);
element->entry = type;
}
@@ -477,11 +477,11 @@ bool Handler::startElement(const QString &, const QString &n,
QStringList names = name.split(QLatin1String("::"));
if (names.size() == 1)
- m_currentEnum = new EnumTypeEntry(QString(), name);
+ m_currentEnum = new EnumTypeEntry(QString(), name, since);
else
m_currentEnum =
new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"),
- names.last());
+ names.last(), since);
element->entry = m_currentEnum;
m_currentEnum->setCodeGeneration(m_generate);
m_currentEnum->setTargetLangPackage(m_defaultPackage);
@@ -492,7 +492,7 @@ bool Handler::startElement(const QString &, const QString &n,
// put in the flags parallel...
if (!attributes["flags"].isEmpty() && attributes["flags"].toLower() != "no") {
- FlagsTypeEntry *ftype = new FlagsTypeEntry("QFlags<" + name + ">");
+ FlagsTypeEntry *ftype = new FlagsTypeEntry("QFlags<" + name + ">", since);
ftype->setOriginator(m_currentEnum);
ftype->setOriginalName(attributes["flags"]);
ftype->setCodeGeneration(m_generate);
@@ -515,12 +515,12 @@ bool Handler::startElement(const QString &, const QString &n,
break;
case StackElement::InterfaceTypeEntry: {
- ObjectTypeEntry *otype = new ObjectTypeEntry(name);
+ ObjectTypeEntry *otype = new ObjectTypeEntry(name, since);
QString targetLangName = attributes["target-lang-name"];
if (targetLangName.isEmpty())
targetLangName = name;
InterfaceTypeEntry *itype =
- new InterfaceTypeEntry(InterfaceTypeEntry::interfaceName(targetLangName));
+ new InterfaceTypeEntry(InterfaceTypeEntry::interfaceName(targetLangName), since);
if (!convertBoolean(attributes["generate"], "generate", true))
itype->setCodeGeneration(TypeEntry::GenerateForSubclass);
@@ -533,17 +533,17 @@ bool Handler::startElement(const QString &, const QString &n,
// fall through
case StackElement::NamespaceTypeEntry:
if (!element->entry)
- element->entry = new NamespaceTypeEntry(name);
+ element->entry = new NamespaceTypeEntry(name, since);
// fall through
case StackElement::ObjectTypeEntry:
if (!element->entry)
- element->entry = new ObjectTypeEntry(name);
+ element->entry = new ObjectTypeEntry(name, since);
// fall through
case StackElement::ValueTypeEntry: {
if (!element->entry)
- element->entry = new ValueTypeEntry(name);
+ element->entry = new ValueTypeEntry(name, since);
element->entry->setStream(attributes["stream"] == QString("yes"));
@@ -628,7 +628,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
} else {
- element->entry = new FunctionTypeEntry(name, signature);
+ element->entry = new FunctionTypeEntry(name, signature, since);
element->entry->setCodeGeneration(m_generate);
}
}
@@ -647,8 +647,10 @@ bool Handler::startElement(const QString &, const QString &n,
QHash<QString, QString> attributes;
attributes["mode"] = "replace";
attributes["format"] = "native";
+ attributes["since"] = QString("0");
fetchAttributeValues(tagName, atts, &attributes);
+ double since = attributes["since"].toDouble();
const int validParent = StackElement::TypeEntryMask
| StackElement::ModifyFunction
@@ -681,7 +683,7 @@ bool Handler::startElement(const QString &, const QString &n,
}
QString signature = m_current->type & StackElement::TypeEntryMask ? QString() : m_currentSignature;
- DocModification mod(mode, signature);
+ DocModification mod(mode, signature, since);
mod.format = lang;
m_docModifications << mod;
} else {
@@ -693,13 +695,16 @@ bool Handler::startElement(const QString &, const QString &n,
// check the XML tag attributes
QHash<QString, QString> attributes;
attributes["xpath"] = QString();
+ attributes["since"] = QString("0");
fetchAttributeValues(tagName, atts, &attributes);
+ double since = attributes["since"].toDouble();
+
const int validParent = StackElement::TypeEntryMask
| StackElement::ModifyFunction
| StackElement::ModifyField;
if (m_current->parent && m_current->parent->type & validParent) {
QString signature = (m_current->type & StackElement::TypeEntryMask) ? QString() : m_currentSignature;
- m_docModifications << DocModification(attributes["xpath"], signature);
+ m_docModifications << DocModification(attributes["xpath"], signature, since);
} else {
m_error = "modify-documentation must be inside modify-function, "
"modify-field or other tags that creates a type";
@@ -724,6 +729,7 @@ bool Handler::startElement(const QString &, const QString &n,
element->entry = topElement.entry;
QHash<QString, QString> attributes;
+ attributes["since"] = QString("0");
switch (element->type) {
case StackElement::Root:
attributes["package"] = QString();
@@ -836,11 +842,14 @@ bool Handler::startElement(const QString &, const QString &n,
attributes["index"] = QString();
attributes["action"] = QString();
default:
- { } // nada
+ { };
};
- if (attributes.count() > 0)
+ double since = 0;
+ if (attributes.count() > 0) {
fetchAttributeValues(tagName, atts, &attributes);
+ since = attributes["since"].toDouble();
+ }
switch (element->type) {
case StackElement::Root:
@@ -850,7 +859,7 @@ bool Handler::startElement(const QString &, const QString &n,
{
TypeSystemTypeEntry* moduleEntry = reinterpret_cast<TypeSystemTypeEntry*>(
m_database->findType(m_defaultPackage));
- element->entry = moduleEntry ? moduleEntry : new TypeSystemTypeEntry(m_defaultPackage);
+ element->entry = moduleEntry ? moduleEntry : new TypeSystemTypeEntry(m_defaultPackage, since);
}
if ((m_generate == TypeEntry::GenerateForSubclass ||
@@ -881,7 +890,7 @@ bool Handler::startElement(const QString &, const QString &n,
QString name = attributes["name"];
bool added = false;
- if (!name.isEmpty()) {
+ if (!name.isEmpty() && m_database->supportedApiVersion(since)) {
added = true;
m_currentEnum->addEnumValueRejection(name);
}
@@ -926,7 +935,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- CodeSnip snip;
+ CodeSnip snip(since);
snip.language = lang;
m_functionMods.last().argument_mods.last().conversion_rules.append(snip);
} else {
@@ -989,7 +998,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- ArgumentModification argumentModification = ArgumentModification(idx);
+ ArgumentModification argumentModification = ArgumentModification(idx, since);
argumentModification.replace_value = replace_value;
argumentModification.resetAfterUse = convertBoolean(attributes["invalidate-after-use"], "invalidate-after-use", false);
m_functionMods.last().argument_mods.append(argumentModification);
@@ -1167,7 +1176,6 @@ bool Handler::startElement(const QString &, const QString &n,
}
m_functionMods.last().argument_mods.last().removed = true;
-
break;
case StackElement::ModifyField: {
@@ -1201,7 +1209,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- AddedFunction func(signature, attributes["return-type"]);
+ AddedFunction func(signature, attributes["return-type"], since);
func.setStatic(attributes["static"] == "yes");
if (!signature.contains("("))
signature += "()";
@@ -1221,7 +1229,7 @@ bool Handler::startElement(const QString &, const QString &n,
m_addedFunctions << func;
- FunctionModification mod;
+ FunctionModification mod(since);
mod.signature = m_currentSignature;
m_functionMods << mod;
}
@@ -1240,7 +1248,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- FunctionModification mod;
+ FunctionModification mod(since);
m_currentSignature = mod.signature = signature;
QString access = attributes["access"].toLower();
@@ -1428,7 +1436,7 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- CodeSnip snip;
+ CodeSnip snip(since);
snip.language = languageNames[className];
snip.position = positionNames[position];
bool in_file = false;
@@ -1471,11 +1479,11 @@ bool Handler::startElement(const QString &, const QString &n,
if (in_file)
m_functionMods.last().modifiers |= FunctionModification::CodeInjection;
element->type = StackElement::InjectCodeInFunction;
-
} else if (topElement.type == StackElement::Root) {
element->entry->addCodeSnip(snip);
- } else if (topElement.type != StackElement::Root)
+ } else if (topElement.type != StackElement::Root) {
m_codeSnips << snip;
+ }
}
break;
@@ -1530,7 +1538,7 @@ bool Handler::startElement(const QString &, const QString &n,
}
break;
case StackElement::Template:
- element->value.templateEntry = new TemplateEntry(attributes["name"]);
+ element->value.templateEntry = new TemplateEntry(attributes["name"], since);
break;
case StackElement::TemplateInstanceEnum:
if (!(topElement.type & StackElement::CodeSnipMask) &&
@@ -1541,7 +1549,7 @@ bool Handler::startElement(const QString &, const QString &n,
m_error = "Can only insert templates into code snippets, templates, custom-constructors, custom-destructors or conversion-rule.";
return false;
}
- element->value.templateInstance = new TemplateInstance(attributes["name"]);
+ element->value.templateInstance = new TemplateInstance(attributes["name"], since);
break;
case StackElement::Replace:
if (topElement.type != StackElement::TemplateInstanceEnum) {
@@ -1571,6 +1579,17 @@ PrimitiveTypeEntry* PrimitiveTypeEntry::basicAliasedTypeEntry() const
return m_aliasedTypeEntry;
}
+CodeSnipList TypeEntry::codeSnips() const
+{
+ CodeSnipList lst;
+ TypeDatabase *td = TypeDatabase::instance();
+ foreach(CodeSnip cs, m_codeSnips) {
+ if (td->supportedApiVersion(cs.version))
+ lst.append(cs);
+ }
+ return lst;
+}
+
QString Modification::accessModifierString() const
{
if (isPrivate()) return "private";
@@ -1583,9 +1602,10 @@ QString Modification::accessModifierString() const
FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) const
{
FunctionModificationList lst;
+ TypeDatabase *td = TypeDatabase::instance();
for (int i = 0; i < m_functionMods.count(); ++i) {
const FunctionModification &mod = m_functionMods.at(i);
- if (mod.signature == signature)
+ if ((mod.signature == signature) && (td->supportedApiVersion(mod.version())))
lst << mod;
}
@@ -1820,7 +1840,7 @@ static AddedFunction::TypeInfo parseType(const QString& signature, int startPos
return result;
}
-AddedFunction::AddedFunction(QString signature, QString returnType) : m_access(Public)
+AddedFunction::AddedFunction(QString signature, QString returnType, double vr) : m_access(Public), m_version(vr)
{
Q_ASSERT(!returnType.isEmpty());
m_returnType = parseType(returnType);
@@ -1915,6 +1935,7 @@ QString ContainerTypeEntry::typeName() const
}
}
+
/*
static void injectCode(ComplexTypeEntry *e,
const char *signature,
@@ -1931,7 +1952,6 @@ static void injectCode(ComplexTypeEntry *e,
mod.signature = QMetaObject::normalizedSignature(signature);
mod.snips << snip;
mod.modifiers = Modification::CodeInjection;
- e->addFunctionModification(mod);
}
*/
diff --git a/typesystem.h b/typesystem.h
index 4c5570726..b609950b7 100644
--- a/typesystem.h
+++ b/typesystem.h
@@ -157,8 +157,8 @@ public:
class TemplateEntry : public CodeSnipAbstract
{
public:
- TemplateEntry(const QString &name)
- : m_name(name)
+ TemplateEntry(const QString &name, double vr)
+ : m_name(name), m_version(vr)
{
};
@@ -167,8 +167,14 @@ public:
return m_name;
};
+ double version() const
+ {
+ return m_version;
+ }
+
private:
QString m_name;
+ double m_version;
};
typedef QHash<QString, TemplateEntry *> TemplateEntryHash;
@@ -176,8 +182,8 @@ typedef QHash<QString, TemplateEntry *> TemplateEntryHash;
class TemplateInstance
{
public:
- TemplateInstance(const QString &name)
- : m_name(name) {}
+ TemplateInstance(const QString &name, double vr)
+ : m_name(name), m_version(vr) {}
void addReplaceRule(const QString &name, const QString &value)
{
@@ -191,8 +197,14 @@ public:
return m_name;
}
+ double version() const
+ {
+ return m_version;
+ }
+
private:
const QString m_name;
+ double m_version;
QHash<QString, QString> replaceRules;
};
@@ -212,20 +224,21 @@ public:
Any
};
- CodeSnip() : language(TypeSystem::TargetLangCode) { }
- CodeSnip(TypeSystem::Language lang) : language(lang) { }
+ CodeSnip(double vr) : language(TypeSystem::TargetLangCode), version(vr) { }
+ CodeSnip(double vr, TypeSystem::Language lang) : language(lang), version(vr) { }
TypeSystem::Language language;
Position position;
ArgumentMap argumentMap;
+ double version;
};
typedef QList<CodeSnip> CodeSnipList;
struct ArgumentModification
{
- ArgumentModification(int idx)
+ ArgumentModification(int idx, double vr)
: removedDefaultExpression(false), removed(false),
- noNullPointers(false), index(idx) {}
+ noNullPointers(false), index(idx), version(vr) {}
// Should the default expression be removed?
uint removedDefaultExpression : 1;
@@ -261,6 +274,9 @@ struct ArgumentModification
//QObject parent(owner) of this argument
ArgumentOwner owner;
+
+ //Api version
+ double version;
};
struct APIEXTRACTOR_API Modification
@@ -350,7 +366,7 @@ struct APIEXTRACTOR_API Modification
struct APIEXTRACTOR_API FunctionModification: public Modification
{
- FunctionModification() : removal(TypeSystem::NoLanguage), m_thread(false), m_allowThread(false) {}
+ FunctionModification(double vr) : removal(TypeSystem::NoLanguage), m_thread(false), m_allowThread(false), m_version(vr) {}
bool isCodeInjection() const
{
@@ -376,6 +392,10 @@ struct APIEXTRACTOR_API FunctionModification: public Modification
{
m_allowThread = allow;
}
+ double version() const
+ {
+ return m_version;
+ }
QString toString() const;
@@ -387,8 +407,12 @@ struct APIEXTRACTOR_API FunctionModification: public Modification
QList<ArgumentModification> argument_mods;
private:
+ FunctionModification() {}
+
bool m_thread;
bool m_allowThread;
+ double m_version;
+
};
typedef QList<FunctionModification> FunctionModificationList;
@@ -439,7 +463,7 @@ struct APIEXTRACTOR_API AddedFunction
};
/// Creates a new AddedFunction with a signature and a return type.
- AddedFunction(QString signature, QString returnType);
+ AddedFunction(QString signature, QString returnType, double vr);
/// Returns the function name.
QString name() const
@@ -488,6 +512,11 @@ struct APIEXTRACTOR_API AddedFunction
{
return m_isStatic;
}
+
+ double version() const
+ {
+ return m_version;
+ }
private:
QString m_name;
Access m_access;
@@ -495,6 +524,7 @@ private:
TypeInfo m_returnType;
bool m_isConst;
bool m_isStatic;
+ double m_version;
};
typedef QList<AddedFunction> AddedFunctionList;
@@ -522,11 +552,11 @@ public:
XPathReplace
};
- DocModification(const QString& xpath, const QString& signature)
+ DocModification(const QString& xpath, const QString& signature, double vr)
: format(TypeSystem::NativeCode), m_mode(XPathReplace),
- m_xpath(xpath), m_signature(signature) {}
- DocModification(Mode mode, const QString& signature)
- : m_mode(mode), m_signature(signature) {}
+ m_xpath(xpath), m_signature(signature), m_version(vr) {}
+ DocModification(Mode mode, const QString& signature, double vr)
+ : m_mode(mode), m_signature(signature), m_version(vr) {}
void setCode(const QString& code)
{
@@ -548,6 +578,10 @@ public:
{
return m_mode;
}
+ double version() const
+ {
+ return m_version;
+ }
TypeSystem::Language format;
@@ -556,6 +590,7 @@ private:
QString m_code;
QString m_xpath;
QString m_signature;
+ double m_version;
};
typedef QList<DocModification> DocModificationList;
@@ -598,12 +633,13 @@ public:
GenerateCode = GenerateTargetLang | GenerateCpp
};
- TypeEntry(const QString &name, Type t)
+ TypeEntry(const QString &name, Type t, double vr)
: m_name(name),
m_type(t),
m_codeGeneration(GenerateAll),
m_preferredConversion(true),
- m_stream(false)
+ m_stream(false),
+ m_version(vr)
{
};
@@ -825,10 +861,7 @@ public:
return false;
}
- CodeSnipList codeSnips() const
- {
- return m_codeSnips;
- }
+ CodeSnipList codeSnips() const;
void setCodeSnips(const CodeSnipList &codeSnips)
{
m_codeSnips = codeSnips;
@@ -890,6 +923,11 @@ public:
return !m_conversionRule.isEmpty();
}
+ double version() const
+ {
+ return m_version;
+ }
+
private:
QString m_name;
Type m_type;
@@ -904,6 +942,7 @@ private:
QHash<QString, bool> m_includesUsed;
QString m_conversionRule;
bool m_stream;
+ double m_version;
};
typedef QHash<QString, QList<TypeEntry *> > TypeEntryHash;
typedef QHash<QString, TypeEntry *> SingleTypeEntryHash;
@@ -912,8 +951,8 @@ typedef QHash<QString, TypeEntry *> SingleTypeEntryHash;
class APIEXTRACTOR_API TypeSystemTypeEntry : public TypeEntry
{
public:
- TypeSystemTypeEntry(const QString &name)
- : TypeEntry(name, TypeSystemType)
+ TypeSystemTypeEntry(const QString &name, double vr)
+ : TypeEntry(name, TypeSystemType, vr)
{
};
};
@@ -921,20 +960,20 @@ public:
class APIEXTRACTOR_API VoidTypeEntry : public TypeEntry
{
public:
- VoidTypeEntry() : TypeEntry("void", VoidType) { }
+ VoidTypeEntry() : TypeEntry("void", VoidType, 0) { }
};
class APIEXTRACTOR_API VarargsTypeEntry : public TypeEntry
{
public:
- VarargsTypeEntry() : TypeEntry("...", VarargsType) { }
+ VarargsTypeEntry() : TypeEntry("...", VarargsType, 0) { }
};
class APIEXTRACTOR_API TemplateArgumentEntry : public TypeEntry
{
public:
- TemplateArgumentEntry(const QString &name)
- : TypeEntry(name, TemplateArgumentType), m_ordinal(0)
+ TemplateArgumentEntry(const QString &name, double vr)
+ : TypeEntry(name, TemplateArgumentType, vr), m_ordinal(0)
{
}
@@ -954,8 +993,8 @@ private:
class APIEXTRACTOR_API ArrayTypeEntry : public TypeEntry
{
public:
- ArrayTypeEntry(const TypeEntry *nested_type)
- : TypeEntry("Array", ArrayType), m_nestedType(nested_type)
+ ArrayTypeEntry(const TypeEntry *nested_type, double vr)
+ : TypeEntry("Array", ArrayType, vr), m_nestedType(nested_type)
{
Q_ASSERT(m_nestedType);
}
@@ -989,8 +1028,8 @@ private:
class APIEXTRACTOR_API PrimitiveTypeEntry : public TypeEntry
{
public:
- PrimitiveTypeEntry(const QString &name)
- : TypeEntry(name, PrimitiveType),
+ PrimitiveTypeEntry(const QString &name, double vr)
+ : TypeEntry(name, PrimitiveType, vr),
m_preferredConversion(true),
m_preferredTargetLangType(true),
m_aliasedTypeEntry(0)
@@ -1082,9 +1121,9 @@ struct EnumValueRedirection
class APIEXTRACTOR_API EnumTypeEntry : public TypeEntry
{
public:
- EnumTypeEntry(const QString &nspace, const QString &enumName)
+ EnumTypeEntry(const QString &nspace, const QString &enumName, double vr)
: TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName,
- EnumType),
+ EnumType, vr),
m_flags(0),
m_extensible(false)
{
@@ -1223,8 +1262,8 @@ private:
class APIEXTRACTOR_API EnumValueTypeEntry : public TypeEntry
{
public:
- EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum)
- : TypeEntry(name, TypeEntry::EnumValue), m_value(value), m_enclosingEnum(enclosingEnum)
+ EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr)
+ : TypeEntry(name, TypeEntry::EnumValue, vr), m_value(value), m_enclosingEnum(enclosingEnum)
{
}
@@ -1238,7 +1277,7 @@ private:
class APIEXTRACTOR_API FlagsTypeEntry : public TypeEntry
{
public:
- FlagsTypeEntry(const QString &name) : TypeEntry(name, FlagsType), m_enum(0)
+ FlagsTypeEntry(const QString &name, double vr) : TypeEntry(name, FlagsType, vr), m_enum(0)
{
}
@@ -1313,8 +1352,8 @@ public:
Unknown
};
- ComplexTypeEntry(const QString &name, Type t)
- : TypeEntry(QString(name).replace(".*::", ""), t),
+ ComplexTypeEntry(const QString &name, Type t, double vr)
+ : TypeEntry(QString(name).replace(".*::", ""), t, vr),
m_qualifiedCppName(name),
m_qobject(false),
m_polymorphicBase(false),
@@ -1332,7 +1371,7 @@ public:
ComplexTypeEntry *copy() const
{
- ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type());
+ ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type(), version());
centry->setInclude(include());
centry->setExtraIncludes(extraIncludes());
centry->setAddedFunctions(addedFunctions());
@@ -1565,8 +1604,8 @@ public:
PairContainer,
};
- ContainerTypeEntry(const QString &name, Type type)
- : ComplexTypeEntry(name, ContainerType), m_type(type)
+ ContainerTypeEntry(const QString &name, Type type, double vr)
+ : ComplexTypeEntry(name, ContainerType, vr), m_type(type)
{
setCodeGeneration(GenerateForSubclass);
}
@@ -1610,14 +1649,14 @@ typedef QList<const ContainerTypeEntry*> ContainerTypeEntryList;
class APIEXTRACTOR_API NamespaceTypeEntry : public ComplexTypeEntry
{
public:
- NamespaceTypeEntry(const QString &name) : ComplexTypeEntry(name, NamespaceType) { }
+ NamespaceTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, NamespaceType, vr) { }
};
class ValueTypeEntry : public ComplexTypeEntry
{
public:
- ValueTypeEntry(const QString &name) : ComplexTypeEntry(name, BasicValueType) { }
+ ValueTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, BasicValueType, vr) { }
bool isValue() const
{
@@ -1630,15 +1669,15 @@ public:
}
protected:
- ValueTypeEntry(const QString &name, Type t) : ComplexTypeEntry(name, t) { }
+ ValueTypeEntry(const QString &name, Type t, double vr) : ComplexTypeEntry(name, t, vr) { }
};
class StringTypeEntry : public ValueTypeEntry
{
public:
- StringTypeEntry(const QString &name)
- : ValueTypeEntry(name, StringType)
+ StringTypeEntry(const QString &name, double vr)
+ : ValueTypeEntry(name, StringType, vr)
{
setCodeGeneration(GenerateNothing);
}
@@ -1656,7 +1695,7 @@ public:
class CharTypeEntry : public ValueTypeEntry
{
public:
- CharTypeEntry(const QString &name) : ValueTypeEntry(name, CharType)
+ CharTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, CharType, vr)
{
setCodeGeneration(GenerateNothing);
}
@@ -1677,7 +1716,7 @@ public:
class VariantTypeEntry: public ValueTypeEntry
{
public:
- VariantTypeEntry(const QString &name) : ValueTypeEntry(name, VariantType) { }
+ VariantTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, VariantType, vr) { }
QString targetLangApiName() const;
QString targetLangName() const;
@@ -1693,8 +1732,8 @@ public:
class APIEXTRACTOR_API InterfaceTypeEntry : public ComplexTypeEntry
{
public:
- InterfaceTypeEntry(const QString &name)
- : ComplexTypeEntry(name, InterfaceType) {}
+ InterfaceTypeEntry(const QString &name, double vr)
+ : ComplexTypeEntry(name, InterfaceType, vr) {}
static QString interfaceName(const QString &name)
{
@@ -1727,8 +1766,8 @@ private:
class APIEXTRACTOR_API FunctionTypeEntry : public TypeEntry
{
public:
- FunctionTypeEntry(const QString& name, const QString& signature)
- : TypeEntry(name, FunctionType)
+ FunctionTypeEntry(const QString& name, const QString& signature, double vr)
+ : TypeEntry(name, FunctionType, vr)
{
addSignature(signature);
}
@@ -1753,8 +1792,8 @@ private:
class APIEXTRACTOR_API ObjectTypeEntry : public ComplexTypeEntry
{
public:
- ObjectTypeEntry(const QString &name)
- : ComplexTypeEntry(name, ObjectType), m_interface(0) {}
+ ObjectTypeEntry(const QString &name, double vr)
+ : ComplexTypeEntry(name, ObjectType, vr), m_interface(0) {}
InterfaceTypeEntry *designatedInterface() const
{