diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-17 08:01:11 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-18 20:08:38 +0300 |
commit | d2cab99a79f7d7718e257f1a41ea3354b6c68fa0 (patch) | |
tree | 73184c48ae82e5db02e574e5564cdb73e4a9488c | |
parent | 94f9f007a444181386ee7fe2b4cb01be93ebe48f (diff) |
Comment on pointer marshalling functions.
-rwxr-xr-x | src/embind/embind.js | 14 |
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; |