interface nsIMutableArray;
interface nsIPropertyBag;
interface nsIArray;
[scriptable, uuid(45be03e1-7fe3-4467-9ea5-c80d0e2b1234)]
interface nsISD : nsISupports
{
nsIArray getData();
void setData(in nsIArray a);
};
1.what's the right data structure that I can use to pass my custom data(var
a)? can nsIArray do the job?
2. if it's not possible to pass my custom data(var a) around to xpcoms as
it is defined now, what's the suitable data structure that I can use to
redefine and populate my custom data?
3.also I read somewhere that nsIArray should be passed by pointer, so what's
the standard way of defining function signatures? can nsIArray be a return
value?
thanks for the help!
"jonathan" <topc...@gmail.com> wrote in message
news:foydnWk8z4qgJ2vY...@mozilla.org...
"jonathan" <topc...@gmail.com> wrote in message
news:o72dnawmUrGFs2rY...@mozilla.org...
var myService = Components.classes["@jonathan.com/myExtension/myService;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
myService.setData([param1:"foo", param2:"bar"]);
You don't need an IDL for the service in this case. However, if you're writing the XPCOM service with C++, I don't know if you can use wrappedJSObject. Given that it has "JS" in the name, I doubt it :) If that's the case, ignore this email.
_______________________________________________
dev-extensions mailing list
dev-ext...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-extensions
thanks
-jonathan
<eric...@yahoo.com> wrote in message
news:mailman.1.1173832008...@lists.mozilla.org...
<eric...@yahoo.com> wrote in message
news:mailman.1.1173832008...@lists.mozilla.org...
>>I still need to define the the getData and setData function along with rest of the class right?<<
Yes, but in the myService object itself... there's no interface anymore
>>And also how do I register the component so that it can be found if I don't compile a IDL?<<
There are tutorials on this at developer.mozilla.org. Also, Ted has a webpage which auto-generates the XPCOM component service code for you automatically after you fill in a few things (like service name, etc). The URL for the webpage was posted in the last few days on this mailing list.
function myService() {
this.wrappedJSObject = this;
}
myService.prototype = {
data:null,
getData:function(){
return this.data;
},
setData: function(d){
this.data=d;
},
}
>>I still need to define the the getData and setData function along with
>>rest of the class right?<<
>Yes, but in the myService object itself... there's no interface anymore
all the tutorial I went through said I need to compile an IDL in order to
create the xpcom component. is this correct?
>>And also how do I register the component so that it can be found if I
>>don't compile a IDL?<<
>There are tutorials on this at developer.mozilla.org. Also, Ted has a
>webpage which auto->generates the XPCOM component service code for you
>automatically after you fill in a few things >(like service name, etc). The
>URL for the webpage was posted in the last few days on this mailing >list.
thanks!
No need to pass Components.interfaces.nsISupports explicitly to
getService. Just use .getService().
> myService.setData(data);
> so do you mean I can just define a javascript class called myService like
> this?
Yes.
> how does that become a service?
>
Just like a component implementing interfaces does. You put this code
in a JS file along with XPCOM registration code, which the above
mentioned Ted's tool can generate for you. Then you put the JS file in
components/
http://ted.mielczarek.org/code/mozilla/jscomponentwiz/
> function myService() {
> this.wrappedJSObject = this;
> }
> myService.prototype = {
> data:null,
> getData:function(){
> return this.data;
> },
> setData: function(d){
> this.data=d;
> },
> }
>
BTW, no-one forces you to use the setData/getData functions. You can
as well set the property directly.
> >>I still need to define the the getData and setData function along with
> >>rest of the class right?<<
> >Yes, but in the myService object itself... there's no interface anymore
> all the tutorial I went through said I need to compile an IDL in order to
> create the xpcom component. is this correct?
It is incorrect. The simplest counter-example is that your component
may only implement existing interfaces, like nsISupports and
nsIObserver. Or just nsISupports, which is what Eric suggested you do.
Which tutorial is that? Please always post the URLs, so that we can
fix the confusing docs (if they are under our control).
Nickolay