I have an application that hosts the Active Script JScript engine. Depending on the version of jscript.dll, it runs up to JScript 5.8. The application exposes many objects and methods to the JScript environment.
When the script calls a certain function, with IDL like this:
HRESULT func(VARIANT varInput);
I want determine if the input is an instanceof
another function (i.e., if the function is a constructor whose prototype is in the prototype chain of input). In JScript:
input instanceof Error
How can this be done in C++ with IDispatch/IDispatchEx?
The method has access to the IActiveScript (implemented by the JScript engine) and IActiveScriptSite (implemented by the host) interfaces, so it is possible to get the global object with IActiveScript::GetScriptDispatch, from which any other constructor (such as Error
) can be retrieved.