aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-01 16:45:58 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:11 -0300
commitfc57e7dd0846f28c319db3bc5c902b3055042fc7 (patch)
treea37a6885b339a4ada2cc92224af0982c67287853
parent35c500c84b6be8f400f8cd1029c528172bca49c7 (diff)
Implement support to target conversion.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--typesystem.cpp26
-rw-r--r--typesystem.h18
2 files changed, 33 insertions, 11 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index e3baf06df..b31e8366c 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -944,16 +944,17 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
- if (topElement.type == StackElement::ModifyArgument) {
- static QHash<QString, TypeSystem::Language> languageNames;
- if (languageNames.isEmpty()) {
- languageNames["target"] = TypeSystem::TargetLangCode;
- languageNames["native"] = TypeSystem::NativeCode;
- }
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames["target"] = TypeSystem::TargetLangCode;
+ languageNames["native"] = TypeSystem::NativeCode;
+ }
+
+ QString languageAttribute = attributes["class"].toLower();
+ TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage);
- QString languageAttribute = attributes["class"].toLower();
- TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage);
- if (lang == TypeSystem::NoLanguage) {
+ if (topElement.type == StackElement::ModifyArgument) {
+ if (lang == TypeSystem::NoLanguage) {
m_error = QString("unsupported class attribute: '%1'").arg(lang);
return false;
}
@@ -977,9 +978,14 @@ bool Handler::startElement(const QString &, const QString &n,
//Handler constructor....
if (m_generate != TypeEntry::GenerateForSubclass
&& m_generate != TypeEntry::GenerateNothing) {
+
+ const char* conversionFlag = NATIVE_CONVERSION_RULE_FLAG;
+ if (lang == TypeSystem::TargetLangCode)
+ conversionFlag = TARGET_CONVERSION_RULE_FLAG;
+
QFile conversionSource(sourceFile);
if (conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) {
- topElement.entry->setConversionRule(QString::fromUtf8(conversionSource.readAll()));
+ topElement.entry->setConversionRule(conversionFlag + QString::fromUtf8(conversionSource.readAll()));
} else {
ReportHandler::warning("File containing conversion code for "
+ topElement.entry->name()
diff --git a/typesystem.h b/typesystem.h
index 682f068e3..62d041892 100644
--- a/typesystem.h
+++ b/typesystem.h
@@ -32,6 +32,10 @@
#include "apiextractormacros.h"
#include "include.h"
+//Used to identify the conversion rule to avoid break API
+#define TARGET_CONVERSION_RULE_FLAG "0"
+#define NATIVE_CONVERSION_RULE_FLAG "1"
+
class Indentor;
class AbstractMetaType;
@@ -913,6 +917,7 @@ public:
m_include = inc;
}
+ // Replace conversionRule arg to CodeSnip in future version
/// Set the type convertion rule
void setConversionRule(const QString& conversionRule)
{
@@ -922,7 +927,8 @@ public:
/// Returns the type convertion rule
QString conversionRule() const
{
- return m_conversionRule;
+ //skip conversions flag
+ return m_conversionRule.mid(1);
}
/// Returns true if there are any conversiton rule for this type, false otherwise.
@@ -936,6 +942,16 @@ public:
return m_version;
}
+ bool hasNativeConversionRule() const
+ {
+ return m_conversionRule.startsWith(NATIVE_CONVERSION_RULE_FLAG);
+ }
+
+ bool hasTargetConversionRule() const
+ {
+ return m_conversionRule.startsWith(TARGET_CONVERSION_RULE_FLAG);
+ }
+
private:
QString m_name;