implementing ObjectTemplate HasInstance() method

21 views
Skip to first unread message

Mike Moening

unread,
Apr 24, 2013, 12:24:13 PM4/24/13
to v8-u...@googlegroups.com
After digging into object construction using FunctionTemplate or ObjectTemplate in this post:


I believe the ObjectTemplate is missing a HasInstance() method for use in testing arguments to JS functions to be of a certain type.

While it is possible to use FunctionTemplate for this purpose (since HasInstance() exists), the FunctionTemplate 
method of construction is convoluted and messy since it requires two FunctionTemplates or a hack to prevent constructor recursion.

My proposal is to create HasInstance() on the ObjectTemplate class.
I'm looking for guidance on the best way to accomplish this.

Questions:
1) How can I get the ObjectTemplate that was used to create an instance of an Object?
2) How can I get the constructor for both the ObjectTemplate and the Object and compare them?

My assumption is that I should be comparing the constructors for equality.
The internals of v8 use a class called ObjectTemplateInfo which is somewhat confusing to me at this point.

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages