aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-03-18 16:33:44 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:26:03 +0300
commitbb23c470f034601b70136a3eb56f829e84674bc4 (patch)
tree814bec466634b31b2530abcb8aed0ff20440998f
parenta09b543bf434b0f5e27b776f7a5a752f3e1c317d (diff)
Give each class a typeid function
-rwxr-xr-xsrc/embind/embind.js5
-rwxr-xr-xsystem/include/emscripten/bind.h11
2 files changed, 14 insertions, 2 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index d664435f..834aed74 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -655,6 +655,7 @@ function RegisteredClass(
isPolymorphic,
baseClassRawType,
baseClass,
+ getActualType,
upcast,
downcast
) {
@@ -663,6 +664,7 @@ function RegisteredClass(
this.isPolymorphic = isPolymorphic;
this.baseClassRawType = baseClassRawType;
this.baseClass = baseClass;
+ this.getActualType = getActualType;
this.upcast = upcast;
this.downcast = downcast;
}
@@ -672,6 +674,7 @@ function __embind_register_class(
rawPointerType,
rawConstPointerType,
baseClassRawType,
+ getActualType,
upcast,
downcast,
isPolymorphic,
@@ -680,6 +683,7 @@ function __embind_register_class(
) {
name = Pointer_stringify(name);
rawDestructor = FUNCTION_TABLE[rawDestructor];
+ getActualType = FUNCTION_TABLE[getActualType];
upcast = FUNCTION_TABLE[upcast];
downcast = FUNCTION_TABLE[downcast];
var legalFunctionName = makeLegalFunctionName(name);
@@ -715,6 +719,7 @@ function __embind_register_class(
isPolymorphic,
baseClassRawType,
baseClass,
+ getActualType,
upcast,
downcast);
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index e5865971..cd208d37 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -114,6 +114,7 @@ namespace emscripten {
TYPEID pointerType,
TYPEID constPointerType,
TYPEID baseClassType,
+ GenericFunction getActualType,
GenericFunction upcast,
GenericFunction downcast,
bool isPolymorphic,
@@ -648,6 +649,11 @@ namespace emscripten {
return nullptr;
}
};
+
+ template<typename T>
+ inline TYPEID getActualType(T* ptr) {
+ return reinterpret_cast<TYPEID>(&typeid(ptr));
+ };
}
template<typename BaseClass>
@@ -692,7 +698,7 @@ namespace emscripten {
template<typename T>
struct is_ptr<ptr<T>> {
enum { value = true };
- };
+ };
};
template<typename ClassType, typename BaseSpecifier = internal::NoBaseClass>
@@ -711,9 +717,10 @@ namespace emscripten {
TypeID<AllowedRawPointer<ClassType>>::get(),
TypeID<AllowedRawPointer<const ClassType>>::get(),
BaseSpecifier::get(),
+ reinterpret_cast<GenericFunction>(&getActualType<ClassType>),
BaseSpecifier::template getUpcaster<ClassType>(),
BaseSpecifier::template getDowncaster<ClassType>(),
- std::is_polymorphic<ClassType>::value,
+ std::is_polymorphic<ClassType>::value, // TODO: may not be necessary
name,
reinterpret_cast<GenericFunction>(&raw_destructor<ClassType>));
}