ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
    ClientData clientData;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *CONST objv[];
{
    Tcl_CmdInfo info;
    int ret;

    DUMP1("call ip_rbNamespaceObjCmd");
    DUMP2("objc = %d", objc);
    DUMP2("objv[0] = '%s'", Tcl_GetString(objv[0]));
    DUMP2("objv[1] = '%s'", Tcl_GetString(objv[1]));
    if (!Tcl_GetCommandInfo(interp, ORIG_NAMESPACE_CMD, &(info))) {
      DUMP1("fail to get "ORIG_NAMESPACE_CMD);
        Tcl_ResetResult(interp);
        Tcl_AppendResult(interp,
                         "invalid command name \"namespace\"", (char*)NULL);
        return TCL_ERROR;
    }

    rbtk_eventloop_depth++;
    DUMP2("namespace wrapper enter depth == %d", rbtk_eventloop_depth);

    if (info.isNativeObjectProc) {
#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6
        DUMP1("call a native-object-proc");
        ret = (*(info.objProc))(info.objClientData, interp, objc, objv);
#else
        /* Tcl8.6 or later */
        int i;
        Tcl_Obj **cp_objv;
        char org_ns_cmd_name[] = ORIG_NAMESPACE_CMD;

        DUMP1("call a native-object-proc for tcl8.6 or later");
        cp_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc + 1));

        cp_objv[0] = Tcl_NewStringObj(org_ns_cmd_name, strlen(org_ns_cmd_name));
        for(i = 1; i < objc; i++) {
            cp_objv[i] = objv[i];
        }
        cp_objv[objc] = (Tcl_Obj *)NULL;

        /* ret = Tcl_EvalObjv(interp, objc, cp_objv, TCL_EVAL_DIRECT); */
        ret = Tcl_EvalObjv(interp, objc, cp_objv, 0);

        ckfree((char*)cp_objv);
#endif
    } else {
        /* string interface */
        int i;
        char **argv;

        DUMP1("call with the string-interface");
        /* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */
        argv = RbTk_ALLOC_N(char *, (objc + 1));
#if 0 /* use Tcl_Preserve/Release */
	Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
#endif

        for(i = 0; i < objc; i++) {
            /* argv[i] = Tcl_GetString(objv[i]); */
            argv[i] = Tcl_GetStringFromObj(objv[i], (int*)NULL);
        }
        argv[objc] = (char *)NULL;

        ret = (*(info.proc))(info.clientData, interp,
                              objc, (CONST84 char **)argv);

#if 0 /* use Tcl_EventuallyFree */
	Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
#else
#if 0 /* use Tcl_Preserve/Release */
	Tcl_Release((ClientData)argv); /* XXXXXXXX */
#else
        /* Tcl_Free((char*)argv); */
        ckfree((char*)argv);
#endif
#endif
    }

    DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth);
    rbtk_eventloop_depth--;

    DUMP1("end of ip_rbNamespaceObjCmd");
    return ret;
}
ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
    ClientData clientData;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *CONST objv[];
{
    Tcl_CmdInfo info;
    int ret;

    DUMP1("call ip_rbNamespaceObjCmd");
    DUMP2("objc = %d", objc);
    DUMP2("objv[0] = '%s'", Tcl_GetString(objv[0]));
    DUMP2("objv[1] = '%s'", Tcl_GetString(objv[1]));
    if (!Tcl_GetCommandInfo(interp, ORIG_NAMESPACE_CMD, &(info))) {
      DUMP1("fail to get "ORIG_NAMESPACE_CMD);
        Tcl_ResetResult(interp);
        Tcl_AppendResult(interp,
                         "invalid command name \"namespace\"", (char*)NULL);
        return TCL_ERROR;
    }

    rbtk_eventloop_depth++;
    DUMP2("namespace wrapper enter depth == %d", rbtk_eventloop_depth);

    if (info.isNativeObjectProc) {
#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6
        DUMP1("call a native-object-proc");
        ret = (*(info.objProc))(info.objClientData, interp, objc, objv);
#else
         
        int i;
        Tcl_Obj **cp_objv;
        char org_ns_cmd_name[] = ORIG_NAMESPACE_CMD;

        DUMP1("call a native-object-proc for tcl8.6 or later");
        cp_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc + 1));

        cp_objv[0] = Tcl_NewStringObj(org_ns_cmd_name, strlen(org_ns_cmd_name));
        for(i = 1; i < objc; i++) {
            cp_objv[i] = objv[i];
        }
        cp_objv[objc] = (Tcl_Obj *)NULL;

         
        ret = Tcl_EvalObjv(interp, objc, cp_objv, 0);

        ckfree((char*)cp_objv);
#endif
    } else {
         
        int i;
        char **argv;

        DUMP1("call with the string-interface");
         
        argv = RbTk_ALLOC_N(char *, (objc + 1));
#if 0  
	Tcl_Preserve((ClientData)argv);  
#endif

        for(i = 0; i < objc; i++) {
             
            argv[i] = Tcl_GetStringFromObj(objv[i], (int*)NULL);
        }
        argv[objc] = (char *)NULL;

        ret = (*(info.proc))(info.clientData, interp,
                              objc, (CONST84 char **)argv);

#if 0  
	Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC);  
#else
#if 0  
	Tcl_Release((ClientData)argv);  
#else
         
        ckfree((char*)argv);
#endif
#endif
    }

    DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth);
    rbtk_eventloop_depth--;

    DUMP1("end of ip_rbNamespaceObjCmd");
    return ret;
}