Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-11-26 04:48:59 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-11-26 04:52:40 +0400
commit892f10fb55955782ebceccd153ce7e43dd49519a (patch)
tree582ed1c23d4dab092030101272964299773177e2
parent41eb50f540d83e9b275f6e0d2086087d4b9d64fb (diff)
[PyBinding] Add IronPython to the supported runtimes.
-rw-r--r--extras/PyBinding/PyBinding/Makefile2
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Gui/PythonOptionsWidget.cs1
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/AbstractPythonRuntime.cs2
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/IPythonRuntime.cs6
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/IronPythonRuntime.cs96
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/Python25Runtime.cs11
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/Python26Runtime.cs11
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.Runtime/Python27Runtime.cs11
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.addin.xml1
-rw-r--r--extras/PyBinding/PyBinding/PyBinding.csproj4
-rw-r--r--extras/PyBinding/PyBinding/PyBinding/PythonExecutionHandler.cs22
-rw-r--r--extras/PyBinding/PyBinding/PyBinding/PythonHelper.cs9
12 files changed, 171 insertions, 5 deletions
diff --git a/extras/PyBinding/PyBinding/Makefile b/extras/PyBinding/PyBinding/Makefile
index 31c563a9b0..f2f98f2fc8 100644
--- a/extras/PyBinding/PyBinding/Makefile
+++ b/extras/PyBinding/PyBinding/Makefile
@@ -88,9 +88,11 @@ FILES = \
PyBinding.Parser/PythonResolver.cs \
PyBinding.Runtime/AbstractPythonRuntime.cs \
PyBinding.Runtime/IPythonRuntime.cs \
+ PyBinding.Runtime/IronPythonRuntime.cs \
PyBinding.Runtime/Python25Runtime.cs \
PyBinding.Runtime/Python26Runtime.cs \
PyBinding.Runtime/Python27Runtime.cs \
+ PyBinding/IronPythonExecutionHandler.cs \
PyBinding/PythonConfiguration.cs \
PyBinding/PythonExecutionCommand.cs \
PyBinding/PythonExecutionHandler.cs \
diff --git a/extras/PyBinding/PyBinding/PyBinding.Gui/PythonOptionsWidget.cs b/extras/PyBinding/PyBinding/PyBinding.Gui/PythonOptionsWidget.cs
index 5739f1261c..423a100534 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Gui/PythonOptionsWidget.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Gui/PythonOptionsWidget.cs
@@ -60,6 +60,7 @@ namespace PyBinding.Gui
m_RuntimeListStore.AppendValues ("Python 2.5", typeof (Python25Runtime));
m_RuntimeListStore.AppendValues ("Python 2.6", typeof (Python26Runtime));
m_RuntimeListStore.AppendValues ("Python 2.7", typeof (Python27Runtime));
+ m_RuntimeListStore.AppendValues ("IronPython", typeof (IronPythonRuntime));
}
public string DefaultModule {
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/AbstractPythonRuntime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/AbstractPythonRuntime.cs
index aabc0d3ab7..417748f03c 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Runtime/AbstractPythonRuntime.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/AbstractPythonRuntime.cs
@@ -28,6 +28,7 @@ using System.Text;
using MonoDevelop.Core;
using MonoDevelop.Core.Serialization;
+using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using PyBinding;
@@ -66,6 +67,7 @@ namespace PyBinding.Runtime
public abstract object Clone ();
public abstract string[] GetArguments (PythonConfiguration config);
+ public abstract IExecutionHandler GetExecutionHandler ();
protected virtual string Resolve (string commandName)
{
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/IPythonRuntime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/IPythonRuntime.cs
index 3c1696d1c1..7a93c7b31b 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Runtime/IPythonRuntime.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/IPythonRuntime.cs
@@ -21,6 +21,7 @@
// THE SOFTWARE.
using System;
+using MonoDevelop.Core.Execution;
using PyBinding.Compiler;
@@ -59,6 +60,11 @@ namespace PyBinding.Runtime
}
/// <summary>
+ /// Gets the associated execution handler for this specific runtime.
+ /// </summary>
+ IExecutionHandler GetExecutionHandler ();
+
+ /// <summary>
/// Builds a list of arguments to pass to the runtime for running
/// a project with the passed configuration.
/// </summary>
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/IronPythonRuntime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/IronPythonRuntime.cs
new file mode 100644
index 0000000000..cc937b1928
--- /dev/null
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/IronPythonRuntime.cs
@@ -0,0 +1,96 @@
+// IronPythonRuntime.cs
+//
+// Copyright (c) 2011 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Collections.Generic;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
+using MonoDevelop.Core.Serialization;
+using MonoDevelop.Projects;
+
+using PyBinding.Compiler;
+
+namespace PyBinding.Runtime
+{
+ public class IronPythonRuntime : AbstractPythonRuntime
+ {
+ static readonly string RuntimeName = "IronPython";
+
+ [ItemProperty ("path")]
+ string path = String.Empty;
+
+ public override IPythonCompiler Compiler {
+ get {
+ return null;
+ }
+ }
+
+ public override string Name {
+ get {
+ return RuntimeName;
+ }
+ }
+
+ public override string Path {
+ get {
+ if (String.IsNullOrEmpty (path))
+ path = Resolve ("ipy.exe");
+
+ return path;
+ }
+ set {
+ path = value;
+ }
+ }
+
+ public override object Clone ()
+ {
+ return new IronPythonRuntime () {
+ Path = path
+ };
+ }
+
+ IExecutionHandler handler;
+
+ public override IExecutionHandler GetExecutionHandler ()
+ {
+ if (handler == null)
+ handler = new IronPythonExecutionHandler ();
+
+ return handler;
+ }
+
+
+ public override string[] GetArguments (PythonConfiguration config)
+ {
+ var args = new List<string> ();
+
+ if (!String.IsNullOrEmpty (config.Module))
+ args.Add (System.IO.Path.ChangeExtension (config.Module, "py"));
+
+ if (!String.IsNullOrEmpty (config.CommandLineParameters))
+ args.Add (config.CommandLineParameters);
+
+ return args.ToArray ();
+ }
+ }
+}
+
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python25Runtime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python25Runtime.cs
index 2235a0d838..0813ef9722 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python25Runtime.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python25Runtime.cs
@@ -25,6 +25,7 @@ using System.Collections.Generic;
using System.IO;
using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using MonoDevelop.Core.Serialization;
using MonoDevelop.Projects.CodeGeneration;
@@ -81,6 +82,16 @@ namespace PyBinding.Runtime
};
}
+ IExecutionHandler handler;
+
+ public override IExecutionHandler GetExecutionHandler ()
+ {
+ if (handler == null)
+ handler = new CPythonExecutionHandler ();
+
+ return handler;
+ }
+
public override string[] GetArguments (PythonConfiguration config)
{
List<string> args = new List<string> ();
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python26Runtime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python26Runtime.cs
index 346718bb83..f044fb4fa5 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python26Runtime.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python26Runtime.cs
@@ -25,6 +25,7 @@ using System.Collections.Generic;
using System.IO;
using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using MonoDevelop.Core.Serialization;
using MonoDevelop.Projects.CodeGeneration;
@@ -81,6 +82,16 @@ namespace PyBinding.Runtime
Path = this.Path
};
}
+
+ IExecutionHandler handler;
+
+ public override IExecutionHandler GetExecutionHandler ()
+ {
+ if (handler == null)
+ handler = new CPythonExecutionHandler ();
+
+ return handler;
+ }
public override string[] GetArguments (PythonConfiguration config)
{
diff --git a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python27Runtime.cs b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python27Runtime.cs
index 27260a34e7..860aed7120 100644
--- a/extras/PyBinding/PyBinding/PyBinding.Runtime/Python27Runtime.cs
+++ b/extras/PyBinding/PyBinding/PyBinding.Runtime/Python27Runtime.cs
@@ -26,6 +26,7 @@ using System.Collections.Generic;
using System.IO;
using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using MonoDevelop.Core.Serialization;
using MonoDevelop.Projects.CodeGeneration;
@@ -82,6 +83,16 @@ namespace PyBinding.Runtime
Path = this.Path
};
}
+
+ IExecutionHandler handler;
+
+ public override IExecutionHandler GetExecutionHandler ()
+ {
+ if (handler == null)
+ handler = new CPythonExecutionHandler ();
+
+ return handler;
+ }
public override string[] GetArguments (PythonConfiguration config)
{
diff --git a/extras/PyBinding/PyBinding/PyBinding.addin.xml b/extras/PyBinding/PyBinding/PyBinding.addin.xml
index dd654c0966..97d6b611c1 100644
--- a/extras/PyBinding/PyBinding/PyBinding.addin.xml
+++ b/extras/PyBinding/PyBinding/PyBinding.addin.xml
@@ -99,6 +99,7 @@
<DataType class = "PyBinding.Runtime.Python25Runtime"/>
<DataType class = "PyBinding.Runtime.Python26Runtime"/>
<DataType class = "PyBinding.Runtime.Python27Runtime"/>
+ <DataType class = "PyBinding.Runtime.IronPythonRuntime"/>
<DataType class = "PyBinding.Compiler.Python25Compiler"/>
</Extension>
diff --git a/extras/PyBinding/PyBinding/PyBinding.csproj b/extras/PyBinding/PyBinding/PyBinding.csproj
index 95d5ee4570..364fc4382e 100644
--- a/extras/PyBinding/PyBinding/PyBinding.csproj
+++ b/extras/PyBinding/PyBinding/PyBinding.csproj
@@ -183,6 +183,8 @@
<Compile Include="PyBinding.Parser\PythonResolver.cs" />
<Compile Include="PyBinding.Parser\PythonExpressionFinder.cs" />
<Compile Include="PyBinding.Runtime\Python27Runtime.cs" />
+ <Compile Include="PyBinding.Runtime\IronPythonRuntime.cs" />
+ <Compile Include="PyBinding\IronPythonExecutionHandler.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\EmptyPyProject.xpt.xml">
@@ -245,4 +247,4 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
-</Project> \ No newline at end of file
+</Project>
diff --git a/extras/PyBinding/PyBinding/PyBinding/PythonExecutionHandler.cs b/extras/PyBinding/PyBinding/PyBinding/PythonExecutionHandler.cs
index e9a4b9ce06..dd718f880b 100644
--- a/extras/PyBinding/PyBinding/PyBinding/PythonExecutionHandler.cs
+++ b/extras/PyBinding/PyBinding/PyBinding/PythonExecutionHandler.cs
@@ -30,7 +30,23 @@ using MonoDevelop.Core.Execution;
namespace PyBinding
{
- public class PythonExecutionHandler: NativePlatformExecutionHandler
+ public class PythonExecutionHandler: IExecutionHandler
+ {
+ public bool CanExecute (ExecutionCommand command)
+ {
+ return command is PythonExecutionCommand;
+ }
+
+ public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
+ {
+ var config = ((PythonExecutionCommand)command).Configuration;
+ return config.Runtime.GetExecutionHandler ().Execute (command, console);
+ }
+
+ }
+
+ // This is our default handler (used by Python2.5/2.6/2.7)
+ public class CPythonExecutionHandler : NativePlatformExecutionHandler
{
public override bool CanExecute (ExecutionCommand command)
{
@@ -38,11 +54,11 @@ namespace PyBinding
}
public override IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
- {
+ {
PythonExecutionCommand cmd = (PythonExecutionCommand) command;
string[] args = cmd.Configuration.Runtime.GetArguments (cmd.Configuration);
- string dir = Path.GetFullPath (cmd.Configuration.OutputDirectory);
+ string dir = Path.GetFullPath (cmd.Configuration.OutputDirectory);
NativeExecutionCommand ncmd = new NativeExecutionCommand (cmd.Configuration.Runtime.Path, string.Join (" ", args), dir, cmd.Configuration.EnvironmentVariables);
return base.Execute (ncmd, console);
diff --git a/extras/PyBinding/PyBinding/PyBinding/PythonHelper.cs b/extras/PyBinding/PyBinding/PyBinding/PythonHelper.cs
index 194755229c..7fb3cb575d 100644
--- a/extras/PyBinding/PyBinding/PyBinding/PythonHelper.cs
+++ b/extras/PyBinding/PyBinding/PyBinding/PythonHelper.cs
@@ -129,6 +129,13 @@ namespace PyBinding
}
catch {}
+ try {
+ return new IronPythonRuntime () {
+ Path = Which ("ipy.exe")
+ };
+ }
+ catch {}
+
// look for "python" and what version it is
return null;
@@ -145,4 +152,4 @@ namespace PyBinding
throw new FileNotFoundException ("Could not locate python executable");
}
}
-} \ No newline at end of file
+}