diff options
author | mey <mey@imvu.com> | 2012-11-12 16:47:03 -0800 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:21:49 +0300 |
commit | 69f2f335d3194ae6ef482169e23ad8edcd8dd1ca (patch) | |
tree | 0c54682ae98b74664d173fbeb5b3663c368a99d7 | |
parent | 8ff84649adf2120ad7800f9bba03fff194b657bb (diff) |
Fleshing out functors and expanding them.
-rw-r--r-- | src/embind/embind.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 4cf58028..74afda02 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -492,7 +492,24 @@ function __embind_register_function_ptr( invoke.handle = h; invoke['delete'] = function() { this.handle.delete(); - }; + }.bind(invoke); + invoke.clone = function() { + if (!this.handle.functorPtr) { + throw new BindingError(functorType.name + ' instance already deleted'); + } + + var clone = createFunctor(this.handle.functorPtr); + clone.handle.count = this.handle.count; + clone.handle.ptr = this.handle.ptr; + + clone.handle.count.value += 1; + return clone; + }.bind(invoke); + invoke.move = function() { + var rv = this.clone(); + this.delete(); + return rv; + }.bind(invoke); return invoke; } @@ -503,7 +520,7 @@ function __embind_register_function_ptr( return createFunctor(ptr); }, toWireType: function(destructors, o) { - return o.ptr; + return o.handle.functorPtr; } }); } |