aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Welden <bwelden@imvu.com>2013-01-31 09:42:34 -0800
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:23:46 +0300
commit5b3d12c90558f0472c374349c5a4cdce474832a4 (patch)
tree9603c8dc8266cf3900611fbb30255e4d70ac1886
parent79a7db6c2f1fee9e5822adbcbf102bea7aeb78ab (diff)
Can now reference base classes through multiple levels of inheritance if one or more intermediate classes are not bound.
Warning: we know nothing about the members of the unbound classes, so you might end up inheriting the bound base class's member when a C++ routine would inherit the identically named member from the unbound class.
-rwxr-xr-xsrc/embind/embind.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index f875aa9a..21a5dc46 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -81,24 +81,35 @@ function createInheritedFunctionOrProperty(name, type, nameInBaseClass, baseClas
}
}
+function collectRegisteredBaseClasses(rawType) {
+ var rawBaseTypes = Module.__getBaseClasses(rawType);
+ var baseTypes = [];
+ for (var i = 0; i < rawBaseTypes.size(); i++) {
+ var baseType = typeRegistry[rawBaseTypes.at(i)];
+ if (baseType) {
+ baseTypes.push(baseType);
+ } else {
+ baseTypes = baseTypes.concat(collectRegisteredBaseClasses(rawBaseTypes.at(i)));
+ }
+ }
+ return baseTypes;
+}
+
function resolveType(type) {
if (!type.resolved) {
var baseClassType, name, baseProto;
var inheritedNames = {};
- var rawBaseClassTypes = Module.__getBaseClasses(type.rawType);
- for (var i = 0; i < rawBaseClassTypes.size(); i++) {
- var rawBaseClassType = rawBaseClassTypes.at(i);
- baseClassType = typeRegistry[rawBaseClassType];
- if (baseClassType) {
- resolveType(baseClassType);
- baseProto = baseClassType.Handle.prototype;
- for (name in baseProto) {
- if (baseProto.hasOwnProperty(name) && baseClassType.Handle.memberType[name]) {
- if (!(name in inheritedNames)) {
- inheritedNames[name] = [];
- }
- inheritedNames[name].push(baseClassType);
+ var baseTypes = collectRegisteredBaseClasses(type.rawType);
+ for (var i = 0; i < baseTypes.length; i++) {
+ var baseType = baseTypes[i];
+ resolveType(baseType);
+ baseProto = baseType.Handle.prototype;
+ for (name in baseProto) {
+ if (baseProto.hasOwnProperty(name) && baseType.Handle.memberType[name]) {
+ if (!(name in inheritedNames)) {
+ inheritedNames[name] = [];
}
+ inheritedNames[name].push(baseType);
}
}
}