Add AfterInit method for Wrappable

This commit is contained in:
Cheng Zhao 2015-02-13 11:37:55 +08:00
parent 8d537ee2b6
commit d0db7bfb58
2 changed files with 5 additions and 0 deletions

View file

@ -29,6 +29,8 @@ void Wrappable::Wrap(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper) {
v8::Handle<v8::Function> init;
if (Dictionary(isolate, wrapper).Get("_init", &init))
init->Call(wrapper, 0, NULL);
AfterInit(isolate);
}
// static

View file

@ -68,6 +68,9 @@ class Wrappable {
virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate);
// Called after the "_init" method gets called in JavaScript.
virtual void AfterInit(v8::Isolate* isolate) {}
private:
static MATE_WEAK_CALLBACK(WeakCallback, v8::Object, Wrappable);