C# Class Rhino.Tools.Shell.Global

Inheritance: Rhino.ImporterTopLevel
Afficher le fichier Open project: hazzik/Rhino.Net

Méthodes publiques

Méthode Description
DefineClass ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

Load a Java class that defines a JavaScript object using the conventions outlined in ScriptableObject.defineClass.

Load a Java class that defines a JavaScript object using the conventions outlined in ScriptableObject.defineClass.

This method is defined as a JavaScript function.

Deserialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
Doctest ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns 2 (since 2 tests were executed).

Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns 2 (since 2 tests were executed).

Gc ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
GetConsole ( Encoding cs ) : ShellConsole
GetErr ( ) : TextWriter
GetIn ( ) : Stream
GetOut ( ) : TextWriter
GetPrompts ( Context cx ) : string[]
Global ( ) : System
Global ( Context cx ) : System
Help ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

Print a help message.

Print a help message. This method is defined as a JavaScript function.

Init ( Context cx ) : void
Init ( ContextFactory factory ) : void
InitQuitAction ( QuitAction quitAction ) : void

Set the action to call from quit().

Set the action to call from quit().

InstallRequire ( Context cx, IList modulePath, bool sandboxed ) : Require
IsInitialized ( ) : bool
Load ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

Load and execute a set of JavaScript source files.

Load and execute a set of JavaScript source files. This method is defined as a JavaScript function.

LoadClass ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

Load and execute a script compiled to a class file.

Load and execute a script compiled to a class file.

This method is defined as a JavaScript function. When called as a JavaScript function, a single argument is expected. This argument should be the name of a class that implements the Script interface, as will any script compiled by jsc.

Print ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

Print the string values of its arguments.

Print the string values of its arguments. This method is defined as a JavaScript function. Note that its arguments are of the "varargs" form, which allows it to handle an arbitrary number of arguments supplied to the JavaScript function.

Quit ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

Call embedding-specific quit action passing its argument as int32 exit code.

Call embedding-specific quit action passing its argument as int32 exit code. This method is defined as a JavaScript function.

ReadFile ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

The readFile reads the given file content and convert it to a string using the specified character coding or default character coding if explicit coding argument is not given.

The readFile reads the given file content and convert it to a string using the specified character coding or default character coding if explicit coding argument is not given.

Usage:

 readFile(filePath) readFile(filePath, charCoding) 
The first form converts file's context to string using the default character coding.
ReadUrl ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

The readUrl opens connection to the given URL, read all its data and converts them to a string using the specified character coding or default character coding if explicit coding argument is not given.

The readUrl opens connection to the given URL, read all its data and converts them to a string using the specified character coding or default character coding if explicit coding argument is not given.

Usage:

 readUrl(url) readUrl(url, charCoding) 
The first form converts file's context to string using the default charCoding.
RunCommand ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

Execute the specified command with the given argument and options as a separate process and return the exit status of the process.

Execute the specified command with the given argument and options as a separate process and return the exit status of the process.

Usage:

 runCommand(command) runCommand(command, arg1, ..., argN) runCommand(command, arg1, ..., argN, options) 
All except the last arguments to runCommand are converted to strings and denote command name and its arguments. If the last argument is a JavaScript object, it is an option object. Otherwise it is converted to string denoting the last argument and options objects assumed to be empty. The following properties of the option object are processed:
  • args - provides an array of additional command arguments
  • env - explicit environment object. All its enumerable properties define the corresponding environment variable names.
  • input - the process input. If it is not java.io.InputStream, it is converted to string and sent to the process as its input. If not specified, no input is provided to the process.
  • output - the process output instead of java.lang.System.out. If it is not instance of java.io.OutputStream, the process output is read, converted to a string, appended to the output property value converted to string and put as the new value of the output property.
  • err - the process error output instead of java.lang.System.err. If it is not instance of java.io.OutputStream, the process error output is read, converted to a string, appended to the err property value converted to string and put as the new value of the err property.
RunDoctest ( Context cx, Scriptable scope, string session, string sourceName, int lineNumber ) : int
Seal ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void

The seal function seals all supplied arguments.

The seal function seals all supplied arguments.

Serialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
SetErr ( TextWriter err ) : void
SetIn ( Stream @in ) : void
SetOut ( TextWriter @out ) : void
SetSealedStdLib ( bool value ) : void
Spawn ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

The spawn function runs a given function or script in a different thread.

The spawn function runs a given function or script in a different thread. js> function g() { a = 7; } js> a = 3; 3 js> spawn(g) Thread[Thread-1,5,main] js> a 3

