aboutsummaryrefslogtreecommitdiff
path: root/src/embind
diff options
context:
space:
mode:
Diffstat (limited to 'src/embind')
-rwxr-xr-xsrc/embind/embind.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 205d7fdc..3b6910a8 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -876,7 +876,9 @@ var genericPointerToWireType = function(destructors, handle) {
return ptr;
};
-var nonConstNoSmartPtrRawPointerToWireType = function(destructors, handle) {
+// If we know a pointer type is not going to have SmartPtr logic in it, we can
+// special-case optimize it a bit (compare to genericPointerToWireType)
+var constNoSmartPtrRawPointerToWireType = function(destructors, handle) {
if (handle === null) {
if (this.isReference) {
throwBindingError('null is not a valid ' + this.name);
@@ -890,15 +892,14 @@ var nonConstNoSmartPtrRawPointerToWireType = function(destructors, handle) {
if (!handle.$$.ptr) {
throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
}
- if (handle.$$.ptrType.isConst) {
- throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
- }
var handleClass = handle.$$.ptrType.registeredClass;
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
return ptr;
};
-var constNoSmartPtrRawPointerToWireType = function(destructors, handle) {
+// An optimized version for non-const method accesses - there we must additionally restrict that
+// the pointer is not a const-pointer.
+var nonConstNoSmartPtrRawPointerToWireType = function(destructors, handle) {
if (handle === null) {
if (this.isReference) {
throwBindingError('null is not a valid ' + this.name);
@@ -912,6 +913,9 @@ var constNoSmartPtrRawPointerToWireType = function(destructors, handle) {
if (!handle.$$.ptr) {
throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
}
+ if (handle.$$.ptrType.isConst) {
+ throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
+ }
var handleClass = handle.$$.ptrType.registeredClass;
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
return ptr;