summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-16 11:05:32 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:18 -0300
commitd151c052d5113fbe1e8d1b921dff3b45105e94ab (patch)
tree4b4245ceed20990602ceb48981ae65b53a8c9821
parent15b355dca205090adf9fe338f02963f945263d98 (diff)
Added setTargetLangPackage and targetLangPackage methods to PrimitiveTypeEntry.sb-0.10.6
Updated tests. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Lauro Moura <lauro.neto@openbossa.org>
-rw-r--r--tests/testabstractmetatype.cpp4
-rw-r--r--typesystem.cpp17
-rw-r--r--typesystem.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/tests/testabstractmetatype.cpp b/tests/testabstractmetatype.cpp
index 17e5278a..ed39ebc3 100644
--- a/tests/testabstractmetatype.cpp
+++ b/tests/testabstractmetatype.cpp
@@ -38,7 +38,7 @@ void TestAbstractMetaType::testConstCharPtrType()
AbstractMetaType* rtype = func->type();
// Test properties of const char*
QVERIFY(rtype);
- QCOMPARE(rtype->package(), QString());
+ QCOMPARE(rtype->package(), QString("Foo"));
QCOMPARE(rtype->name(), QString("char"));
QVERIFY(rtype->isConstant());
QVERIFY(!rtype->isArray());
@@ -107,7 +107,7 @@ void TestAbstractMetaType::testCharType()
AbstractMetaType* rtype = func->type();
// Test properties of const char*
QVERIFY(rtype);
- QCOMPARE(rtype->package(), QString());
+ QCOMPARE(rtype->package(), QString("Foo"));
QCOMPARE(rtype->name(), QString("char"));
QVERIFY(!rtype->isConstant());
QVERIFY(!rtype->isArray());
diff --git a/typesystem.cpp b/typesystem.cpp
index 8d52e7aa..b99cf2fc 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -568,6 +568,7 @@ bool Handler::startElement(const QString &, const QString &n,
type->setCodeGeneration(m_generate);
type->setTargetLangName(targetLangName);
type->setTargetLangApiName(targetLangApiName);
+ type->setTargetLangPackage(m_defaultPackage);
type->setDefaultConstructor(defaultConstructor);
bool preferred;
@@ -1725,6 +1726,20 @@ PrimitiveTypeEntry* PrimitiveTypeEntry::basicAliasedTypeEntry() const
return m_aliasedTypeEntry;
}
+typedef QHash<const PrimitiveTypeEntry*, QString> PrimitiveTypeEntryTargetLangPackageMap;
+Q_GLOBAL_STATIC(PrimitiveTypeEntryTargetLangPackageMap, primitiveTypeEntryTargetLangPackages);
+
+void PrimitiveTypeEntry::setTargetLangPackage(const QString& package)
+{
+ primitiveTypeEntryTargetLangPackages()->insert(this, package);
+}
+QString PrimitiveTypeEntry::targetLangPackage() const
+{
+ if (!primitiveTypeEntryTargetLangPackages()->contains(this))
+ return this->::TypeEntry::targetLangPackage();
+ return primitiveTypeEntryTargetLangPackages()->value(this);
+}
+
CodeSnipList TypeEntry::codeSnips() const
{
return m_codeSnips;
@@ -1742,13 +1757,11 @@ 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)
lst << mod;
}
-
return lst;
}
diff --git a/typesystem.h b/typesystem.h
index 3fcb241f..abba4455 100644
--- a/typesystem.h
+++ b/typesystem.h
@@ -1142,6 +1142,8 @@ public:
m_preferredTargetLangType = b;
}
+ void setTargetLangPackage(const QString& package);
+ QString targetLangPackage() const;
private:
QString m_targetLangName;
QString m_targetLangApiName;