diff options
author | Dominic Wong <dombot@gmail.com> | 2012-11-30 15:16:00 +0800 |
---|---|---|
committer | Dominic Wong <dombot@gmail.com> | 2012-11-30 15:16:00 +0800 |
commit | e0c208c49395be56aefd37247a8852ef942703c8 (patch) | |
tree | fddf57640a6df256fbe73944be861dfa7fcbe101 | |
parent | 64b3836a68c51bfe5823bbd0a82050b4a43536ca (diff) |
Fixed embind for non-void non-const class methods (with test).
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | system/include/emscripten/bind.h | 2 | ||||
-rw-r--r-- | tests/embind/embind_test.cpp | 5 | ||||
-rw-r--r-- | tests/embind/embind_test.js | 2 |
4 files changed, 9 insertions, 1 deletions
@@ -41,4 +41,5 @@ a license to everyone to use it as detailed in LICENSE.) * Joel Martin <github@martintribe.org> * Manuel Wellmann <manuel.wellmann@autodesk.com> (copyright owned by Autodesk, Inc.) * Xuejie Xiao <xxuejie@gmail.com> +* Dominic Wong <dom@slowbunyip.org> diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 4a82eacb..8ce95de7 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -218,7 +218,7 @@ namespace emscripten { template<typename ClassType, typename ReturnType, typename... Args> struct MethodInvoker { typedef ReturnType (ClassType::*MemberPointer)(Args...); - typename internal::BindingType<ReturnType>::WireType invoke( + static typename internal::BindingType<ReturnType>::WireType invoke( ClassType* ptr, const MemberPointer& method, typename internal::BindingType<Args>::WireType... args diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index e7b4d985..dc052d1a 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -96,6 +96,10 @@ public: this->v = v;
}
+ int returnIntPlusFive( int x ) {
+ return x + 5;
+ }
+
static int some_class_method(int i) {
return i;
}
@@ -286,6 +290,7 @@ EMSCRIPTEN_BINDINGS(([]() { .constructor<val>()
.method("getVal", &ValHolder::getVal)
.method("setVal", &ValHolder::setVal)
+ .method("returnIntPlusFive", &ValHolder::returnIntPlusFive)
.classmethod("some_class_method", &ValHolder::some_class_method)
;
function("emval_test_return_ValHolder", &emval_test_return_ValHolder);
diff --git a/tests/embind/embind_test.js b/tests/embind/embind_test.js index e01f0236..8c61553b 100644 --- a/tests/embind/embind_test.js +++ b/tests/embind/embind_test.js @@ -137,6 +137,8 @@ module({ c.setVal('1234'); assert.equal('1234', c.getVal()); + assert.equal(1239, c.returnIntPlusFive(1234)); + c.delete(); assert.equal(0, cm.count_emval_handles()); }, |