aboutsummaryrefslogtreecommitdiffstats
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>2012-03-08 16:08:57 -0300
commit43c16539246a1ac6abc12b141ab32b5932e8c51e (patch)
treed70519cad37b4c1289131fbc265dd07c932bd955
parent899f9c2ccfc6967867f6d5f1cad925011a2f756b (diff)
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 4afbc1d7d..d9560d2ab 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 40d7b22e4..aeed89178 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 dff144782..c52e1e4a8 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;