aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-07-21 14:25:44 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:04 -0300
commit3fb03a226e59b15c4c33dc824749ceb8b18b65e8 (patch)
treead2dd10d41d07f73661a912c184493de4bd98892
parent922a9a1f7d4cb6a1387cfb0aafe8f41e0c71b42a (diff)
Moved the methods isObjectType() and isPointer() from ShibokenGenerator to Generator Runner.
They were needed by other methods in the Generator class.
-rw-r--r--generator/cppgenerator.cpp22
-rw-r--r--generator/shibokengenerator.cpp39
-rw-r--r--generator/shibokengenerator.h9
3 files changed, 18 insertions, 52 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 527ca6f8c..e46780cd5 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -189,7 +189,7 @@ void CppGenerator::writeRegisterType(QTextStream& s, const AbstractMetaClass* me
QString typeName = metaClass->qualifiedCppName();
QString reducedName = reduceTypeName(metaClass);
- if (!ShibokenGenerator::isObjectType(metaClass)) {
+ if (!isObjectType(metaClass)) {
s << INDENT << "Shiboken::TypeResolver::createValueTypeResolver< ::" << typeName << " >" << "(\"" << typeName << "\");\n";
if (!reducedName.isEmpty())
s << INDENT << "Shiboken::TypeResolver::createValueTypeResolver< ::" << typeName << " >" << "(\"" << reducedName << "\");\n";
@@ -198,7 +198,7 @@ void CppGenerator::writeRegisterType(QTextStream& s, const AbstractMetaClass* me
s << INDENT << "Shiboken::TypeResolver::createObjectTypeResolver< ::" << typeName << " >" << "(\"" << typeName << "*\");\n";
if (!reducedName.isEmpty())
s << INDENT << "Shiboken::TypeResolver::createObjectTypeResolver< ::" << typeName << " >" << "(\"" << reducedName << "*\");\n";
- QString functionSufix = (ShibokenGenerator::isObjectType(metaClass) ? "Object" : "Value");
+ QString functionSufix = (isObjectType(metaClass) ? "Object" : "Value");
s << INDENT << "Shiboken::TypeResolver::create" << functionSufix;
s << "TypeResolver< ::" << typeName << " >" << "(typeid(::" << typeName << ").name());\n";
if (shouldGenerateCppWrapper(metaClass)) {
@@ -846,7 +846,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
desiredType = '"' + func->typeReplaced(0) + '"';
}
s << "(" PYTHON_RETURN_VAR ");" << endl;
- if (ShibokenGenerator::isPointerToWrapperType(func->type()))
+ if (isPointerToWrapperType(func->type()))
s << INDENT << "typeIsValid = typeIsValid || (" PYTHON_RETURN_VAR " == Py_None);" << endl;
s << INDENT << "if (!typeIsValid) {" << endl;
@@ -1189,7 +1189,7 @@ void CppGenerator::writeMinimalConstructorCallArguments(QTextStream& s, const Ab
Q_ASSERT(metaType);
const TypeEntry* type = metaType->typeEntry();
- if (ShibokenGenerator::isPointerToWrapperType(metaType)) {
+ if (isPointerToWrapperType(metaType)) {
s << "0";
} else if (type->isPrimitive()) {
const PrimitiveTypeEntry* primitiveTypeEntry = reinterpret_cast<const PrimitiveTypeEntry*>(type);
@@ -1578,7 +1578,7 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
}
if (!arg->defaultValueExpression().isEmpty()) {
strArg += " = ";
- if ((isCString(argType) || ShibokenGenerator::isPointerToWrapperType(argType))
+ if ((isCString(argType) || isPointerToWrapperType(argType))
&& arg->defaultValueExpression() == "0") {
strArg += "None";
} else {
@@ -2710,7 +2710,7 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
s << INDENT << "/*priv_data*/ 0" << endl;
s << "};" << endl;
QString suffix;
- if (ShibokenGenerator::isObjectType(metaClass))
+ if (isObjectType(metaClass))
suffix = "*";
s << "} //extern" << endl;
}
@@ -3035,7 +3035,7 @@ void CppGenerator::writeSetterFunction(QTextStream& s, const AbstractMetaField*
}
s << ';' << endl << endl;
- if (ShibokenGenerator::isPointerToWrapperType(metaField->type())) {
+ if (isPointerToWrapperType(metaField->type())) {
s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(self), \"";
s << metaField->name() << "\", value);" << endl;
//s << INDENT << "Py_XDECREF(oldvalue);" << endl;
@@ -3589,7 +3589,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
// Set OriginalName
QByteArray suffix;
- if (ShibokenGenerator::isObjectType(metaClass))
+ if (isObjectType(metaClass))
suffix = "*";
s << INDENT << "Shiboken::ObjectType::setOriginalName(&" << pyTypeName << ", \"" << metaClass->qualifiedCppName() << suffix << "\");" << endl;
@@ -3672,7 +3672,7 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream& s, const Abstrac
if (!metaClass->isNamespace() && !metaClass->isAbstract()) {
// Qt metatypes are registered only on their first use, so we do this now.
bool canBeValue = false;
- if (!ShibokenGenerator::isObjectType(metaClass)) {
+ if (!isObjectType(metaClass)) {
// check if there's a empty ctor
foreach (AbstractMetaFunction* func, metaClass->functions()) {
if (func->isConstructor() && !func->arguments().count()) {
@@ -4136,7 +4136,7 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
int childIndex = argIndex;
if (ctorHeuristicEnabled && argIndex > 0 && numArgs) {
AbstractMetaArgument* arg = func->arguments().at(argIndex-1);
- if (arg->name() == "parent" && ShibokenGenerator::isObjectType(arg->type())) {
+ if (arg->name() == "parent" && isObjectType(arg->type())) {
action = ArgumentOwner::Add;
parentIndex = argIndex;
childIndex = -1;
@@ -4201,7 +4201,7 @@ void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMeta
ArgumentOwner argOwner = getArgumentOwner(func, ArgumentOwner::ReturnIndex);
if (argOwner.action == ArgumentOwner::Invalid || argOwner.index != ArgumentOwner::ThisIndex) {
- if (ShibokenGenerator::isPointerToWrapperType(type))
+ if (isPointerToWrapperType(type))
s << INDENT << "Shiboken::Object::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
}
}
diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp
index c33a4221b..d7bbc0a9f 100644
--- a/generator/shibokengenerator.cpp
+++ b/generator/shibokengenerator.cpp
@@ -519,7 +519,7 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const TypeEntry* typ
typeName = protectedEnumSurrogateName(metaEnum);
} else {
typeName = type->qualifiedCppName().trimmed();
- if (ShibokenGenerator::isObjectType(type))
+ if (isObjectType(type))
typeName.append('*');
}
s << baseConversionString(typeName);
@@ -797,25 +797,6 @@ bool ShibokenGenerator::isPairContainer(const AbstractMetaType* type)
&& ((ContainerTypeEntry*)type->typeEntry())->type() == ContainerTypeEntry::PairContainer;
}
-bool ShibokenGenerator::isObjectType(const TypeEntry* type)
-{
- if (type->isComplex())
- return ShibokenGenerator::isObjectType((const ComplexTypeEntry*)type);
- return type->isObject();
-}
-bool ShibokenGenerator::isObjectType(const ComplexTypeEntry* type)
-{
- return type->isObject() || type->isQObject();
-}
-bool ShibokenGenerator::isObjectType(const AbstractMetaClass* metaClass)
-{
- return ShibokenGenerator::isObjectType(metaClass->typeEntry());
-}
-bool ShibokenGenerator::isObjectType(const AbstractMetaType* metaType)
-{
- return metaType->isObject() || metaType->isQObject();
-}
-
bool ShibokenGenerator::isWrapperType(const TypeEntry* type)
{
if (type->isComplex())
@@ -824,22 +805,17 @@ bool ShibokenGenerator::isWrapperType(const TypeEntry* type)
}
bool ShibokenGenerator::isWrapperType(const ComplexTypeEntry* type)
{
- return ShibokenGenerator::isObjectType(type) || type->isValue();
+ return isObjectType(type) || type->isValue();
}
bool ShibokenGenerator::isWrapperType(const AbstractMetaType* metaType)
{
- return ShibokenGenerator::isObjectType(metaType)
+ return isObjectType(metaType)
|| metaType->typeEntry()->isValue();
}
-bool ShibokenGenerator::isPointer(const AbstractMetaType* type)
-{
- return type->indirections() > 0;
-}
-
bool ShibokenGenerator::isPointerToWrapperType(const AbstractMetaType* type)
{
- return ShibokenGenerator::isObjectType(type) || type->isValuePointer();
+ return isObjectType(type) || type->isValuePointer();
}
bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg)
@@ -849,8 +825,7 @@ bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgum
bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType* metaType)
{
- return ShibokenGenerator::isWrapperType(metaType)
- && !ShibokenGenerator::isPointer(metaType)
+ return isWrapperType(metaType) && !isPointer(metaType)
&& (metaType->isValue() || metaType->isReference());
}
@@ -1255,7 +1230,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
code.replace("%0.", QString("%1->").arg("cptr"));
code.replace("%0", "cptr");
} else if (func->type()) {
- QString returnValueOp = ShibokenGenerator::isPointerToWrapperType(func->type()) ? "%1->" : "%1.";
+ QString returnValueOp = isPointerToWrapperType(func->type()) ? "%1->" : "%1.";
if (ShibokenGenerator::isWrapperType(func->type()))
code.replace("%0.", returnValueOp.arg(CPP_RETURN_VAR));
code.replace("%0", CPP_RETURN_VAR);
@@ -1639,7 +1614,7 @@ QString ShibokenGenerator::extendedToCppFunctionName(const TypeEntry* targetType
bool ShibokenGenerator::isCopyable(const AbstractMetaClass *metaClass)
{
- if (metaClass->isNamespace() || ShibokenGenerator::isObjectType(metaClass))
+ if (metaClass->isNamespace() || isObjectType(metaClass))
return false;
else if (metaClass->typeEntry()->copyable() == ComplexTypeEntry::Unknown)
return metaClass->hasCloneOperator();
diff --git a/generator/shibokengenerator.h b/generator/shibokengenerator.h
index b1a5d677a..040d9e563 100644
--- a/generator/shibokengenerator.h
+++ b/generator/shibokengenerator.h
@@ -253,12 +253,6 @@ public:
static bool isCString(const AbstractMetaType* type);
static bool isPairContainer(const AbstractMetaType* type);
- /// Tells if the type or class is an Object (or QObject) Type.
- static bool isObjectType(const TypeEntry* type);
- static bool isObjectType(const ComplexTypeEntry* type);
- static bool isObjectType(const AbstractMetaType* metaType);
- static bool isObjectType(const AbstractMetaClass* metaClass);
-
/**
* Returns true if the type passed has a Python wrapper for it.
* Although namespace has a Python wrapper, it's not considered a type.
@@ -273,9 +267,6 @@ public:
*/
static bool isPointerToWrapperType(const AbstractMetaType* type);
- /// Check if type is a pointer.
- static bool isPointer(const AbstractMetaType* type);
-
/// Checks if an argument type should be dereferenced by the Python method wrapper before calling the C++ method.
static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg);
/// Checks if a meta type should be dereferenced by the Python method wrapper passing it to C++.