You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.3 KiB
JavaScript
85 lines
2.3 KiB
JavaScript
12 years ago
|
// TODO: this file needs to be converted to the v1.7 loader
|
||
14 years ago
|
|
||
|
|
||
14 years ago
|
/*
|
||
|
* SpiderMonkey host environment
|
||
|
*/
|
||
|
|
||
14 years ago
|
if(dojo.config["baseUrl"]){
|
||
14 years ago
|
dojo.baseUrl = dojo.config["baseUrl"];
|
||
14 years ago
|
}else{
|
||
14 years ago
|
dojo.baseUrl = "./";
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
|
dojo._name = 'spidermonkey';
|
||
|
|
||
|
/*=====
|
||
|
dojo.isSpidermonkey = {
|
||
13 years ago
|
// summary: Detect spidermonkey
|
||
14 years ago
|
};
|
||
14 years ago
|
=====*/
|
||
|
|
||
|
dojo.isSpidermonkey = true;
|
||
13 years ago
|
dojo.exit = function(exitcode){
|
||
|
quit(exitcode);
|
||
12 years ago
|
};
|
||
14 years ago
|
|
||
|
if(typeof print == "function"){
|
||
|
console.debug = print;
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
|
if(typeof line2pc == 'undefined'){
|
||
|
throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
|
dojo._spidermonkeyCurrentFile = function(depth){
|
||
13 years ago
|
//
|
||
14 years ago
|
// 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).
|
||
13 years ago
|
//
|
||
14 years ago
|
// 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.
|
||
13 years ago
|
//
|
||
12 years ago
|
var s = '';
|
||
|
try{
|
||
14 years ago
|
throw Error("whatever");
|
||
|
}catch(e){
|
||
|
s = e.stack;
|
||
|
}
|
||
12 years ago
|
// lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101
|
||
|
var matches = s.match(/[^@]*\.js/gi);
|
||
|
if(!matches){
|
||
14 years ago
|
throw Error("could not parse stack string: '" + s + "'");
|
||
|
}
|
||
12 years ago
|
var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1];
|
||
|
if(!fname){
|
||
14 years ago
|
throw Error("could not find file name in stack string '" + s + "'");
|
||
|
}
|
||
12 years ago
|
//print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'");
|
||
|
return fname;
|
||
|
};
|
||
14 years ago
|
|
||
13 years ago
|
// print(dojo._spidermonkeyCurrentFile(0));
|
||
14 years ago
|
|
||
|
dojo._loadUri = function(uri){
|
||
|
// spidermonkey load() evaluates the contents into the global scope (which
|
||
|
// is what we want).
|
||
13 years ago
|
// TODO: sigh, load() does not return a useful value.
|
||
14 years ago
|
// Perhaps it is returning the value of the last thing evaluated?
|
||
12 years ago
|
// var ok =
|
||
|
load(uri);
|
||
14 years ago
|
// console.log("spidermonkey load(", uri, ") returned ", ok);
|
||
|
return 1;
|
||
12 years ago
|
};
|
||
14 years ago
|
|
||
|
//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.
|
||
14 years ago
|
if(dojo.config["modulePaths"]){
|
||
14 years ago
|
for(var param in dojo.config["modulePaths"]){
|
||
|
dojo.registerModulePath(param, dojo.config["modulePaths"][param]);
|
||
|
}
|
||
14 years ago
|
}
|