C# Класс Rhino.Tools.Shell.Global

Наследование: Rhino.ImporterTopLevel
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

DefineClass() публичный статический Метод

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
Результат void

Deserialize() публичный статический Метод

public static Deserialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : object
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Результат object

Doctest() публичный статический Метод

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
Результат object

Gc() публичный статический Метод

public static Gc ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Результат void

GetConsole() публичный Метод

public GetConsole ( Encoding cs ) : ShellConsole
cs System.Text.Encoding
Результат ShellConsole

GetErr() публичный Метод

public GetErr ( ) : TextWriter
Результат System.IO.TextWriter

GetIn() публичный Метод

public GetIn ( ) : Stream
Результат Stream

GetOut() публичный Метод

public GetOut ( ) : TextWriter
Результат System.IO.TextWriter

GetPrompts() публичный Метод

public GetPrompts ( Context cx ) : string[]
cx Rhino.Context
Результат string[]

Global() публичный Метод

public Global ( ) : System
Результат System

Global() публичный Метод

public Global ( Context cx ) : System
cx Rhino.Context
Результат System

Help() публичный статический Метод

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
Результат void

Init() публичный Метод

public Init ( Context cx ) : void
cx Rhino.Context
Результат void

Init() публичный Метод

public Init ( ContextFactory factory ) : void
factory ContextFactory
Результат void

InitQuitAction() публичный Метод

Set the action to call from quit().
Set the action to call from quit().
public InitQuitAction ( QuitAction quitAction ) : void
quitAction QuitAction
Результат void

InstallRequire() публичный Метод

public InstallRequire ( Context cx, IList modulePath, bool sandboxed ) : Require
cx Rhino.Context
modulePath IList
sandboxed bool
Результат Rhino.Commonjs.Module.Require

IsInitialized() публичный Метод

public IsInitialized ( ) : bool
Результат bool

Load() публичный статический Метод

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
Результат void

LoadClass() публичный статический Метод

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
Результат void

Print() публичный статический Метод

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
Результат object

Quit() публичный статический Метод

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
Результат void

ReadFile() публичный статический Метод

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
Результат object

ReadUrl() публичный статический Метод

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
Результат object

RunCommand() публичный статический Метод

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
Результат object

RunDoctest() публичный Метод

public RunDoctest ( Context cx, Scriptable scope, string session, string sourceName, int lineNumber ) : int
cx Rhino.Context
scope Scriptable
session string
sourceName string
lineNumber int
Результат int

Seal() публичный статический Метод

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
Результат void

Serialize() публичный статический Метод

public static Serialize ( Context cx, Scriptable thisObj, object args, System.Function funObj ) : void
cx Rhino.Context
thisObj Scriptable
args object
funObj System.Function
Результат void

SetErr() публичный Метод

public SetErr ( TextWriter err ) : void
err System.IO.TextWriter
Результат void

SetIn() публичный Метод

public SetIn ( Stream @in ) : void
@in Stream
Результат void

SetOut() публичный Метод

public SetOut ( TextWriter @out ) : void
@out System.IO.TextWriter
Результат void

SetSealedStdLib() публичный Метод

public SetSealedStdLib ( bool value ) : void
value bool
Результат void

Spawn() публичный статический Метод

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
Результат object

Sync() публичный статический Метод

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
Результат object

Toint32() публичный статический Метод

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
Результат object

Version() публичный статический Метод

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
Результат double