C# 클래스 Rhino.FunctionObject

상속: BaseFunction
파일 보기 프로젝트 열기: hazzik/Rhino.Net

공개 메소드들

메소드 설명
AddAsConstructor ( Scriptable scope, Scriptable prototype ) : void

Define this function as a JavaScript constructor.

Define this function as a JavaScript constructor.

Sets up the "prototype" and "constructor" properties. Also calls setParent and setPrototype with appropriate values. Then adds the function object as a property of the given scope, using prototype.getClassName() as the name of the property.

Call ( Context cx, Scriptable scope, Scriptable thisObj, object args ) : object

Performs conversions on argument types if needed and invokes the underlying Java method or constructor.

Performs conversions on argument types if needed and invokes the underlying Java method or constructor.

Implements Function.call.

ConvertArg ( Context cx, Scriptable scope, object arg, int typeTag ) : object
CreateObject ( Context cx, Scriptable scope ) : Scriptable

Return new Scriptable instance using the default constructor for the class of the underlying Java method. Return null to indicate that the call method should be used to create new objects.

FunctionObject ( string name, MemberInfo methodOrConstructor, Scriptable scope ) : System

Create a JavaScript function object from a Java method.

Create a JavaScript function object from a Java method.

The member argument must be either a java.lang.reflect.Method or a java.lang.reflect.Constructor and must match one of two forms.

The first form is a member with zero or more parameters of the following types: Object, String, boolean, Scriptable, int, or double. The Long type is not supported because the double representation of a long (which is the EMCA-mandated storage type for Numbers) may lose precision. If the member is a Method, the return value must be void or one of the types allowed for parameters.

The runtime will perform appropriate conversions based upon the type of the parameter. A parameter type of Object specifies that no conversions are to be done. A parameter of type String will use Context.toString to convert arguments. Similarly, parameters of type double, boolean, and Scriptable will cause Context.toNumber, Context.toBoolean, and Context.toObject, respectively, to be called.

If the method is not static, the Java 'this' value will correspond to the JavaScript 'this' value. Any attempt to call the function with a 'this' value that is not of the right Java type will result in an error.

The second form is the variable arguments (or "varargs") form. If the FunctionObject will be used as a constructor, the member must have the following parameters

 (Context cx, Object[] args, Function ctorObj, boolean inNewExpr)
and if it is a Method, be static and return an Object result.

Otherwise, if the FunctionObject will not be used to define a constructor, the member must be a static Method with parameters

 (Context cx, Scriptable thisObj, Object[] args, Function funObj) 
and an Object result.

When the function varargs form is called as part of a function call, the args parameter contains the arguments, with thisObj set to the JavaScript 'this' value. funObj is the function object for the invoked function.

When the constructor varargs form is called or invoked while evaluating a new expression, args contains the arguments, ctorObj refers to this FunctionObject, and inNewExpr is true if and only if a new expression caused the call. This supports defining a function that has different behavior when called as a constructor than when invoked as a normal function call. (For example, the Boolean constructor, when called as a function, will convert to boolean rather than creating a new object.)

GetArity ( ) : int

Return the value defined by the method used to construct the object (number of parameters of the method, or 1 if the method is a "varargs" form).

Return the value defined by the method used to construct the object (number of parameters of the method, or 1 if the method is a "varargs" form).

GetFunctionName ( ) : string
GetLength ( ) : int

Return the same value as GetArity() .

GetMethodOrConstructor ( ) : MemberInfo

Get Java method or constructor this function represent.

Get Java method or constructor this function represent.

GetTypeTag ( Type type ) : int

비공개 메소드들

메소드 설명
ConvertArg ( Context cx, Scriptable scope, object arg, Type desired ) : object
FindSingleMethod ( MethodInfo methods, string name ) : MethodInfo
GetMethodList ( Type clazz ) : System.Reflection.MethodInfo[]

Returns all public methods declared by the specified class.

Returns all public methods declared by the specified class. This excludes inherited methods.

InitAsConstructor ( Scriptable scope, Scriptable prototype ) : void
IsVarArgsConstructor ( ) : bool
IsVarArgsMethod ( ) : bool
ReadObject ( ObjectInputStream @in ) : void

메소드 상세

AddAsConstructor() 공개 메소드

Define this function as a JavaScript constructor.
Define this function as a JavaScript constructor.

