How to inherit objects like a c++'s objects??

33 views
Skip to first unread message

Le_t0s

unread,
Jul 7, 2016, 3:08:23 AM7/7/16
to v8-users
Hello. I have following situation. I have 2 classes (e.g. Parent and Child). Parent has method "DoSmth", and Child have method "DoSmthElse". I create two templates, like these:
auto parentObj = ObjectTemplate::New(isolate);
Local<FunctionTemplate> SmthCallBack = FunctionTemplate::New(isolate, FuncCallBack, External::New(isolate, DoSmth));

parentObj->Set(String::NewFromUtf8(isolate, "DoSmth", NewStringType::kNormal).ToLocalChecked(), SmthCallBack);

auto childObj = ObjectTemplate::New(isolate);
Local<FunctionTemplate> SmthElseCallBack = FunctionTemplate::New(isolate, FuncCallBack, External::New(isolate, DoSmthElse));

childObj->Set(String::NewFromUtf8(isolate, "DoSmthElse", NewStringType::kNormal).ToLocalChecked(), SmthElseCallBack);

And my question is: Is there any way to inherit method "DoSmth" from Parent to Child (and other methods if they exists)?
Thanks.

Jochen Eisinger

unread,
Jul 8, 2016, 3:38:27 AM7/8/16
to v8-users
Does using FunctionTemplate::Inherit solve your problem?

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Le_t0s

unread,
Jul 8, 2016, 5:01:15 AM7/8/16
to v8-users
Yes, it should solve my problem. But object template hasn't any way to inherit for now, am I right?

пятница, 8 июля 2016 г., 11:38:27 UTC+4 пользователь Jochen Eisinger написал:

Jochen Eisinger

unread,
Jul 11, 2016, 5:57:56 AM7/11/16
to v8-users
Right
Reply all
Reply to author
Forward
0 new messages