On 10/30/12 9:11 AM, Kyle Huey wrote:
tl;dr: Code in Gecko must now set "magic" properties (such as
EXPORTED_SYMBOLS, the symbols themselves, and NSGetFactory) on the 'this'
object instead of implicitly on the global via 'var', 'let', 'function',
'const', etc
So:
const EXPORTED_SYMBOLS = ["Foo", "Bar"];
let Foo = 3;
function Bar() { dump("hi"); }
var NSGetModule = ...;
becomes
this.EXPORTED_SYMBOLS = ["Foo", "Bar"];
this.Foo = 3;
this.Bar = function Bar() { dump("hi"); }
this.NSGetModule = ...;
To clarify, you only need to "this qualify" the symbols you wish to
export from the file. If you have file-level symbols that don't need
exported, you do *not* need to add them to "this".
So:
const Cu = Components.utils;
const EXPORTED_SYMBOLS = ["ExportedFunction"];
function ExportedFunction() { }
function supportFunction() { }
becomes
const Cu = Components.utils
this.EXPORTED_SYMBOLS = ["ExportedFunction"];
this.ExportedFunction = function ExportedFunction() { }
function supportFunction() { }
(Note that "Cu" and "supportFunction" remain unchanged.)
Also, an unfortunate side-effect of this is that you lose the ability to
easily create constant exported symbols via "const." Instead, you'll
have to do something like:
Object.defineProperty(this, "MY_CONSTANT",
{configurable: false, writable:false, value: "MY_CONSTANT_VALUE"});
p.s. khuey deserves credit for clarifying this over IRC
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform