diff options
author | Andrew Dolgov <[email protected]> | 2011-03-04 19:02:28 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2011-03-04 19:02:59 +0300 |
commit | a089699c8915636ba4f158d77dba9b012bc93208 (patch) | |
tree | b2d7d051f1f55d44a6be07d3ee137e5a7ccfcefb /lib/dojo/_base/_loader/hostenv_spidermonkey.js | |
parent | cfad9259a6feacfa8194b1312770ae6db1ecce50 (diff) |
build custom layer of Dojo to speed up loading of tt-rss (refs #293)
Diffstat (limited to 'lib/dojo/_base/_loader/hostenv_spidermonkey.js')
-rw-r--r-- | lib/dojo/_base/_loader/hostenv_spidermonkey.js | 101 |
1 files changed, 69 insertions, 32 deletions
diff --git a/lib/dojo/_base/_loader/hostenv_spidermonkey.js b/lib/dojo/_base/_loader/hostenv_spidermonkey.js index ca63f16ce..17b21f5f0 100644 --- a/lib/dojo/_base/_loader/hostenv_spidermonkey.js +++ b/lib/dojo/_base/_loader/hostenv_spidermonkey.js @@ -5,46 +5,83 @@ */ +/* + * SpiderMonkey host environment + */ + if(dojo.config["baseUrl"]){ -dojo.baseUrl=dojo.config["baseUrl"]; + dojo.baseUrl = dojo.config["baseUrl"]; }else{ -dojo.baseUrl="./"; + dojo.baseUrl = "./"; } -dojo._name="spidermonkey"; -dojo.isSpidermonkey=true; -dojo.exit=function(_1){ -quit(_1); + +dojo._name = 'spidermonkey'; + +/*===== +dojo.isSpidermonkey = { + // summary: Detect spidermonkey }; -if(typeof print=="function"){ -console.debug=print; -} -if(typeof line2pc=="undefined"){ -throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global"); +=====*/ + +dojo.isSpidermonkey = true; +dojo.exit = function(exitcode){ + quit(exitcode); } -dojo._spidermonkeyCurrentFile=function(_2){ -var s=""; -try{ -throw Error("whatever"); + +if(typeof print == "function"){ + console.debug = print; } -catch(e){ -s=e.stack; + +if(typeof line2pc == 'undefined'){ + throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global"); } -var _3=s.match(/[^@]*\.js/gi); -if(!_3){ -throw Error("could not parse stack string: '"+s+"'"); + +dojo._spidermonkeyCurrentFile = function(depth){ + // + // This is a hack that determines the current script file by parsing a + // generated stack trace (relying on the non-standard "stack" member variable + // of the SpiderMonkey Error object). + // + // If param depth is passed in, it'll return the script file which is that far down + // the stack, but that does require that you know how deep your stack is when you are + // calling. + // + var s = ''; + try{ + throw Error("whatever"); + }catch(e){ + s = e.stack; + } + // lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101 + var matches = s.match(/[^@]*\.js/gi); + if(!matches){ + throw Error("could not parse stack string: '" + s + "'"); + } + var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1]; + if(!fname){ + throw Error("could not find file name in stack string '" + s + "'"); + } + //print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'"); + return fname; } -var _4=(typeof _2!="undefined"&&_2)?_3[_2+1]:_3[_3.length-1]; -if(!_4){ -throw Error("could not find file name in stack string '"+s+"'"); + +// print(dojo._spidermonkeyCurrentFile(0)); + +dojo._loadUri = function(uri){ + // spidermonkey load() evaluates the contents into the global scope (which + // is what we want). + // TODO: sigh, load() does not return a useful value. + // Perhaps it is returning the value of the last thing evaluated? + var ok = load(uri); + // console.log("spidermonkey load(", uri, ") returned ", ok); + return 1; } -return _4; -}; -dojo._loadUri=function(_5){ -var ok=load(_5); -return 1; -}; + +//Register any module paths set up in djConfig. Need to do this +//in the hostenvs since hostenv_browser can read djConfig from a +//script tag's attribute. if(dojo.config["modulePaths"]){ -for(var param in dojo.config["modulePaths"]){ -dojo.registerModulePath(param,dojo.config["modulePaths"][param]); -} + for(var param in dojo.config["modulePaths"]){ + dojo.registerModulePath(param, dojo.config["modulePaths"][param]); + } } |