Sync ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function.

The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function. The new function synchronizes on the the second argument if it is defined, or otherwise the this object of its invocation. js> var o = { f : sync(function(x) { print("entry"); Packages.java.lang.Thread.sleep(x*1000); print("exit"); })}; js> spawn(function() {o.f(5);}); Thread[Thread-0,5,main] entry js> spawn(function() {o.f(5);}); Thread[Thread-1,5,main] js> exit entry exit

Toint32 ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object

Convert the argument to int32 number.

Convert the argument to int32 number.

Version ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : double

Get and set the language version.

Get and set the language version. This method is defined as a JavaScript function.

Private Methods

Méthode Description
DoctestOutputMatches ( string expected, string actual ) : bool

Compare actual result of doctest to expected, modulo some acceptable differences.

Compare actual result of doctest to expected, modulo some acceptable differences. Currently just trims the strings before comparing, but should ignore differences in line numbers for error messages for example.

GetCharCodingFromType ( string type ) : string
GetClass ( object args ) : Type
GetInstance ( System.Function function ) : Global
LoadJLine ( Encoding cs ) : bool
Pipe ( bool fromProcess, Stream from, Stream to ) : void
ReadReader ( TextReader reader ) : string
ReadReader ( TextReader reader, int initialBufferSize ) : string
ReadUrl ( string filePath, string charCoding, bool urlIsFile ) : string
ReportRuntimeError ( string msgId ) : Exception
ReportRuntimeError ( string msgId, string msgArg ) : Exception
RunProcess ( string cmd, string environment, Stream @in, Stream @out, Stream err ) : int

Runs the given process using Runtime.exec().

Runs the given process using Runtime.exec(). If any of in, out, err is null, the corresponding process stream will be closed immediately, otherwise it will be closed as soon as all data will be read from/written to process

ToInputStream ( object value ) : Stream
ToOutputStream ( object value ) : Stream

Method Details

DefineClass() public static méthode

Load a Java class that defines a JavaScript object using the conventions outlined in ScriptableObject.defineClass.
Load a Java class that defines a JavaScript object using the conventions outlined in ScriptableObject.defineClass.

This method is defined as a JavaScript function.

/// IllegalAccessException /// if access is not available /// to a reflected class member /// /// InstantiationException /// if unable to instantiate /// the named class /// /// InvocationTargetException /// if an exception is thrown /// during execution of methods of the named class ///
public static DefineClass ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

Deserialize() public static méthode

public static Deserialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Doctest() public static méthode

Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns 2 (since 2 tests were executed).
Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns 2 (since 2 tests were executed).
public static Doctest ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Gc() public static méthode

public static Gc ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

GetConsole() public méthode

public GetConsole ( Encoding cs ) : ShellConsole
cs System.Text.Encoding
Résultat ShellConsole

GetErr() public méthode

public GetErr ( ) : TextWriter
Résultat System.IO.TextWriter

GetIn() public méthode

public GetIn ( ) : Stream
Résultat Stream

GetOut() public méthode

public GetOut ( ) : TextWriter
Résultat System.IO.TextWriter

GetPrompts() public méthode

public GetPrompts ( Context cx ) : string[]
cx Rhino.Context
Résultat string[]

Global() public méthode

public Global ( ) : System
Résultat System

Global() public méthode

public Global ( Context cx ) : System
cx Rhino.Context
Résultat System

Help() public static méthode

Print a help message.
Print a help message. This method is defined as a JavaScript function.
public static Help ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

Init() public méthode

public Init ( Context cx ) : void
cx Rhino.Context
Résultat void

Init() public méthode

public Init ( ContextFactory factory ) : void
factory ContextFactory
Résultat void

InitQuitAction() public méthode

Set the action to call from quit().
Set the action to call from quit().
public InitQuitAction ( QuitAction quitAction ) : void
quitAction QuitAction
Résultat void

InstallRequire() public méthode

public InstallRequire ( Context cx, IList modulePath, bool sandboxed ) : Require
cx Rhino.Context
modulePath IList
sandboxed bool
Résultat Rhino.Commonjs.Module.Require

IsInitialized() public méthode

public IsInitialized ( ) : bool
Résultat bool

Load() public static méthode

Load and execute a set of JavaScript source files.
Load and execute a set of JavaScript source files. This method is defined as a JavaScript function.
public static Load ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

LoadClass() public static méthode

Load and execute a script compiled to a class file.
Load and execute a script compiled to a class file.

