MCPcopy Create free account
hub / github.com/SimHacker/micropolis / Tcl_CreateCommand

Function Tcl_CreateCommand

micropolis-activity/src/tcl/tclbasic.c:331–365  ·  view source on GitHub ↗
(interp, cmdName, proc, clientData, deleteProc)

Source from the content-addressed store, hash-verified

329 * manual entry for details on the calling sequence.
330 *
331 *----------------------------------------------------------------------
332 */
333
334void
335Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc)
336 Tcl_Interp *interp; /* Token for command interpreter (returned
337 * by a previous call to Tcl_CreateInterp). */
338 char *cmdName; /* Name of command. */
339 Tcl_CmdProc *proc; /* Command procedure to associate with
340 * cmdName. */
341 ClientData clientData; /* Arbitrary one-word value to pass to proc. */
342 Tcl_CmdDeleteProc *deleteProc;
343 /* If not NULL, gives a procedure to call when
344 * this command is deleted. */
345{
346 Interp *iPtr = (Interp *) interp;
347 register Command *cmdPtr;
348 Tcl_HashEntry *hPtr;
349 int new;
350
351 hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new);
352 if (!new) {
353 /*
354 * Command already exists: delete the old one.
355 */
356
357 cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
358 if (cmdPtr->deleteProc != NULL) {
359 (*cmdPtr->deleteProc)(cmdPtr->clientData);
360 }
361 } else {
362 cmdPtr = (Command *) ckalloc(sizeof(Command));
363 Tcl_SetHashValue(hPtr, cmdPtr);
364 }
365 cmdPtr->proc = proc;
366 cmdPtr->clientData = clientData;
367 cmdPtr->deleteProc = deleteProc;
368}

Callers 15

Tcl_ProcCmdFunction · 0.70
Tcl_InitHistoryFunction · 0.70
Tcl_InitMemoryFunction · 0.70
mainFunction · 0.70
w_map.cFile · 0.50
CamCmdFunction · 0.50
w_cam.cFile · 0.50
GraphViewCmdFunction · 0.50
w_graph.cFile · 0.50
DateViewCmdFunction · 0.50
w_date.cFile · 0.50
w_sim.cFile · 0.50

Calls

no outgoing calls

Tested by 1

mainFunction · 0.56