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