2014-06-25 05:12:07 +00:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
1999-09-21 21:11:29 +00:00
|
|
|
|
2010-06-21 18:29:32 +00:00
|
|
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We set up a sample component. The constructor is empty, all the interesting
|
|
|
|
* stuff goes in the prototype.
|
1999-11-02 07:36:25 +00:00
|
|
|
*/
|
2010-06-21 18:29:32 +00:00
|
|
|
function mySample() { }
|
1999-09-21 21:11:29 +00:00
|
|
|
|
1999-11-02 07:36:25 +00:00
|
|
|
mySample.prototype = {
|
2010-06-21 18:29:32 +00:00
|
|
|
/**
|
|
|
|
* .classID is required for generateNSGetFactory to work correctly.
|
|
|
|
* Make sure this CID matches the "component" in your .manifest file.
|
|
|
|
*/
|
|
|
|
classID: Components.ID("{dea98e50-1dd1-11b2-9344-8902b4805a2e}"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* .classDescription and .contractID are only used for
|
|
|
|
* backwards compatibility with Gecko 1.9.2 and
|
|
|
|
* XPCOMUtils.generateNSGetModule.
|
|
|
|
*/
|
|
|
|
classDescription: "nsSample: JS version", // any human-readable string
|
|
|
|
contractID: "@mozilla.org/jssample;1",
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List all the interfaces your component supports.
|
|
|
|
* @note nsISupports is generated automatically; you don't need to list it.
|
|
|
|
*/
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISample]),
|
|
|
|
|
1999-11-02 07:36:25 +00:00
|
|
|
/*
|
2000-09-18 02:31:11 +00:00
|
|
|
* get and set are new Magic in JS1.5, borrowing the intent -- if not
|
|
|
|
* the exact syntax -- from the JS2 design. They define accessors for
|
1999-11-02 07:36:25 +00:00
|
|
|
* properties on the JS object, follow the expected rules for prototype
|
|
|
|
* delegation, and make a mean cup of coffee.
|
|
|
|
*/
|
2000-06-14 04:46:22 +00:00
|
|
|
get value() { return this.val; },
|
2000-05-24 07:20:11 +00:00
|
|
|
set value(newval) { return this.val = newval; },
|
1999-09-21 21:11:29 +00:00
|
|
|
|
1999-11-02 07:36:25 +00:00
|
|
|
writeValue: function (aPrefix) {
|
2002-04-23 07:30:11 +00:00
|
|
|
debug("mySample::writeValue => " + aPrefix + this.val + "\n");
|
1999-11-02 07:36:25 +00:00
|
|
|
},
|
|
|
|
poke: function (aValue) { this.val = aValue; },
|
|
|
|
|
|
|
|
val: "<default value>"
|
2010-06-11 20:13:26 +00:00
|
|
|
};
|
1999-09-21 21:11:29 +00:00
|
|
|
|
2010-06-21 18:29:32 +00:00
|
|
|
/**
|
|
|
|
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
|
|
|
|
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
|
|
|
|
*/
|
|
|
|
if (XPCOMUtils.generateNSGetFactory)
|
2012-10-31 16:13:28 +00:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([mySample]);
|
2010-06-21 18:29:32 +00:00
|
|
|
else
|
2010-06-23 17:43:02 +00:00
|
|
|
var NSGetModule = XPCOMUtils.generateNSGetModule([mySample]);
|