From c5c59e9a432a488cdce149270f16c5b321e7e42a Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 23 Sep 2008 19:49:52 +0000 Subject: [PATCH] Updated to IronPython 2.0 Beta 5. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3553 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/PythonCompiler.cs | 2 +- .../PythonBinding/Project/Src/PythonAstWalker.cs | 3 ++- .../Project/Src/PythonCompilerError.cs | 2 +- .../Project/Src/PythonCompilerSink.cs | 2 +- .../PythonBinding/Project/Src/PythonParser.cs | 8 ++++---- .../Project/Src/PythonVariableResolver.cs | 14 ++++---------- .../Python/PythonBinding/Project/Src/TextEditor.cs | 5 +++-- .../Test/Console/PythonConsoleHostTests.cs | 2 +- .../Test/Parsing/IronPythonParserTestFixture.cs | 2 +- 9 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs b/src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs index e148a2cc46..3aefc51b26 100644 --- a/src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs +++ b/src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs @@ -93,7 +93,7 @@ namespace ICSharpCode.Python.Build.Tasks public void Compile() { // Compile the source files to a dll first. - ScriptEngine engine = PythonEngine.CurrentEngine; + ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); PythonDictionary dictionary = new PythonDictionary(); dictionary.setdefault("mainModule", mainFile); string outputAssemblyDll = Path.ChangeExtension(outputAssembly, ".dll"); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs index a98c90b390..b122602db0 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs @@ -5,10 +5,11 @@ // $Revision$ // +using Microsoft.Scripting; using System; using System.Collections.Generic; using System.IO; -using System.Scripting; + using ICSharpCode.SharpDevelop.Dom; using IronPython.Compiler; using IronPython.Compiler.Ast; diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs index fafde5525d..6ce250980e 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs @@ -5,8 +5,8 @@ // $Revision$ // +using Microsoft.Scripting; using System; -using System.Scripting; namespace ICSharpCode.PythonBinding { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs index f8074f012f..50450edd04 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs @@ -5,9 +5,9 @@ // $Revision$ // +using Microsoft.Scripting; using System; using System.Collections.Generic; -using System.Scripting; namespace ICSharpCode.PythonBinding { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonParser.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonParser.cs index c13819b383..34e770d0da 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonParser.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonParser.cs @@ -5,11 +5,11 @@ // $Revision$ // -using Microsoft.Scripting.Compilers; +using Microsoft.Scripting; using Microsoft.Scripting.Hosting; +using Microsoft.Scripting.Runtime; using System; using System.IO; -using System.Scripting; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; @@ -83,13 +83,13 @@ namespace ICSharpCode.PythonBinding if (fileContent != null) { // try { if (scriptEngine == null) { - scriptEngine = PythonEngine.CurrentEngine; + scriptEngine = IronPython.Hosting.Python.CreateEngine(); } PythonCompilerSink sink = new PythonCompilerSink(); SourceUnit source = DefaultContext.DefaultPythonContext.CreateFileUnit(fileName, fileContent); CompilerContext context = new CompilerContext(source, new PythonCompilerOptions(), sink); - Parser parser = Parser.CreateParser(context, new PythonEngineOptions()); + Parser parser = Parser.CreateParser(context, new PythonOptions()); PythonAst ast = parser.ParseFile(false); PythonAstWalker walker = new PythonAstWalker(projectContent, fileName); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonVariableResolver.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonVariableResolver.cs index 69902c8cfb..688723da12 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonVariableResolver.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonVariableResolver.cs @@ -5,11 +5,11 @@ // $Revision$ // -using Microsoft.Scripting.Compilers; +using Microsoft.Scripting; using Microsoft.Scripting.Hosting; +using Microsoft.Scripting.Runtime; using System; using System.Collections.Generic; -using System.Scripting; using System.Text; using ICSharpCode.SharpDevelop.Dom; @@ -51,20 +51,14 @@ namespace ICSharpCode.PythonBinding public string Resolve(string variableName, string fileName, string code) { if (code != null) { - ScriptEngine scriptEngine = PythonEngine.CurrentEngine; + ScriptEngine scriptEngine = IronPython.Hosting.Python.CreateEngine(); PythonCompilerSink sink = new PythonCompilerSink(); SourceUnit source = DefaultContext.DefaultPythonContext.CreateFileUnit(fileName, code); CompilerContext context = new CompilerContext(source, new PythonCompilerOptions(), sink); - Parser parser = Parser.CreateParser(context, new PythonEngineOptions()); + Parser parser = Parser.CreateParser(context, new PythonOptions()); PythonAst ast = parser.ParseFile(false); return Resolve(variableName, ast); - - //PythonCompilerSink sink = new PythonCompilerSink(); - //CompilerContext context = new CompilerContext(null, sink); - //Parser parser = Parser.FromString(null, context, code); - //Statement statement = parser.ParseFileInput(); - //return Resolve(variableName, statement); } return null; } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs index a5c45d4f0b..428f113e35 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs @@ -16,6 +16,7 @@ namespace ICSharpCode.PythonBinding public class TextEditor : ITextEditor { delegate string GetLineInvoker(int index); + delegate void WriteInvoker(string text, Color color); TextEditorControl textEditorControl; TextArea textArea; @@ -56,8 +57,8 @@ namespace ICSharpCode.PythonBinding public void Write(string text, Color backgroundColour) { if (textEditorControl.InvokeRequired) { - Action action = Write; - textEditorControl.Invoke(action, new object[] {text, backgroundColour}); + WriteInvoker invoker = new WriteInvoker(Write); + textEditorControl.Invoke(invoker, new object[] {text, backgroundColour}); } else { int offset = textEditorControl.Document.PositionToOffset(new TextLocation(Column, Line)); textEditorControl.ActiveTextAreaControl.TextArea.InsertString(text); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs index 7713be07ac..d5d73eb2f4 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs @@ -37,7 +37,7 @@ namespace PythonBinding.Tests.Console textEditor = new TextEditor(textEditorControl); host = new DerivedPythonConsoleHost(textEditor); - ScriptRuntime runtime = ScriptRuntime.Create(); + ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime(); // expectedEngine = runtime.GetEngine(typeof(PythonContext)); // host.ScriptEngineToReturn = expectedEngine; // engine = host.CallCreateEngine(); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/IronPythonParserTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/IronPythonParserTestFixture.cs index 0eb0aa5538..658732db68 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/IronPythonParserTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/IronPythonParserTestFixture.cs @@ -5,7 +5,7 @@ // $Revision$ // -using Microsoft.Scripting.Compilers; +using Microsoft.Scripting.Runtime; using System; using System.CodeDom; using System.CodeDom.Compiler;