summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-10 15:30:08 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-10 15:36:29 -0200
commit5c813360b2f647753bfbacaf705504b7710d613c (patch)
treeb1adb090b1e7ad58010dbba801c5fe9166f051e2
parentf2a10c2257e40a7f24c457ad45d875f997a2cc5a (diff)
downloadshiboken-5c813360b2f647753bfbacaf705504b7710d613c.tar.gz
shiboken-5c813360b2f647753bfbacaf705504b7710d613c.tar.xz
shiboken-5c813360b2f647753bfbacaf705504b7710d613c.zip
Remove macro Shiboken_TypeCheck
-rw-r--r--generator/headergenerator.cpp26
-rw-r--r--libshiboken/basewrapper.h5
-rw-r--r--libshiboken/conversions.h4
3 files changed, 7 insertions, 28 deletions
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index 4afbc1d7..d9560d2a 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -558,23 +558,17 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
s << "inline " << type->name() << " Shiboken::Converter<" << type->name() << " >::toCpp(PyObject* pyobj)" << endl;
s << '{' << endl;
- s << INDENT << "if (!Shiboken_TypeCheck(pyobj, " << type->name() << ")) {" << endl;
+ s << INDENT << "if (PyObject_TypeCheck(pyobj, SbkType<" << type->qualifiedCppName() << ">()))" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<";
- s << type->name() << " >());" << endl;
+ s << INDENT << "return *" << cpythonWrapperCPtr(type, "pyobj") << ';' << endl;
}
- bool firstImplicitIf = true;
+
foreach (const AbstractMetaFunction* ctor, implicitConvs) {
if (ctor->isModifiedRemoved())
continue;
- Indentation indent(INDENT);
- s << INDENT;
- if (firstImplicitIf)
- firstImplicitIf = false;
- else
- s << "else ";
+ s << INDENT << "else ";
QString typeCheck;
QString toCppConv;
@@ -597,20 +591,12 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
}
{
- Indentation indent(INDENT);
- s << INDENT << "else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyobj)) {" << endl;
+ s << INDENT << "else" << endl;
{
Indentation indent(INDENT);
- s << INDENT << type->name() << "* cptr = reinterpret_cast<" << type->name() << "*>(shiboType->ext_tocpp(pyobj));" << endl;
- s << INDENT << "std::auto_ptr<" << type->name() << " > cptr_auto_ptr(cptr);" << endl;
- s << INDENT << "return *cptr;" << endl;
+ s << INDENT << "return Shiboken::ValueTypeConverter<" << type->qualifiedCppName() << " >::toCpp(pyobj);" << endl;
}
- s << INDENT << '}' << endl;
}
-
- s << INDENT << '}' << endl;
-
- s << INDENT << "return *" << cpythonWrapperCPtr(type, "pyobj") << ';' << endl;
s << '}' << endl << endl;
}
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 40d7b22e..aeed8917 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -162,11 +162,6 @@ LIBSHIBOKEN_API void* getTypeUserData(SbkObject* wrapper);
LIBSHIBOKEN_API bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType);
/**
- * Shiboken_TypeCheck macro performs a type check using the values registered with SbkType<>() template.
- */
-#define Shiboken_TypeCheck(pyobj, type) (PyObject_TypeCheck(pyobj, SbkType<type>()))
-
-/**
* Increments the reference count of the referred Python object.
* A previous Python object in the same position identified by the 'key' parameter
* will have its reference counter decremented automatically when replaced.
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index dff14478..c52e1e4a 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -149,12 +149,10 @@ struct Converter<T*>
static T* toCpp(PyObject* pyobj)
{
- if (Shiboken_TypeCheck(pyobj, T))
+ if (PyObject_TypeCheck(pyobj, SbkType<T>()))
return (T*) Wrapper::cppPointer(pyobj, SbkType<T>());
-
else if (Converter<T>::isConvertible(pyobj))
return CppObjectCopier<T>::copy(Converter<T>::toCpp(pyobj));
-
else if (pyobj == Py_None)
return 0;