From e088a9f6162dc1e374bc508b8c6cfe5ee7493f09 Mon Sep 17 00:00:00 2001 From: EvilBeaver Date: Sun, 25 May 2014 11:19:53 +0400 Subject: [PATCH 1/3] console host removed --- src/1Script.sln | 105 +++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/src/1Script.sln b/src/1Script.sln index 68643e0..db00551 100644 --- a/src/1Script.sln +++ b/src/1Script.sln @@ -1,59 +1,46 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{4585BA5D-9EC4-4C89-8250-2033D2AC2999}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptEngine", "ScriptEngine\ScriptEngine.csproj", "{F062D1D9-D307-492A-A56B-FF3C55F8F6C0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "oscript", "oscript\oscript.csproj", "{2590E2BB-CC1F-4775-80ED-451F45C9A4F1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|x86.ActiveCfg = Debug|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|x86.Build.0 = Debug|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Any CPU.Build.0 = Release|Any CPU - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Mixed Platforms.Build.0 = Release|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|x86.ActiveCfg = Release|x86 - {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|x86.Build.0 = Release|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|x86.ActiveCfg = Debug|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|x86.Build.0 = Debug|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Any CPU.Build.0 = Release|Any CPU - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Mixed Platforms.Build.0 = Release|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.ActiveCfg = Release|x86 - {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.Build.0 = Release|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Debug|x86.ActiveCfg = Debug|Any CPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|Any CPU.Build.0 = Release|Any CPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|Mixed Platforms.Build.0 = Release|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|x86.ActiveCfg = Release|x86 - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{4585BA5D-9EC4-4C89-8250-2033D2AC2999}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptEngine", "ScriptEngine\ScriptEngine.csproj", "{F062D1D9-D307-492A-A56B-FF3C55F8F6C0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|x86.ActiveCfg = Debug|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Debug|x86.Build.0 = Debug|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Any CPU.Build.0 = Release|Any CPU + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|Mixed Platforms.Build.0 = Release|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|x86.ActiveCfg = Release|x86 + {4585BA5D-9EC4-4C89-8250-2033D2AC2999}.Release|x86.Build.0 = Release|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|x86.ActiveCfg = Debug|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Debug|x86.Build.0 = Debug|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Any CPU.Build.0 = Release|Any CPU + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Mixed Platforms.Build.0 = Release|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.ActiveCfg = Release|x86 + {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From 30bf50b869606d6ca56391e6c67369438e89d27f Mon Sep 17 00:00:00 2001 From: EvilBeaver Date: Sun, 25 May 2014 11:21:24 +0400 Subject: [PATCH 2/3] oscript removed --- src/oscript/AppBehavior.cs | 12 ---- src/oscript/BehaviorSelector.cs | 46 ------------- src/oscript/ExecuteScriptBehavior.cs | 66 ------------------- src/oscript/MeasureBehavior.cs | 27 -------- src/oscript/Program.cs | 34 ---------- src/oscript/Properties/AssemblyInfo.cs | 36 ----------- src/oscript/ShowCompiledBehavior.cs | 26 -------- src/oscript/ShowUsageBehavior.cs | 29 --------- src/oscript/oscript.csproj | 89 -------------------------- 9 files changed, 365 deletions(-) delete mode 100644 src/oscript/AppBehavior.cs delete mode 100644 src/oscript/BehaviorSelector.cs delete mode 100644 src/oscript/ExecuteScriptBehavior.cs delete mode 100644 src/oscript/MeasureBehavior.cs delete mode 100644 src/oscript/Program.cs delete mode 100644 src/oscript/Properties/AssemblyInfo.cs delete mode 100644 src/oscript/ShowCompiledBehavior.cs delete mode 100644 src/oscript/ShowUsageBehavior.cs delete mode 100644 src/oscript/oscript.csproj diff --git a/src/oscript/AppBehavior.cs b/src/oscript/AppBehavior.cs deleted file mode 100644 index f4c9251..0000000 --- a/src/oscript/AppBehavior.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace oscript -{ - abstract class AppBehavior - { - public abstract int Execute(); - } -} diff --git a/src/oscript/BehaviorSelector.cs b/src/oscript/BehaviorSelector.cs deleted file mode 100644 index 1ad8ea0..0000000 --- a/src/oscript/BehaviorSelector.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace oscript -{ - static class BehaviorSelector - { - public static AppBehavior Select(string[] cmdLineArgs) - { - if (cmdLineArgs.Length == 0) - { - return new ShowUsageBehavior(); - } - else - { - if (!cmdLineArgs[0].StartsWith("-")) - { - var path = cmdLineArgs[0]; - return new ExecuteScriptBehavior(path, cmdLineArgs.Skip(1).ToArray()); - } - else if (cmdLineArgs[0].ToLower() == "-measure") - { - if (cmdLineArgs.Length > 1) - { - var path = cmdLineArgs[1]; - return new MeasureBehavior(path, cmdLineArgs.Skip(2).ToArray()); - } - } - else if (cmdLineArgs[0].ToLower() == "-compile") - { - if (cmdLineArgs.Length > 1) - { - var path = cmdLineArgs[1]; - return new ShowCompiledBehavior(path); - } - } - } - - return new ShowUsageBehavior(); - - } - } - -} diff --git a/src/oscript/ExecuteScriptBehavior.cs b/src/oscript/ExecuteScriptBehavior.cs deleted file mode 100644 index cd8d10d..0000000 --- a/src/oscript/ExecuteScriptBehavior.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using ScriptEngine; - -namespace oscript -{ - class ExecuteScriptBehavior : AppBehavior, IHostApplication - { - string[] _scriptArgs; - string _path; - - public ExecuteScriptBehavior(string path, string[] args) - { - _scriptArgs = args; - _path = path; - } - - public override int Execute() - { - if (!System.IO.File.Exists(_path)) - { - throw new System.IO.FileNotFoundException("Script file is not found", _path); - } - - var source = ScriptSourceFactory.FileBased(_path); - var process = Process.Create(this, source); - return process.Start(); - } - - #region IHostApplication Members - - public void Echo(string text) - { - Console.WriteLine(text); - } - - public void ShowExceptionInfo(Exception exc) - { - Console.WriteLine(exc.ToString()); - } - - public bool InputString(out string result, int maxLen) - { - if (maxLen == 0) - { - result = Console.ReadLine(); - } - else - { - result = Console.ReadLine().Substring(0, maxLen); - } - - return result.Length > 0; - - } - - public string[] GetCommandLineArguments() - { - return _scriptArgs; - } - - #endregion - } -} diff --git a/src/oscript/MeasureBehavior.cs b/src/oscript/MeasureBehavior.cs deleted file mode 100644 index 5992208..0000000 --- a/src/oscript/MeasureBehavior.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace oscript -{ - class MeasureBehavior : ExecuteScriptBehavior - { - public MeasureBehavior(string path, string[] args) : base(path,args) - { - - } - - public override int Execute() - { - var sw = new System.Diagnostics.Stopwatch(); - Console.WriteLine("Script started: " + DateTime.Now.ToString() + "\n"); - sw.Start(); - int exitCode = base.Execute(); - sw.Stop(); - Console.WriteLine("\nScript completed: " + DateTime.Now.ToString()); - Console.WriteLine("\nDuration: " + sw.Elapsed.ToString()); - return exitCode; - } - } -} diff --git a/src/oscript/Program.cs b/src/oscript/Program.cs deleted file mode 100644 index cda0971..0000000 --- a/src/oscript/Program.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace oscript -{ - class Program - { - static int Main(string[] args) - { - int returnCode; - var behavior = BehaviorSelector.Select(args); - try - { - returnCode = behavior.Execute(); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - returnCode = 1; - } - - if (System.Diagnostics.Debugger.IsAttached) - { - Console.Write("Press any key to continue. . . "); - Console.ReadKey(true); - } - - return returnCode; - - } - } -} diff --git a/src/oscript/Properties/AssemblyInfo.cs b/src/oscript/Properties/AssemblyInfo.cs deleted file mode 100644 index d465a31..0000000 --- a/src/oscript/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("oscript")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("oscript")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b57ae6b4-3701-4062-b81b-25d326383b4f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/oscript/ShowCompiledBehavior.cs b/src/oscript/ShowCompiledBehavior.cs deleted file mode 100644 index 4a69e36..0000000 --- a/src/oscript/ShowCompiledBehavior.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using ScriptEngine; - -namespace oscript -{ - class ShowCompiledBehavior : AppBehavior - { - string _path; - - public ShowCompiledBehavior(string path) - { - _path = path; - } - - public override int Execute() - { - var source = ScriptSourceFactory.FileBased(_path); - var writer = new ScriptEngine.Compiler.ModuleWriter(); - writer.Write(Console.Out, source); - return 0; - } - } -} diff --git a/src/oscript/ShowUsageBehavior.cs b/src/oscript/ShowUsageBehavior.cs deleted file mode 100644 index b6b5c70..0000000 --- a/src/oscript/ShowUsageBehavior.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace oscript -{ - class ShowUsageBehavior : AppBehavior - { - public override int Execute() - { - Console.WriteLine("1Script Execution Engine. Version {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); - Console.WriteLine(); - Console.WriteLine("Usage:"); - Console.WriteLine(); - Console.WriteLine("I. Script execution: oscript.exe [script arguments..]"); - Console.WriteLine(); - Console.WriteLine("II. Special mode: oscript.exe [script arguments..]"); - Console.WriteLine("Mode can be one of these:"); - Console.WriteLine(" {0,-11}measures execution time", "-measure"); - Console.WriteLine(" {0,-11}shows compiled module without execution", "-compile"); - //Console.WriteLine(); - //Console.WriteLine("III. Build standalone executable: oscript.exe -build "); - //Console.WriteLine("Builds a standalone executable module based on script specified"); - - return 0; - } - } -} diff --git a/src/oscript/oscript.csproj b/src/oscript/oscript.csproj deleted file mode 100644 index 3bb7ba0..0000000 --- a/src/oscript/oscript.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - - Debug - AnyCPU - {2590E2BB-CC1F-4775-80ED-451F45C9A4F1} - Exe - Properties - oscript - oscript - v4.0 - 512 - SAK - SAK - SAK - SAK - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - - - - - - - {f062d1d9-d307-492a-a56b-ff3c55f8f6c0} - ScriptEngine - - - - - \ No newline at end of file From eecb1d285e42c55335e733048c5f4ff9cc79a8a7 Mon Sep 17 00:00:00 2001 From: EvilBeaver Date: Sun, 25 May 2014 12:19:54 +0400 Subject: [PATCH 3/3] =?UTF-8?q?COM=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=D1=8B=20ActiveScript=20=D0=B8=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=B7=D0=B0=D0=B3=D0=BB?= =?UTF-8?q?=D1=83=D1=88=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/1Script.sln | 24 + .../ConsoleApplication1.csproj | 79 +++ src/ConsoleApplication1/Program.cs | 17 + .../Properties/AssemblyInfo.cs | 36 ++ src/oscript/ActiveScriptImpl.cs | 89 +++ src/oscript/ActiveXInterfaces.cs | 552 ++++++++++++++++++ src/oscript/Properties/AssemblyInfo.cs | 36 ++ src/oscript/oscript.csproj | 74 +++ 8 files changed, 907 insertions(+) create mode 100644 src/ConsoleApplication1/ConsoleApplication1.csproj create mode 100644 src/ConsoleApplication1/Program.cs create mode 100644 src/ConsoleApplication1/Properties/AssemblyInfo.cs create mode 100644 src/oscript/ActiveScriptImpl.cs create mode 100644 src/oscript/ActiveXInterfaces.cs create mode 100644 src/oscript/Properties/AssemblyInfo.cs create mode 100644 src/oscript/oscript.csproj diff --git a/src/1Script.sln b/src/1Script.sln index db00551..d8777d4 100644 --- a/src/1Script.sln +++ b/src/1Script.sln @@ -5,6 +5,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptEngine", "ScriptEngine\ScriptEngine.csproj", "{F062D1D9-D307-492A-A56B-FF3C55F8F6C0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "oscript", "oscript\oscript.csproj", "{F7C89194-ECDC-4C76-8418-407994209BE8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{4959854F-ED1C-454D-906C-286D4868618A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +43,26 @@ Global {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|Mixed Platforms.Build.0 = Release|x86 {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.ActiveCfg = Release|x86 {F062D1D9-D307-492A-A56B-FF3C55F8F6C0}.Release|x86.Build.0 = Release|x86 + {F7C89194-ECDC-4C76-8418-407994209BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {F7C89194-ECDC-4C76-8418-407994209BE8}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {F7C89194-ECDC-4C76-8418-407994209BE8}.Debug|x86.ActiveCfg = Debug|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Release|Any CPU.Build.0 = Release|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F7C89194-ECDC-4C76-8418-407994209BE8}.Release|x86.ActiveCfg = Release|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {4959854F-ED1C-454D-906C-286D4868618A}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {4959854F-ED1C-454D-906C-286D4868618A}.Debug|x86.ActiveCfg = Debug|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Release|Any CPU.Build.0 = Release|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4959854F-ED1C-454D-906C-286D4868618A}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ConsoleApplication1/ConsoleApplication1.csproj b/src/ConsoleApplication1/ConsoleApplication1.csproj new file mode 100644 index 0000000..c594879 --- /dev/null +++ b/src/ConsoleApplication1/ConsoleApplication1.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {4959854F-ED1C-454D-906C-286D4868618A} + Exe + Properties + ConsoleApplication1 + ConsoleApplication1 + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + {f7c89194-ecdc-4c76-8418-407994209be8} + oscript + + + + + \ No newline at end of file diff --git a/src/ConsoleApplication1/Program.cs b/src/ConsoleApplication1/Program.cs new file mode 100644 index 0000000..dc74ef0 --- /dev/null +++ b/src/ConsoleApplication1/Program.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ConsoleApplication1 +{ + class Program + { + static void Main(string[] args) + { + var t = Type.GetTypeFromCLSID(Guid.Parse("E8900E22-412F-45D3-9EA9-A216D416E872")); + var inst = (Oscript.Interop.IActiveScript) Activator.CreateInstance(t); + inst.Close(); + } + } +} diff --git a/src/ConsoleApplication1/Properties/AssemblyInfo.cs b/src/ConsoleApplication1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c9b661a --- /dev/null +++ b/src/ConsoleApplication1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleApplication1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApplication1")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e93dc274-f9bb-4877-bb99-b23baff3b7c0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/oscript/ActiveScriptImpl.cs b/src/oscript/ActiveScriptImpl.cs new file mode 100644 index 0000000..dfa1a3b --- /dev/null +++ b/src/oscript/ActiveScriptImpl.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace Oscript.Interop +{ + [ComVisible(true)] + [Guid("E8900E22-412F-45D3-9EA9-A216D416E872")] + [ProgId("OScript")] + [ClassInterface(ClassInterfaceType.None)] + public class ActiveScriptImpl : IActiveScript + { + public ActiveScriptImpl() + { + + } + + #region IActiveScript Members + + public void SetScriptSite(IActiveScriptSite site) + { + throw new NotImplementedException(); + } + + public void GetScriptSite(ref Guid riid, out IntPtr ppvObject) + { + throw new NotImplementedException(); + } + + public void SetScriptState(SCRIPTSTATE ss) + { + throw new NotImplementedException(); + } + + public void GetScriptState(out SCRIPTSTATE ss) + { + throw new NotImplementedException(); + } + + public void Close() + { + throw new NotImplementedException(); + } + + public void AddNamedItem(string name, uint flags) + { + throw new NotImplementedException(); + } + + public void AddTypeLib(ref Guid rguidTypeLib, uint major, uint minor, uint flags) + { + throw new NotImplementedException(); + } + + public void GetScriptDispatch(string itemName, out object ppdisp) + { + throw new NotImplementedException(); + } + + public void GetCurrentScriptThreadiD(out uint id) + { + throw new NotImplementedException(); + } + + public void GetScriptThreadID(uint threadID, out uint id) + { + throw new NotImplementedException(); + } + + public void GetScriptThreadState(uint id, out SCRIPTTHREADSTATE state) + { + throw new NotImplementedException(); + } + + public void InterruptScriptThread(uint id, ref System.Runtime.InteropServices.ComTypes.EXCEPINFO info, uint flags) + { + throw new NotImplementedException(); + } + + public void Clone(out IActiveScript item) + { + throw new NotImplementedException(); + } + + #endregion + } +} diff --git a/src/oscript/ActiveXInterfaces.cs b/src/oscript/ActiveXInterfaces.cs new file mode 100644 index 0000000..2770319 --- /dev/null +++ b/src/oscript/ActiveXInterfaces.cs @@ -0,0 +1,552 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Oscript.Interop +{ + #region Using directives. + // ---------------------------------------------------------------------- + + using System; + using System.Runtime.InteropServices; + using ComTypes = System.Runtime.InteropServices.ComTypes; + + // ---------------------------------------------------------------------- + #endregion + + ///////////////////////////////////////////////////////////////////////// + + /* + * A good series of articles for working with Scripting Host under .NET + * can be found at the DDJ: + * http://google.com/search?q=site%3Addj.com+%22.NET+Scripting+Hosts%22 + * + * Also, the Weblog of Eric Lippert contains good references: + * http://blogs.msdn.com/ericlippert + * + * Last, the Google group microsoft.public.scripting.hosting contains + * good resources: + * http://groups.google.com/group/microsoft.public.scripting.hosting + * + * The definitions can also be found at: + * http://msdn.microsoft.com/library/en-us/script56/html/f2afee5f-b930-4b32-b903-84ba41eb2d88.asp + */ + + ///////////////////////////////////////////////////////////////////////// + + /// + /// Interface IActiveScript. + /// + /// + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), + Guid(@"BB1A2AE1-A4F9-11cf-8F20-00805F2CD064")] + public interface IActiveScript + { + #region Interface members. + // ------------------------------------------------------------------ + + /// + /// Sets the script site. + /// + /// The site. + /// + void SetScriptSite( + [In, MarshalAs(UnmanagedType.Interface)] + IActiveScriptSite site); + + /// + /// Gets the script site. + /// + /// The riid. + /// The PPV object. + /// + void GetScriptSite( + ref Guid riid, + out IntPtr ppvObject); + + /// + /// Sets the state of the script. + /// + /// The ss. + /// + void SetScriptState( + SCRIPTSTATE ss); + + /// + /// Gets the state of the script. + /// + /// The ss. + /// + void GetScriptState( + out SCRIPTSTATE ss); + + /// + /// Closes this instance. + /// + /// + void Close(); + + /// + /// Adds the named item. + /// + /// The name. + /// The flags. + /// + void AddNamedItem( + [In, MarshalAs(UnmanagedType.BStr)] + string name, + [In, MarshalAs(UnmanagedType.U4)] + uint flags); + + /// + /// Adds the type lib. + /// + /// The rguid type lib. + /// The major. + /// The minor. + /// The flags. + /// + void AddTypeLib( + ref Guid rguidTypeLib, + uint major, + uint minor, + uint flags); + + /// + /// Gets the script dispatch. + /// + /// Name of the item. + /// The ppdisp. + /// + void GetScriptDispatch( + string itemName, + out object ppdisp); + + /// + /// Gets the current script threadi D. + /// + /// The ID. + /// + void GetCurrentScriptThreadiD( + out uint id); + + /// + /// Gets the script thread ID. + /// + /// The thread ID. + /// The ID. + /// + void GetScriptThreadID( + uint threadID, + out uint id); + + /// + /// Gets the state of the script thread. + /// + /// The ID. + /// The state. + /// + void GetScriptThreadState( + uint id, + out SCRIPTTHREADSTATE state); + + /// + /// Interrupts the script thread. + /// + /// The ID. + /// The info. + /// The flags. + /// + void InterruptScriptThread( + uint id, + ref ComTypes.EXCEPINFO info, + uint flags); + + /// + /// Clones the specified item. + /// + /// The item. + /// + void Clone( + out IActiveScript item); + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// Interface IActiveScriptParse. + /// + /// + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), + Guid(@"BB1A2AE2-A4F9-11cf-8F20-00805F2CD064")] + public interface IActiveScriptParse + { + #region Interface members. + // ------------------------------------------------------------------ + + /// + /// Inits the new. + /// + /// + void InitNew(); + + /// + /// Adds the scriptlet. + /// + /// Name of the default. + /// The code. + /// Name of the item. + /// Name of the sub item. + /// Name of the event. + /// The delimiter. + /// The source context cookie. + /// The starting line number. + /// The flags. + /// The name. + /// The info. + /// + void AddScriptlet( + string defaultName, + string code, + string itemName, + string subItemName, + string eventName, + string delimiter, + uint sourceContextCookie, + uint startingLineNumber, + uint flags, + out string name, + out ComTypes.EXCEPINFO info); + + /// + /// Parses the script text. + /// + /// LPCOLESTR pstrCode, address of scriptlet text. + /// LPCOLESTR pstrItemName, address of item name. + /// IUnknown *punkContext, address of debugging context. + /// LPCOLESTR pstrDelimiter, address of end-of-scriptlet delimiter. + /// DWORD_PTR dwSourceContextCookie, application-defined value for debugging. + /// ULONG ulStartingLineNumber, starting line number of the script. + /// int dwFlags, scriptlet flags. + /// VARIANT *pvarResult, address of buffer for results. + /// EXCEPINFO *pexcepinfo, address of buffer for error data. + /// + void ParseScriptText( + string code, + string itemName, + IntPtr context, + string delimiter, + uint sourceContextCookie, + uint startingLineNumber, + uint flags, + IntPtr result, + out ComTypes.EXCEPINFO info); + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// Interface IActiveScriptSite. + /// + /// + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), + Guid(@"DB01A1E3-A42B-11cf-8F20-00805F2CD064")] + public interface IActiveScriptSite + { + #region Interface members. + // ------------------------------------------------------------------ + + /// + /// Gets the LCID. + /// + /// The ID. + /// + void GetLCID( + out uint id); + + /// + /// Gets the item info. + /// + /// The name. + /// The return mask. + /// The item. + /// The ppti. + /// + void GetItemInfo( + [In, MarshalAs(UnmanagedType.BStr)] string name, + [In, MarshalAs(UnmanagedType.U4)] uint returnMask, + [Out, MarshalAs(UnmanagedType.IUnknown)] out object item, + IntPtr ppti); + + /// + /// Gets the doc version string. + /// + /// The v. + /// + void GetDocVersionString( + out string v); + + /// + /// Called when [script terminate]. + /// + /// The result. + /// The info. + /// + void OnScriptTerminate( + ref object result, + ref ComTypes.EXCEPINFO info); + + /// + /// Called when [state change]. + /// + /// The state. + /// + void OnStateChange( + SCRIPTSTATE state); + + /// + /// Called when [script error]. + /// + /// This should be casted to IActiveScriptError in the implementation + /// of this interface. I had errors when changing the parameter here to the + /// IActiveScriptError type. + /// + void OnScriptError( + [In, MarshalAs(UnmanagedType.IUnknown)] object err); + + /// + /// Called when [enter script]. + /// + /// + void OnEnterScript(); + + /// + /// Called when [leave script]. + /// + /// + void OnLeaveScript(); + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// Interface IActiveScriptError. + /// + /// + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), + Guid(@"EAE1BA61-A4ED-11cf-8F20-00805F2CD064")] + public interface IActiveScriptError + { + #region Interface members. + // ------------------------------------------------------------------ + + /// + /// Gets the exception info. + /// + /// The info. + /// + void GetExceptionInfo( + [Out, MarshalAs(UnmanagedType.Struct)] out ComTypes.EXCEPINFO info); + + + /// + /// Gets the source position. + /// + /// The source context. + /// The line number. + /// "-1" for unknown. + /// + void GetSourcePosition( + [Out, MarshalAs(UnmanagedType.U4)] out uint sourceContext, + [Out, MarshalAs(UnmanagedType.U4)] out uint lineNumber, + [Out, MarshalAs(UnmanagedType.U4)] out int characterPosition); + + /// + /// Gets the source line text. + /// + /// The source line. + /// + /// Throws E_FAIL if the line in the source file was not retrieved. + void GetSourceLineText( + out string sourceLine); + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// The script state. + /// + /// + public enum SCRIPTSTATE : uint + { + #region Enum members. + // ------------------------------------------------------------------ + + /// + /// + /// + SCRIPTSTATE_UNINITIALIZED = 0, + + /// + /// + /// + SCRIPTSTATE_INITIALIZED = 5, + + /// + /// + /// + SCRIPTSTATE_STARTED = 1, + + /// + /// + /// + SCRIPTSTATE_CONNECTED = 2, + + /// + /// + /// + SCRIPTSTATE_DISCONNECTED = 3, + + /// + /// + /// + SCRIPTSTATE_CLOSED = 4, + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// The script thread state. + /// + /// + public enum SCRIPTTHREADSTATE : uint + { + #region Enum members. + // ------------------------------------------------------------------ + + /// + /// + /// + SCRIPTTHREADSTATE_NOTINSCRIPT = 0, + + /// + /// + /// + SCRIPTTHREADSTATE_RUNNING = 1, + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// The script item flags when adding. + /// + /// + [Flags] + public enum SCRIPTITEMFLAGS : uint + { + #region Enum members. + // ------------------------------------------------------------------ + + /// + /// + /// + SCRIPTITEM_ISVISIBLE = 0x00000002, + + /// + /// + /// + SCRIPTITEM_ISSOURCE = 0x00000004, + + /// + /// + /// + SCRIPTITEM_GLOBALMEMBERS = 0x00000008, + + /// + /// + /// + SCRIPTITEM_ISPERSISTENT = 0x00000040, + + /// + /// + /// + SCRIPTITEM_CODEONLY = 0x00000200, + + /// + /// + /// + SCRIPTITEM_NOCODE = 0x00000400, + + /// + /// + /// + SCRIPTITEM_ALL_FLAGS = + SCRIPTITEM_ISSOURCE | + SCRIPTITEM_ISVISIBLE | + SCRIPTITEM_ISPERSISTENT | + SCRIPTITEM_GLOBALMEMBERS | + SCRIPTITEM_NOCODE | + SCRIPTITEM_CODEONLY + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// + + /// + /// The IActiveScriptSite.GetItemInfo() input flags. + /// + /// + [Flags] + public enum SCRIPTINFOFLAGS : uint + { + #region Enum members. + // ------------------------------------------------------------------ + + /// + /// + /// + SCRIPTINFO_IUNKNOWN = 0x00000001, + + /// + /// + /// + SCRIPTINFO_ITYPEINFO = 0x00000002, + + /// + /// + /// + SCRIPTINFO_ALL_FLAGS = + SCRIPTINFO_IUNKNOWN | + SCRIPTINFO_ITYPEINFO + + // ------------------------------------------------------------------ + #endregion + } + + ///////////////////////////////////////////////////////////////////////// +} diff --git a/src/oscript/Properties/AssemblyInfo.cs b/src/oscript/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c09a206 --- /dev/null +++ b/src/oscript/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("oscript")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("oscript")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("178c7466-e8a8-4852-bc3f-6a792e1702d9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/oscript/oscript.csproj b/src/oscript/oscript.csproj new file mode 100644 index 0000000..c6899e6 --- /dev/null +++ b/src/oscript/oscript.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {F7C89194-ECDC-4C76-8418-407994209BE8} + Library + Properties + Oscript.Interop + oscript + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + true + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + \ No newline at end of file