diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2011-01-19 09:38:17 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:53 -0300 |
commit | f23f606c02e8c62635bd0d0f030e5c9550171b9c (patch) | |
tree | 7d2623c3aa6c1efc49a5e868e8027b46f86caf23 /generator | |
parent | 3b747443bde5752277aa9791adbfc1d32868689b (diff) |
Fix windows compilation.
Reviewer: Hugo Parente <hugo.lima@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r-- | generator/cppgenerator.cpp | 3 | ||||
-rw-r--r-- | generator/headergenerator.cpp | 24 |
2 files changed, 20 insertions, 7 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index dcee8fd77..f62e14f59 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -2723,8 +2723,7 @@ void CppGenerator::writeGetterFunction(QTextStream& s, const AbstractMetaField* #ifdef AVOID_PROTECTED_HACK if (metaField->isProtected()) - cppField = QString("(%1(%2*)%3)->%4()") - .arg(useReference ? '&' : ' ') + cppField = QString("((%1*)%2)->%3()") .arg(wrapperName(metaField->enclosingClass())) .arg(cpythonWrapperCPtr(metaField->enclosingClass(), "self")) .arg(protectedFieldGetterName(metaField)); diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp index 9a28cdb94..bb8f341a1 100644 --- a/generator/headergenerator.cpp +++ b/generator/headergenerator.cpp @@ -47,13 +47,27 @@ void HeaderGenerator::writeCopyCtor(QTextStream& s, const AbstractMetaClass* met void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const AbstractMetaField* field) const { - QString fieldType = field->type()->cppSignature(); + AbstractMetaType *metaType = field->type(); + QString fieldType = metaType->cppSignature(); QString fieldName = field->enclosingClass()->qualifiedCppName() + "::" + field->name(); - s << INDENT << "inline " << fieldType << ' ' << protectedFieldGetterName(field) << "()"; - s << " { return " << fieldName << "; }" << endl; - s << INDENT << "inline void " << protectedFieldSetterName(field) << '(' << fieldType << " value)"; - s << " { " << fieldName << " = value; }" << endl; + // Force use of pointer to return internal variable memory + bool useReference = (!metaType->isConstant() && + !metaType->isEnum() && + !metaType->isPrimitive() && + metaType->indirections() == 0); + + + // Get function + s << INDENT << "inline " << fieldType + << (useReference ? '*' : ' ') + << ' ' << protectedFieldGetterName(field) << "()" + << " { return " + << (useReference ? '&' : ' ') << "this->" << fieldName << "; }" << endl; + + // Set function + s << INDENT << "inline void " << protectedFieldSetterName(field) << '(' << fieldType << " value)" + << " { " << fieldName << " = value; }" << endl; } void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* metaClass) |