Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/prefs.js

Issue 29329760: Issue 3260 - Remove expression closure from build tools (Closed)
Patch Set: Created Nov. 5, 2015, 10:55 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/prefs.js
===================================================================
--- a/lib/prefs.js
+++ b/lib/prefs.js
@@ -39,17 +39,20 @@ function init()
setter(defaultBranch, pref, value);
defineProperty(pref, false, getter, setter);
}
// Add preference change observer
try
{
branch.QueryInterface(Ci.nsIPrefBranch2).addObserver("", Prefs, true);
- onShutdown.add(function() branch.removeObserver("", Prefs));
+ onShutdown.add(function()
+ {
+ branch.removeObserver("", Prefs);
+ });
Wladimir Palant 2015/11/05 11:25:16 I'd really prefer an arrow function here instead o
}
catch (e)
{
Cu.reportError(e);
}
}
/**
@@ -65,17 +68,20 @@ function defineProperty(/**String*/ name
value = readFunc(branch, name);
triggerListeners(name);
}
catch(e)
{
Cu.reportError(e);
}
};
- Prefs.__defineGetter__(name, function() value);
+ Prefs.__defineGetter__(name, function()
+ {
+ return value;
+ });
Wladimir Palant 2015/11/05 11:25:16 Same here, I'd rather have this changed into an ar
Prefs.__defineSetter__(name, function(newValue)
{
if (value == newValue)
return value;
try
{
ignorePrefChanges = true;
@@ -173,26 +179,47 @@ let Prefs = exports.Prefs =
let typeMap =
{
boolean: [getBoolPref, setBoolPref],
number: [getIntPref, setIntPref],
string: [getCharPref, setCharPref],
object: [getJSONPref, setJSONPref]
};
-function getIntPref(branch, pref) branch.getIntPref(pref)
-function setIntPref(branch, pref, newValue) branch.setIntPref(pref, newValue)
+function getIntPref(branch, pref)
+{
+ return branch.getIntPref(pref);
+}
+function setIntPref(branch, pref, newValue)
+{
+ branch.setIntPref(pref, newValue);
+}
-function getBoolPref(branch, pref) branch.getBoolPref(pref)
-function setBoolPref(branch, pref, newValue) branch.setBoolPref(pref, newValue)
+function getBoolPref(branch, pref)
+{
+ return branch.getBoolPref(pref);
+}
+function setBoolPref(branch, pref, newValue)
+{
+ branch.setBoolPref(pref, newValue);
+}
-function getCharPref(branch, pref) branch.getComplexValue(pref, Ci.nsISupportsString).data
+function getCharPref(branch, pref)
+{
+ return branch.getComplexValue(pref, Ci.nsISupportsString).data;
+}
function setCharPref(branch, pref, newValue)
{
let str = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
str.data = newValue;
branch.setComplexValue(pref, Ci.nsISupportsString, str);
}
-function getJSONPref(branch, pref) JSON.parse(getCharPref(branch, pref))
-function setJSONPref(branch, pref, newValue) setCharPref(branch, pref, JSON.stringify(newValue))
+function getJSONPref(branch, pref)
+{
+ return JSON.parse(getCharPref(branch, pref));
+}
+function setJSONPref(branch, pref, newValue)
+{
+ setCharPref(branch, pref, JSON.stringify(newValue))
+}
init();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld