On 3/7/2016 11:17 AM, Tobias Wolf wrote:
I try to call this code dynamically:
nsCOMPtr<nsIPromptService> promptService =
do_GetService("@mozilla.org/embedcomp/prompt-service;1"));
promptService->Alert(NULL, NULL, NULL);
I do the following:
nsISomeInterface* mXPTCStub;
nsresult rc;
nsXPTCVariant params[3];
Why are you trying to do this? Are you writing a shim layer that
connects some other dynamic/scripting language to XPCOM?
rc = NS_GetXPTCallStub(NS_IPROMPTSERVICE_IID, proxy, &mXPTCStub);
params[0].val.p = NULL;
params[0].type = nsXPTType::T_VOID;
params[0].flags = 0;
params[1].val.p = (void*)title;
params[1].type = nsXPTType::T_CHAR_STR;
params[1].flags = 0;
params[2].val.p = (void*)text;
params[2].type = nsXPTType::T_CHAR_STR;
params[2].flags = 0;
rc = NS_InvokeByIndex(mXPTCStub, 1, 3, params);
NS_DestroyXPTCallStub(mXPTCStub);
But I don`t know how to use NS_GetXPTCallStub!
What means the second and third parameter from NS_GetXPTCallStub?
Have you read the doccomments at
http://mxr.mozilla.org/mozilla-central/source/xpcom/reflect/xptcall/xptcall.h#174
?
If you are trying to *invoke* a method, you don't need an xptcall stub
at all. You just need NS_InvokeByIndex.
An XPTCall stub is used to *implement* an XPCOM object whose
type/interface definition isn't known at compile time, typically by
mirroring it to an underlying scriptable object. You would need to
implement a c++ class which implements nsIXPTCProxy and implements
CallMethod.
--BDS
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform