summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libshiboken/typeresolver.cpp22
-rw-r--r--libshiboken/typeresolver.h8
2 files changed, 30 insertions, 0 deletions
diff --git a/libshiboken/typeresolver.cpp b/libshiboken/typeresolver.cpp
index a88634a1..d2e042ba 100644
--- a/libshiboken/typeresolver.cpp
+++ b/libshiboken/typeresolver.cpp
@@ -126,3 +126,25 @@ PyTypeObject* TypeResolver::pythonType()
{
return m_d->pyType;
}
+
+TypeResolver::Type TypeResolver::getType(const char* name)
+{
+ std::string typeName(name);
+ int len = typeName.size() - 1;
+ if (len > 1) {
+ if (typeName[len] == '*')
+ typeName.erase(len, 1);
+
+ TypeResolver *resolver = TypeResolver::get(typeName.c_str());
+ if (resolver)
+ return TypeResolver::ValueType;
+
+ typeName += '*';
+ resolver = TypeResolver::get(typeName.c_str());
+ if (resolver)
+ return TypeResolver::ObjectType;
+ }
+
+ return TypeResolver::UnknownType;
+}
+
diff --git a/libshiboken/typeresolver.h b/libshiboken/typeresolver.h
index 1f4c4642..a55c0e56 100644
--- a/libshiboken/typeresolver.h
+++ b/libshiboken/typeresolver.h
@@ -77,6 +77,13 @@ void initTypeResolver();
class LIBSHIBOKEN_API TypeResolver
{
public:
+ enum Type
+ {
+ ObjectType,
+ ValueType,
+ UnknownType
+ };
+
typedef PyObject* (*CppToPythonFunc)(void*);
typedef void* (*PythonToCppFunc)(PyObject*);
typedef void (*DeleteObjectFunc)(void*);
@@ -96,6 +103,7 @@ public:
return new TypeResolver(typeName, &objectTypeToPython<T>, &pythonToObjectType<T>, SbkType<T>());
}
+ static Type getType(const char* name);
static TypeResolver* get(const char* typeName);
const char* typeName() const;