aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/embind/embind.js8
-rwxr-xr-xsystem/include/emscripten/bind.h26
-rwxr-xr-xsystem/lib/embind/bind.cpp4
3 files changed, 24 insertions, 14 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 48bf2a7f..5dd631ff 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -339,10 +339,12 @@ function __embind_register_tuple_element(
memberPointer = copyMemberPointer(memberPointer, memberPointerSize);
var tupleType = requireRegisteredType(rawTupleType, 'tuple');
- // TODO: this could register elements out of order
+ var index = tupleType.elements.length;
+ tupleType.elements.push(undefined);
+
whenDependentTypesAreResolved([rawType], function(type) {
type = type[0];
- tupleType.elements.push({
+ tupleType.elements[index] = {
read: function(ptr) {
return type.fromWireType(getter(ptr, memberPointer));
},
@@ -351,7 +353,7 @@ function __embind_register_tuple_element(
setter(ptr, memberPointer, type.toWireType(destructors, o));
runDestructors(destructors);
}
- });
+ };
});
}
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index a1b2a015..b7b17f20 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -169,14 +169,6 @@ namespace emscripten {
GenericFunction constructor,
GenericFunction destructor);
}
-
- class BindingsDefinition {
- public:
- template<typename Function>
- BindingsDefinition(Function fn) {
- fn();
- }
- };
}
}
@@ -1155,4 +1147,20 @@ namespace emscripten {
};
}
-#define EMSCRIPTEN_BINDINGS(fn) static emscripten::internal::BindingsDefinition anon_symbol(fn);
+namespace emscripten {
+ namespace internal {
+ class BindingsDefinition {
+ public:
+ template<typename Function>
+ BindingsDefinition(Function fn) {
+ fn();
+ }
+ };
+ }
+}
+
+#define EMSCRIPTEN_BINDINGS(name) \
+ static struct BindingInitializer_##name { \
+ BindingInitializer_##name(); \
+ } BindingInitializer_##name##_instance; \
+ BindingInitializer_##name::BindingInitializer_##name()
diff --git a/system/lib/embind/bind.cpp b/system/lib/embind/bind.cpp
index e844e52e..6994ef0c 100755
--- a/system/lib/embind/bind.cpp
+++ b/system/lib/embind/bind.cpp
@@ -38,7 +38,7 @@ namespace emscripten {
}
}
-EMSCRIPTEN_BINDINGS(([]() {
+EMSCRIPTEN_BINDINGS(native_and_builtin_types) {
using namespace emscripten::internal;
_embind_register_void(TypeID<void>::get(), "void");
@@ -60,4 +60,4 @@ EMSCRIPTEN_BINDINGS(([]() {
_embind_register_cstring(TypeID<std::string>::get(), "std::string");
_embind_register_emval(TypeID<val>::get(), "emscripten::val");
-}));
+}