On Thu, Apr 12, 2012 at 5:55 PM, Stewart Mckinney <[email protected]>wrote:
> v8::Handle<v8::Boolean> result( v8::Boolean::New( false ) ); > > return handleScope.Close( result ); > In the context of a function called from v8, HandleScope is unnecessary, at least for what you're doing here. > Rectangle *rectangle = new Rectangle( x, y, width, height, Color( CM_HSV, > randFloat(), 1, 1 ) ); > > me->mRectangleProxy->newInstance( args.This(), rectangle ); > > return args.This(); > > > ...where mRectangleProxy->newInstance essentially does the following: > > v8::HandleScope handleScope; > > v8::Context::Scope contextScope( mContext->getV8Context() ); > > //make the object weak > > Persistent<Object> obj = Persistent<Object>::New( object ); > > //V8::AdjustAmountOfExternalAllocatedMemory( sizeof( Rectangle ) ); > > obj.MakeWeak( instance, mDeleter ); > > obj->SetInternalField( 0, External::New( instance ) ); > > return obj; > What you're doing is in principal sound. i don't see any immediate problems, but personally i genericize all of that behind templates which i wrote long time ago, and i don't remember the exact order everything happens. Anyway, the object is created and all of its methods defined, but the > object itself has no prototype. This concerns me, as I'd rather have the > object be like any other JS object. Any ideas on what I'm doing incorrectly? > i have some code which you might find useful as a comparison: http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#725 that is basically the ctor proxy you describe: instantiate the native, associate it with an internal field in a Persistent object, and return to v8. Perhaps in that code you can find something you've done out of order, or a similar minor mistake. i hope that helps. -- ----- stephan beal http://wanderinghorse.net/home/stephan/ http://gplus.to/sgbeal -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
