// // M() -- macro to abbreviate @selector() // #define M( messageName ) @selector( messageName )The M() macro is currently nothing more than an abbreviation for the Objective C syntax used to obtain a selector for a particular message name. It is provided as a convenience for use in messages that combine a selector with other arguments.
// // func_t -- function pointer type // typedef void (*func_t)( void );func_t provides a type definition for a generic function pointer type (taking no arguments and returning no value). This type name is used in declaring messages that accept or return function pointers of various alternative types.
// // initModule() -- module initialization macro // #define initModule( module )The initModule function must be called to initialize all the definitions of a library module before any attempt is made to use the library. Initializing a particular library module will also initialize all other library modules on which the library depends. The macro has no effect if the library has already been initialized, so that multiple libraries that all depend on another library can all request initialization of the other library with no ill effect. The argument of the macro is the name of module to be initialized. For example, if just the collections library were being initialized, the macro would be coded:
#define globalZone #define scratchZoneThe identifiers globalZone and scratchZone refer to two standard zones created by initialization of the defobj library. All other created zones must obtain their storage from one or the other of these two initial zones. (These initial zones are defined as macros only to follow conventions on global external names.)
globalZone may be used for all storage which must be allocated for the duration of the program, or until explicitly released. scratchZone should be used for storage which is allocated only for use during execution of a single function. It is typically used for objects which are strictly temporary as part of a local computation. (.. Currently, a scratch zone has the identical implementation as the global zone, but eventually a scratch zone may be optimized for temporary allocations, and such allocations may also be freed automatically at various points when functions are guaranteed to be complete.)
extern FILE *_obj_xerror; // output file for error messages extern FILE *_obj_xdebug; // output file for debugging messagesThe file pointers _obj_xerror and _obj_xerror define standard output files used for error messages and debugging messages, respectively. If not set otherwise by the time of defobj module initialization, they both default to the standard error output defined by the C library.
extern BOOL _obj_debug; // if true then perform all debug error checking extern void xprint( id anObject ); // debugger object print extern void xfprint( id anObject ); // debugger foreach object print extern void xexec( id anObject, char *name ); // debugger method exec extern void xfexec( id anObject, char *name ); // debugger foreach method execThe _obj_debug variable enables debug-level error checking in libraries that support optional levels of checking. Its default value is true. The default may be overridden either before initialization of the defobj module, or by means of a compiler macro setting (-D_obj_debug=0). If set to zero by a compiler macro setting, optimized compilation of code that refers to it will see only the constant zero and so avoid even generating code to test the variable.
The xprint function prints a standard object description to the standard debugging output file. It generates the string to be printed using the describe: message defined by the DefinedObject supertype, but it is defined as a function so that it may be called directly from a debugger.
The xfprint function is similar to the xprint function, except that it prints a debug description for each member of a collection. The argument of xfprint must support enumeration of collection members using the messages of the Collection type.
The xexec function executes a message on an object passed as an argument. The name of message to be executed (the full name including arguments as would be used in naming a selector) must be given as the second argument. This function is equivalent to the "perform:" message of Objective C, but is defined as a function so that it may be called directly from a debugger.
The xfexec function is similar to the xexec function, except that it executes a message on each member of a collection. The first argument of xfprint must support enumeration of collection members using the messages of the Collection type.
Roger Burkhart <rmb@santafe.edu> Last modified: