Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
11
/*
12
 * JScript .NET jsc
13
 *
14
 */
15
 
16
dojo.hostenv.name_ = 'jsc';
17
 
18
// Sanity check this is the right hostenv.
19
// See the Rotor source code jscript/engine/globalobject.cs for what globals
20
// are available.
21
if((typeof ScriptEngineMajorVersion != 'function')||(ScriptEngineMajorVersion() < 7)){
22
	dojo.raise("attempt to use JScript .NET host environment with inappropriate ScriptEngine");
23
}
24
 
25
// for more than you wanted to know about why this import is required even if
26
// we fully qualify all symbols, see
27
// http://groups.google.com/groups?th=f050c7aeefdcbde2&rnum=12
28
import System;
29
 
30
dojo.hostenv.getText = function(uri){
31
	if(!System.IO.File.Exists(uri)){
32
		// dojo.raise("No such file '" + uri + "'");
33
		return 0;
34
	}
35
	var reader = new System.IO.StreamReader(uri);
36
	var contents : String = reader.ReadToEnd();
37
	return contents;
38
}
39
 
40
dojo.hostenv.loadUri = function(uri){
41
	var contents = this.getText(uri);
42
	if(!contents){
43
		dojo.raise("got no back contents from uri '" + uri + "': " + contents);
44
	}
45
	// TODO: in JScript .NET, eval will not affect the symbol table of the current code?
46
	var value = dj_eval(contents);
47
	dojo.debug("jsc eval of contents returned: ", value);
48
	return 1;
49
 
50
	// for an example doing runtime code compilation, see:
51
	// http://groups.google.com/groups?selm=eQ1aeciCBHA.1644%40tkmsftngp05&rnum=6
52
	// Microsoft.JScript or System.CodeDom.Compiler ?
53
	// var engine = new Microsoft.JScript.Vsa.VsaEngine()
54
	// what about loading a js file vs. a dll?
55
	// GetObject("script:" . uri);
56
}
57
 
58
/* The System.Environment object is useful:
59
    print ("CommandLine='" + System.Environment.CommandLine + "' " +
60
	   "program name='" + System.Environment.GetCommandLineArgs()[0] + "' " +
61
	   "CurrentDirectory='" + System.Environment.CurrentDirectory + "' " +
62
	   "StackTrace='" + System.Environment.StackTrace + "'");
63
*/
64
 
65
// same as System.Console.WriteLine
66
// sigh; Rotor treats symbol "print" at parse time without actually putting it
67
// in the builtin symbol table.
68
// Note that the print symbol is not available if jsc is run with the "/print-"
69
// option.
70
dojo.hostenv.println = function(s){
71
	print(s); // = print
72
}
73
 
74
dojo.hostenv.getLibraryScriptUri = function(){
75
	return System.Environment.GetCommandLineArgs()[0];
76
}
77
 
78
dojo.requireIf((djConfig["isDebug"] || djConfig["debugAtAllCosts"]), "dojo.debug");