summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-01 14:27:39 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-12-01 14:29:35 -0200
commitaebf1341686e1a694a5ad9b24e384ee494683af8 (patch)
tree3712cb8e08edb590adbc604e50bd6e317461ae9b
parentd117950aa36d409140296d7efdfbbfc928722e04 (diff)
downloadshiboken-aebf1341686e1a694a5ad9b24e384ee494683af8.tar.gz
shiboken-aebf1341686e1a694a5ad9b24e384ee494683af8.tar.xz
shiboken-aebf1341686e1a694a5ad9b24e384ee494683af8.zip
Remove SbkTypeInfo and CppObjectCopier structs, they aren't needed after the fix on qt_metacall.
-rw-r--r--generator/headergenerator.cpp13
-rw-r--r--generator/headergenerator.h1
-rw-r--r--libshiboken/conversions.h37
-rw-r--r--libshiboken/typeresolver.cpp4
-rw-r--r--libshiboken/typeresolver.h17
5 files changed, 9 insertions, 63 deletions
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index 3e242cc1..76206d32 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -360,7 +360,6 @@ void HeaderGenerator::finishGeneration()
if (!metaClass->isNamespace()) {
writeSbkTypeFunction(typeFunctions, metaClass);
- writeSbkCopyCppObjectFunction(convDecl, metaClass);
writeTypeConverterDecl(convDecl, classType);
writeTypeConverterImpl(convImpl, classType);
convDecl << endl;
@@ -505,18 +504,6 @@ void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaCla
<< "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(cppClass->typeEntry()) << "); }\n";
}
-void HeaderGenerator::writeSbkCopyCppObjectFunction(QTextStream& s, const AbstractMetaClass* metaClass)
-{
- if (!metaClass->typeEntry()->isValue() || !shouldGenerateCppWrapper(metaClass))
- return;
- QString className = metaClass->qualifiedCppName();
- s << "template <>" << endl;
- s << "struct SbkTypeInfo<" << className << " >" << endl;
- s << '{' << endl;
- s << INDENT << "static const bool isCppWrapper = true;" << endl;
- s << "};" << endl;
-}
-
void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* type)
{
if (type->hasNativeConversionRule())
diff --git a/generator/headergenerator.h b/generator/headergenerator.h
index 96d63c64..d7502a9e 100644
--- a/generator/headergenerator.h
+++ b/generator/headergenerator.h
@@ -47,7 +47,6 @@ private:
void writeTypeConverterDecl(QTextStream& s, const TypeEntry* type);
void writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum);
void writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass);
- void writeSbkCopyCppObjectFunction(QTextStream& s, const AbstractMetaClass* metaClass);
void writeTypeIndexDefineLine(QTextStream& s, const TypeEntry* typeEntry, int& idx);
void writeTypeIndexDefine(QTextStream& s, const AbstractMetaClass* metaClass, int& idx);
void writeTypeConverterImpl(QTextStream& s, const TypeEntry* type);
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index ed7dcc01..8b312dfe 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -69,41 +69,6 @@ template<> inline PyTypeObject* SbkType<char>() { return &PyInt_Type; }
template<> inline PyTypeObject* SbkType<signed char>() { return &PyInt_Type; }
template<> inline PyTypeObject* SbkType<unsigned char>() { return &PyInt_Type; }
-template<typename T>
-struct SbkTypeInfo {
- static const bool isCppWrapper = false;
-};
-
-/**
- * This struct template is used to copy a C++ object using the proper
- * constructor, which could be the same type as used on the wrapped library
- * or a C++ wrapper type provided by the binding.
- */
-template <typename T, bool hasWrapper = SbkTypeInfo<T>::isCppWrapper>
-struct CppObjectCopier
-{
- static inline T* copy(const T& obj);
-};
-
-template<typename T>
-struct CppObjectCopier<T, false>
-{
- static inline T* copy(const T& obj)
- {
- return new T(obj);
- }
-};
-
-template<typename T>
-struct CppObjectCopier<T, true>
-{
- static inline T* copy(const T& obj)
- {
- return reinterpret_cast<T*>(ObjectType::copy(reinterpret_cast<SbkObjectType*>(SbkType<T>()), &obj));
- }
-};
-
-
/**
* Convenience template to create wrappers using the proper Python type for a given C++ class instance.
*/
@@ -152,7 +117,7 @@ struct Converter<T*>
if (PyObject_TypeCheck(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));
+ return new T(Converter<T>::toCpp(pyobj));
else if (pyobj == Py_None)
return 0;
diff --git a/libshiboken/typeresolver.cpp b/libshiboken/typeresolver.cpp
index 3d0cb11a..8d3ce7a9 100644
--- a/libshiboken/typeresolver.cpp
+++ b/libshiboken/typeresolver.cpp
@@ -97,9 +97,9 @@ const char* TypeResolver::typeName() const
return m_d->typeName;
}
-void* TypeResolver::toCpp(PyObject* pyObj, void** place, bool alloc)
+void TypeResolver::toCpp(PyObject* pyObj, void** place)
{
- return m_d->pythonToCpp(pyObj, place, alloc);
+ m_d->pythonToCpp(pyObj, place);
}
void TypeResolver::deleteObject(void* object)
diff --git a/libshiboken/typeresolver.h b/libshiboken/typeresolver.h
index 6a3750c1..d53d313f 100644
--- a/libshiboken/typeresolver.h
+++ b/libshiboken/typeresolver.h
@@ -31,20 +31,15 @@ namespace Shiboken
/* To C++ convertion functions. */
template <typename T>
-inline void* pythonToValueType(PyObject* pyobj, void** data, bool alloc)
+inline void pythonToValueType(PyObject* pyobj, void** data)
{
- if (alloc)
- *data = Shiboken::CppObjectCopier<T>::copy(Shiboken::Converter<T>::toCpp(pyobj));
-
- *reinterpret_cast< T*>(*data) = Shiboken::Converter<T>::toCpp(pyobj);
- return *data;
+ *reinterpret_cast<T*>(*data) = Shiboken::Converter<T>::toCpp(pyobj);
}
template <typename T>
-inline void* pythonToObjectType(PyObject* pyobj, void** data, bool)
+inline void pythonToObjectType(PyObject* pyobj, void** data)
{
- *data = Shiboken::Converter<T*>::toCpp(pyobj);
- return *data;
+ *reinterpret_cast<T**>(*data) = Shiboken::Converter<T*>::toCpp(pyobj);
}
template <typename T>
@@ -70,7 +65,7 @@ public:
};
typedef PyObject* (*CppToPythonFunc)(void*);
- typedef void* (*PythonToCppFunc)(PyObject*, void**, bool);
+ typedef void (*PythonToCppFunc)(PyObject*, void**);
typedef void (*DeleteObjectFunc)(void*);
~TypeResolver();
@@ -92,7 +87,7 @@ public:
const char* typeName() const;
PyObject* toPython(void* cppObj);
- void* toCpp(PyObject* pyObj, void** place, bool alloc=false);
+ void toCpp(PyObject* pyObj, void** place);
void deleteObject(void* object);
PyTypeObject* pythonType();