MPInterpreter |
Tcl interpreter object
Superclass: NSObject
Declared In: MPInterpreter.h
Contains a shared per-thread instance of a Tcl interpreter. The MPInterpreter class is where the Objective-C API meets the Tcl command line. It is a per-thread interpreter to allow users of the API to multi-thread their programs with relative ease.
evaluateArrayAsString: |
Returns the NSstring result of evaluating a Tcl expression
- (NSString *)evaluateArrayAsString:(NSArray *)statement;
statement
For example, here is the header definition of a MacPorts Tcl API
call proc macports::getindex {source}. This is how to call this procedure
in Tcl: [macports::getindex $source]. Calling the macports::getindex
procedure from Objective-C code with -evaluateArrayAsString however takes the following form:
[SomeMPInterpreterObject evaluateArrayAsString:[NSArray arrayWithObjects:
@"return [macports::getindex",
[NSString stringWithString:@"SomeValidMacPortsSourcePath"],
@"]",
nil]];
Each element in the array is an NSString. Note the "return" in the first element of the statement
NSArray.
evaluateStringAsString: |
Returns the NSString result of evaluating a Tcl expression
- (NSString *)evaluateStringAsString:(NSString *)statement;
statement
Using the macports::getindex {source} procedure as an example (see discussion for
-evaluateArrayAsString), we have the following Objective-C form for calling the macports::getindex
procedure:
[SomeMPInterpreterObject evaluateStringAsString:
[NSString stringWithString:@"return [macports::getindex SomeValidMacPortsSourcePath]"]];
arrayFromTclListAsString: |
Returns an NSArray whose elements are the the elements of a Tcl list in the form of an NSString
- (NSArray *)arrayFromTclListAsString:(NSString *)list;
list
This method usually takes the result of a call to the evaluateStringAsString and evaluateArrayAsString methods which is a Tcl list and parses it into an NSArray.
dictionaryFromTclListAsString: |
Returns an NSDictionary whose elements are the the elements of a Tcl list in the form of an NSString
- (NSDictionary *)dictionaryFromTclListAsString:(NSString *)list;
list
The returned NSDictionary is of the form {k1, v1, k2, v2, ...} with ki being the keys and vi the values in the dictionary. These keys and values are obtained from an NSString Tcl list of the form {k1 v1 k2 v2 ...}
mutableDictionaryFromTclListAsString: |
Same as dictionaryFromTclListAsString method. Returns an NSMutableDictionary
- (NSMutableDictionary *) mutableDictionaryFromTclListAsString:(NSString *)list;
rather than NSDictionary.
getVariableAsArray: |
Returns an NSArray whose elements are the contents of a Tcl variable
- (NSArray *)getVariableAsArray:(NSString *)variable;
variable
getVariableAsString: |
Returns an NSString representation of a Tcl variable
- (NSString *)getVariableAsString:(NSString *)variable;
variable
Last Updated: Sunday, July 13, 2008