| 1 | '\" |
| 2 | '\" Copyright (c) 1996-1997 Sun Microsystems, Inc. |
| 3 | '\" |
| 4 | '\" See the file "license.terms" for information on usage and redistribution |
| 5 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 6 | '\" |
| 7 | '\" RCS: @(#) $Id: CrtObjCmd.3,v 1.7.2.1 2004/05/05 20:54:47 dkf Exp $ |
| 8 | '\" |
| 9 | '\" The definitions below are for supplemental macros used in Tcl/Tk |
| 10 | '\" manual entries. |
| 11 | '\" |
| 12 | '\" .AP type name in/out ?indent? |
| 13 | '\" Start paragraph describing an argument to a library procedure. |
| 14 | '\" type is type of argument (int, etc.), in/out is either "in", "out", |
| 15 | '\" or "in/out" to describe whether procedure reads or modifies arg, |
| 16 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be |
| 17 | '\" needed; use .AS below instead) |
| 18 | '\" |
| 19 | '\" .AS ?type? ?name? |
| 20 | '\" Give maximum sizes of arguments for setting tab stops. Type and |
| 21 | '\" name are examples of largest possible arguments that will be passed |
| 22 | '\" to .AP later. If args are omitted, default tab stops are used. |
| 23 | '\" |
| 24 | '\" .BS |
| 25 | '\" Start box enclosure. From here until next .BE, everything will be |
| 26 | '\" enclosed in one large box. |
| 27 | '\" |
| 28 | '\" .BE |
| 29 | '\" End of box enclosure. |
| 30 | '\" |
| 31 | '\" .CS |
| 32 | '\" Begin code excerpt. |
| 33 | '\" |
| 34 | '\" .CE |
| 35 | '\" End code excerpt. |
| 36 | '\" |
| 37 | '\" .VS ?version? ?br? |
| 38 | '\" Begin vertical sidebar, for use in marking newly-changed parts |
| 39 | '\" of man pages. The first argument is ignored and used for recording |
| 40 | '\" the version when the .VS was added, so that the sidebars can be |
| 41 | '\" found and removed when they reach a certain age. If another argument |
| 42 | '\" is present, then a line break is forced before starting the sidebar. |
| 43 | '\" |
| 44 | '\" .VE |
| 45 | '\" End of vertical sidebar. |
| 46 | '\" |
| 47 | '\" .DS |
| 48 | '\" Begin an indented unfilled display. |
| 49 | '\" |
| 50 | '\" .DE |
| 51 | '\" End of indented unfilled display. |
| 52 | '\" |
| 53 | '\" .SO |
| 54 | '\" Start of list of standard options for a Tk widget. The |
| 55 | '\" options follow on successive lines, in four columns separated |
| 56 | '\" by tabs. |
| 57 | '\" |
| 58 | '\" .SE |
| 59 | '\" End of list of standard options for a Tk widget. |
| 60 | '\" |
| 61 | '\" .OP cmdName dbName dbClass |
| 62 | '\" Start of description of a specific option. cmdName gives the |
| 63 | '\" option's name as specified in the class command, dbName gives |
| 64 | '\" the option's name in the option database, and dbClass gives |
| 65 | '\" the option's class in the option database. |
| 66 | '\" |
| 67 | '\" .UL arg1 arg2 |
| 68 | '\" Print arg1 underlined, then print arg2 normally. |
| 69 | '\" |
| 70 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ |
| 71 | '\" |
| 72 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. |
| 73 | .if t .wh -1.3i ^B |
| 74 | .nr ^l \n(.l |
| 75 | .ad b |
| 76 | '\" # Start an argument description |
| 77 | .de AP |
| 78 | .ie !"\\$4"" .TP \\$4 |
| 79 | .el \{\ |
| 80 | . ie !"\\$2"" .TP \\n()Cu |
| 81 | . el .TP 15 |
| 82 | .\} |
| 83 | .ta \\n()Au \\n()Bu |
| 84 | .ie !"\\$3"" \{\ |
| 85 | \&\\$1 \\fI\\$2\\fP (\\$3) |
| 86 | .\".b |
| 87 | .\} |
| 88 | .el \{\ |
| 89 | .br |
| 90 | .ie !"\\$2"" \{\ |
| 91 | \&\\$1 \\fI\\$2\\fP |
| 92 | .\} |
| 93 | .el \{\ |
| 94 | \&\\fI\\$1\\fP |
| 95 | .\} |
| 96 | .\} |
| 97 | .. |
| 98 | '\" # define tabbing values for .AP |
| 99 | .de AS |
| 100 | .nr )A 10n |
| 101 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n |
| 102 | .nr )B \\n()Au+15n |
| 103 | .\" |
| 104 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n |
| 105 | .nr )C \\n()Bu+\\w'(in/out)'u+2n |
| 106 | .. |
| 107 | .AS Tcl_Interp Tcl_CreateInterp in/out |
| 108 | '\" # BS - start boxed text |
| 109 | '\" # ^y = starting y location |
| 110 | '\" # ^b = 1 |
| 111 | .de BS |
| 112 | .br |
| 113 | .mk ^y |
| 114 | .nr ^b 1u |
| 115 | .if n .nf |
| 116 | .if n .ti 0 |
| 117 | .if n \l'\\n(.lu\(ul' |
| 118 | .if n .fi |
| 119 | .. |
| 120 | '\" # BE - end boxed text (draw box now) |
| 121 | .de BE |
| 122 | .nf |
| 123 | .ti 0 |
| 124 | .mk ^t |
| 125 | .ie n \l'\\n(^lu\(ul' |
| 126 | .el \{\ |
| 127 | .\" Draw four-sided box normally, but don't draw top of |
| 128 | .\" box if the box started on an earlier page. |
| 129 | .ie !\\n(^b-1 \{\ |
| 130 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 131 | .\} |
| 132 | .el \}\ |
| 133 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 134 | .\} |
| 135 | .\} |
| 136 | .fi |
| 137 | .br |
| 138 | .nr ^b 0 |
| 139 | .. |
| 140 | '\" # VS - start vertical sidebar |
| 141 | '\" # ^Y = starting y location |
| 142 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) |
| 143 | .de VS |
| 144 | .if !"\\$2"" .br |
| 145 | .mk ^Y |
| 146 | .ie n 'mc \s12\(br\s0 |
| 147 | .el .nr ^v 1u |
| 148 | .. |
| 149 | '\" # VE - end of vertical sidebar |
| 150 | .de VE |
| 151 | .ie n 'mc |
| 152 | .el \{\ |
| 153 | .ev 2 |
| 154 | .nf |
| 155 | .ti 0 |
| 156 | .mk ^t |
| 157 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' |
| 158 | .sp -1 |
| 159 | .fi |
| 160 | .ev |
| 161 | .\} |
| 162 | .nr ^v 0 |
| 163 | .. |
| 164 | '\" # Special macro to handle page bottom: finish off current |
| 165 | '\" # box/sidebar if in box/sidebar mode, then invoked standard |
| 166 | '\" # page bottom macro. |
| 167 | .de ^B |
| 168 | .ev 2 |
| 169 | 'ti 0 |
| 170 | 'nf |
| 171 | .mk ^t |
| 172 | .if \\n(^b \{\ |
| 173 | .\" Draw three-sided box if this is the box's first page, |
| 174 | .\" draw two sides but no top otherwise. |
| 175 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 176 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 177 | .\} |
| 178 | .if \\n(^v \{\ |
| 179 | .nr ^x \\n(^tu+1v-\\n(^Yu |
| 180 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c |
| 181 | .\} |
| 182 | .bp |
| 183 | 'fi |
| 184 | .ev |
| 185 | .if \\n(^b \{\ |
| 186 | .mk ^y |
| 187 | .nr ^b 2 |
| 188 | .\} |
| 189 | .if \\n(^v \{\ |
| 190 | .mk ^Y |
| 191 | .\} |
| 192 | .. |
| 193 | '\" # DS - begin display |
| 194 | .de DS |
| 195 | .RS |
| 196 | .nf |
| 197 | .sp |
| 198 | .. |
| 199 | '\" # DE - end display |
| 200 | .de DE |
| 201 | .fi |
| 202 | .RE |
| 203 | .sp |
| 204 | .. |
| 205 | '\" # SO - start of list of standard options |
| 206 | .de SO |
| 207 | .SH "STANDARD OPTIONS" |
| 208 | .LP |
| 209 | .nf |
| 210 | .ta 5.5c 11c |
| 211 | .ft B |
| 212 | .. |
| 213 | '\" # SE - end of list of standard options |
| 214 | .de SE |
| 215 | .fi |
| 216 | .ft R |
| 217 | .LP |
| 218 | See the \\fBoptions\\fR manual entry for details on the standard options. |
| 219 | .. |
| 220 | '\" # OP - start of full description for a single option |
| 221 | .de OP |
| 222 | .LP |
| 223 | .nf |
| 224 | .ta 4c |
| 225 | Command-Line Name: \\fB\\$1\\fR |
| 226 | Database Name: \\fB\\$2\\fR |
| 227 | Database Class: \\fB\\$3\\fR |
| 228 | .fi |
| 229 | .IP |
| 230 | .. |
| 231 | '\" # CS - begin code excerpt |
| 232 | .de CS |
| 233 | .RS |
| 234 | .nf |
| 235 | .ta .25i .5i .75i 1i |
| 236 | .. |
| 237 | '\" # CE - end code excerpt |
| 238 | .de CE |
| 239 | .fi |
| 240 | .RE |
| 241 | .. |
| 242 | .de UL |
| 243 | \\$1\l'|0\(ul'\\$2 |
| 244 | .. |
| 245 | .TH Tcl_CreateObjCommand 3 8.0 Tcl "Tcl Library Procedures" |
| 246 | .BS |
| 247 | .SH NAME |
| 248 | Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_DeleteCommandFromToken, Tcl_GetCommandInfo, Tcl_GetCommandInfoFromToken, Tcl_SetCommandInfo, Tcl_SetCommandInfoFromToken, Tcl_GetCommandName, Tcl_GetCommandFullName, Tcl_GetCommandFromObj \- implement new commands in C |
| 249 | .SH SYNOPSIS |
| 250 | .nf |
| 251 | \fB#include <tcl.h>\fR |
| 252 | .sp |
| 253 | Tcl_Command |
| 254 | \fBTcl_CreateObjCommand\fR(\fIinterp, cmdName, proc, clientData, deleteProc\fR) |
| 255 | .sp |
| 256 | int |
| 257 | \fBTcl_DeleteCommand\fR(\fIinterp, cmdName\fR) |
| 258 | .sp |
| 259 | int |
| 260 | \fBTcl_DeleteCommandFromToken\fR(\fIinterp, token\fR) |
| 261 | .sp |
| 262 | int |
| 263 | \fBTcl_GetCommandInfo\fR(\fIinterp, cmdName, infoPtr\fR) |
| 264 | .sp |
| 265 | int |
| 266 | \fBTcl_SetCommandInfo\fR(\fIinterp, cmdName, infoPtr\fR) |
| 267 | .sp |
| 268 | .VS 8.4 |
| 269 | int |
| 270 | \fBTcl_GetCommandInfoFromToken\fR(\fItoken, infoPtr\fR) |
| 271 | .sp |
| 272 | int |
| 273 | \fBTcl_SetCommandInfoFromToken\fR(\fItoken, infoPtr\fR) |
| 274 | .VE |
| 275 | .sp |
| 276 | .VS 8.4 |
| 277 | CONST char * |
| 278 | .VE |
| 279 | \fBTcl_GetCommandName\fR(\fIinterp, token\fR) |
| 280 | .sp |
| 281 | void |
| 282 | \fBTcl_GetCommandFullName\fR(\fIinterp, token, objPtr\fR) |
| 283 | .sp |
| 284 | Tcl_Command |
| 285 | \fBTcl_GetCommandFromObj\fR(\fIinterp, objPtr\fR) |
| 286 | .SH ARGUMENTS |
| 287 | .AS Tcl_ObjCmdProc *deleteProc in/out |
| 288 | .AP Tcl_Interp *interp in |
| 289 | Interpreter in which to create a new command or that contains a command. |
| 290 | .VS 8.4 |
| 291 | .AP char *cmdName in |
| 292 | .VE |
| 293 | Name of command. |
| 294 | .AP Tcl_ObjCmdProc *proc in |
| 295 | Implementation of the new command: \fIproc\fR will be called whenever |
| 296 | \fIcmdName\fR is invoked as a command. |
| 297 | .AP ClientData clientData in |
| 298 | Arbitrary one-word value to pass to \fIproc\fR and \fIdeleteProc\fR. |
| 299 | .AP Tcl_CmdDeleteProc *deleteProc in |
| 300 | Procedure to call before \fIcmdName\fR is deleted from the interpreter; |
| 301 | allows for command-specific cleanup. If NULL, then no procedure is |
| 302 | called before the command is deleted. |
| 303 | .AP Tcl_Command token in |
| 304 | Token for command, returned by previous call to \fBTcl_CreateObjCommand\fR. |
| 305 | The command must not have been deleted. |
| 306 | .AP Tcl_CmdInfo *infoPtr in/out |
| 307 | Pointer to structure containing various information about a |
| 308 | Tcl command. |
| 309 | .AP Tcl_Obj *objPtr in |
| 310 | Object containing the name of a Tcl command. |
| 311 | .BE |
| 312 | .SH DESCRIPTION |
| 313 | .PP |
| 314 | \fBTcl_CreateObjCommand\fR defines a new command in \fIinterp\fR |
| 315 | and associates it with procedure \fIproc\fR |
| 316 | such that whenever \fIname\fR is |
| 317 | invoked as a Tcl command (e.g., via a call to \fBTcl_EvalObjEx\fR) |
| 318 | the Tcl interpreter will call \fIproc\fR to process the command. |
| 319 | .PP |
| 320 | \fBTcl_CreateObjCommand\fR deletes any existing command |
| 321 | \fIname\fR already associated with the interpreter |
| 322 | (however see below for an exception where the existing command |
| 323 | is not deleted). |
| 324 | It returns a token that may be used to refer |
| 325 | to the command in subsequent calls to \fBTcl_GetCommandName\fR. |
| 326 | If \fIname\fR contains any \fB::\fR namespace qualifiers, |
| 327 | then the command is added to the specified namespace; |
| 328 | otherwise the command is added to the global namespace. |
| 329 | If \fBTcl_CreateObjCommand\fR is called for an interpreter that is in |
| 330 | the process of being deleted, then it does not create a new command |
| 331 | and it returns NULL. |
| 332 | \fIproc\fR should have arguments and result that match the type |
| 333 | \fBTcl_ObjCmdProc\fR: |
| 334 | .CS |
| 335 | typedef int Tcl_ObjCmdProc( |
| 336 | ClientData \fIclientData\fR, |
| 337 | Tcl_Interp *\fIinterp\fR, |
| 338 | int \fIobjc\fR, |
| 339 | .VS |
| 340 | Tcl_Obj *CONST \fIobjv\fR[]); |
| 341 | .CE |
| 342 | When \fIproc\fR is invoked, the \fIclientData\fR and \fIinterp\fR parameters |
| 343 | will be copies of the \fIclientData\fR and \fIinterp\fR arguments given to |
| 344 | \fBTcl_CreateObjCommand\fR. Typically, \fIclientData\fR points to an |
| 345 | application-specific data structure that describes what to do when the |
| 346 | command procedure is invoked. \fIObjc\fR and \fIobjv\fR describe the |
| 347 | arguments to the command, \fIobjc\fR giving the number of argument objects |
| 348 | (including the command name) and \fIobjv\fR giving the values of the |
| 349 | arguments. The \fIobjv\fR array will contain \fIobjc\fR values, pointing to |
| 350 | the argument objects. Unlike \fIargv\fR[\fIargv\fR] used in a |
| 351 | string-based command procedure, \fIobjv\fR[\fIobjc\fR] will not contain NULL. |
| 352 | .PP |
| 353 | Additionally, when \fIproc\fR is invoked, it must not modify the contents |
| 354 | of the \fIobjv\fR array by assigning new pointer values to any element of the |
| 355 | array (for example, \fIobjv\fR[\fB2\fR] = \fBNULL\fR) because this will |
| 356 | cause memory to be lost and the runtime stack to be corrupted. The |
| 357 | \fBCONST\fR in the declaration of \fIobjv\fR will cause ANSI-compliant |
| 358 | compilers to report any such attempted assignment as an error. However, |
| 359 | it is acceptable to modify the internal representation of any individual |
| 360 | object argument. For instance, the user may call |
| 361 | \fBTcl_GetIntFromObj\fR on \fIobjv\fR[\fB2\fR] to obtain the integer |
| 362 | representation of that object; that call may change the type of the object |
| 363 | that \fIobjv\fR[\fB2\fR] points at, but will not change where |
| 364 | \fIobjv\fR[\fB2\fR] points. |
| 365 | .VE |
| 366 | .PP |
| 367 | \fIproc\fR must return an integer code that is either \fBTCL_OK\fR, |
| 368 | \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR. |
| 369 | See the Tcl overview man page |
| 370 | for details on what these codes mean. Most normal commands will only |
| 371 | return \fBTCL_OK\fR or \fBTCL_ERROR\fR. |
| 372 | In addition, if \fIproc\fR needs to return a non-empty result, |
| 373 | it can call \fBTcl_SetObjResult\fR to set the interpreter's result. |
| 374 | In the case of a \fBTCL_OK\fR return code this gives the result |
| 375 | of the command, |
| 376 | and in the case of \fBTCL_ERROR\fR this gives an error message. |
| 377 | Before invoking a command procedure, |
| 378 | \fBTcl_EvalObjEx\fR sets interpreter's result to |
| 379 | point to an object representing an empty string, so simple |
| 380 | commands can return an empty result by doing nothing at all. |
| 381 | .PP |
| 382 | The contents of the \fIobjv\fR array belong to Tcl and are not |
| 383 | guaranteed to persist once \fIproc\fR returns: \fIproc\fR should |
| 384 | not modify them. |
| 385 | Call \fBTcl_SetObjResult\fR if you want |
| 386 | to return something from the \fIobjv\fR array. |
| 387 | .PP |
| 388 | Ordinarily, \fBTcl_CreateObjCommand\fR deletes any existing command |
| 389 | \fIname\fR already associated with the interpreter. |
| 390 | However, if the existing command was created by a previous call to |
| 391 | \fBTcl_CreateCommand\fR, |
| 392 | \fBTcl_CreateObjCommand\fR does not delete the command |
| 393 | but instead arranges for the Tcl interpreter to call the |
| 394 | \fBTcl_ObjCmdProc\fR \fIproc\fR in the future. |
| 395 | The old string-based \fBTcl_CmdProc\fR associated with the command |
| 396 | is retained and its address can be obtained by subsequent |
| 397 | \fBTcl_GetCommandInfo\fR calls. This is done for backwards compatibility. |
| 398 | .PP |
| 399 | \fIDeleteProc\fR will be invoked when (if) \fIname\fR is deleted. |
| 400 | This can occur through a call to \fBTcl_DeleteCommand\fR, |
| 401 | \fBTcl_DeleteCommandFromToken\fR, or \fBTcl_DeleteInterp\fR, |
| 402 | or by replacing \fIname\fR in another call to \fBTcl_CreateObjCommand\fR. |
| 403 | \fIDeleteProc\fR is invoked before the command is deleted, and gives the |
| 404 | application an opportunity to release any structures associated |
| 405 | with the command. \fIDeleteProc\fR should have arguments and |
| 406 | result that match the type \fBTcl_CmdDeleteProc\fR: |
| 407 | .CS |
| 408 | typedef void Tcl_CmdDeleteProc(ClientData \fIclientData\fR); |
| 409 | .CE |
| 410 | The \fIclientData\fR argument will be the same as the \fIclientData\fR |
| 411 | argument passed to \fBTcl_CreateObjCommand\fR. |
| 412 | .PP |
| 413 | \fBTcl_DeleteCommand\fR deletes a command from a command interpreter. |
| 414 | Once the call completes, attempts to invoke \fIcmdName\fR in |
| 415 | \fIinterp\fR will result in errors. |
| 416 | If \fIcmdName\fR isn't bound as a command in \fIinterp\fR then |
| 417 | \fBTcl_DeleteCommand\fR does nothing and returns -1; otherwise |
| 418 | it returns 0. |
| 419 | There are no restrictions on \fIcmdName\fR: it may refer to |
| 420 | a built-in command, an application-specific command, or a Tcl procedure. |
| 421 | If \fIname\fR contains any \fB::\fR namespace qualifiers, |
| 422 | the command is deleted from the specified namespace. |
| 423 | .PP |
| 424 | Given a token returned by \fBTcl_CreateObjCommand\fR, |
| 425 | \fBTcl_DeleteCommandFromToken\fR deletes the command |
| 426 | from a command interpreter. |
| 427 | It will delete a command even if that command has been renamed. |
| 428 | Once the call completes, attempts to invoke the command in |
| 429 | \fIinterp\fR will result in errors. |
| 430 | If the command corresponding to \fItoken\fR |
| 431 | has already been deleted from \fIinterp\fR then |
| 432 | \fBTcl_DeleteCommand\fR does nothing and returns -1; |
| 433 | otherwise it returns 0. |
| 434 | .PP |
| 435 | \fBTcl_GetCommandInfo\fR checks to see whether its \fIcmdName\fR argument |
| 436 | exists as a command in \fIinterp\fR. |
| 437 | \fIcmdName\fR may include \fB::\fR namespace qualifiers |
| 438 | to identify a command in a particular namespace. |
| 439 | If the command is not found, then it returns 0. |
| 440 | Otherwise it places information about the command |
| 441 | in the \fBTcl_CmdInfo\fR structure |
| 442 | pointed to by \fIinfoPtr\fR and returns 1. |
| 443 | A \fBTcl_CmdInfo\fR structure has the following fields: |
| 444 | .CS |
| 445 | typedef struct Tcl_CmdInfo { |
| 446 | int isNativeObjectProc; |
| 447 | Tcl_ObjCmdProc *objProc; |
| 448 | ClientData objClientData; |
| 449 | Tcl_CmdProc *proc; |
| 450 | ClientData clientData; |
| 451 | Tcl_CmdDeleteProc *deleteProc; |
| 452 | ClientData deleteData; |
| 453 | Tcl_Namespace *namespacePtr; |
| 454 | } Tcl_CmdInfo; |
| 455 | .CE |
| 456 | The \fIisNativeObjectProc\fR field has the value 1 |
| 457 | if \fBTcl_CreateObjCommand\fR was called to register the command; |
| 458 | it is 0 if only \fBTcl_CreateCommand\fR was called. |
| 459 | It allows a program to determine whether it is faster to |
| 460 | call \fIobjProc\fR or \fIproc\fR: |
| 461 | \fIobjProc\fR is normally faster |
| 462 | if \fIisNativeObjectProc\fR has the value 1. |
| 463 | The fields \fIobjProc\fR and \fIobjClientData\fR |
| 464 | have the same meaning as the \fIproc\fR and \fIclientData\fR |
| 465 | arguments to \fBTcl_CreateObjCommand\fR; |
| 466 | they hold information about the object-based command procedure |
| 467 | that the Tcl interpreter calls to implement the command. |
| 468 | The fields \fIproc\fR and \fIclientData\fR |
| 469 | hold information about the string-based command procedure |
| 470 | that implements the command. |
| 471 | If \fBTcl_CreateCommand\fR was called for this command, |
| 472 | this is the procedure passed to it; |
| 473 | otherwise, this is a compatibility procedure |
| 474 | registered by \fBTcl_CreateObjCommand\fR |
| 475 | that simply calls the command's |
| 476 | object-based procedure after converting its string arguments to Tcl objects. |
| 477 | The field \fIdeleteData\fR is the ClientData value |
| 478 | to pass to \fIdeleteProc\fR; it is normally the same as |
| 479 | \fIclientData\fR but may be set independently using the |
| 480 | \fBTcl_SetCommandInfo\fR procedure. |
| 481 | The field \fInamespacePtr\fR holds a pointer to the |
| 482 | Tcl_Namespace that contains the command. |
| 483 | .PP |
| 484 | \fBTcl_GetCommandInfoFromToken\fR is identical to |
| 485 | \fBTcl_GetCommandInfo\fR except that it uses a command token returned |
| 486 | from \fBTcl_CreateObjCommand\fR in place of the command name. If the |
| 487 | \fItoken\fR parameter is NULL, it returns 0; otherwise, it returns 1 |
| 488 | and fills in the structure designated by \fIinfoPtr\fR. |
| 489 | .PP |
| 490 | \fBTcl_SetCommandInfo\fR is used to modify the procedures and |
| 491 | ClientData values associated with a command. |
| 492 | Its \fIcmdName\fR argument is the name of a command in \fIinterp\fR. |
| 493 | \fIcmdName\fR may include \fB::\fR namespace qualifiers |
| 494 | to identify a command in a particular namespace. |
| 495 | If this command does not exist then \fBTcl_SetCommandInfo\fR returns 0. |
| 496 | Otherwise, it copies the information from \fI*infoPtr\fR to |
| 497 | Tcl's internal structure for the command and returns 1. |
| 498 | .PP |
| 499 | \fBTcl_SetCommandInfoFromToken\fR is identical to |
| 500 | \fBTcl_SetCommandInfo\fR except that it takes a command token as |
| 501 | returned by \fBTcl_CreateObjCommand\fR instead of the command name. |
| 502 | If the \fItoken\fR parameter is NULL, it returns 0. Otherwise, it |
| 503 | copies the information from \fI*infoPtr\fR to Tcl's internal structure |
| 504 | for the command and returns 1. |
| 505 | .PP |
| 506 | Note that \fBTcl_SetCommandInfo\fR and |
| 507 | \fBTcl_SetCommandInfoFromToken\fR both allow the ClientData for a |
| 508 | command's deletion procedure to be given a different value than the |
| 509 | ClientData for its command procedure. |
| 510 | .PP |
| 511 | Note that neither \fBTcl_SetCommandInfo\fR nor |
| 512 | \fBTcl_SetCommandInfoFromToken\fR will change a command's namespace. |
| 513 | Use \fBTcl_Eval\fR to call the \fBrename\fR command to do that. |
| 514 | .PP |
| 515 | \fBTcl_GetCommandName\fR provides a mechanism for tracking commands |
| 516 | that have been renamed. |
| 517 | Given a token returned by \fBTcl_CreateObjCommand\fR |
| 518 | when the command was created, \fBTcl_GetCommandName\fR returns the |
| 519 | string name of the command. If the command has been renamed since it |
| 520 | was created, then \fBTcl_GetCommandName\fR returns the current name. |
| 521 | This name does not include any \fB::\fR namespace qualifiers. |
| 522 | The command corresponding to \fItoken\fR must not have been deleted. |
| 523 | The string returned by \fBTcl_GetCommandName\fR is in dynamic memory |
| 524 | owned by Tcl and is only guaranteed to retain its value as long as the |
| 525 | command isn't deleted or renamed; callers should copy the string if |
| 526 | they need to keep it for a long time. |
| 527 | .PP |
| 528 | \fBTcl_GetCommandFullName\fR produces the fully-qualified name |
| 529 | of a command from a command token. |
| 530 | The name, including all namespace prefixes, |
| 531 | is appended to the object specified by \fIobjPtr\fP. |
| 532 | .PP |
| 533 | \fBTcl_GetCommandFromObj\fR returns a token for the command |
| 534 | specified by the name in a \fBTcl_Obj\fP. |
| 535 | The command name is resolved relative to the current namespace. |
| 536 | Returns NULL if the command is not found. |
| 537 | .SH "SEE ALSO" |
| 538 | Tcl_CreateCommand, Tcl_ResetResult, Tcl_SetObjResult |
| 539 | |
| 540 | .SH KEYWORDS |
| 541 | bind, command, create, delete, namespace, object |