michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: /** michael@0: * We set up a sample component. The constructor is empty, all the interesting michael@0: * stuff goes in the prototype. michael@0: */ michael@0: function mySample() { } michael@0: michael@0: mySample.prototype = { michael@0: /** michael@0: * .classID is required for generateNSGetFactory to work correctly. michael@0: * Make sure this CID matches the "component" in your .manifest file. michael@0: */ michael@0: classID: Components.ID("{dea98e50-1dd1-11b2-9344-8902b4805a2e}"), michael@0: michael@0: /** michael@0: * .classDescription and .contractID are only used for michael@0: * backwards compatibility with Gecko 1.9.2 and michael@0: * XPCOMUtils.generateNSGetModule. michael@0: */ michael@0: classDescription: "nsSample: JS version", // any human-readable string michael@0: contractID: "@mozilla.org/jssample;1", michael@0: michael@0: /** michael@0: * List all the interfaces your component supports. michael@0: * @note nsISupports is generated automatically; you don't need to list it. michael@0: */ michael@0: QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISample]), michael@0: michael@0: /* michael@0: * get and set are new Magic in JS1.5, borrowing the intent -- if not michael@0: * the exact syntax -- from the JS2 design. They define accessors for michael@0: * properties on the JS object, follow the expected rules for prototype michael@0: * delegation, and make a mean cup of coffee. michael@0: */ michael@0: get value() { return this.val; }, michael@0: set value(newval) { return this.val = newval; }, michael@0: michael@0: writeValue: function (aPrefix) { michael@0: debug("mySample::writeValue => " + aPrefix + this.val + "\n"); michael@0: }, michael@0: poke: function (aValue) { this.val = aValue; }, michael@0: michael@0: val: "" michael@0: }; michael@0: michael@0: /** michael@0: * XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4). michael@0: * XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6). michael@0: */ michael@0: if (XPCOMUtils.generateNSGetFactory) michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([mySample]); michael@0: else michael@0: var NSGetModule = XPCOMUtils.generateNSGetModule([mySample]);