source: Dev/branches/rest-dojo-ui/client/dojo/_base/configSpidermonkey.js @ 263

Last change on this file since 263 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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