[TOC] [Prev] [Next]

ITKJSProperties

Declared in: itkJavaScript/ITKJSProperties.h

ITKJSProperties is an informal protocol to define the semantics of getting, setting, deleting, and enumerating JavaScript properties of Objective-C objects.

All JavaScript objects have properties. These are accessible via the object.property and object[property] syntax. If the JavaScript object happens to be a Joy reflection of an Objective-C object, the object can implement this protocol to determine what its JavaScript properties refer to.

The default behaviour for Objective-C objects (without implementing ITKJSProperties) is as follows:

For example, in an application built on the Enterprise Objects Framework, you could easily implement ITKJSProperties for your business objects, so you can access EOF properties using the convenient syntax object.property instead of accessor methods. The itkJavaScript framework already provides implementations of ITKJSProperties for the NSArray and NSDictionary classes.

Instance Methods

getJSProperty:value:

-(BOOL)getJSProperty:(JSVal)slot value:(JSVal *)vp

On entry, vp will contain the current value of the property as remembered by JavaScript. You can change it, or leave it alone. Return YES if your method has already placed the authoritative value of slot into vp, or NO if you want to leave the default behaviour detailed above.

setJSProperty:value:

-(BOOL)setJSProperty:(JSVal)slot value:(JSVal *)vp

On entry, vp will contain the assigned value. You can modify it in place if it needs to be coerced somehow. Return YES if your method has already taken all necessary actions for assigning to slot, or NO if you still want the default behaviour to happen.

delJSProperty:value:

-(BOOL)delJSProperty:(JSVal)slot value:(JSVal *)vp

On entry, vp will contain 'true'. You can modify it to 'false' if slot can't possibly be removed from the object. (To report an error, raise an exception.) Return YES if your method already took all necessary actions for removing slot, or NO if you still want the default behaviour to happen.

jsPropertyEnumerator

-(id <ITKJSPropertyEnumerator>)jsPropertyEnumerator

If implemented, defines the behaviour of loops like for (i in object). The variable i will take on all values returned by the property enumerator's getNextJSProperty: method.



[TOC] [Prev] [Next]

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