summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-23 14:56:27 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-23 14:58:15 -0200
commit521cf2b6190a89ecaf19fff925c75bb47b72fa49 (patch)
tree454a90c8211326a4046e76e13141389ddab14de0 /generator
parent81a8bd714bf4ea7783277052da932d8a7a909fd1 (diff)
parent605bbf8d03eaf5c90b1efdb17eabfa66fedc24be (diff)
downloadshiboken-521cf2b6190a89ecaf19fff925c75bb47b72fa49.tar.gz
shiboken-521cf2b6190a89ecaf19fff925c75bb47b72fa49.tar.xz
shiboken-521cf2b6190a89ecaf19fff925c75bb47b72fa49.zip
Merge branch 'fixapi'
Reviewer: Renato Ara├║jo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org> Conflicts: generator/cppgenerator.cpp libshiboken/basewrapper.cpp libshiboken/basewrapper_p.h
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp112
-rw-r--r--generator/headergenerator.cpp44
-rw-r--r--generator/shibokengenerator.cpp16
3 files changed, 88 insertions, 84 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index b1f8d573..fa8b2cc2 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::Object::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::Object::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::Object::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"
- << INDENT << "void* typeData = Shiboken::Wrapper::getTypeUserData(pySelf);" << endl
+ s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);\n"
+ << INDENT << "void* typeData = Shiboken::Object::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, &Shiboken::callCppDestructor<PySide::DynamicQMetaObject>);" << 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::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType<" << metaClass->qualifiedCppName() << " >()))" << endl;
Indentation indent(INDENT);
s << INDENT << "return " << m_currentErrorCode << ';' << endl << endl;
}
@@ -866,8 +864,8 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
s << INDENT << "SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);" << endl;
if (metaClass->isAbstract() || metaClass->baseClassNames().size() > 1) {
- s << INDENT << "SbkBaseType* type = reinterpret_cast<SbkBaseType*>(self->ob_type);" << endl;
- s << INDENT << "SbkBaseType* myType = reinterpret_cast<SbkBaseType*>(" << cpythonTypeNameExt(metaClass->typeEntry()) << ");" << endl;
+ s << INDENT << "SbkObjectType* type = reinterpret_cast<SbkObjectType*>(self->ob_type);" << endl;
+ s << INDENT << "SbkObjectType* myType = reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(metaClass->typeEntry()) << ");" << endl;
}
if (metaClass->isAbstract()) {
@@ -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;
@@ -922,7 +920,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
if (hasPythonConvertion)
s << INDENT << "}" << endl;
- s << INDENT << "if (PyErr_Occurred() || !Shiboken::Wrapper::setCppPointer(sbkSelf, Shiboken::SbkType<" << metaClass->qualifiedCppName() << " >(), cptr)) {" << endl;
+ s << INDENT << "if (PyErr_Occurred() || !Shiboken::Object::setCppPointer(sbkSelf, Shiboken::SbkType<" << metaClass->qualifiedCppName() << " >(), cptr)) {" << endl;
{
Indentation indent(INDENT);
s << INDENT << "delete cptr;" << endl;
@@ -934,14 +932,14 @@ void CppGenerator::writeConstructorWrapper(QTextStream& s, const AbstractMetaFun
s << endl;
}
- s << INDENT << "Shiboken::Wrapper::setValidCpp(sbkSelf, true);" << endl;
+ s << INDENT << "Shiboken::Object::setValidCpp(sbkSelf, true);" << endl;
// If the created C++ object has a C++ wrapper the ownership is assigned to Python
// (first "1") and the flag indicating that the Python wrapper holds an C++ wrapper
// is marked as true (the second "1"). Otherwise the default values apply:
// 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::Object::setHasCppWrapper(sbkSelf, true);" << endl;
+ s << INDENT << "Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);" << endl;
// Create metaObject and register signal/slot
if (metaClass->isQObject() && usePySideExtensions()) {
@@ -1173,7 +1171,7 @@ void CppGenerator::writeMethodWrapper(QTextStream& s, const AbstractMetaFunction
s << INDENT << "if (!isReverse" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "&& Shiboken::Wrapper::checkType(arg)" << endl;
+ s << INDENT << "&& Shiboken::Object::checkType(arg)" << endl;
s << INDENT << "&& !PyObject_TypeCheck(arg, self->ob_type)" << endl;
s << INDENT << "&& PyObject_HasAttrString(arg, const_cast<char*>(\"" << revOpName << "\"))) {" << endl;
// This PyObject_CallMethod call will emit lots of warnings like
@@ -1427,7 +1425,7 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
void CppGenerator::writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName, const TypeEntry* type)
{
- s << INDENT << "if (!Shiboken::Wrapper::isValid(" << pyArgName << "))" << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(" << pyArgName << "))" << endl;
Indentation indent(INDENT);
s << INDENT << "return " << m_currentErrorCode << ';' << endl;
}
@@ -1850,7 +1848,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
if (func->isAbstract()) {
- s << INDENT << "if (Shiboken::Wrapper::hasCppWrapper(reinterpret_cast<SbkObject*>(self))) {\n";
+ s << INDENT << "if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(self))) {\n";
{
Indentation indent(INDENT);
s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"pure virtual method '";
@@ -2057,7 +2055,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
normalCall = normalCall.replace("::%CLASS_NAME::", "");
methodCall = "";
- mc << "(Shiboken::Wrapper::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ mc << "(Shiboken::Object::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
}
}
}
@@ -2142,15 +2140,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::Object::getOwnership(" << pyArgName << ");";
} else if (wrappedClass->hasVirtualDestructor()) {
if (arg_mod.index == 0) {
- s << "Wrapper::releaseOwnership(" PYTHON_RETURN_VAR ");";
+ s << "Shiboken::Object::releaseOwnership(" PYTHON_RETURN_VAR ");";
} else {
- s << "Wrapper::releaseOwnership(" << pyArgName << ");";
+ s << "Shiboken::Object::releaseOwnership(" << pyArgName << ");";
}
} else {
- s << "Wrapper::invalidate(" << pyArgName << ");";
+ s << "Shiboken::Object::invalidate(" << pyArgName << ");";
}
s << endl;
}
@@ -2166,7 +2164,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
break;
}
- s << INDENT << "Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(self), \"";
+ s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(self), \"";
QString varName = arg_mod.referenceCounts.first().varName;
if (varName.isEmpty())
varName = func->minimalSignature() + QString().number(arg_mod.index);
@@ -2238,12 +2236,12 @@ void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, c
void CppGenerator::writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass)
{
QString className = metaClass->qualifiedCppName();
- s << "static void* " << cpythonSpecialCastFunctionName(metaClass) << "(void* obj, SbkBaseType* desiredType)\n";
+ s << "static void* " << cpythonSpecialCastFunctionName(metaClass) << "(void* obj, SbkObjectType* desiredType)\n";
s << "{\n";
s << INDENT << className << "* me = reinterpret_cast<" << className << "*>(obj);\n";
bool firstClass = true;
foreach (const AbstractMetaClass* baseClass, getAllAncestors(metaClass)) {
- s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkBaseType*>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n";
+ s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n";
Indentation indent(INDENT);
s << INDENT << "return static_cast<" << baseClass->qualifiedCppName() << "*>(me);\n";
firstClass = false;
@@ -2295,11 +2293,11 @@ void CppGenerator::writeExtendedToCppFunction(QTextStream& s, const TypeEntry* e
void CppGenerator::writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType, const QList<const AbstractMetaClass*>& conversions)
{
s << INDENT << "// Extended implicit conversions for " << externalType->targetLangPackage() << '.' << externalType->name() << endl;
- s << INDENT << "shiboType = reinterpret_cast<SbkBaseType*>(";
+ 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)
@@ -2428,8 +2426,8 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
s << "// Class Definition -----------------------------------------------" << endl;
s << "extern \"C\" {" << endl;
- s << "static SbkBaseType " << className + "_Type" << " = { { {" << endl;
- s << INDENT << "PyObject_HEAD_INIT(&SbkBaseType_Type)" << endl;
+ s << "static SbkObjectType " << className + "_Type" << " = { { {" << endl;
+ s << INDENT << "PyObject_HEAD_INIT(&SbkObjectType_Type)" << endl;
s << INDENT << "/*ob_size*/ 0," << endl;
s << INDENT << "/*tp_name*/ \"" << metaClass->fullName() << "\"," << endl;
s << INDENT << "/*tp_basicsize*/ sizeof(SbkObject)," << endl;
@@ -2644,7 +2642,7 @@ void CppGenerator::writeCopyFunction(QTextStream& s, const AbstractMetaClass *me
s << "static PyObject *" << className << "___copy__(PyObject *self)" << endl;
s << "{" << endl;
s << INDENT << metaClass->qualifiedCppName() << "* " CPP_SELF_VAR " = 0;" << endl;
- s << INDENT << "if (!Shiboken::Wrapper::isValid(self))" << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))" << endl;
{
Indentation indent(INDENT);
s << INDENT << "return 0;" << endl;
@@ -2658,7 +2656,7 @@ void CppGenerator::writeCopyFunction(QTextStream& s, const AbstractMetaClass *me
s << INDENT << PYTHON_RETURN_VAR " = Shiboken::Converter<" << metaClass->qualifiedCppName();
s << "*>::toPython(copy);" << endl;
- s << INDENT << "Shiboken::Wrapper::getOwnership(" PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "Shiboken::Object::getOwnership(" PYTHON_RETURN_VAR ");" << endl;
s << endl;
@@ -2740,7 +2738,7 @@ void CppGenerator::writeSetterFunction(QTextStream& s, const AbstractMetaField*
bool pythonWrapperRefCounting = metaField->type()->typeEntry()->isObject()
|| metaField->type()->isValuePointer();
if (pythonWrapperRefCounting) {
- s << INDENT << "Shiboken::Wrapper::keepReference(reinterpret_cast<SbkObject*>(self), \"";
+ s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(self), \"";
s << metaField->name() << "\", value);" << endl;
//s << INDENT << "Py_XDECREF(oldvalue);" << endl;
s << endl;
@@ -3216,7 +3214,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()) {
@@ -3248,10 +3246,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<SbkBaseType*>(" << 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
@@ -3265,12 +3263,12 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (metaClass->typeEntry()->isValue())
dtorClassName = wrapperName(metaClass);
- 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;
@@ -3279,10 +3277,10 @@ 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<SbkBaseType*>(" << cpythonTypeNameExt(base->typeEntry()) << "), &" << cpythonTypeName(metaClass) << ");" << endl;
+ s << INDENT << "bm.addClassInheritance(reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(base->typeEntry()) << "), &" << cpythonTypeName(metaClass) << ");" << endl;
}
}
s << endl;
@@ -3292,7 +3290,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,"
@@ -3363,7 +3361,7 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
{
QString polymorphicExpr = metaClass->typeEntry()->polymorphicIdValue();
- s << "static SbkBaseType* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkBaseType* instanceType)\n{" << endl;
+ s << "static SbkObjectType* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkObjectType* instanceType)\n{" << endl;
if (!metaClass->baseClass()) {
s << INDENT << "TypeResolver* typeResolver = TypeResolver::get(typeid(*reinterpret_cast<"
@@ -3371,7 +3369,7 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
s << INDENT << "if (typeResolver)" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return reinterpret_cast<SbkBaseType*>(typeResolver->pythonType());" << endl;
+ s << INDENT << "return reinterpret_cast<SbkObjectType*>(typeResolver->pythonType());" << endl;
}
} else if (!polymorphicExpr.isEmpty()) {
polymorphicExpr = polymorphicExpr.replace("%1", " reinterpret_cast<"+metaClass->qualifiedCppName()+"*>(cptr)");
@@ -3386,7 +3384,7 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
if (ancestor->baseClass())
continue;
if (ancestor->isPolymorphic()) {
- s << INDENT << "if (instanceType == reinterpret_cast<SbkBaseType*>(Shiboken::SbkType<"
+ s << INDENT << "if (instanceType == reinterpret_cast<SbkObjectType*>(Shiboken::SbkType<"
<< ancestor->qualifiedCppName() << " >()) && dynamic_cast<" << metaClass->qualifiedCppName()
<< "*>(reinterpret_cast<"<< ancestor->qualifiedCppName() << "*>(cptr)))" << endl;
Indentation indent(INDENT);
@@ -3478,7 +3476,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
@@ -3707,7 +3705,7 @@ void CppGenerator::finishGeneration()
if (!extendedConverters.isEmpty()) {
s << INDENT << "// Initialize extended Converters" << endl;
- s << INDENT << "SbkBaseType* shiboType;" << endl << endl;
+ s << INDENT << "SbkObjectType* shiboType;" << endl << endl;
}
foreach (const TypeEntry* externalType, extendedConverters.keys()) {
writeExtendedConverterInitialization(s, externalType, extendedConverters[externalType]);
@@ -3825,7 +3823,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::Object::setParent(" << parentVariable << ", " << childVariable << ");\n";
return true;
}
@@ -3859,7 +3857,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::Object::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
}
void CppGenerator::writeHashFunction(QTextStream& s, const AbstractMetaClass* metaClass)
@@ -3887,7 +3885,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream& s, const AbstractMeta
{
//len
s << "Py_ssize_t " << cpythonBaseName(metaClass->typeEntry()) << "__len__" << "(PyObject* self)" << endl << '{' << endl;
- s << INDENT << "if (!Shiboken::Wrapper::isValid(self))" << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))" << endl;
s << INDENT << INDENT << "return 0;" << endl << endl;
s << INDENT << metaClass->qualifiedCppName() << " &cppSelf = Shiboken::Converter<" << metaClass->qualifiedCppName() <<"& >::toCpp(self);" << endl;
s << INDENT << "return cppSelf.size();" << endl;
@@ -3895,7 +3893,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream& s, const AbstractMeta
//getitem
s << "PyObject* " << cpythonBaseName(metaClass->typeEntry()) << "__getitem__" << "(PyObject* self, Py_ssize_t _i)" << endl << '{' << endl;
- s << INDENT << "if (!Shiboken::Wrapper::isValid(self))" << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))" << endl;
s << INDENT << INDENT << "return 0;" << endl << endl;
s << INDENT << metaClass->qualifiedCppName() << " &cppSelf = Shiboken::Converter<" << metaClass->qualifiedCppName() <<"& >::toCpp(self);" << endl;
s << INDENT << "if (_i < 0 || _i >= (Py_ssize_t) cppSelf.size()) {" << endl;
@@ -3908,7 +3906,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream& s, const AbstractMeta
//setitem
s << "int " << cpythonBaseName(metaClass->typeEntry()) << "__setitem__" << "(PyObject* self, Py_ssize_t _i, PyObject* _value)" << endl << '{' << endl;
- s << INDENT << "if (!Shiboken::Wrapper::isValid(self))" << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))" << endl;
s << INDENT << INDENT << "return -1;" << endl;
s << INDENT << metaClass->qualifiedCppName() << " &cppSelf = Shiboken::Converter<" << metaClass->qualifiedCppName() <<"& >::toCpp(self);" << endl;
s << INDENT << "if (_i < 0 || _i >= (Py_ssize_t) cppSelf.size()) {" << endl;
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index 590aea38..4775331c 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<SbkBaseType*>(SbkType<" << metaClass->qualifiedCppName() << " >()),"
+ s << INDENT << "PyObject* pyObj = Shiboken::Object::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 << "SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(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 4990eb19..b064573d 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().trimmed();
+ if (!type->isCppPrimitive())
+ typeName.prepend("::");
if (type->isObject())
typeName.append('*');
#ifdef AVOID_PROTECTED_HACK
@@ -499,11 +501,13 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaTy
ptype = ptype->basicAliasedTypeEntry();
typeName = ptype->name();
} else {
- if (type->isObject() || (type->isValue() && !type->isReference()))
+ if (!isCString(type)) // not "const char*"
options |= Generator::ExcludeConst;
- if (type->isContainer() )
- options |= Generator::ExcludeReference | Generator::ExcludeConst;
- typeName = translateTypeForWrapperMethod(type, context, options);
+ if (type->isContainer() || type->isFlags() || type->isEnum() || (type->isConstant() && type->isReference()))
+ options |= Generator::ExcludeReference;
+ typeName = translateTypeForWrapperMethod(type, context, options).trimmed();
+ if (!type->typeEntry()->isCppPrimitive())
+ typeName.prepend("::");
}
s << baseConversionString(typeName);