summaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-10-28 15:25:22 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-12-09 20:28:07 -0300
commitead1f6c17cfa75d01896002179eb1c2ebd3097fc (patch)
tree1c0e743ddfa5d5f051ac3d47659b2abefdc46d65 /libshiboken
parent67d52935834ee4b76771f5ada462e97a39c0300b (diff)
downloadshiboken-ead1f6c17cfa75d01896002179eb1c2ebd3097fc.tar.gz
shiboken-ead1f6c17cfa75d01896002179eb1c2ebd3097fc.tar.xz
shiboken-ead1f6c17cfa75d01896002179eb1c2ebd3097fc.zip
Register type converters by name.
This way they can be queried as the soon-to-be-deprecated TypeResolvers.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp10
-rw-r--r--libshiboken/sbkconverter.cpp17
-rw-r--r--libshiboken/sbkconverter.h6
3 files changed, 27 insertions, 6 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 43ce1de8..7d67c732 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -1034,13 +1034,13 @@ PyObject* newObject(SbkObjectType* instanceType,
{
// Try to find the exact type of cptr.
if (!isExactType) {
- TypeResolver* tr = 0;
+ PyTypeObject* exactType = 0;
if (typeName) {
- tr = TypeResolver::get(typeName);
- if (tr)
- instanceType = reinterpret_cast<SbkObjectType*>(tr->pythonType());
+ exactType = Shiboken::Conversions::getPythonTypeObject(typeName);
+ if (exactType)
+ instanceType = reinterpret_cast<SbkObjectType*>(exactType);
}
- if (!tr)
+ if (!exactType)
instanceType = BindingManager::instance().resolveType(&cptr, instanceType);
}
diff --git a/libshiboken/sbkconverter.cpp b/libshiboken/sbkconverter.cpp
index 79a2f65f..3a32bec5 100644
--- a/libshiboken/sbkconverter.cpp
+++ b/libshiboken/sbkconverter.cpp
@@ -283,12 +283,15 @@ bool isImplicitConversion(SbkObjectType* type, PythonToCppFunc toCppFunc)
void registerConverterName(SbkConverter* converter , const char* typeName)
{
ConvertersMap::iterator iter = converters.find(typeName);
- if (iter == converters.end())
+ if (iter == converters.end()) {
+ //SbkDbg() << "Registering " << typeName;
converters.insert(std::make_pair(typeName, converter));
+ }
}
SbkConverter* getConverter(const char* typeName)
{
+ //SbkDbg() << "Looking for converter for type " << typeName;
ConvertersMap::const_iterator it = converters.find(typeName);
if (it != converters.end())
return it->second;
@@ -423,4 +426,16 @@ bool convertibleDictTypes(SbkConverter* keyConverter, bool keyCheckExact, SbkCon
return true;
}
+PyTypeObject* getPythonTypeObject(SbkConverter* converter)
+{
+ if (converter)
+ return converter->pythonType;
+ return 0;
+}
+
+PyTypeObject* getPythonTypeObject(const char* typeName)
+{
+ return getPythonTypeObject(getConverter(typeName));
+}
+
} } // namespace Shiboken::Conversions
diff --git a/libshiboken/sbkconverter.h b/libshiboken/sbkconverter.h
index 463014fd..f760e82f 100644
--- a/libshiboken/sbkconverter.h
+++ b/libshiboken/sbkconverter.h
@@ -242,6 +242,12 @@ LIBSHIBOKEN_API bool checkDictTypes(PyTypeObject* keyType, PyTypeObject* valueTy
/// Returns true if a Python dictionary can be converted to a C++ hash or map.
LIBSHIBOKEN_API bool convertibleDictTypes(SbkConverter* keyConverter, bool keyCheckExact, SbkConverter* valueConverter, bool valueCheckExact, PyObject* pyIn);
+/// Returns the Python type object associated with the given \p converter.
+LIBSHIBOKEN_API PyTypeObject* getPythonTypeObject(SbkConverter* converter);
+
+/// Returns the Python type object for the given \p typeName.
+LIBSHIBOKEN_API PyTypeObject* getPythonTypeObject(const char* typeName);
+
#define SBK_PY_LONG_LONG_IDX 0
#define SBK_BOOL_IDX 1
#define SBK_CHAR_IDX 2