Example #1
0
    // This is called when the python extension is first loaded.
    public static void LoadExtension()
    {
        WriteOutput("IronPython-Mdbg Extension loaded");

        g_python = new IronPython.Hosting.PythonEngine();
        g_pythonInteractive = new PythonCommandLine(g_python);

        string ver = g_python.GetType().Assembly.GetName().Version.ToString();
        WriteOutput(MDbgOutputConstants.Ignore, "Binding against Iron Python version: " + ver);

        // Get original load command, for use in python load command.
        g_origLoadCmd = Shell.Commands.Lookup("load");

        // Add Python extension commands to Shell.Commands.
        MDbgAttributeDefinedCommand.AddCommandsFromType(Shell.Commands, typeof(PythonExt));

        // Add the current directory to the python engine search path.
        
        g_python.AddToPath(Environment.CurrentDirectory);

        // Tell Python about some key objects in Mdbg. Python can then reflect over these objects.
        // These variables live at some special "main" scope. Python Modules imported via python "import" command
        // can't access them. Use PythonEngine.ExecuteFile() to import files such that they can access these vars.
        g_python.Globals.Add("CommandBase", IronPython.Runtime.Types.ReflectedType.FromType(typeof(CommandBase)));

        // Hook input + output. This is redirecting pythons 'sys.stdout, sys.stdin, sys.stderr' 
        // This connects python's sys.stdout --> Stream --> Mdbg console.
        MDbgStream s = new MDbgStream();

        // New codepaths for IronPython 1.0
        g_python.SetStandardInput(s);
        g_python.SetStandardOutput(s);
        g_python.SetStandardError(s);
    }
Example #2
0
    // This is called when the python extension is first loaded.
    public static void LoadExtension()
    {
        WriteOutput("IronPython-Mdbg Extension loaded");

        g_python            = new IronPython.Hosting.PythonEngine();
        g_pythonInteractive = new PythonCommandLine(g_python);

        string ver = g_python.GetType().Assembly.GetName().Version.ToString();

        WriteOutput(MDbgOutputConstants.Ignore, "Binding against Iron Python version: " + ver);

        // Get original load command, for use in python load command.
        g_origLoadCmd = Shell.Commands.Lookup("load");

        // Add Python extension commands to Shell.Commands.
        MDbgAttributeDefinedCommand.AddCommandsFromType(Shell.Commands, typeof(PythonExt));

        // Add the current directory to the python engine search path.

        g_python.AddToPath(Environment.CurrentDirectory);

        // Tell Python about some key objects in Mdbg. Python can then reflect over these objects.
        // These variables live at some special "main" scope. Python Modules imported via python "import" command
        // can't access them. Use PythonEngine.ExecuteFile() to import files such that they can access these vars.
        g_python.Globals.Add("CommandBase", IronPython.Runtime.Types.ReflectedType.FromType(typeof(CommandBase)));

        // Hook input + output. This is redirecting pythons 'sys.stdout, sys.stdin, sys.stderr'
        // This connects python's sys.stdout --> Stream --> Mdbg console.
        MDbgStream s = new MDbgStream();

        // New codepaths for IronPython 1.0
        g_python.SetStandardInput(s);
        g_python.SetStandardOutput(s);
        g_python.SetStandardError(s);
    }