Inherits From:
ITKInterp : NSObject
Conforms To:
NSObject (NSObject)
NSCoding (ITKInterp)
Declared in: itkJavaScript/ITKJSInterp.h
The generic methods for evaluating scripts and accessing variables use the class ITKJSVal for wrapping JavaScript values as Objective-C objects. In some situations this generic, ITKValue-based API can be overkill, e.g. when you are running in JavaScript and just want to evaluate a script in another ITKJSInterp instance. In this case, it is easiest (and most efficient) to use a method like eval:, which avoids any conversion overhead by simply passing raw JavaScript values between interpreters.
mainInterp
Returns the first instance of ITKJSInterp created by the application, creating one if none exists.
eval:
(JSVal)script Evaluates script in the currently executing scope of the receiving interpreter and returns the result. Raises an exception if an error occurs. This method is most conveniently called from JavaScript rather than from Objective-C.
globEval:
(JSVal)script Evaluates script in the global scope of the receiving interpreter and returns the result. Raises an exception if an error occurs. This method is most conveniently called from JavaScript rather than from Objective-C.
nativeInterp
Returns the JSContext * representing the interpreter for use with the low-level JavaScript API exported by jsapi.h. The Objective-C API should be sufficient for almost every purpose, though.
unsetVariable:
(NSString *)variable global:
(BOOL)global Deletes the variable variable from the interpreter's name space, analogous to the JavaScript delete operator. If global is YES, looks for variable in the global scope, otherwise in the currently executing scope.