aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-15 19:27:54 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-17 15:23:44 -0300
commit9214943397eb156d79c6b762460a28d458366995 (patch)
treeec9a586ba3b5ce7e25b55e5563f4fd5d74552a3d /libshiboken
parent8671479384870a0c6f819f333adde85e66213756 (diff)
Create getType function on TypeResolver.
This function allow the programmer discovery if a type is Object or Value type. Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>, Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libshiboken')
-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 a88634a17..d2e042ba4 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 1f4c46424..a55c0e56f 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;