aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/embind/embind.js34
-rwxr-xr-xsystem/include/emscripten/bind.h2
-rwxr-xr-xsystem/include/emscripten/wire.h25
3 files changed, 36 insertions, 25 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index e850cc3f..589f7ba9 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -833,7 +833,6 @@ function __embind_register_class_constructor(
) {
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
invoker = FUNCTION_TABLE[invoker];
- rawConstructor = rawConstructor;
requestDeferredRegistration(function() {
var classType = requireRegisteredType(rawClassType, 'class');
@@ -858,6 +857,39 @@ function __embind_register_class_constructor(
});
}
+function __embind_register_class_smart_ptr_constructor(
+ rawClassType,
+ argCount,
+ rawArgTypesAddr,
+ invoker,
+ rawConstructor
+) {
+ var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
+ invoker = FUNCTION_TABLE[invoker];
+
+ requestDeferredRegistration(function() {
+ var classType = requireRegisteredType(rawClassType, 'class');
+ var humanName = 'constructor ' + classType.name;
+ var argTypes = requireArgumentTypes(rawArgTypes, humanName);
+ classType.constructor.body = function() {
+ if (arguments.length !== argCount - 1) {
+ throwBindingError(humanName + ' + called with ' + arguments.length + ' arguments, expected ' + (argCount-1));
+ }
+ var destructors = [];
+ var args = new Array(argCount);
+ args[0] = rawConstructor;
+ for (var i = 1; i < argCount; ++i) {
+ args[i] = argTypes[i].toWireType(destructors, arguments[i - 1]);
+ }
+
+ var ptr = invoker.apply(null, args);
+ runDestructors(destructors);
+
+ return argTypes[0].fromWireType(ptr);
+ };
+ });
+}
+
function __embind_register_class_method(
rawClassType,
methodName,
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index bf9706d4..baa579c6 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -650,7 +650,7 @@ namespace emscripten {
// todo: generate unique name
smart_ptr<SmartPtr>("SmartPtr");
- typename WithPolicies<>::template ArgTypeList<void, Args...> args;
+ typename WithPolicies<>::template ArgTypeList<SmartPtr, Args...> args;
_embind_register_class_smart_ptr_constructor(
TypeID<ClassType>::get(),
args.count,
diff --git a/system/include/emscripten/wire.h b/system/include/emscripten/wire.h
index 10484a61..1be23e78 100755
--- a/system/include/emscripten/wire.h
+++ b/system/include/emscripten/wire.h
@@ -261,33 +261,12 @@ namespace emscripten {
typedef typename std::remove_reference<T>::type ActualT;
typedef ActualT* WireType;
- struct Marshaller {
- explicit Marshaller(WireType wt)
- : wireType(wt)
- {}
-
- Marshaller(Marshaller&& wt)
- : wireType(wt.wireType)
- {
- wt.wireType = 0;
- }
-
- operator ActualT&() const {
- return *wireType;
- }
-
- private:
- Marshaller() = delete;
- Marshaller(const Marshaller&) = delete;
- ActualT* wireType;
- };
-
static WireType toWireType(T v) {
return new T(v);
}
- static Marshaller fromWireType(WireType p) {
- return Marshaller(p);
+ static ActualT& fromWireType(WireType p) {
+ return *p;
}
static void destroy(WireType p) {