]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/_loader/hostenv_spidermonkey.js
remove call-by-reference to comply with php 5.4
[tt-rss.git] / lib / dojo / _base / _loader / hostenv_spidermonkey.js
1 /*
2 Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
5 */
6
7
8 /*
9 * SpiderMonkey host environment
10 */
11
12 if(dojo.config["baseUrl"]){
13 dojo.baseUrl = dojo.config["baseUrl"];
14 }else{
15 dojo.baseUrl = "./";
16 }
17
18 dojo._name = 'spidermonkey';
19
20 /*=====
21 dojo.isSpidermonkey = {
22 // summary: Detect spidermonkey
23 };
24 =====*/
25
26 dojo.isSpidermonkey = true;
27 dojo.exit = function(exitcode){
28 quit(exitcode);
29 }
30
31 if(typeof print == "function"){
32 console.debug = print;
33 }
34
35 if(typeof line2pc == 'undefined'){
36 throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
37 }
38
39 dojo._spidermonkeyCurrentFile = function(depth){
40 //
41 // This is a hack that determines the current script file by parsing a
42 // generated stack trace (relying on the non-standard "stack" member variable
43 // of the SpiderMonkey Error object).
44 //
45 // If param depth is passed in, it'll return the script file which is that far down
46 // the stack, but that does require that you know how deep your stack is when you are
47 // calling.
48 //
49 var s = '';
50 try{
51 throw Error("whatever");
52 }catch(e){
53 s = e.stack;
54 }
55 // lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101
56 var matches = s.match(/[^@]*\.js/gi);
57 if(!matches){
58 throw Error("could not parse stack string: '" + s + "'");
59 }
60 var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1];
61 if(!fname){
62 throw Error("could not find file name in stack string '" + s + "'");
63 }
64 //print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'");
65 return fname;
66 }
67
68 // print(dojo._spidermonkeyCurrentFile(0));
69
70 dojo._loadUri = function(uri){
71 // spidermonkey load() evaluates the contents into the global scope (which
72 // is what we want).
73 // TODO: sigh, load() does not return a useful value.
74 // Perhaps it is returning the value of the last thing evaluated?
75 var ok = load(uri);
76 // console.log("spidermonkey load(", uri, ") returned ", ok);
77 return 1;
78 }
79
80 //Register any module paths set up in djConfig. Need to do this
81 //in the hostenvs since hostenv_browser can read djConfig from a
82 //script tag's attribute.
83 if(dojo.config["modulePaths"]){
84 for(var param in dojo.config["modulePaths"]){
85 dojo.registerModulePath(param, dojo.config["modulePaths"][param]);
86 }
87 }