aboutsummaryrefslogtreecommitdiff
path: root/system/lib
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-03-20 20:15:36 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:26:32 +0300
commite10ede1e07ee85d9d99bd34eb4ec8a62ae972616 (patch)
tree4bad80cb9e227d265333b979d5e938221c117cf1 /system/lib
parent0a6f5476f19792164e122c27ffca83baa69c1ca3 (diff)
Add sensible error messages when working with classes that depend on unbound types.
Diffstat (limited to 'system/lib')
-rwxr-xr-xsystem/lib/embind/bind.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/system/lib/embind/bind.cpp b/system/lib/embind/bind.cpp
index a75ba96a..a5c878f5 100755
--- a/system/lib/embind/bind.cpp
+++ b/system/lib/embind/bind.cpp
@@ -8,25 +8,24 @@
using namespace emscripten;
-static std::string _embind_getTypeName(intptr_t ti_raw) {
- auto ti = reinterpret_cast<const std::type_info*>(ti_raw);
- int stat;
- char* demangled = abi::__cxa_demangle(ti->name(), NULL, NULL, &stat);
- if (stat == 0) {
- std::string rv(demangled);
- free(demangled);
- return rv;
- }
+extern "C" {
+ const char* EMSCRIPTEN_KEEPALIVE __getTypeName(const std::type_info* ti) {
+ int stat;
+ char* demangled = abi::__cxa_demangle(ti->name(), NULL, NULL, &stat);
+ if (stat == 0 && demangled) {
+ return demangled;
+ }
- switch (stat) {
- case -1:
- return "<allocation failure>";
- case -2:
- return "<invalid C++ symbol>";
- case -3:
- return "<invalid argument>";
- default:
- return "<unknown error>";
+ switch (stat) {
+ case -1:
+ return strdup("<allocation failure>");
+ case -2:
+ return strdup("<invalid C++ symbol>");
+ case -3:
+ return strdup("<invalid argument>");
+ default:
+ return strdup("<unknown error>");
+ }
}
}
@@ -60,6 +59,4 @@ EMSCRIPTEN_BINDINGS(native_and_builtin_types) {
_embind_register_cstring(TypeID<std::string>::get(), "std::string");
_embind_register_emval(TypeID<val>::get(), "emscripten::val");
-
- function("_embind_getTypeName", &_embind_getTypeName);
}