Posted to tcl by aspect at Thu Dec 17 01:10:40 GMT 2015view raw

  1. int CreateQualifiedCmd(
  2. Tcl_Interp* interp,
  3. char* cmdName,
  4. Tcl_ObjCmdProc* proc,
  5. ClientData clientData,
  6. Tcl_CmdDeleteProc* deleteProc)
  7. {
  8. Tcl_Namespace* nsPtr;
  9. Tcl_DString ds;
  10. Tcl_Command cmdToken;
  11.  
  12. nsPtr = Tcl_GetCurrentNamespace(interp);
  13. Tcl_DStringInit(&ds);
  14. if(nsPtr->parent != NULL) { // root's fullName is "::", which we don't want doubled
  15. Tcl_DStringAppend(ds, nsPtr->fullName);
  16. }
  17. Tcl_DStringAppend(ds, "::");
  18. Tcl_DStringAppend(ds, cmdName);
  19.  
  20. cmdToken = Tcl_CreateObjCommand(interp, Tcl_DStringValue(ds), proc, clientData, deleteProc);
  21.  
  22. Tcl_SetResult(interp, Tcl_DStringValue(ds), TCL_VOLATILE);
  23. Tcl_DStringFree(ds);
  24.  
  25. return TCL_OK;
  26. }
  27.