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

int CreateQualifiedCmd(
        Tcl_Interp* interp, 
        char* cmdName,
        Tcl_ObjCmdProc* proc,
        ClientData clientData,
        Tcl_CmdDeleteProc* deleteProc)
{
    Tcl_Namespace* nsPtr;
    Tcl_DString ds;
    Tcl_Command cmdToken;

    nsPtr = Tcl_GetCurrentNamespace(interp);
    Tcl_DStringInit(&ds);
    if(nsPtr->parent != NULL) { // root's fullName is "::", which we don't want doubled
        Tcl_DStringAppend(ds, nsPtr->fullName);
    }
    Tcl_DStringAppend(ds, "::");
    Tcl_DStringAppend(ds, cmdName);

    cmdToken = Tcl_CreateObjCommand(interp, Tcl_DStringValue(ds), proc, clientData, deleteProc);

    Tcl_SetResult(interp, Tcl_DStringValue(ds), TCL_VOLATILE);
    Tcl_DStringFree(ds);

    return TCL_OK;
}