Thanks Bholly. regards, Shan'
On Wednesday, August 13, 2014 8:48:40 PM UTC+5:30, Bobby Holley wrote: > If this is from a binary component, i would advise against passing > > JSVals directly, because the APIs you need to manipulate are no longer > > exported (they're still temporarily exported in Windows IIUC, but > > that's changing soon). See > > https://bugzilla.mozilla.org/show_bug.cgi?id=978995 > > > > Instead, you might consider passing an [array] of nsIVariants. See the > > example below: > > > > http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/amIWebInstallListener.idl#50 > > > > On Wed, Aug 13, 2014 at 7:45 AM, Shanmugham Sundaram > > <shansyman...@gmail.com> wrote: > > > Hi, > > > > > > > > > I have to pass an array of strings (or JS::Value array) to JS-XPCOM from my > > C++ code. I could not find the proper example in C++ to implements this. > > > > > > Based on the "jsFunction" I am passing in JS-XPCOM, i will extract the > > correct number of values in the JS and call the expected function. > > > > > > How to pass the array of JS::Value to JS::HandleValue in the C++ fn ? Your > > help is highly appreciated > > > > > > > > > 1 - My IDL as below > > > > > > #include "nsISupports.idl" > > > #include "nsIDOMWindow.idl" > > > [scriptable, uuid(e583b11e-2043-11e4-9070-fd8b1d5d46b0)] > > > interface nsISbCollectURL: nsISupports > > > { > > > jsval callJSXPCOMFunction(in nsIDOMWindow domWindow, in wstring > > jsFunction, in unsigned short argc, in jsval argv); > > > > > > }; > > > > > > 2 My "C++" Header file has the following signature (after compiled by > > /gecko-sdk/xulrunner-sdk/sdk/bin/typelib.py ) > > > > > > NS_IMETHOD CallJSXPCOMFunction(nsIDOMWindow *domWindow, const char16_t * > > jsFunction, uint16_t argc, JS::HandleValue argv, JS::MutableHandleValue > > _retval) = 0; > > > > > > --> How to convert the populate JS::Value arrays to "JS::HandleValue param" > > in the method signature? I got stuck here. <--- > > > > > > > > > 3 - MY JS-XPCOM as below > > > > > > Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); > > > > > > function MyComponent() { } > > > > > > MyComponent.prototype = { > > > classDescription: "test JS XPCOM Component", > > > classID: > > Components.ID("{8f1a877e-2045-11e4-b92a-1b8d1d5d46b0}"), > > > contractID: "@test.com/mytest/jssource;1", > > > QueryInterface: > > XPCOMUtils.generateQI([Components.interfaces.nsISbCollectURL,Components.interfaces.nsISupports]), > > > > > > callJSXPCOMFunction: function(win, jsFunction, argc, argv) > > > { > > > win.wrappedJSObject.alert("Coming to callJSXPCOMFunction"); > > > win.wrappedJSObject.alert(argc); > > > if(jsFunction == "readMe") > > > { > > > > > > win.wrappedJSObject.alert("Coming to readMe"); > > > var name ; > > > var age; > > > var hobby; > > > if(argc >= 1) > > > var name = argv[0]; > > > if(argc >= 2) > > > var age = argv[1]; > > > if(argc >= 3) > > > var hobby = argv[2]; > > > var as = "shan : name : " +name + " age " + age > > + " hobby : " + hobby); > > > var myData = win.wrappedJSObject.shan_readme(name, > > age, hobby); > > > return myData; > > > > > > }else if(jsFunction == "writeMe"){ > > > win.wrappedJSObject.alert("Coming to writeMe"); > > > if(argc >= 1) > > > var xmlStuff = argv[0]; > > > > > > win.wrappedJSObject.alert(xmldata); > > > return win.wrappedJSObject.shan_rwriteme(xmldata); > > > } > > > } > > > > > > }; > > > > > > > > > var components = [MyComponent]; > > > > > > if ("generateNSGetFactory" in XPCOMUtils) > > > var NSGetFactory = XPCOMUtils.generateNSGetFactory(components); > > > else > > > var NSGetModule = XPCOMUtils.generateNSGetModule(components); > > > > > > > > > Thanks > > > Shan > > > _______________________________________________ > > > dev-platform mailing list > > > dev-platform@lists.mozilla.org > > > https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform