[TOC] [Prev] [Next]

ITKJSVal

Inherits From:
ITKValue : NSObject

Conforms To: NSObject (NSObject)

Declared in: itkJavaScript/ITKJSVal.h

Class Description

ITKJSVal is used for wrapping JavaScript values in Objective-C objects. All the generic methods of ITKJSInterp that are formally declared as returning and accepting ITKValues will really return and accept ITKJSVal instances exclusively!

The native representation mentioned in the class description of ITKValue is defined to be a JSVal by the ITKJSVal class. JSVal is conceptually equivalent to the jsval type from the low-level JavaScript API exported by jsapi.h, but is defined as a union containing a few useless fields besides the actual jsval so it can be distinguished from a plain integer in method type signatures. ITKJSVal.h provides two macros, JSVal() and jsval() to convert between the JSVal union and the actual jsval. If you don't want to use the low-level JavaScript API, you need not worry about this at all. The Objective-C API should be sufficient for almost every purpose.

Class Methods

jsVal:

+(ITKJSVal *)jsVal:(JSVal)value

Creates and returns an ITKJSVal wrapping value.

See also: - initWithJSVal:

nullValue

+(ITKValue *)nullValue

Returns an ITKJSVal wrapping the JavaScript "undefined" value.

See also: - isNull

valueWithArray:

+(ITKValue *)valueWithArray:(NSArray *)values

Creates and returns an ITKJSVal wrapping a JavaScript array composed of values, all of which have to be instances of ITKJSVal.

See also: - initWithArray:

valueWithNativeRep:

+(ITKValue *)valueWithNativeRep:(void *)value

Creates and returns an ITKJSVal wrapping value, which must be a valid JSVal. To avoid complicated type casting of the argument you should consider using the equivalent jsVal: method instead.

See also: - initWithNativeRep:

Instance Methods

arrayValue

- (NSArray *)arrayValue

If the wrapped value is a JavaScript array, returns its elements as an NSArray of ITKJSVal's. Raises an exception otherwise.

initWithArray:

- (ITKValue *)initWithArray:(NSArray *)values

Initializes a newly created ITKJSVal with a JavaScript array composed of values, all of which have to be instances of ITKJSVal.

See also: + valueWithArray:

initWithJSVal:

- (ITKJSVal *)initWithJSVal:(JSVal)value

Initializes a newly created ITKJSVal with value.

See also: + jsVal:

initWithNativeRep:

- (ITKValue *)initWithNativeRep:(void *)value

Initializes a newly created ITKJSVal with value, which must be a valid JSVal. To avoid complicated type casting of the argument you should consider using the equivalent initWithJSVal: method instead.

See also: + valueWithNativeRep:

isNull

- (BOOL)isNull

Returns YES if the wrapped value equals the JavaScript "undefined" value.

See also: + nullValue

jsVal

- (JSVal)jsVal

Returns the JSVal wrapped by the receiver.

nativeRep

- (void *)nativeRep

Returns the JSVal wrapped by the receiver. You won't ever need to use this method unless you want to use the low-level JavaScript API exported by jsapi.h, and even then you should consider using the equivalent jsVal method instead, to avoid complicated type casting of the return value.



[TOC] [Prev] [Next]

Copyright © 1999, AAA+ Software. All rights reserved.