On 2/14/15 11:06 PM, obastemur wrote:
On Friday, February 13, 2015 at 5:06:31 PM UTC+1, Boris Zbarsky wrote:
Note that this does not do the same thing as obastemur's proposed API.
Whether it does what he actually wants is an interesting question, of

@bzbarsky, what do you mean ?

Your suggestion:

  return obj->is<RegExpObject>();

would return true only if obj is a RegExp object. On the other hand, JS_ObjectIsRegExp will return true for RegExp objects or cross-compartment wrappers for RegExp objects or possibly other cases in which a proxy wants to pretend to be a RegEp object.

Which of those you want depends on what you're trying to do based on the results of the test. If you plan to use it as a "this" value to regexp_exec or some other case where you'd want a regexp in a JS script, then you want the test JS_ObjectIsRegExp does. On the other hand, if you plan to call as<RegExpObject>() and then use the accessors that exposes (e.g getLastIndex()), or directly poke at the object's reserved slots, then you really do want the is<RegExpObject> test, or at least usage of CallNonGenericMethod or whatnot.

-Boris
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to