-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathpatch_emscripten_master.diff
66 lines (62 loc) · 2.4 KB
/
patch_emscripten_master.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- ./emscripten/master/system/include/emscripten/bind.h 2016-12-20 13:05:20.498980029 -0800
+++ ./emscripten/master/system/include/emscripten/bind.h 2016-12-20 13:12:11.599146929 -0800
@@ -999,7 +999,7 @@
};
}
- template<typename BaseClass>
+ template<typename BaseClass, bool isPoly=false>
struct base {
typedef BaseClass class_type;
@@ -1035,6 +1035,43 @@
}
};
+ template<typename BaseClass>
+ struct base<BaseClass, true> {
+
+ typedef BaseClass class_type;
+
+ template<typename ClassType>
+ static void verify() {
+ static_assert(!std::is_same<ClassType, BaseClass>::value, "Base must not have same type as class");
+ static_assert(std::is_base_of<BaseClass, ClassType>::value, "Derived class must derive from base");
+ }
+
+ static internal::TYPEID get() {
+ return internal::TypeID<BaseClass>::get();
+ }
+
+ template<typename ClassType>
+ using Upcaster = BaseClass* (*)(ClassType*);
+
+ template<typename ClassType>
+ using Downcaster = ClassType* (*)(BaseClass*);
+
+ template<typename ClassType>
+ static Upcaster<ClassType> getUpcaster() {
+ return &convertPointer<ClassType, BaseClass>;
+ }
+
+ template<typename ClassType>
+ static Downcaster<ClassType> getDowncaster() {
+ return &convertPointer<BaseClass, ClassType>;
+ }
+
+ template<typename From, typename To>
+ static To* convertPointer(From* ptr) {
+ return dynamic_cast<To*>(ptr);
+ }
+ };
+
namespace internal {
template<typename WrapperType>
val wrapped_extend(const std::string& name, const val& properties) {
--- ./emscripten/master/src/embind/embind.js 2016-12-20 13:05:20.498980029 -0800
+++ ./emscripten/master/src/embind/embind.js 2016-12-20 13:12:11.599146929 -0800
@@ -2077,6 +2077,7 @@
var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
var func = craftInvokerFunction(humanName, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn);
if (undefined === proto[methodName].overloadTable) {
+ func.argCount = argCount-1;
proto[methodName] = func;
} else {
proto[methodName].overloadTable[argCount-1] = func;