#include <tcl.h> Tcl_Command Tcl_CreateObjCommand(interp, name, length, proc, clientData, deleteProc)
The procedures Tcl_DeleteCommand, Tcl_GetCommandInfo, and Tcl_SetCommandInfo are used in conjunction with both Tcl_CreateObjCommand and Tcl_CreateCommand.
Tcl_CreateObjCommand will delete any command name already associated with the interpreter. It returns a token that may be used to refer to the command in subsequent calls to Tcl_GetCommandName. If Tcl_CreateObjCommand is called for an interpreter that is in the process of being deleted, then it does not create a new command and it returns NULL. ObjProc should have arguments and result that match the type Tcl_ObjCmdProc:
When proc is invoked the clientData and interp parameters will be copies of the clientData and interp arguments given to Tcl_CreateObjCommand. Typically, clientData points to an application-specific data structure that describes what to do when the command procedure is invoked. Objc and objv describe the arguments to the command, objc giving the number of argument objects (including the command name) and objv giving the values of the arguments as objects. The objv array will contain objc+1 values; the first objc values point to the argument objects, and the last value is NULL.typedef int Tcl_ObjCmdProc( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *objv[]);
ObjProc must return an integer code that is either TCL_OK, TCL_ERROR, TCL_RETURN, TCL_BREAK, or TCL_CONTINUE. See the Tcl overview man page for details on what these codes mean. Most normal commands will only return TCL_OK or TCL_ERROR. In addition, proc must set interp->objResult to point to an object; in the case of a TCL_OK return code this gives the result of the command, and in the case of TCL_ERROR it gives an error message. The Tcl_GetObjResult and Tcl_SetObjResult procedures provide an easy interface for getting and setting the result object; for details about how the interp->objResult field is managed, see the man page for Tcl_SetObjResult. Before invoking a command procedure, Tcl_Eval sets interp->objResult to point to an object representing an empty string, so simple commands can return an empty result by doing nothing at all.
The contents of the objv array belong to Tcl and are not guaranteed to persist once proc returns: proc should not modify them, nor should it set interp->objResult to point to one of the objv values. Call Tcl_SetObjResult if you want to return something from the objv array.
DeleteProc will be invoked when (if) name is deleted. This can occur through a call to Tcl_DeleteCommand or Tcl_DeleteInterp, or by replacing name in another call to Tcl_CreateObjCommand or Tcl_CreateCommand. DeleteProc is invoked before the command is deleted, and gives the application an opportunity to release any structures associated with the command. DeleteProc should have arguments and result that match the type Tcl_CmdDeleteProc:
The clientData argument will be the same as the clientData argument passed to Tcl_CreateObjCommand.typedef void Tcl_CmdDeleteProc(ClientData clientData);
Copyright © 1989-1994 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.