On Tue, Jul 10, 2012 at 4:26 PM, mschwartz <[email protected]> wrote:
> meant to free the programmer from making certain mistakes. The answer
> that we should manually call a destroy() type function because we know it's
> a good time to do so suggests we should call delete (operator) as well for
> every object we call new (operator).
>
FWIW: for ALL of my bound natives i bind a member "destroy" function (and
typically use the try/finally approach to ensuring that they are cleaned
up). The exact name of the function is class-dependent but the
implementation is a template which does:
a) unbinds the native pointer from the JS Object.
b) calls the registered weak destruction callback (which almost always
calls (delete theNative)).
Afterwards, calling theBoundJSObject.anyMemberFuncWhichNeedsTheNative()
will cause a JS exception to be thrown ("cannot find native 'this'
pointer"), as opposed to crashing or stepping on a now-reallocated address
which might now even belong to a different class of object.
http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#1017
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users