diff options
author | Bill Welden <bwelden@imvu.com> | 2013-01-28 14:03:27 -0800 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:23:41 +0300 |
commit | 40ad51a5c81881ae0ddb5c36f19e7d362107ccc6 (patch) | |
tree | 0c8763dcc4d5eb5610ef71e423398039d886cb78 /system/lib | |
parent | ec5bc68515751aae5e90eb9a55af1908b2cb8329 (diff) |
Revert "register_smart_ptr changed to .shared_ptr (mod to class definition) -- shared_ptr (outside of class definition) is still allowed"
This reverts commit c38bb38e9d6393dfacb4afb0e9ba80ce42aee965.
Diffstat (limited to 'system/lib')
-rwxr-xr-x | system/lib/embind/bind.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/system/lib/embind/bind.cpp b/system/lib/embind/bind.cpp index bc79876f..5e82bb7e 100755 --- a/system/lib/embind/bind.cpp +++ b/system/lib/embind/bind.cpp @@ -101,7 +101,7 @@ namespace emscripten { // __getDerivationPath returns an array of type_info pointers describing the derivation chain starting with
// the derived type and proceeding toward (and ending with) the base type. Types are only included if they
// appear on all possible derivation paths.
- std::vector<int> __getDerivationPath(int dv, const int bs) { // todo: use emval array to pass return value??
+ std::vector<int> __getDerivationPath(int dv, const int bs) {
std::vector<std::vector<const __cxxabiv1::__class_type_info*>> paths;
const std::type_info* dv1 = (std::type_info*)dv;
@@ -176,11 +176,27 @@ namespace emscripten { // __getDynamicPointerType returns (for polymorphic types only!) the type of the instance actually
// pointed to.
- int EMSCRIPTEN_KEEPALIVE __getDynamicPointerType(int p) { // use size_t
+ int EMSCRIPTEN_KEEPALIVE __getDynamicPointerType(int p) {
void** vtable = *(void***)p;
return (int)static_cast<const std::type_info*>(vtable[-1]);
}
+ // Calls to __dynamic_cast are generated by the compiler to implement dynamic_cast<>() -- its prototype is
+ // not available through any header file. It is called directly here because it allows run-time
+ // specification of the target pointer type (which can only be specified at compile time when using
+ // dynamic_cast<>().
+ void* __dynamic_cast(void*, const std::type_info*, const std::type_info*, int);
+
+ // __dynamicPointerCast performs a C++ dynamic_cast<>() operation, but allowing run-time specification of
+ // the from and to pointer types.
+ int EMSCRIPTEN_KEEPALIVE __dynamicPointerCast(int p, int to) {
+ int ret = (int)__staticPointerCast((void *)p, __getDynamicPointerType(p), to);
+ if (ret < 0) {
+ return 0;
+ }
+ return ret;
+ }
+
const char* EMSCRIPTEN_KEEPALIVE __typeName(int p) {
const std::type_info* ti = (const std::type_info*)p;
size_t nameLen = std::min(strlen(ti->name()), (unsigned int)1024);
|