Objective-Everything Release 5. Copyright ©1994-1998 by TipTop Software, Inc. All Rights Reserved.
Objective-Tcl introspection facility allows you to obtain various information about the runtime system.
All Objective-Tcl procedures live in the objtcl:: namespace. This namespace is, by default, imported into global namespace so that you normally do not have to prefix ObjTcl commands with objtcl::
Unparse extracts the class and protocol information from the runtime and returns it in the familiar ObjC-style syntax form.
If the object is a class, that class is unparsed.
If the object is an instance, its class is unparsed.
If the object is a protocol, the protocol is unparsed
If you specify the -decompile flag, method implementation
bodies for Objective-Everything-defined methods will be included.
If you specify the -verbose flag, type names are fully
expanded.
Example:
tcl% unparse NSObject @interface NSObject : Nil <NSObject> // Subclasses: NSLayoutHole NSCustomResource NSStorage ... { Class isa; }
// Class methods ...
// Instance methods ... @end
tcl% unparse [protocol NSObject] @protocol NSObject // Implemented by: NSObject NSProxy
// Class methods: none
// Instance methods - (id)description; ... @end
tcl% class MyObject NSObject { %--> NSString *aString; %--> id anObject; %--> char *aCString; %--> NSRect aRect; %--> } { %--> method -(void)dealloc { %--> set aString [nil] ; # release aString %--> set anObject [nil] ; # release anObject %--> set aCString [NULL] ; # free aCString %--> super dealloc %--> } %--> %--> method -(void)setStringValue:(NSString*)s { %--> puts "$self $_cmd $s" %--> set aString $s %--> } %--> %--> method -(NSString*)stringValue { %--> puts "$self $_cmd" %--> return $aString %--> } %--> %--> # etc. %--> } MyObject tcl% unparse MyObject @interface MyObject : NSObject // Subclasses: None { NSString* aString; id anObject; STR aCString; NSRect aRect; } // Class methods // Instance methods // ------------------------------- 1 ------------------------------- - (id)stringValue; - (void)setStringValue:(id)s; - (void)dealloc; @end tcl% unparse -decomp MyObject @interface MyObject : NSObject // Subclasses: None { NSString* aString; id anObject; STR aCString; NSRect aRect; } // Class methods // Instance methods // ------------------------------- 1 ------------------------------- - (id)stringValue; /* ObjTcl: puts "$self $_cmd" return $aString */ - (void)setStringValue:(id)s; /* ObjTcl: puts "$self $_cmd $s" set aString $s */ - (void)dealloc; /* ObjTcl: set aString [nil] ; # release aString set anObject [nil] ; # release anObject set aCString [NULL] ; # free aCString super dealloc */ @end
Note that the result of unparse can be used as a header file for compiled ObjC.
All the introspection functionality is available via the info command.
Note: The info command is not exported from the objtcl:: namespace because that would conflict with the standard Tcl info command. Hence, you invoke info as objtcl::info. Alternatively, you can use xinfo, which is exported from the objtcl:: namespace
Returns the ObjTcl version number.
Returns ObjTcl library path.
Returns architecture name.
Returns OS name.
Returns OS version.
Returns TipTop contact information.
Returns TipTop copyright information.
Returns a list of all class names which match the pattern.
Example:
tcl% objtcl::info classes *Window* NSWindowTemplate NSWindow NSComboBoxWindow
Returns a list of all protocol names known to the Objective-Everything runtime system which match the pattern.
Returns a list of all objects names registered with the Objective-Everything runtime system which match the pattern.
Returns a list of all type names known to the system which match the pattern.
Example:
tcl% objtcl::info types *int* uint NSPoint int
Returns a list of all function names known to the system which match the pattern.
Example:
tcl% objtcl::info func *Run*AlertPanel NSRunInformationalAlertPanel NSRunCriticalAlertPanel NSRunAlertPanel
Returns a list of all global variable names known to the system which match the pattern.
Example:
tcl% xinfo glob NSArg* NSArgc NSArgv
Returns a list of all constant names known to the system which match the pattern.
Returns a list of all method names in the class which match the pattern. To obtain method information for a specific instance obj, simply use [obj class] as the class argument.
Example:
tcl% xinfo meth MyObject {*[sS]tring*} - (id)stringValue; - (void)setStringValue:(id)s;
tcl% xinfo meth -decomp MyObject dealloc - (void)dealloc; /* ObjTcl: set aString [nil] ; # release aString set anObject [nil] ; # release anObject set aCString [NULL] ; # free aCString super dealloc */
Returns a list of instance variable names declared in the class which match the pattern.
Example:
tcl% xinfo ivar -all MyObject isa Class isa;
tcl% xinfo ivar -all MyObject *String NSString* aString; STR aCString;
Returns a list of argument names for the specified method in class, or function.
Returns a list of argument types for the specified method in class, or function.
Returns method implementation body.
Returns language name in which the specified method is implemented.
Examples:
tcl% xinfo argnames MyObject setStringValue: self _cmd s tcl% xinfo argnames NSObject performSelector:withObject: self _cmd a0 a1 tcl% xinfo argt MyObject setStringValue: void id SEL id tcl% xinfo body MyObject setStringValue: puts "$self $_cmd $s" set aString $s tcl% xinfo lang MyObject setStringValue: ObjTcl tcl% xinfo lang NSObject performSelector:withObject: ObjC
Returns type of the specified instance variable in class.
Examples:
tcl% xinfo ivtype MyObject aString NSString* aString