summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--generator/cppgenerator.cpp112
-rw-r--r--generator/headergenerator.cpp44
-rw-r--r--generator/shibokengenerator.cpp16
-rw-r--r--libshiboken/basewrapper.cpp134
-rw-r--r--libshiboken/basewrapper.h66
-rw-r--r--libshiboken/basewrapper_p.h25
-rw-r--r--libshiboken/bindingmanager.cpp28
-rw-r--r--libshiboken/bindingmanager.h6
-rw-r--r--libshiboken/conversions.h34
-rw-r--r--tests/samplebinding/typesystem_sample.xml14
10 files changed, 242 insertions, 237 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);
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 6fb69bf9..8f5acff8 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -34,16 +34,16 @@
extern "C"
{
-static void SbkBaseTypeDealloc(PyObject* pyObj);
-static PyObject* SbkBaseTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds);
+static void SbkObjectTypeDealloc(PyObject* pyObj);
+static PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds);
-PyTypeObject SbkBaseType_Type = {
+PyTypeObject SbkObjectType_Type = {
PyObject_HEAD_INIT(0)
/*ob_size*/ 0,
/*tp_name*/ "Shiboken.ObjectType",
- /*tp_basicsize*/ sizeof(SbkBaseType),
+ /*tp_basicsize*/ sizeof(SbkObjectType),
/*tp_itemsize*/ 0,
- /*tp_dealloc*/ SbkBaseTypeDealloc,
+ /*tp_dealloc*/ SbkObjectTypeDealloc,
/*tp_print*/ 0,
/*tp_getattr*/ 0,
/*tp_setattr*/ 0,
@@ -76,7 +76,7 @@ PyTypeObject SbkBaseType_Type = {
/*tp_dictoffset*/ 0,
/*tp_init*/ 0,
/*tp_alloc*/ 0,
- /*tp_new*/ SbkBaseTypeTpNew,
+ /*tp_new*/ SbkObjectTypeTpNew,
/*tp_free*/ 0,
/*tp_is_gc*/ 0,
/*tp_bases*/ 0,
@@ -101,8 +101,8 @@ static PyGetSetDef SbkObjectGetSetList[] = {
{0} // Sentinel
};
-SbkBaseType SbkObject_Type = { { {
- PyObject_HEAD_INIT(&SbkBaseType_Type)
+SbkObjectType SbkObject_Type = { { {
+ PyObject_HEAD_INIT(&SbkObjectType_Type)
/*ob_size*/ 0,
/*tp_name*/ "Shiboken.Object",
/*tp_basicsize*/ sizeof(SbkObject),
@@ -161,7 +161,7 @@ void SbkDeallocWrapper(PyObject* pyObj)
// If I have ownership and is valid delete C++ pointer
if (sbkObj->d->hasOwnership && sbkObj->d->validCppObject) {
- SbkBaseType* sbkType = reinterpret_cast<SbkBaseType*>(pyObj->ob_type);
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
if (sbkType->d->is_multicpp) {
Shiboken::DtorCallerVisitor visitor(sbkObj);
Shiboken::walkThroughClassHierarchy(pyObj->ob_type, &visitor);
@@ -170,7 +170,7 @@ void SbkDeallocWrapper(PyObject* pyObj)
}
}
- Shiboken::Wrapper::deallocData(sbkObj, !sbkObj->d->containsCppWrapper);
+ Shiboken::Object::deallocData(sbkObj, !sbkObj->d->containsCppWrapper);
}
void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
@@ -179,12 +179,12 @@ void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
if (sbkObj->weakreflist)
PyObject_ClearWeakRefs(self);
- Shiboken::Wrapper::deallocData(sbkObj, true);
+ Shiboken::Object::deallocData(sbkObj, true);
}
-void SbkBaseTypeDealloc(PyObject* pyObj)
+void SbkObjectTypeDealloc(PyObject* pyObj)
{
- SbkBaseType *sbkType = reinterpret_cast<SbkBaseType*>(pyObj->ob_type);
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
if (!sbkType->d)
return;
@@ -198,20 +198,20 @@ void SbkBaseTypeDealloc(PyObject* pyObj)
sbkType->d = 0;
}
-PyObject* SbkBaseTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
+PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
{
// The meta type creates a new type when the Python programmer extends a wrapped C++ class.
- SbkBaseType* newType = reinterpret_cast<SbkBaseType*>(PyType_Type.tp_new(metatype, args, kwds));
+ SbkObjectType* newType = reinterpret_cast<SbkObjectType*>(PyType_Type.tp_new(metatype, args, kwds));
if (!newType)
return 0;
- SbkBaseTypePrivate* d = new SbkBaseTypePrivate;
- memset(d, 0, sizeof(SbkBaseTypePrivate));
+ SbkObjectTypePrivate* d = new SbkObjectTypePrivate;
+ memset(d, 0, sizeof(SbkObjectTypePrivate));
- std::list<SbkBaseType*> bases = Shiboken::getCppBaseClasses(reinterpret_cast<PyTypeObject*>(newType));
+ std::list<SbkObjectType*> bases = Shiboken::getCppBaseClasses(reinterpret_cast<PyTypeObject*>(newType));
if (bases.size() == 1) {
- SbkBaseTypePrivate* parentType = bases.front()->d;
+ SbkObjectTypePrivate* parentType = bases.front()->d;
d->mi_offsets = parentType->mi_offsets;
d->mi_init = parentType->mi_init;
d->mi_specialcast = parentType->mi_specialcast;
@@ -248,7 +248,7 @@ PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*)
SbkObject* self = reinterpret_cast<SbkObject*>(subtype->tp_alloc(subtype, 0));
self->d = new SbkObjectPrivate;
- SbkBaseType* sbkType = reinterpret_cast<SbkBaseType*>(subtype);
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(subtype);
int numBases = ((sbkType->d && sbkType->d->is_multicpp) ? Shiboken::getNumberOfCppBaseClasses(subtype) : 1);
self->d->cptr = new void*[numBases];
std::memset(self->d->cptr, 0, sizeof(void*)*numBases);
@@ -278,10 +278,10 @@ void walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visi
for (int i = 0; i < numBases; ++i) {
PyTypeObject* type = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(bases, i));
- if (type->ob_type != &SbkBaseType_Type) {
+ if (type->ob_type != &SbkObjectType_Type) {
continue;
} else {
- SbkBaseType* sbkType = reinterpret_cast<SbkBaseType*>(type);
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(type);
if (sbkType->d->is_user_type)
walkThroughClassHierarchy(type, visitor);
else
@@ -310,7 +310,7 @@ bool importModule(const char* moduleName, PyTypeObject*** cppApiPtr)
// Wrapper metatype and base type ----------------------------------------------------------
-void DtorCallerVisitor::visit(SbkBaseType* node)
+void DtorCallerVisitor::visit(SbkObjectType* node)
{
node->d->cpp_dtor(m_pyObj->d->cptr[m_count]);
m_count++;
@@ -330,7 +330,7 @@ void init()
if (PyType_Ready(&SbkEnumType_Type) < 0)
Py_FatalError("[libshiboken] Failed to initialise Shiboken.SbkEnumType metatype.");
- if (PyType_Ready(&SbkBaseType_Type) < 0)
+ if (PyType_Ready(&SbkObjectType_Type) < 0)
Py_FatalError("[libshiboken] Failed to initialise Shiboken.BaseWrapperType metatype.");
if (PyType_Ready((PyTypeObject *)&SbkObject_Type) < 0)
@@ -384,7 +384,7 @@ class FindBaseTypeVisitor : public HierarchyVisitor
{
public:
FindBaseTypeVisitor(PyTypeObject* typeToFind) : m_found(false), m_typeToFind(typeToFind) {}
- virtual void visit(SbkBaseType* node)
+ virtual void visit(SbkObjectType* node)
{
if (reinterpret_cast<PyTypeObject*>(node) == m_typeToFind) {
m_found = true;
@@ -406,7 +406,7 @@ std::list<SbkObject*> splitPyObject(PyObject* pyObj)
if (!lst.isNull()) {
for(int i = 0, i_max = PySequence_Fast_GET_SIZE(lst.object()); i < i_max; i++) {
PyObject* item = PySequence_Fast_GET_ITEM(lst.object(), i);
- if (Wrapper::checkType(item))
+ if (Object::checkType(item))
result.push_back(reinterpret_cast<SbkObject*>(item));
}
}
@@ -436,17 +436,17 @@ static void decRefPyObjectList(const std::list<SbkObject*>& lst)
}
}
-namespace BaseType
+namespace ObjectType
{
bool checkType(PyTypeObject* type)
{
- return type->ob_type == &SbkBaseType_Type;
+ return type->ob_type == &SbkObjectType_Type;
}
bool isUserType(PyTypeObject* type)
{
- return BaseType::checkType(type) && reinterpret_cast<SbkBaseType*>(type)->d->is_user_type;
+ return checkType(type) && reinterpret_cast<SbkObjectType*>(type)->d->is_user_type;
}
bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType)
@@ -460,119 +460,119 @@ bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType)
return true;
}
-void* copy(SbkBaseType* self, const void* obj)
+void* copy(SbkObjectType* self, const void* obj)
{
return self->d->obj_copier(obj);
}
-void setCopyFunction(SbkBaseType* self, ObjectCopierFunction func)
+void setCopyFunction(SbkObjectType* self, ObjectCopierFunction func)
{
self->d->obj_copier = func;
}
-bool hasExternalCppConversions(SbkBaseType* self)
+bool hasExternalCppConversions(SbkObjectType* self)
{
return self->d->ext_tocpp;
}
-void* callExternalCppConversion(SbkBaseType* self, PyObject* obj)
+void* callExternalCppConversion(SbkObjectType* self, PyObject* obj)
{
return self->d->ext_tocpp(obj);
}
-void setExternalCppConversionFunction(SbkBaseType* self, ExtendedToCppFunc func)
+void setExternalCppConversionFunction(SbkObjectType* self, ExtendedToCppFunc func)
{
self->d->ext_tocpp = func;
}
-void setExternalIsConvertibleFunction(SbkBaseType* self, ExtendedIsConvertibleFunc func)
+void setExternalIsConvertibleFunction(SbkObjectType* self, ExtendedIsConvertibleFunc func)
{
self->d->ext_isconvertible = func;
}
-bool isExternalConvertible(SbkBaseType* self, PyObject* obj)
+bool isExternalConvertible(SbkObjectType* self, PyObject* obj)
{
return self->d->ext_isconvertible && self->d->ext_isconvertible(obj);
}
-bool hasCast(SbkBaseType* self)
+bool hasCast(SbkObjectType* self)
{
return self->d->mi_specialcast;
}
-void* cast(SbkBaseType* self, SbkObject* obj, PyTypeObject *target)
+void* cast(SbkObjectType* self, SbkObject* obj, PyTypeObject *target)
{
- return self->d->mi_specialcast(Wrapper::cppPointer(obj, target), reinterpret_cast<SbkBaseType*>(target));
+ return self->d->mi_specialcast(Object::cppPointer(obj, target), reinterpret_cast<SbkObjectType*>(target));
}
-void setCastFunction(SbkBaseType* self, SpecialCastFunction func)
+void setCastFunction(SbkObjectType* self, SpecialCastFunction func)
{
self->d->mi_specialcast = func;
}
-void setOriginalName(SbkBaseType* self, const char* name)
+void setOriginalName(SbkObjectType* self, const char* name)
{
if (self->d->original_name)
free(self->d->original_name);
self->d->original_name = strdup(name);
}
-const char* getOriginalName(SbkBaseType* self)
+const char* getOriginalName(SbkObjectType* self)
{
return self->d->original_name;
}
-void setTypeDiscoveryFunction(SbkBaseType* self, TypeDiscoveryFunc func)
+void setTypeDiscoveryFunction(SbkObjectType* self, TypeDiscoveryFunc func)
{
self->d->type_discovery = func;
}
-TypeDiscoveryFunc getTypeDiscoveryFunction(SbkBaseType* self)
+TypeDiscoveryFunc getTypeDiscoveryFunction(SbkObjectType* self)
{
return self->d->type_discovery;
}
-void copyMultimpleheritance(SbkBaseType* self, SbkBaseType* other)
+void copyMultimpleheritance(SbkObjectType* self, SbkObjectType* other)
{
self->d->mi_init = other->d->mi_init;
self->d->mi_offsets = other->d->mi_offsets;
self->d->mi_specialcast = other->d->mi_specialcast;
}
-void setMultipleIheritanceFunction(SbkBaseType* self, MultipleInheritanceInitFunction function)
+void setMultipleIheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction function)
{
self->d->mi_init = function;
}
-MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkBaseType* self)
+MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkObjectType* self)
{
return self->d->mi_init;
}
-void setDestructorFunction(SbkBaseType* self, ObjectDestructor func)
+void setDestructorFunction(SbkObjectType* self, ObjectDestructor func)
{
self->d->cpp_dtor = func;
}
-void initPrivateData(SbkBaseType* self)
+void initPrivateData(SbkObjectType* self)
{
- self->d = new SbkBaseTypePrivate;
- memset(self->d, 0, sizeof(SbkBaseTypePrivate));
+ self->d = new SbkObjectTypePrivate;
+ memset(self->d, 0, sizeof(SbkObjectTypePrivate));
}
-} // namespace BaseType
+} // namespace ObjectType
-namespace Wrapper
+namespace Object
{
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)
@@ -586,7 +586,7 @@ static void setSequenceOwnership(PyObject* pyObj, bool owner)
else
releaseOwnership(*it);
}
- } else if (Wrapper::checkType(pyObj)) {
+ } else if (Object::checkType(pyObj)) {
if (owner)
getOwnership(reinterpret_cast<SbkObject*>(pyObj));
else
@@ -602,7 +602,7 @@ static void _destroyParentInfo(SbkObject* obj, bool keepReference)
while(!pInfo->children.empty()) {
SbkObject* first = pInfo->children.front();
// Mark child as invalid
- Shiboken::Wrapper::invalidate(first);
+ Shiboken::Object::invalidate(first);
removeParent(first, false, keepReference);
}
removeParent(obj, false);
@@ -739,7 +739,7 @@ void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType)
{
PyTypeObject* type = pyObj->ob_type;
int idx = 0;
- if (reinterpret_cast<SbkBaseType*>(type)->d->is_multicpp)
+ if (reinterpret_cast<SbkObjectType*>(type)->d->is_multicpp)
idx = getTypeIndexOnHierarchy(type, desiredType);
return pyObj->d->cptr[idx];
}
@@ -747,7 +747,7 @@ void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType)
bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr)
{
int idx = 0;
- if (reinterpret_cast<SbkBaseType*>(sbkObj->ob_type)->d->is_multicpp)
+ if (reinterpret_cast<SbkObjectType*>(sbkObj->ob_type)->d->is_multicpp)
idx = getTypeIndexOnHierarchy(sbkObj->ob_type, desiredType);
bool alreadyInitialized = sbkObj->d->cptr[idx];
@@ -762,7 +762,7 @@ bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr)
bool isValid(PyObject* pyObj)
{
if (!pyObj || pyObj == Py_None
- || pyObj->ob_type->ob_type != &SbkBaseType_Type
+ || pyObj->ob_type->ob_type != &SbkObjectType_Type
|| ((SbkObject*)pyObj)->d->validCppObject) {
return true;
}
@@ -770,7 +770,7 @@ bool isValid(PyObject* pyObj)
return false;
}
-PyObject* newObject(SbkBaseType* instanceType,
+PyObject* newObject(SbkObjectType* instanceType,
void* cptr,
bool hasOwnership,
bool isExactType,
@@ -782,7 +782,7 @@ PyObject* newObject(SbkBaseType* instanceType,
if (typeName) {
tr = TypeResolver::get(typeName);
if (tr)
- instanceType = reinterpret_cast<SbkBaseType*>(tr->pythonType());
+ instanceType = reinterpret_cast<SbkObjectType*>(tr->pythonType());
}
if (!tr)
instanceType = BindingManager::instance().resolveType(cptr, instanceType);
@@ -876,7 +876,7 @@ void setParent(PyObject* parent, PyObject* child)
* so if you pass this class to someone that takes the ownership, we CAN'T enter in this if, but hey! QString
* follows the sequence protocol.
*/
- if (PySequence_Check(child) && !Wrapper::checkType(child)) {
+ if (PySequence_Check(child) && !Object::checkType(child)) {
Shiboken::AutoDecRef seq(PySequence_Fast(child, 0));
for (int i = 0, max = PySequence_Size(seq); i < max; ++i)
setParent(parent, PySequence_Fast_GET_ITEM(seq.object(), i));
@@ -948,19 +948,19 @@ void deallocData(SbkObject* self, bool cleanup)
Py_TYPE(self)->tp_free(self);
}
-void setTypeUserData(SbkObject* wrapper, void *user_data, DeleteUserDataFunc d_func)
+void setTypeUserData(SbkObject* wrapper, void* userData, DeleteUserDataFunc d_func)
{
- SbkBaseType* ob_type = reinterpret_cast<SbkBaseType*>(wrapper->ob_type);
+ SbkObjectType* ob_type = reinterpret_cast<SbkObjectType*>(wrapper->ob_type);
if (ob_type->d->user_data)
ob_type->d->d_func(ob_type->d->user_data);
ob_type->d->d_func = d_func;
- ob_type->d->user_data = user_data;
+ ob_type->d->user_data = userData;
}
void* getTypeUserData(SbkObject* wrapper)
{
- return reinterpret_cast<SbkBaseType*>(wrapper->ob_type)->d->user_data;
+ return reinterpret_cast<SbkObjectType*>(wrapper->ob_type)->d->user_data;
}
void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append)
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index aa1301df..460f3159 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -51,7 +51,7 @@ struct LIBSHIBOKEN_API SbkObject
LIBSHIBOKEN_API void SbkDeallocWrapper(PyObject* pyObj);
LIBSHIBOKEN_API void SbkDeallocWrapperWithPrivateDtor(PyObject* self);
-struct SbkBaseType;
+struct SbkObjectType;
/// Function signature for the multiple inheritance information initializers that should be provided by classes with multiple inheritance.
typedef int* (*MultipleInheritanceInitFunction)(const void*);
@@ -61,9 +61,9 @@ typedef int* (*MultipleInheritanceInitFunction)(const void*);
* part of a multiple inheritance hierarchy.
* The implementation of this function is auto generated by the generator and you don't need to care about it.
*/
-typedef void* (*SpecialCastFunction)(void*, SbkBaseType*);
+typedef void* (*SpecialCastFunction)(void*, SbkObjectType*);
typedef void* (*ObjectCopierFunction)(const void*);
-typedef SbkBaseType* (*TypeDiscoveryFunc)(void*, SbkBaseType*);
+typedef SbkObjectType* (*TypeDiscoveryFunc)(void*, SbkObjectType*);
typedef void* (*ExtendedToCppFunc)(PyObject*);
typedef bool (*ExtendedIsConvertibleFunc)(PyObject*);
@@ -73,16 +73,16 @@ typedef void (*DeleteUserDataFunc)(void*);
typedef void (*ObjectDestructor)(void*);
-extern LIBSHIBOKEN_API PyTypeObject SbkBaseType_Type;
-extern LIBSHIBOKEN_API SbkBaseType SbkObject_Type;
+extern LIBSHIBOKEN_API PyTypeObject SbkObjectType_Type;
+extern LIBSHIBOKEN_API SbkObjectType SbkObject_Type;
-struct SbkBaseTypePrivate;
+struct SbkObjectTypePrivate;
/// PyTypeObject extended with C++ multiple inheritance information.
-struct LIBSHIBOKEN_API SbkBaseType
+struct LIBSHIBOKEN_API SbkObjectType
{
PyHeapTypeObject super;
- SbkBaseTypePrivate* d;
+ SbkObjectTypePrivate* d;
};
LIBSHIBOKEN_API PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*);
@@ -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.
@@ -129,35 +129,35 @@ LIBSHIBOKEN_API bool canCallConstructor(PyTypeObject* myType, PyTypeObjec
/**
* Call copy function for the object type
**/
-LIBSHIBOKEN_API void* copy(SbkBaseType* self, const void *obj);
-LIBSHIBOKEN_API void setCopyFunction(SbkBaseType* self, ObjectCopierFunction func);
+LIBSHIBOKEN_API void* copy(SbkObjectType* self, const void* obj);
+LIBSHIBOKEN_API void setCopyFunction(SbkObjectType* self, ObjectCopierFunction func);
-LIBSHIBOKEN_API void setExternalCppConversionFunction(SbkBaseType* self, ExtendedToCppFunc func);
-LIBSHIBOKEN_API void setExternalIsConvertibleFunction(SbkBaseType* self, ExtendedIsConvertibleFunc func);
-LIBSHIBOKEN_API bool hasExternalCppConversions(SbkBaseType* self);
-LIBSHIBOKEN_API bool isExternalConvertible(SbkBaseType* self, PyObject* obj);
-LIBSHIBOKEN_API void* callExternalCppConversion(SbkBaseType* self, PyObject* obj);
+LIBSHIBOKEN_API void setExternalCppConversionFunction(SbkObjectType* self, ExtendedToCppFunc func);
+LIBSHIBOKEN_API void setExternalIsConvertibleFunction(SbkObjectType* self, ExtendedIsConvertibleFunc func);
+LIBSHIBOKEN_API bool hasExternalCppConversions(SbkObjectType* self);
+LIBSHIBOKEN_API bool isExternalConvertible(SbkObjectType* self, PyObject* obj);
+LIBSHIBOKEN_API void* callExternalCppConversion(SbkObjectType* self, PyObject* obj);
-LIBSHIBOKEN_API bool hasCast(SbkBaseType* self);
-LIBSHIBOKEN_API void* cast(SbkBaseType* self, SbkObject* obj, PyTypeObject* target);
-LIBSHIBOKEN_API void setCastFunction(SbkBaseType* self, SpecialCastFunction func);
+LIBSHIBOKEN_API bool hasCast(SbkObjectType* self);
+LIBSHIBOKEN_API void* cast(SbkObjectType* self, SbkObject* obj, PyTypeObject* target);
+LIBSHIBOKEN_API void setCastFunction(SbkObjectType* self, SpecialCastFunction func);
-LIBSHIBOKEN_API void setOriginalName(SbkBaseType* self, const char* name);
-LIBSHIBOKEN_API const char* getOriginalName(SbkBaseType* self);
+LIBSHIBOKEN_API void setOriginalName(SbkObjectType* self, const char* name);
+LIBSHIBOKEN_API const char* getOriginalName(SbkObjectType* self);
-LIBSHIBOKEN_API void setTypeDiscoveryFunction(SbkBaseType* self, TypeDiscoveryFunc func);
-LIBSHIBOKEN_API TypeDiscoveryFunc getTypeDiscoveryFunction(SbkBaseType* self);
+LIBSHIBOKEN_API void setTypeDiscoveryFunction(SbkObjectType* self, TypeDiscoveryFunc func);
+LIBSHIBOKEN_API TypeDiscoveryFunc getTypeDiscoveryFunction(SbkObjectType* self);
-LIBSHIBOKEN_API void copyMultimpleheritance(SbkBaseType* self, SbkBaseType* other);
-LIBSHIBOKEN_API void setMultipleIheritanceFunction(SbkBaseType* self, MultipleInheritanceInitFunction func);
-LIBSHIBOKEN_API MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkBaseType* self);
+LIBSHIBOKEN_API void copyMultimpleheritance(SbkObjectType* self, SbkObjectType* other);
+LIBSHIBOKEN_API void setMultipleIheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction func);
+LIBSHIBOKEN_API MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkObjectType* self);
-LIBSHIBOKEN_API void setDestructorFunction(SbkBaseType* self, ObjectDestructor func);
+LIBSHIBOKEN_API void setDestructorFunction(SbkObjectType* self, ObjectDestructor func);
-LIBSHIBOKEN_API void initPrivateData(SbkBaseType* self);
+LIBSHIBOKEN_API void initPrivateData(SbkObjectType* self);
}
-namespace Wrapper {
+namespace Object {
/**
* Returns true if the object is an instance of a type created by the Shiboken generator.
@@ -166,7 +166,7 @@ LIBSHIBOKEN_API bool checkType(PyObject* pyObj);
LIBSHIBOKEN_API bool isUserType(PyObject* pyObj);
-LIBSHIBOKEN_API PyObject* newObject(SbkBaseType* instanceType,
+LIBSHIBOKEN_API PyObject* newObject(SbkObjectType* instanceType,
void* cptr,
bool hasOwnership = true,
bool isExactType = false,
@@ -242,7 +242,7 @@ LIBSHIBOKEN_API void destroy(SbkObject* self);
/**
* Get/Set Userdata in type class
*/
-LIBSHIBOKEN_API void setTypeUserData(SbkObject* wrapper, void* user_data, DeleteUserDataFunc d_func);
+LIBSHIBOKEN_API void setTypeUserData(SbkObject* wrapper, void* userData, DeleteUserDataFunc d_func);
LIBSHIBOKEN_API void* getTypeUserData(SbkObject* wrapper);
/**
@@ -257,9 +257,9 @@ LIBSHIBOKEN_API void* getTypeUserData(SbkObject* wrapper);
* \param key a key that identifies the C++ method signature and argument where the referredObject came from.
* \parem referredObject the object whose reference is used by the self object.
*/
-LIBSHIBOKEN_API void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append=false);
+LIBSHIBOKEN_API void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append = false);
-} // namespace Wrapper
+} // namespace Object
} // namespace Shiboken
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index 428159e0..b90aaa45 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -28,7 +28,7 @@
#include <map>
struct SbkObject;
-struct SbkBaseType;
+struct SbkObjectType;
namespace Shiboken
{
@@ -81,7 +81,7 @@ struct SbkObjectPrivate
};
-struct SbkBaseTypePrivate
+struct SbkObjectTypePrivate
{
int* mi_offsets;
MultipleInheritanceInitFunction mi_init;
@@ -125,7 +125,7 @@ class HierarchyVisitor
public:
HierarchyVisitor() : m_wasFinished(false) {}
virtual ~HierarchyVisitor() {}
- virtual void visit(SbkBaseType* node) = 0;
+ virtual void visit(SbkObjectType* node) = 0;
void finish() { m_wasFinished = true; };
bool wasFinished() const { return m_wasFinished; }
private:
@@ -137,7 +137,7 @@ class BaseCountVisitor : public HierarchyVisitor
public:
BaseCountVisitor() : m_count(0) {}
- void visit(SbkBaseType*)
+ void visit(SbkObjectType*)
{
m_count++;
}
@@ -152,21 +152,21 @@ class BaseAccumulatorVisitor : public HierarchyVisitor
public:
BaseAccumulatorVisitor() {}
- void visit(SbkBaseType* node)
+ void visit(SbkObjectType* node)
{
m_bases.push_back(node);
}
- std::list<SbkBaseType*> bases() const { return m_bases; }
+ std::list<SbkObjectType*> bases() const { return m_bases; }
private:
- std::list<SbkBaseType*> m_bases;
+ std::list<SbkObjectType*> m_bases;
};
class GetIndexVisitor : public HierarchyVisitor
{
public:
GetIndexVisitor(PyTypeObject* desiredType) : m_index(-1), m_desiredType(desiredType) {}
- virtual void visit(SbkBaseType* node)
+ virtual void visit(SbkObjectType* node)
{
m_index++;
if (PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(node), m_desiredType))
@@ -183,7 +183,7 @@ class DtorCallerVisitor : public HierarchyVisitor
{
public:
DtorCallerVisitor(SbkObject* pyObj) : m_count(0), m_pyObj(pyObj) {}
- void visit(SbkBaseType* node);
+ void visit(SbkObjectType* node);
private:
int m_count;
SbkObject* m_pyObj;
@@ -211,14 +211,14 @@ inline int getNumberOfCppBaseClasses(PyTypeObject* baseType)
return visitor.count();
}
-inline std::list<SbkBaseType*> getCppBaseClasses(PyTypeObject* baseType)
+inline std::list<SbkObjectType*> getCppBaseClasses(PyTypeObject* baseType)
{
BaseAccumulatorVisitor visitor;
walkThroughClassHierarchy(baseType, &visitor);
return visitor.bases();
}
-namespace Wrapper
+namespace Object
{
/**
* Decrements the reference counters of every object referred by self.
@@ -230,7 +230,8 @@ void clearReferences(SbkObject* self);
* Destroy internal data
**/
void deallocData(SbkObject* self, bool doCleanup);
-} // namespace Wrapper
+
+} // namespace Object
} // namespace Shiboken
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index 3742f6fe..9f73833c 100644
--- a/libshiboken/bindingmanager.cpp
+++ b/libshiboken/bindingmanager.cpp
@@ -37,8 +37,8 @@ typedef google::dense_hash_map<const void*, SbkObject*> WrapperMap;
class Graph
{
public:
- typedef std::list<SbkBaseType*> NodeList;
- typedef google::dense_hash_map<SbkBaseType*, NodeList> Edges;
+ typedef std::list<SbkObjectType*> NodeList;
+ typedef google::dense_hash_map<SbkObjectType*, NodeList> Edges;
Edges m_edges;
@@ -47,7 +47,7 @@ public:
m_edges.set_empty_key(0);
}
- void addEdge(SbkBaseType* from, SbkBaseType* to)
+ void addEdge(SbkObjectType* from, SbkObjectType* to)
{
m_edges[from].push_back(to);
}
@@ -61,7 +61,7 @@ public:
Edges::const_iterator i = m_edges.begin();
for (; i != m_edges.end(); ++i) {
- SbkBaseType* node1 = i->first;
+ SbkObjectType* node1 = i->first;
const NodeList& nodeList = i->second;
NodeList::const_iterator j = nodeList.begin();
for (; j != nodeList.end(); ++j)
@@ -71,14 +71,14 @@ public:
}
#endif
- SbkBaseType* identifyType(void* cptr, SbkBaseType* type, SbkBaseType* baseType) const
+ SbkObjectType* identifyType(void* cptr, SbkObjectType* type, SbkObjectType* baseType) const
{
Edges::const_iterator edgesIt = m_edges.find(type);
if (edgesIt != m_edges.end()) {
const NodeList& adjNodes = m_edges.find(type)->second;
NodeList::const_iterator i = adjNodes.begin();
for (; i != adjNodes.end(); ++i) {
- SbkBaseType* newType = identifyType(cptr, *i, baseType);
+ SbkObjectType* newType = identifyType(cptr, *i, baseType);
if (newType)
return newType;
}
@@ -148,7 +148,7 @@ BindingManager::~BindingManager()
* the BindingManager is being destroyed the interpreter is alredy
* shutting down. */
while (!m_d->wrapperMapper.empty()) {
- Wrapper::destroy(m_d->wrapperMapper.begin()->second);
+ Object::destroy(m_d->wrapperMapper.begin()->second);
}
assert(m_d->wrapperMapper.size() == 0);
delete m_d;
@@ -166,8 +166,8 @@ bool BindingManager::hasWrapper(const void* cptr)
void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
{
- SbkBaseType* instanceType = reinterpret_cast<SbkBaseType*>(pyObj->ob_type);
- SbkBaseTypePrivate* d = instanceType->d;
+ SbkObjectType* instanceType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
+ SbkObjectTypePrivate* d = instanceType->d;
if (!d)
return;
@@ -187,8 +187,8 @@ void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
void BindingManager::releaseWrapper(SbkObject* sbkObj)
{
- SbkBaseType* sbkType = reinterpret_cast<SbkBaseType*>(sbkObj->ob_type);
- SbkBaseTypePrivate* d = sbkType->d;
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(sbkObj->ob_type);
+ SbkObjectTypePrivate* d = sbkType->d;
int numBases = ((d && d->is_multicpp) ? getNumberOfCppBaseClasses(sbkObj->ob_type) : 1);
void** cptrs = reinterpret_cast<SbkObject*>(sbkObj)->d->cptr;
@@ -255,14 +255,14 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
return 0;
}
-void BindingManager::addClassInheritance(SbkBaseType* parent, SbkBaseType* child)
+void BindingManager::addClassInheritance(SbkObjectType* parent, SbkObjectType* child)
{
m_d->classHierarchy.addEdge(parent, child);
}
-SbkBaseType* BindingManager::resolveType(void* cptr, SbkBaseType* type)
+SbkObjectType* BindingManager::resolveType(void* cptr, SbkObjectType* type)
{
- SbkBaseType* identifiedType = m_d->classHierarchy.identifyType(cptr, type, type);
+ SbkObjectType* identifiedType = m_d->classHierarchy.identifyType(cptr, type, type);
return identifiedType ? identifiedType : type;
}
diff --git a/libshiboken/bindingmanager.h b/libshiboken/bindingmanager.h
index 2ead2351..b6d4ac42 100644
--- a/libshiboken/bindingmanager.h
+++ b/libshiboken/bindingmanager.h
@@ -28,7 +28,7 @@
#include "shibokenmacros.h"
struct SbkObject;
-struct SbkBaseType;
+struct SbkObjectType;
namespace Shiboken
{
@@ -46,8 +46,8 @@ public:
SbkObject* retrieveWrapper(const void* cptr);
PyObject* getOverride(const void* cptr, const char* methodName);
- void addClassInheritance(SbkBaseType* parent, SbkBaseType* child);
- SbkBaseType* resolveType(void* cptr, SbkBaseType* type);
+ void addClassInheritance(SbkObjectType* parent, SbkObjectType* child);
+ SbkObjectType* resolveType(void* cptr, SbkObjectType* type);
std::set<SbkObject*> getAllPyObjects();
private:
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index d6a3dd5e..a49ec34d 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<SbkBaseType*>(SbkType<T>()), &obj));
+ return reinterpret_cast<T*>(ObjectType::copy(reinterpret_cast<SbkObjectType*>(SbkType<T>()), &obj));
}
};
@@ -113,7 +113,7 @@ inline PyObject* createWrapper(const T* cppobj, bool hasOwnership = false, bool
const char* typeName = 0;
if (!isExactType)
typeName = typeid(*const_cast<T*>(cppobj)).name();
- return Wrapper::newObject(reinterpret_cast<SbkBaseType*>(SbkType<T>()),
+ return Object::newObject(reinterpret_cast<SbkObjectType*>(SbkType<T>()),
const_cast<T*>(cppobj), hasOwnership, isExactType, typeName);
}
@@ -150,7 +150,7 @@ struct Converter<T*>
static T* toCpp(PyObject* pyobj)
{
if (PyObject_TypeCheck(pyobj, SbkType<T>()))
- return (T*) Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>());
+ return (T*) Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>());
else if (Converter<T>::isConvertible(pyobj))
return CppObjectCopier<T>::copy(Converter<T>::toCpp(pyobj));
else if (pyobj == Py_None)
@@ -213,8 +213,8 @@ struct ValueTypeConverter
{
if (PyObject_TypeCheck(pyobj, SbkType<T>()))
return true;
- SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<T>());
- return BaseType::isExternalConvertible(shiboType, pyobj);
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
+ return ObjectType::isExternalConvertible(shiboType, pyobj);
}
static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<T*>(cppobj)); }
static inline PyObject* toPython(const T& cppobj)
@@ -231,15 +231,15 @@ struct ValueTypeConverter
static inline T toCpp(PyObject* pyobj)
{
if (!PyObject_TypeCheck(pyobj, SbkType<T>())) {
- SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<T>());
- if (BaseType::hasExternalCppConversions(shiboType) && isConvertible(pyobj)) {
- T* cptr = reinterpret_cast<T*>(BaseType::callExternalCppConversion(shiboType, pyobj));
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
+ 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;
}
assert(false);
}
- return *reinterpret_cast<T*>(Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
+ return *reinterpret_cast<T*>(Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
}
};
@@ -271,10 +271,10 @@ struct ObjectTypeConverter
{
if (pyobj == Py_None)
return 0;
- SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(pyobj->ob_type);
- if (BaseType::hasCast(shiboType))
- return reinterpret_cast<T*>(BaseType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
- return (T*) Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>());
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(pyobj->ob_type);
+ if (ObjectType::hasCast(shiboType))
+ return reinterpret_cast<T*>(ObjectType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
+ return (T*) Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>());
}
};
@@ -560,7 +560,7 @@ struct StdListConverter
// binded types implementing sequence protocol, otherwise this will
// cause a mess like QBitArray being accepted by someone expecting a
// QStringList.
- if ((SbkType<StdList>() && Wrapper::checkType(pyObj)) || !PySequence_Check(pyObj))
+ if ((SbkType<StdList>() && Object::checkType(pyObj)) || !PySequence_Check(pyObj))
return false;
for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) {
AutoDecRef item(PySequence_GetItem(pyObj, i));
@@ -583,7 +583,7 @@ struct StdListConverter
static StdList toCpp(PyObject* pyobj)
{
if (PyObject_TypeCheck(pyobj, SbkType<StdList>()))
- return *reinterpret_cast<StdList*>(Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<StdList>()));
+ return *reinterpret_cast<StdList*>(Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<StdList>()));
StdList result;
for (int i = 0; i < PySequence_Size(pyobj); i++) {
@@ -606,7 +606,7 @@ struct StdPairConverter
{
if (PyObject_TypeCheck(pyObj, SbkType<StdPair>()))
return true;
- if ((SbkType<StdPair>() && Wrapper::checkType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2)
+ if ((SbkType<StdPair>() && Object::checkType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2)
return false;
AutoDecRef item1(PySequence_GetItem(pyObj, 0));
@@ -651,7 +651,7 @@ struct StdMapConverter
{
if (PyObject_TypeCheck(pyObj, SbkType<StdMap>()))
return true;
- if ((SbkType<StdMap>() && Wrapper::checkType(pyObj)) || !PyDict_Check(pyObj))
+ if ((SbkType<StdMap>() && Object::checkType(pyObj)) || !PyDict_Check(pyObj))
return false;
PyObject* key;
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index b0fff8dc..fb133b51 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -183,9 +183,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::Object::setParent(layout, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
} else {
- Wrapper::setParent(parent, %CONVERTTOPYTHON[ObjectType*](*it));
+ Shiboken::Object::setParent(parent, %CONVERTTOPYTHON[ObjectType*](*it));
}
}
}
@@ -714,8 +714,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>
@@ -919,7 +919,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;
}
@@ -943,7 +943,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;
}
@@ -1181,7 +1181,7 @@
</modify-argument>
<inject-code class="target" position="end">
%RETURN_TYPE %0 = %TYPE::%FUNCTION_NAME();
- %PYARG_0 = Shiboken::Wrapper::newObject(&amp;SbkObject_Type, %0, false, false);
+ %PYARG_0 = Shiboken::Object::newObject(&amp;SbkObject_Type, %0, false, false);
</inject-code>
</modify-function>
</value-type>