开发者

How can you get a prototype member function (C++ -> Javascript)

开发者 https://www.devze.com 2023-02-11 05:40 出处:网络
Does anyone know how you can call a method of a prototype in Javascript from C++? I have an pointer to script IDispatch, and I can get the IDsOfNames for the prototype, but I can\'t find how to get t

Does anyone know how you can call a method of a prototype in Javascript from C++?

I have an pointer to script IDispatch, and I can get the IDsOfNames for the prototype, but I can't find how to get the IDispatch of it's member function.

Say (pseudocode):

JSprototype foo
{
    method bar(baz);
}

I can get a valid DISPID of foo, but I don'开发者_如何转开发t know how to call bar(baz). Does anyone have an idea?


That's what IDispatch::Invoke is for. You don't need a separate IDispatch for every function. However, you do need a DISPID of bar, and therefore an IDispatch of foo. That means you'll have to call iFoo->Invoke(DISPID_bar) and QueryInterface(IDispatch) the result.

0

精彩评论

暂无评论...
验证码 换一张
取 消