This method is defined as a JavaScript function. When called as a JavaScript function, a single argument is expected. This argument should be the name of a class that implements the Script interface, as will any script compiled by jsc.

/// IllegalAccessException /// if access is not available /// to the class /// /// InstantiationException /// if unable to instantiate /// the named class ///
public static LoadClass ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

Print() public static méthode

Print the string values of its arguments.
Print the string values of its arguments. This method is defined as a JavaScript function. Note that its arguments are of the "varargs" form, which allows it to handle an arbitrary number of arguments supplied to the JavaScript function.
public static Print ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Quit() public static méthode

Call embedding-specific quit action passing its argument as int32 exit code.
Call embedding-specific quit action passing its argument as int32 exit code. This method is defined as a JavaScript function.
public static Quit ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

ReadFile() public static méthode

The readFile reads the given file content and convert it to a string using the specified character coding or default character coding if explicit coding argument is not given.
The readFile reads the given file content and convert it to a string using the specified character coding or default character coding if explicit coding argument is not given.

Usage:

 readFile(filePath) readFile(filePath, charCoding) 
The first form converts file's context to string using the default character coding.
public static ReadFile ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

ReadUrl() public static méthode

The readUrl opens connection to the given URL, read all its data and converts them to a string using the specified character coding or default character coding if explicit coding argument is not given.
The readUrl opens connection to the given URL, read all its data and converts them to a string using the specified character coding or default character coding if explicit coding argument is not given.

Usage:

 readUrl(url) readUrl(url, charCoding) 
The first form converts file's context to string using the default charCoding.
public static ReadUrl ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

RunCommand() public static méthode

Execute the specified command with the given argument and options as a separate process and return the exit status of the process.
Execute the specified command with the given argument and options as a separate process and return the exit status of the process.

Usage:

 runCommand(command) runCommand(command, arg1, ..., argN) runCommand(command, arg1, ..., argN, options) 
All except the last arguments to runCommand are converted to strings and denote command name and its arguments. If the last argument is a JavaScript object, it is an option object. Otherwise it is converted to string denoting the last argument and options objects assumed to be empty. The following properties of the option object are processed:
  • args - provides an array of additional command arguments
  • env - explicit environment object. All its enumerable properties define the corresponding environment variable names.
  • input - the process input. If it is not java.io.InputStream, it is converted to string and sent to the process as its input. If not specified, no input is provided to the process.
  • output - the process output instead of java.lang.System.out. If it is not instance of java.io.OutputStream, the process output is read, converted to a string, appended to the output property value converted to string and put as the new value of the output property.
  • err - the process error output instead of java.lang.System.err. If it is not instance of java.io.OutputStream, the process error output is read, converted to a string, appended to the err property value converted to string and put as the new value of the err property.
public static RunCommand ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

RunDoctest() public méthode

public RunDoctest ( Context cx, Scriptable scope, string session, string sourceName, int lineNumber ) : int
cx Rhino.Context
scope Scriptable
session string
sourceName string
lineNumber int
Résultat int

Seal() public static méthode

The seal function seals all supplied arguments.
The seal function seals all supplied arguments.
public static Seal ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

Serialize() public static méthode

public static Serialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat void

SetErr() public méthode

public SetErr ( TextWriter err ) : void
err System.IO.TextWriter
Résultat void

SetIn() public méthode

public SetIn ( Stream @in ) : void
@in Stream
Résultat void

SetOut() public méthode

public SetOut ( TextWriter @out ) : void
@out System.IO.TextWriter
Résultat void

SetSealedStdLib() public méthode

public SetSealedStdLib ( bool value ) : void
value bool
Résultat void

Spawn() public static méthode

The spawn function runs a given function or script in a different thread.
The spawn function runs a given function or script in a different thread. js> function g() { a = 7; } js> a = 3; 3 js> spawn(g) Thread[Thread-1,5,main] js> a 3
public static Spawn ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Sync() public static méthode

The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function.
The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function. The new function synchronizes on the the second argument if it is defined, or otherwise the this object of its invocation. js> var o = { f : sync(function(x) { print("entry"); Packages.java.lang.Thread.sleep(x*1000); print("exit"); })}; js> spawn(function() {o.f(5);}); Thread[Thread-0,5,main] entry js> spawn(function() {o.f(5);}); Thread[Thread-1,5,main] js> exit entry exit
public static Sync ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Toint32() public static méthode

Convert the argument to int32 number.
Convert the argument to int32 number.
public static Toint32 ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat object

Version() public static méthode

Get and set the language version.
Get and set the language version. This method is defined as a JavaScript function.
public static Version ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : double
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Résultat double