aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2013-11-10 17:09:31 -0500
committerJohn Ehresman <jpe@wingware.com>2014-04-16 00:40:02 +0200
commit35d006a7bf9b33807c1df93f5f9439ff83cd32c0 (patch)
treec5a9359e631251dd3d5c6a09a159de08b64c7aa3 /tests/libsample
parent5b39f7fd9e216dd16e32ee5950d8d3d781cf1d17 (diff)
Fix function rejections (i.e. support overloads)
Add an additional check to AbstractMetaBuilder::traverseFunction to also perform a quick-and-dirty construction of the function signature, and to check that against the rejections. Add a unit test for matching full signatures. Before, we were only testing the function name; as a result, a rejection like 'foo()' would never match (because the name does not have ()'s). This is especially helpful for rejecting specific overloads of functions while allowing others to be wrapped normally. (The unit test shows a not-so-far-fetched example why one might want to do this.) The signature building logic isn't very sophisticated and likely requires a very exacting match to the signature as it appears in the wrapped sources, but that's likely not a serious issue, and at any rate this is much better than not being able to match overloads at all. Change-Id: Ic686377477aacf54f79c7bd2013e9aea8521a4ea Reviewed-by: John Ehresman <jpe@wingware.com>
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/photon.cpp3
-rw-r--r--tests/libsample/photon.h13
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/libsample/photon.cpp b/tests/libsample/photon.cpp
index b1b3328ca..ae2031c0b 100644
--- a/tests/libsample/photon.cpp
+++ b/tests/libsample/photon.cpp
@@ -24,6 +24,9 @@
namespace Photon
{
+const ClassType Base::staticType;
+template <> const ClassType TemplateBase<IdentityType>::staticType;
+template <> const ClassType TemplateBase<DuplicatorType>::staticType;
int callCalculateForValueDuplicatorPointer(ValueDuplicator* value)
{
return value->calculate();
diff --git a/tests/libsample/photon.h b/tests/libsample/photon.h
index f6c97b7c7..18917e26c 100644
--- a/tests/libsample/photon.h
+++ b/tests/libsample/photon.h
@@ -33,6 +33,7 @@ namespace Photon
{
enum ClassType {
+ BaseType = 0,
IdentityType = 1,
DuplicatorType = 2
};
@@ -41,9 +42,17 @@ class LIBSAMPLE_API Base
{
public:
explicit Base(int value) : m_value(value) {}
+ virtual ~Base() {}
inline void setValue(int value) { m_value = value; }
inline int value() const { return m_value; }
+
+ template <class T> bool isType() { return type() == T::staticType; }
+ bool isType(ClassType t) { return type() == t; }
+
protected:
+ virtual ClassType type() const { return BaseType; };
+ static const ClassType staticType = BaseType;
+
int m_value;
};
@@ -68,6 +77,10 @@ public:
}
static inline TemplateBase<CLASS_TYPE>* passPointerThrough(TemplateBase<CLASS_TYPE>* obj) { return obj; }
+
+protected:
+ virtual ClassType type() const { return CLASS_TYPE; }
+ static const ClassType staticType = CLASS_TYPE;
};
#if defined _WIN32 || defined __CYGWIN__