aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-19 17:56:10 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:59 -0300
commit2927e38cb46d3aa2cf278238d2a585d96f669d91 (patch)
tree995d9feaabe6439d26f87753abd71608ab563d58
parentbe2c1160275e63c148297b0001e735e3969f0b7e (diff)
namespace Shiboken::BaseType renamed to Shiboken::ObjectType.
-rw-r--r--generator/cppgenerator.cpp58
-rw-r--r--generator/headergenerator.cpp44
-rw-r--r--generator/shibokengenerator.cpp10
-rw-r--r--libshiboken/basewrapper.cpp10
-rw-r--r--libshiboken/basewrapper.h2
-rw-r--r--libshiboken/conversions.h12
-rw-r--r--tests/samplebinding/typesystem_sample.xml12
7 files changed, 76 insertions, 72 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index d1ebf773c..fe90843fc 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -209,8 +209,6 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
if (metaClass->typeEntry()->typeFlags() & ComplexTypeEntry::Deprecated)
s << "#Deprecated" << endl;
- s << "using namespace Shiboken;" << endl;
-
//Use class base namespace
const AbstractMetaClass *context = metaClass->enclosingClass();
while(context) {
@@ -470,8 +468,8 @@ void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass
{
Indentation indentation(INDENT);
s << wrapperName(metaClass) << "::~" << wrapperName(metaClass) << "()" << endl << '{' << endl;
- s << INDENT << "SbkObject* wrapper = BindingManager::instance().retrieveWrapper(this);" << endl;
- s << INDENT << "Wrapper::destroy(wrapper);" << endl;
+ s << INDENT << "SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "Shiboken::Wrapper::destroy(wrapper);" << endl;
s << '}' << endl;
}
@@ -534,7 +532,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
s << INDENT << "Shiboken::GilState gil;" << endl;
- s << INDENT << "Shiboken::AutoDecRef py_override(BindingManager::instance().getOverride(this, \"";
+ s << INDENT << "Shiboken::AutoDecRef py_override(Shiboken::BindingManager::instance().getOverride(this, \"";
s << func->name() << "\"));" << endl;
s << INDENT << "if (py_override.isNull()) {" << endl;
@@ -682,7 +680,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (func->type()->isPrimitive())
desiredType = "\"" + func->type()->name() + "\"";
else
- desiredType = "SbkType<" + typeName + " >()->tp_name";
+ desiredType = "Shiboken::SbkType<" + typeName + " >()->tp_name";
}
} else {
s << guessCPythonIsConvertible(func->typeReplaced(0));
@@ -740,7 +738,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (invalidateReturn) {
s << INDENT << "if (invalidadeArg0)" << endl;
Indentation indentation(INDENT);
- s << INDENT << "Wrapper::invalidate(" << PYTHON_RETURN_VAR ".object());" << endl;
+ s << INDENT << "Shiboken::Wrapper::invalidate(" << PYTHON_RETURN_VAR ".object());" << endl;
}
foreach (FunctionModification funcMod, func->modifications()) {
@@ -748,7 +746,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (argMod.resetAfterUse) {
s << INDENT << "if (invalidadeArg" << argMod.index << ")" << endl;
Indentation indentation(INDENT);
- s << INDENT << "Wrapper::invalidate(PyTuple_GET_ITEM(pyargs, ";
+ s << INDENT << "Shiboken::Wrapper::invalidate(PyTuple_GET_ITEM(pyargs, ";
s << (argMod.index - 1) << "));" << endl;
}
}
@@ -787,14 +785,14 @@ void CppGenerator::writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass
s << INDENT << "if (!m_metaObject) {\n";
{
Indentation indentation(INDENT);
- s << INDENT << "SbkObject* pySelf = BindingManager::instance().retrieveWrapper(this);\n"
+ s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);\n"
<< INDENT << "void* typeData = Shiboken::Wrapper::getTypeUserData(pySelf);" << endl
<< INDENT << "if (!typeData) {" << endl;
{
Indentation indentation2(INDENT);
s << INDENT << "m_metaObject = PySide::DynamicQMetaObject::createBasedOn((PyObject*)pySelf, pySelf->ob_type, &"
<< metaClass->qualifiedCppName() << "::staticMetaObject);" << endl
- << INDENT << "Shiboken::Wrapper::setTypeUserData(pySelf, m_metaObject, PySide::deleteDynamicQMetaObject);" << endl;
+ << INDENT << "Shiboken::Object::setTypeUserData(pySelf, m_metaObject, Shiboken::callCppDestructor<PySide::DynamicQMetaObject>);" << endl;
}
s << INDENT << "} else {" << endl;
{
@@ -830,7 +828,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
// Check if the right constructor was called.
if (!metaClass->hasPrivateDestructor()) {
- s << INDENT << "if (Shiboken::Wrapper::isUserType(self) && !Shiboken::BaseType::canCallConstructor(self->ob_type, Shiboken::SbkType<" << metaClass->qualifiedCppName() << " >()))" << endl;
+ s << INDENT << "if (Shiboken::Wrapper::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType<" << metaClass->qualifiedCppName() << " >()))" << endl;
Indentation indent(INDENT);
s << INDENT << "return " << m_currentErrorCode << ';' << endl << endl;
}
@@ -891,7 +889,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
}
{
Indentation indentation(INDENT);
- s << INDENT << "Shiboken::BaseType::copyMultimpleheritance(type, myType);" << endl;
+ s << INDENT << "Shiboken::ObjectType::copyMultimpleheritance(type, myType);" << endl;
}
if (!metaClass->isAbstract())
s << INDENT << '}' << endl << endl;
@@ -941,7 +939,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
// Python owns it and C++ wrapper is false.
if (shouldGenerateCppWrapper(overloads.first()->ownerClass()))
s << INDENT << "Shiboken::Wrapper::setHasCppWrapper(sbkSelf, true);" << endl;
- s << INDENT << "BindingManager::instance().registerWrapper(sbkSelf, cptr);" << endl;
+ s << INDENT << "Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);" << endl;
// Create metaObject and register signal/slot
if (metaClass->isQObject() && usePySideExtensions()) {
@@ -2128,15 +2126,15 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
s << INDENT;
if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::TargetLangOwnership) {
- s << "Wrapper::getOwnership(" << pyArgName << ");";
+ s << "Shiboken::Wrapper::getOwnership(" << pyArgName << ");";
} else if (wrappedClass->hasVirtualDestructor()) {
if (arg_mod.index == 0) {
- s << "Wrapper::releaseOwnership(" PYTHON_RETURN_VAR ");";
+ s << "Shiboken::Wrapper::releaseOwnership(" PYTHON_RETURN_VAR ");";
} else {
- s << "Wrapper::releaseOwnership(" << pyArgName << ");";
+ s << "Shiboken::Wrapper::releaseOwnership(" << pyArgName << ");";
}
} else {
- s << "Wrapper::invalidate(" << pyArgName << ");";
+ s << "Shiboken::Wrapper::invalidate(" << pyArgName << ");";
}
s << endl;
}
@@ -2284,8 +2282,8 @@ void CppGenerator::writeExtendedConverterInitialization(QTextStream& s, const Ty
s << INDENT << "shiboType = reinterpret_cast<SbkObjectType*>(";
s << cppApiVariableName(externalType->targetLangPackage()) << '[';
s << getTypeIndexVariableName(externalType) << "]);" << endl;
- s << INDENT << "Shiboken::BaseType::setExternalIsConvertibleFunction(shiboType, " << extendedIsConvertibleFunctionName(externalType) << ");" << endl;
- s << INDENT << "Shiboken::BaseType::setExternalCppConversionFunction(shiboType, " << extendedToCppFunctionName(externalType) << ");" << endl;
+ s << INDENT << "Shiboken::ObjectType::setExternalIsConvertibleFunction(shiboType, " << extendedIsConvertibleFunctionName(externalType) << ");" << endl;
+ s << INDENT << "Shiboken::ObjectType::setExternalCppConversionFunction(shiboType, " << extendedToCppFunctionName(externalType) << ");" << endl;
}
QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass)
@@ -3202,7 +3200,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
s << INDENT << cpythonTypeNameExt(metaClass->typeEntry()) << " = reinterpret_cast<PyTypeObject*>(&" << cpythonTypeName(metaClass->typeEntry()) << ");" << endl << endl;
// alloc private data
- s << INDENT << "Shiboken::BaseType::initPrivateData(&" << cpythonTypeName(metaClass->typeEntry()) << ");" << endl;
+ s << INDENT << "Shiboken::ObjectType::initPrivateData(&" << cpythonTypeName(metaClass->typeEntry()) << ");" << endl;
// class inject-code target/beginning
if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
@@ -3234,10 +3232,10 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (miClass == metaClass)
s << INDENT << "func = " << multipleInheritanceInitializerFunctionName(miClass) << ";" << endl;
else
- s << INDENT << "func = Shiboken::BaseType::getMultipleIheritanceFunction(reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(miClass->typeEntry()) << "));" << endl;
+ s << INDENT << "func = Shiboken::ObjectType::getMultipleIheritanceFunction(reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(miClass->typeEntry()) << "));" << endl;
- s << INDENT << "Shiboken::BaseType::setMultipleIheritanceFunction(&" << cpythonTypeName(metaClass) << ", func);" << endl;
- s << INDENT << "Shiboken::BaseType::setCastFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonSpecialCastFunctionName(metaClass) << ");" << endl;
+ s << INDENT << "Shiboken::ObjectType::setMultipleIheritanceFunction(&" << cpythonTypeName(metaClass) << ", func);" << endl;
+ s << INDENT << "Shiboken::ObjectType::setCastFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonSpecialCastFunctionName(metaClass) << ");" << endl;
}
// Fill destrutor
@@ -3247,12 +3245,12 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (metaClass->hasProtectedDestructor())
dtorClassName = wrapperName(metaClass);
#endif
- s << INDENT << "Shiboken::BaseType::setDestructorFunction(&" << cpythonTypeName(metaClass) << ", &Shiboken::callCppDestructor<" << dtorClassName << " >);" << endl;
+ s << INDENT << "Shiboken::ObjectType::setDestructorFunction(&" << cpythonTypeName(metaClass) << ", &Shiboken::callCppDestructor<" << dtorClassName << " >);" << endl;
}
// Fill copy function
if (metaClass->typeEntry()->isValue() && shouldGenerateCppWrapper(metaClass))
- s << INDENT << "Shiboken::BaseType::setCopyFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonBaseName(metaClass) + "_ObjCopierFunc);" << endl;
+ s << INDENT << "Shiboken::ObjectType::setCopyFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonBaseName(metaClass) + "_ObjCopierFunc);" << endl;
s << INDENT << "if (PyType_Ready((PyTypeObject*)&" << pyTypeName << ") < 0)" << endl;
s << INDENT << INDENT << "return;" << endl << endl;
@@ -3261,7 +3259,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (metaClass->isPolymorphic()) {
s << INDENT << "// Fill type discovery information" << endl;
if (metaClass->baseClass()) {
- s << INDENT << "Shiboken::BaseType::setTypeDiscoveryFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonBaseName(metaClass) << "_typeDiscovery);" << endl;
+ s << INDENT << "Shiboken::ObjectType::setTypeDiscoveryFunction(&" << cpythonTypeName(metaClass) << ", &" << cpythonBaseName(metaClass) << "_typeDiscovery);" << endl;
s << INDENT << "Shiboken::BindingManager& bm = Shiboken::BindingManager::instance();" << endl;
foreach (const AbstractMetaClass* base, baseClasses) {
s << INDENT << "bm.addClassInheritance(reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(base->typeEntry()) << "), &" << cpythonTypeName(metaClass) << ");" << endl;
@@ -3274,7 +3272,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
QByteArray suffix;
if (metaClass->typeEntry()->isObject() || metaClass->typeEntry()->isQObject())
suffix = "*";
- s << INDENT << "Shiboken::BaseType::setOriginalName(&" << pyTypeName << ", \"" << metaClass->qualifiedCppName() << suffix << "\");" << endl;
+ s << INDENT << "Shiboken::ObjectType::setOriginalName(&" << pyTypeName << ", \"" << metaClass->qualifiedCppName() << suffix << "\");" << endl;
if (metaClass->enclosingClass() && (metaClass->enclosingClass()->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass) ) {
s << INDENT << "PyDict_SetItemString(module,"
@@ -3460,7 +3458,7 @@ void CppGenerator::writeGetattroFunction(QTextStream& s, const AbstractMetaClass
s << INDENT << "if (!attr && !QString(PyString_AS_STRING(name)).startsWith(\"__\")) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "QObject* cppSelf = Converter<QObject*>::toCpp(self);" << endl
+ s << INDENT << "QObject* cppSelf = Shiboken::Converter<QObject*>::toCpp(self);" << endl
<< INDENT << "const QMetaObject* metaObject = cppSelf->metaObject();" << endl
<< INDENT << "QByteArray cname(PyString_AS_STRING(name));" << endl
<< INDENT << "cname += '(';" << endl
@@ -3807,7 +3805,7 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
else
childVariable = usePyArgs ? "pyargs["+QString::number(childIndex-1)+"]" : "arg";
- s << INDENT << "Wrapper::setParent(" << parentVariable << ", " << childVariable << ");\n";
+ s << INDENT << "Shiboken::Wrapper::setParent(" << parentVariable << ", " << childVariable << ");\n";
return true;
}
@@ -3841,7 +3839,7 @@ void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMeta
}
if (type->isQObject() || type->isObject() || type->isValuePointer())
- s << INDENT << "Wrapper::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "Shiboken::Wrapper::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
}
void CppGenerator::writeHashFunction(QTextStream& s, const AbstractMetaClass* metaClass)
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index f1b8086d0..3f14712bb 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -214,8 +214,8 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
}
bool isValueTypeWithImplConversions = type->isValue() && !implicitConvs.isEmpty();
bool hasCustomConversion = type->hasNativeConversionRule();
- QString typeT = type->name() + (isAbstractOrObjectType ? "*" : "");
- QString typeName = type->name();
+ QString typeT = "::" + type->qualifiedCppName() + (isAbstractOrObjectType ? "*" : "");
+ QString typeName = "::" + type->qualifiedCppName();
#ifdef AVOID_PROTECTED_HACK
const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(type);
@@ -225,7 +225,7 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
}
#endif
- s << "struct Converter<" << typeT << " >";
+ s << "struct Converter< " << typeT << " >";
if (!hasCustomConversion) {
if (type->isEnum())
s << " : EnumConverter";
@@ -235,17 +235,17 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
s << " : ObjectTypeConverter";
else
s << " : ValueTypeConverter";
- s << '<' << typeName << " >";
+ s << "< " << typeName << " >";
}
s << endl << '{' << endl;
if (isValueTypeWithImplConversions || hasCustomConversion) {
- s << INDENT << "static " << type->name() << " toCpp(PyObject* pyobj);" << endl;
+ s << INDENT << "static " << typeName << " toCpp(PyObject* pyobj);" << endl;
s << INDENT << "static bool isConvertible(PyObject* pyobj);" << endl;
if (hasCustomConversion) {
s << INDENT << "static bool checkType(PyObject* pyobj);" << endl;
- s << INDENT << "static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<"
- << type->name() << (isAbstractOrObjectType ? "" : "*") << " >(cppObj)); }" << endl;
- s << INDENT << "static PyObject* toPython(const " << type->name() << "& cppObj);" << endl;
+ s << INDENT << "static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast< "
+ << typeName << (isAbstractOrObjectType ? "" : "*") << " >(cppObj)); }" << endl;
+ s << INDENT << "static PyObject* toPython(const " << typeName << "& cppObj);" << endl;
}
}
s << "};" << endl;
@@ -253,7 +253,7 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
// write value-type like converter to object-types
if (isAbstractOrObjectType) {
s << endl << "template<>" << endl;
- s << "struct Converter<" << type->name() << "& > : ObjectTypeReferenceConverter<" << type->name() << " >" << endl << '{' << endl;
+ s << "struct Converter< " << typeName << " > : ObjectTypeReferenceConverter< " << typeName << " >" << endl << '{' << endl;
s << "};" << endl;
}
}
@@ -434,7 +434,7 @@ void HeaderGenerator::finishGeneration()
s << INDENT << metaClass->qualifiedCppName() << "* value = const_cast<" << metaClass->qualifiedCppName() << "* >(cppobj);" << endl;
s << INDENT << "if (!isExactType)" << endl;
s << INDENT << INDENT << "typeName = typeid(*value).name();" << endl;
- s << INDENT << "PyObject* pyObj = Shiboken::Wrapper::newObject(reinterpret_cast<SbkObjectType*>(SbkType<" << metaClass->qualifiedCppName() << " >()),"
+ s << INDENT << "PyObject* pyObj = Shiboken::Wrapper::newObject(reinterpret_cast<SbkObjectType*>(SbkType< ::" << metaClass->qualifiedCppName() << " >()),"
<< "value, hasOwnership, isExactType, typeName);" << endl;
s << INDENT << "PySide::Signal::updateSourceObject(pyObj);" << endl;
s << INDENT << "return pyObj;" << endl;
@@ -472,19 +472,19 @@ void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnu
}
#endif
- s << "template<> inline PyTypeObject* SbkType<" << enumName << " >() ";
+ s << "template<> inline PyTypeObject* SbkType< ::" << enumName << " >() ";
s << "{ return " << cpythonTypeNameExt(cppEnum->typeEntry()) << "; }\n";
FlagsTypeEntry* flag = cppEnum->typeEntry()->flags();
if (flag) {
- s << "template<> inline PyTypeObject* SbkType<" << flag->name() << " >() "
+ s << "template<> inline PyTypeObject* SbkType< ::" << flag->name() << " >() "
<< "{ return " << cpythonTypeNameExt(flag) << "; }\n";
}
}
void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass)
{
- s << "template<> inline PyTypeObject* SbkType<" << cppClass->qualifiedCppName() << " >() "
+ s << "template<> inline PyTypeObject* SbkType< ::" << cppClass->qualifiedCppName() << " >() "
<< "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(cppClass->typeEntry()) << "); }\n";
}
@@ -520,19 +520,21 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
if (!hasImplicitConversions)
return;
+ const QString typeName = "::" + type->qualifiedCppName();
+
// Write Converter<T>::isConvertible
- s << "inline bool Shiboken::Converter<" << type->name() << " >::isConvertible(PyObject* pyobj)" << endl;
+ s << "inline bool Shiboken::Converter< " << typeName << " >::isConvertible(PyObject* pyobj)" << endl;
s << '{' << endl;
if (type->isValue()) {
- s << INDENT << "if (ValueTypeConverter<" << type->name() << " >::isConvertible(pyobj))" << endl;
+ s << INDENT << "if (ValueTypeConverter< " << typeName << " >::isConvertible(pyobj))" << endl;
Indentation indent(INDENT);
s << INDENT << "return true;" << endl;
}
- s << INDENT << "SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<";
- s << type->name() << " >());" << endl;
+ s << INDENT << "SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ";
+ s << typeName << " >());" << endl;
s << INDENT << "return ";
bool isFirst = true;
foreach (const AbstractMetaFunction* ctor, implicitConvs) {
@@ -550,15 +552,15 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
s << endl;
{
Indentation indent(INDENT);
- s << INDENT << " || (BaseType::isExternalConvertible(shiboType, pyobj));" << endl;
+ s << INDENT << " || (ObjectType::isExternalConvertible(shiboType, pyobj));" << endl;
}
s << '}' << endl << endl;
// Write Converter<T>::toCpp function
- s << "inline " << type->name() << " Shiboken::Converter<" << type->name() << " >::toCpp(PyObject* pyobj)" << endl;
+ s << "inline " << typeName << " Shiboken::Converter< " << typeName << " >::toCpp(PyObject* pyobj)" << endl;
s << '{' << endl;
- s << INDENT << "if (PyObject_TypeCheck(pyobj, SbkType<" << type->qualifiedCppName() << ">()))" << endl;
+ s << INDENT << "if (PyObject_TypeCheck(pyobj, SbkType< " << typeName << " >()))" << endl;
{
Indentation indent(INDENT);
s << INDENT << "return *" << cpythonWrapperCPtr(type, "pyobj") << ';' << endl;
@@ -594,7 +596,7 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
s << INDENT << "else" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return Shiboken::ValueTypeConverter<" << type->qualifiedCppName() << " >::toCpp(pyobj);" << endl;
+ s << INDENT << "return Shiboken::ValueTypeConverter< " << typeName << " >::toCpp(pyobj);" << endl;
}
}
s << '}' << endl << endl;
diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp
index 4990eb190..5ddbb6d7e 100644
--- a/generator/shibokengenerator.cpp
+++ b/generator/shibokengenerator.cpp
@@ -471,12 +471,14 @@ QString ShibokenGenerator::getFunctionReturnType(const AbstractMetaFunction* fun
static QString baseConversionString(QString typeName)
{
- return QString("Shiboken::Converter<%1 >::").arg(typeName);
+ return QString("Shiboken::Converter< %1 >::").arg(typeName);
}
void ShibokenGenerator::writeBaseConversion(QTextStream& s, const TypeEntry* type)
{
- QString typeName = type->name();
+ QString typeName = type->qualifiedCppName();
+ if (!type->isCppPrimitive())
+ typeName.prepend("::");
if (type->isObject())
typeName.append('*');
#ifdef AVOID_PROTECTED_HACK
@@ -501,9 +503,11 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaTy
} else {
if (type->isObject() || (type->isValue() && !type->isReference()))
options |= Generator::ExcludeConst;
- if (type->isContainer() )
+ if (type->isContainer() || (type->isConstant() && type->isReference()))
options |= Generator::ExcludeReference | Generator::ExcludeConst;
typeName = translateTypeForWrapperMethod(type, context, options);
+ if (!type->typeEntry()->isCppPrimitive())
+ typeName.prepend("::");
}
s << baseConversionString(typeName);
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 5c47a357f..948a24e34 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -437,7 +437,7 @@ static void decRefPyObjectList(const std::list<SbkObject*>& lst)
}
}
-namespace BaseType
+namespace ObjectType
{
bool checkType(PyTypeObject* type)
@@ -447,7 +447,7 @@ bool checkType(PyTypeObject* type)
bool isUserType(PyTypeObject* type)
{
- return BaseType::checkType(type) && reinterpret_cast<SbkObjectType*>(type)->d->is_user_type;
+ return checkType(type) && reinterpret_cast<SbkObjectType*>(type)->d->is_user_type;
}
bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType)
@@ -561,19 +561,19 @@ void initPrivateData(SbkObjectType* self)
memset(self->d, 0, sizeof(SbkBaseTypePrivate));
}
-} // namespace BaseType
+} // namespace ObjectType
namespace Wrapper
{
bool checkType(PyObject* pyObj)
{
- return BaseType::checkType(pyObj->ob_type);
+ return ObjectType::checkType(pyObj->ob_type);
}
bool isUserType(PyObject* pyObj)
{
- return BaseType::isUserType(pyObj->ob_type);
+ return ObjectType::isUserType(pyObj->ob_type);
}
static void setSequenceOwnership(PyObject* pyObj, bool owner)
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 80207e251..7ae5502fc 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -108,7 +108,7 @@ void callCppDestructor(void* cptr)
LIBSHIBOKEN_API bool importModule(const char* moduleName, PyTypeObject*** cppApiPtr);
LIBSHIBOKEN_API void setErrorAboutWrongArguments(PyObject* args, const char* funcName, const char** cppOverloads);
-namespace BaseType {
+namespace ObjectType {
/**
* Returns true if the object is an instance of a type created by the Shiboken generator.
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index afc4989f4..5d0048fe8 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -99,7 +99,7 @@ struct CppObjectCopier<T, true>
{
static inline T* copy(const T& obj)
{
- return reinterpret_cast<T*>(BaseType::copy(reinterpret_cast<SbkObjectType*>(SbkType<T>()), &obj));
+ return reinterpret_cast<T*>(ObjectType::copy(reinterpret_cast<SbkObjectType*>(SbkType<T>()), &obj));
}
};
@@ -214,7 +214,7 @@ struct ValueTypeConverter
if (PyObject_TypeCheck(pyobj, SbkType<T>()))
return true;
SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
- return BaseType::isExternalConvertible(shiboType, pyobj);
+ return ObjectType::isExternalConvertible(shiboType, pyobj);
}
static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<T*>(cppobj)); }
static inline PyObject* toPython(const T& cppobj)
@@ -232,8 +232,8 @@ struct ValueTypeConverter
{
if (!PyObject_TypeCheck(pyobj, SbkType<T>())) {
SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
- if (BaseType::hasExternalCppConversions(shiboType) && isConvertible(pyobj)) {
- T* cptr = reinterpret_cast<T*>(BaseType::callExternalCppConversion(shiboType, pyobj));
+ if (ObjectType::hasExternalCppConversions(shiboType) && isConvertible(pyobj)) {
+ T* cptr = reinterpret_cast<T*>(ObjectType::callExternalCppConversion(shiboType, pyobj));
std::auto_ptr<T> cptr_auto_ptr(cptr);
return *cptr;
}
@@ -272,8 +272,8 @@ struct ObjectTypeConverter
if (pyobj == Py_None)
return 0;
SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(pyobj->ob_type);
- if (BaseType::hasCast(shiboType))
- return reinterpret_cast<T*>(BaseType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
+ if (ObjectType::hasCast(shiboType))
+ return reinterpret_cast<T*>(ObjectType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
return (T*) Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>());
}
};
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 37fa4742e..fb46eb2f7 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -178,9 +178,9 @@
if ((*it)->isLayoutType()) {
ObjectTypeLayout* l = reinterpret_cast&lt;ObjectTypeLayout*>(*it);
reparent_layout_items(parent, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
- Wrapper::setParent(layout, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
+ Shiboken::Wrapper::setParent(layout, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
} else {
- Wrapper::setParent(parent, %CONVERTTOPYTHON[ObjectType*](*it));
+ Shiboken::Wrapper::setParent(parent, %CONVERTTOPYTHON[ObjectType*](*it));
}
}
}
@@ -709,8 +709,8 @@
<modify-argument index="return">
<replace-type modified-type="PySequence"/>
<conversion-rule class="native">
- AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 0));
- AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 1));
+ Shiboken::AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 1));
%RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](_py_ok_);
%2 = %CONVERTTOCPP[Str*](_py_ret_);
</conversion-rule>
@@ -914,7 +914,7 @@
<inject-code class="target" position="beginning">
int argc;
char** argv;
- if (!sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
+ if (!Shiboken::sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
PyErr_SetString(PyExc_TypeError, "error");
return 0;
}
@@ -938,7 +938,7 @@
<inject-code class="target" position="beginning">
int argc;
char** argv;
- if (!sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
+ if (!Shiboken::sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
PyErr_SetString(PyExc_TypeError, "error");
return 0;
}