C# Class Jurassic.TypeUtilities

Contains type-related functionality that isn't conversion or comparison.
显示文件 Open project: paulbartrum/jurassic Class Usage Examples

Public Methods

Method Description
Add ( object left, object right ) : object

Adds two objects together, as if by the javascript addition operator.

EnumeratePropertyNames ( ScriptEngine engine, object obj ) : IEnumerable

Enumerates the names of the enumerable properties on the given object, including properties defined on the object's prototype. Used by the for-in statement.

GetIterator ( ScriptEngine engine, ObjectInstance iterable ) : ObjectInstance

Converts an iteratable object into a iterator by looking up the @@iterator property, then calling that value as a function.

IsNegativeZero ( double value ) : bool

Determines if the given number is negative zero.

IsPositiveZero ( double value ) : bool

Determines if the given number is positive zero.

IsPrimitive ( object value ) : bool

Determines if the given value is a supported JavaScript primitive.

IsPrimitiveOrObject ( object value ) : bool

Determines if the given value is a supported JavaScript primitive or derives from ObjectInstance.

IsRegularExpression ( object value ) : bool

Determines if the given value is a regular expression.

Iterate ( ScriptEngine engine, ObjectInstance iterator ) : IEnumerable

Iterate over the values in an iterator.

TypeOf ( object obj ) : string

Gets the type name for the given object. Used by the typeof operator.

VerifyThisObject ( ScriptEngine engine, object value, string functionName ) : void

Throws a TypeError when the given value is null or undefined.

Private Methods

Method Description
IsNumeric ( object obj ) : bool

Returns true if the given value is a supported numeric type.

IsString ( object obj ) : bool

Returns true if the given value is a supported string type.

IsUndefined ( object obj ) : bool

Returns true if the given value is undefined.

NormalizeValue ( object obj ) : object

Converts the given value into a standard .NET type, suitable for returning from an API.

SliceArray ( object args, int offset ) : object[]

Utility method for create a slice of an array.

Method Details

Add() public static method

Adds two objects together, as if by the javascript addition operator.
public static Add ( object left, object right ) : object
left object The left hand side operand.
right object The right hand side operand.
return object

EnumeratePropertyNames() public static method

Enumerates the names of the enumerable properties on the given object, including properties defined on the object's prototype. Used by the for-in statement.
public static EnumeratePropertyNames ( ScriptEngine engine, object obj ) : IEnumerable
engine ScriptEngine The script engine used to convert the given value to an object.
obj object The object to enumerate.
return IEnumerable

GetIterator() public static method

Converts an iteratable object into a iterator by looking up the @@iterator property, then calling that value as a function.
public static GetIterator ( ScriptEngine engine, ObjectInstance iterable ) : ObjectInstance
engine ScriptEngine The script engine.
iterable Jurassic.Library.ObjectInstance The object to get a iterator from.
return Jurassic.Library.ObjectInstance

IsNegativeZero() public static method

Determines if the given number is negative zero.
public static IsNegativeZero ( double value ) : bool
value double The value to test.
return bool

IsPositiveZero() public static method

Determines if the given number is positive zero.
public static IsPositiveZero ( double value ) : bool
value double The value to test.
return bool

IsPrimitive() public static method

Determines if the given value is a supported JavaScript primitive.
public static IsPrimitive ( object value ) : bool
value object The value to test.
return bool

IsPrimitiveOrObject() public static method

Determines if the given value is a supported JavaScript primitive or derives from ObjectInstance.
public static IsPrimitiveOrObject ( object value ) : bool
value object The value to test.
return bool

IsRegularExpression() public static method

Determines if the given value is a regular expression.
public static IsRegularExpression ( object value ) : bool
value object The value to test.
return bool

Iterate() public static method

Iterate over the values in an iterator.
public static Iterate ( ScriptEngine engine, ObjectInstance iterator ) : IEnumerable
engine ScriptEngine The script engine.
iterator Jurassic.Library.ObjectInstance The iterator object. Must contain a next function.
return IEnumerable

TypeOf() public static method

Gets the type name for the given object. Used by the typeof operator.
public static TypeOf ( object obj ) : string
obj object The object to get the type name for.
return string

VerifyThisObject() public static method

Throws a TypeError when the given value is null or undefined.
public static VerifyThisObject ( ScriptEngine engine, object value, string functionName ) : void
engine ScriptEngine The associated script engine.
value object The value to check.
functionName string The name of the function which is doing the check.
return void