Sets up the "prototype" and "constructor" properties. Also calls setParent and setPrototype with appropriate values. Then adds the function object as a property of the given scope, using prototype.getClassName() as the name of the property.

public AddAsConstructor ( Scriptable scope, Scriptable prototype ) : void
scope Scriptable /// the scope in which to define the constructor (typically /// the global object) ///
prototype Scriptable the prototype object
리턴 void

Call() 공개 메소드

Performs conversions on argument types if needed and invokes the underlying Java method or constructor.
Performs conversions on argument types if needed and invokes the underlying Java method or constructor.

Implements Function.call.

public Call ( Context cx, Scriptable scope, Scriptable thisObj, object args ) : object
cx Context
scope Scriptable
thisObj Scriptable
args object
리턴 object

ConvertArg() 공개 정적인 메소드

public static ConvertArg ( Context cx, Scriptable scope, object arg, int typeTag ) : object
cx Context
scope Scriptable
arg object
typeTag int
리턴 object

CreateObject() 공개 메소드

Return new Scriptable instance using the default constructor for the class of the underlying Java method. Return null to indicate that the call method should be used to create new objects.
public CreateObject ( Context cx, Scriptable scope ) : Scriptable
cx Context
scope Scriptable
리턴 Scriptable

FunctionObject() 공개 메소드

Create a JavaScript function object from a Java method.
Create a JavaScript function object from a Java method.

The member argument must be either a java.lang.reflect.Method or a java.lang.reflect.Constructor and must match one of two forms.

The first form is a member with zero or more parameters of the following types: Object, String, boolean, Scriptable, int, or double. The Long type is not supported because the double representation of a long (which is the EMCA-mandated storage type for Numbers) may lose precision. If the member is a Method, the return value must be void or one of the types allowed for parameters.

The runtime will perform appropriate conversions based upon the type of the parameter. A parameter type of Object specifies that no conversions are to be done. A parameter of type String will use Context.toString to convert arguments. Similarly, parameters of type double, boolean, and Scriptable will cause Context.toNumber, Context.toBoolean, and Context.toObject, respectively, to be called.

If the method is not static, the Java 'this' value will correspond to the JavaScript 'this' value. Any attempt to call the function with a 'this' value that is not of the right Java type will result in an error.

The second form is the variable arguments (or "varargs") form. If the FunctionObject will be used as a constructor, the member must have the following parameters

 (Context cx, Object[] args, Function ctorObj, boolean inNewExpr)
and if it is a Method, be static and return an Object result.

Otherwise, if the FunctionObject will not be used to define a constructor, the member must be a static Method with parameters

 (Context cx, Scriptable thisObj, Object[] args, Function funObj) 
and an Object result.

When the function varargs form is called as part of a function call, the args parameter contains the arguments, with thisObj set to the JavaScript 'this' value. funObj is the function object for the invoked function.

When the constructor varargs form is called or invoked while evaluating a new expression, args contains the arguments, ctorObj refers to this FunctionObject, and inNewExpr is true if and only if a new expression caused the call. This supports defining a function that has different behavior when called as a constructor than when invoked as a normal function call. (For example, the Boolean constructor, when called as a function, will convert to boolean rather than creating a new object.)

public FunctionObject ( string name, MemberInfo methodOrConstructor, Scriptable scope ) : System
name string the name of the function
methodOrConstructor MemberInfo /// a java.lang.reflect.Method or a java.lang.reflect.Constructor /// that defines the object ///
scope Scriptable enclosing scope of function
리턴 System

GetArity() 공개 메소드

Return the value defined by the method used to construct the object (number of parameters of the method, or 1 if the method is a "varargs" form).
Return the value defined by the method used to construct the object (number of parameters of the method, or 1 if the method is a "varargs" form).
public GetArity ( ) : int
리턴 int

GetFunctionName() 공개 메소드

public GetFunctionName ( ) : string
리턴 string

GetLength() 공개 메소드

Return the same value as GetArity() .
public GetLength ( ) : int
리턴 int

GetMethodOrConstructor() 공개 메소드

Get Java method or constructor this function represent.
Get Java method or constructor this function represent.
public GetMethodOrConstructor ( ) : MemberInfo
리턴 MemberInfo

GetTypeTag() 공개 정적인 메소드

public static GetTypeTag ( Type type ) : int
type System.Type
리턴 int