aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/embind/embind.js10
-rwxr-xr-xsystem/include/emscripten/bind.h50
2 files changed, 32 insertions, 28 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index b0eef51f..b823e281 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -332,7 +332,7 @@ function makeInvoker(name, argCount, argTypes, invoker, fn) {
var args = new Array(argCount);
args[0] = fn;
for (var i = 1; i < argCount; ++i) {
- args[i] = argTypes[i].toWireType(destructors, arguments[i-1]);
+ args[i] = argTypes[i].toWireType(destructors, arguments[i - 1]);
}
var rv = invoker.apply(null, args);
if (argTypes[0].fromWireTypeAutoDowncast) {
@@ -800,9 +800,9 @@ function __embind_register_class_constructor(
throw new BindingError('emscripten binding ' + humanName + ' called with ' + arguments.length + ' arguments, expected ' + (argCount-1));
}
var destructors = [];
- var args = new Array(argCount-1);
+ var args = new Array(argCount - 1);
for (var i = 1; i < argCount; ++i) {
- args[i-1] = argTypes[i].toWireType(destructors, arguments[i-1]);
+ args[i - 1] = argTypes[i].toWireType(destructors, arguments[i - 1]);
}
var ptr = rawConstructor.apply(null, args);
@@ -843,7 +843,7 @@ function __embind_register_class_method(
args[0] = this.$$.ptr;
args[1] = memberFunction;
for (var i = 1; i < argCount; ++i) {
- args[i + 1] = argTypes[i].toWireType(destructors, arguments[i-1]);
+ args[i + 1] = argTypes[i].toWireType(destructors, arguments[i - 1]);
}
var rv = rawInvoker.apply(null, args);
if (argTypes[0].fromWireTypeAutoDowncast) {
@@ -902,7 +902,7 @@ function __embind_register_class_operator_call(
var args = new Array(argCount);
args[0] = this.$$.ptr;
for (var i = 1; i < argCount; ++i) {
- args[i] = argTypes[i].toWireType(destructors, arguments[i-1]);
+ args[i] = argTypes[i].toWireType(destructors, arguments[i - 1]);
}
var rv = argTypes[0].fromWireType(rawInvoker.apply(null, args));
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index fd949234..f4fe37af 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -579,22 +579,18 @@ namespace emscripten {
////////////////////////////////////////////////////////////////////////////////
template<typename PointerType>
- class smart_ptr {
- public:
- smart_ptr(const char* name) {
- using namespace internal;
- typedef typename PointerType::element_type PointeeType;
-
- registerStandardTypes();
- _embind_register_smart_ptr(
- TypeID<PointerType>::get(),
- TypeID<PointeeType>::get(),
- name,
- reinterpret_cast<GenericFunction>(&raw_smart_pointer_constructor<PointeeType*>),
- reinterpret_cast<GenericFunction>(&raw_destructor<PointerType>),
- reinterpret_cast<GenericFunction>(&get_pointee<PointerType>));
-
- }
+ void smart_ptr(const char* name) {
+ using namespace internal;
+ typedef typename PointerType::element_type PointeeType;
+
+ registerStandardTypes();
+ _embind_register_smart_ptr(
+ TypeID<PointerType>::get(),
+ TypeID<PointeeType>::get(),
+ name,
+ reinterpret_cast<GenericFunction>(&raw_smart_pointer_constructor<PointeeType*>),
+ reinterpret_cast<GenericFunction>(&raw_destructor<PointerType>),
+ reinterpret_cast<GenericFunction>(&get_pointee<PointerType>));
};
////////////////////////////////////////////////////////////////////////////////
@@ -630,13 +626,6 @@ namespace emscripten {
}
};
- /*
- void assertInitialized() {
- if (!jsobj) {
- internal::_embind_fatal_error(
- "Cannot invoke call on uninitialized Javascript interface wrapper.", "JSInterface");
- }
- }*/
val wrapped;
};
@@ -673,6 +662,21 @@ namespace emscripten {
return *this;
}
+ template<typename SmartPtr, typename... Args>
+ class_& constructor(SmartPtr (*factory)(Args...)) {
+ using namespace internal;
+
+ smart_ptr<SmartPtr>("SmartPtr");
+
+ typename WithPolicies<>::template ArgTypeList<void, ConstructorArgs...> args;
+ _embind_register_class_smart_ptr_constructor(
+ TypeID<ClassType>::get(),
+ args.count,
+ args.types,
+ reinterpret_cast<GenericFunction>(&raw_smart_ptr_constructor
+ return *this;
+ }
+
template<typename WrapperType>
class_& allow_subclass() {
using namespace internal;