mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
Moved X# custom tool to XSharp asm.
This commit is contained in:
parent
b38ab25f3e
commit
d59f512831
8 changed files with 55 additions and 62 deletions
|
|
@ -286,17 +286,16 @@ Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{8355452D-6D2F-4
|
|||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{8355452D-6D2F-41B0-89B8-BB2AA2529E94}; ValueType: string; ValueName: InprocServer32; ValueData: {sys}\mscoree.dll
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{8355452D-6D2F-41B0-89B8-BB2AA2529E94}; ValueType: string; ValueName: CodeBase; ValueData: {app}\build\vsip\Cosmos.Debug.VSDebugEngine.dll
|
||||
|
||||
; X# file generator type
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: none; Flags: uninsdeletekey
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Assembly; ValueData: Cosmos.VS.Package
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Class; ValueData: Cosmos.VS.Package.FileGenerators.XSharpGenerator
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: InprocServer32; ValueData: {sys}\mscoree.dll
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: CodeBase; ValueData: {app}\build\vsip\Cosmos.VS.Package.dll
|
||||
|
||||
; X# custom tool registration
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\Generators\{{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}\CosmosXSharpGenerator; ValueType: none; Flags: uninsdeletekey
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\Generators\{{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}\CosmosXSharpGenerator; ValueType: string; ValueName: CLSID; ValueData: {{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA};
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\Generators\{{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}\CosmosXSharpGenerator; ValueType: dword; ValueName: GeneratesDesignTimeSource; ValueData: 1
|
||||
; X# file generator type
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: none; Flags: uninsdeletekey
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Assembly; ValueData: Cosmos.VS.XSharp
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Class; ValueData: Cosmos.VS.XSharp.FileGenerator
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: InprocServer32; ValueData: {sys}\mscoree.dll
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: CodeBase; ValueData: {app}\build\vsip\Cosmos.VS.XSharp.dll
|
||||
|
||||
; program provider
|
||||
Root: HKLM; SubKey: Software\Microsoft\VisualStudio\10.0\CLSID\{{B4DE9307-C062-45F1-B1AF-9A5FB25402D5}; ValueType: none; Flags: uninsdeletekey
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<h3>Public Tasks</h3>
|
||||
<ul>
|
||||
<li>Comsmos.VS.Windows - use vsix reg tool</li>
|
||||
<li>X# custom tool generator - Move to Cosmos.VS.XSharp probably</li>
|
||||
<li>iss - call vsix unreg on uninstall</li>
|
||||
<li>VIX - Shutdown VMWare<ul>
|
||||
<li><a href="http://www.codeproject.com/Articles/31961/Automating-VMWare-Tasks-in-C-with-the-VIX-API">http://www.codeproject.com/Articles/31961/Automating-VMWare-Tasks-in-C-with-the-VIX-API</a></li>
|
||||
</ul>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<h3>
|
||||
Matthijs</h3>
|
||||
<ul>
|
||||
<li>File New : "CosmosProject", "Cosmos"</li>
|
||||
<li></li>
|
||||
</ul>
|
||||
<h3>
|
||||
Kudzu
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ new Comment("This next line allows emission of standard yucky Intel mnemonics");
|
|||
new LiteralAssemblerCode("Mov EAX, 1");
|
||||
new Comment("This is X# code");
|
||||
new Move{DestinationReg = RegistersEnum.EAX, SourceValue = 1};
|
||||
new Move{DestinationReg = RegistersEnum.EDX, SourceValue = 2};
|
||||
new Move{DestinationReg = RegistersEnum.EDX, SourceValue = 2};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,3 +6,4 @@
|
|||
# This is X# code
|
||||
EAX = 1
|
||||
EDX = 2
|
||||
EDX = 2
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@
|
|||
<Compile Include="DebugPageSub.Designer.cs">
|
||||
<DependentUpon>DebugPageSub.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FileGenerators\XSharpGenerator.cs" />
|
||||
<Compile Include="GACDetectionUtility.cs" />
|
||||
<Compile Include="Guids.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
using Microsoft.VisualStudio;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
namespace Cosmos.VS.Package.FileGenerators
|
||||
{
|
||||
public class XSharpGenerator : IVsSingleFileGenerator
|
||||
{
|
||||
public int DefaultExtension(out string pbstrDefaultExtension)
|
||||
{
|
||||
pbstrDefaultExtension = ".cs";
|
||||
return VSConstants.S_OK;
|
||||
}
|
||||
|
||||
public int Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents,
|
||||
out uint pcbOutput, IVsGeneratorProgress pGenerateProgress)
|
||||
{
|
||||
var xGeneratedCode = DoGenerate(wszInputFilePath, bstrInputFileContents, wszDefaultNamespace);
|
||||
var xBytes = Encoding.UTF8.GetBytes(xGeneratedCode);
|
||||
|
||||
if (xBytes.Length > 0)
|
||||
{
|
||||
rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(xBytes.Length);
|
||||
Marshal.Copy(xBytes, 0, rgbOutputFileContents[0], xBytes.Length);
|
||||
pcbOutput = (uint)xBytes.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgbOutputFileContents[0] = IntPtr.Zero;
|
||||
pcbOutput = 0;
|
||||
}
|
||||
return VSConstants.S_OK;
|
||||
}
|
||||
|
||||
private static string DoGenerate(string inputFileName, string inputFileContents, string defaultNamespace)
|
||||
{
|
||||
using (var xInput = new StringReader(inputFileContents))
|
||||
{
|
||||
using (var xOut = new StringWriter())
|
||||
{
|
||||
Cosmos.Compiler.XSharp.Generator.Execute(xInput, inputFileName, xOut, defaultNamespace);
|
||||
return xOut.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -127,6 +127,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Scanner.cs" />
|
||||
<Compile Include="LanguageService.cs" />
|
||||
<Compile Include="FileGenerator.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources.resx">
|
||||
|
|
|
|||
44
source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs
Normal file
44
source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
using Microsoft.VisualStudio;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
namespace Cosmos.VS.XSharp {
|
||||
|
||||
// This is the custom tool used to compile .XS files to .CS files in VS
|
||||
public class FileGenerator : IVsSingleFileGenerator {
|
||||
public int DefaultExtension(out string pbstrDefaultExtension) {
|
||||
pbstrDefaultExtension = ".cs";
|
||||
return VSConstants.S_OK;
|
||||
}
|
||||
|
||||
public int Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents,
|
||||
out uint pcbOutput, IVsGeneratorProgress pGenerateProgress) {
|
||||
var xGeneratedCode = DoGenerate(wszInputFilePath, bstrInputFileContents, wszDefaultNamespace);
|
||||
var xBytes = Encoding.UTF8.GetBytes(xGeneratedCode);
|
||||
|
||||
if (xBytes.Length > 0) {
|
||||
rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(xBytes.Length);
|
||||
Marshal.Copy(xBytes, 0, rgbOutputFileContents[0], xBytes.Length);
|
||||
pcbOutput = (uint)xBytes.Length;
|
||||
} else {
|
||||
rgbOutputFileContents[0] = IntPtr.Zero;
|
||||
pcbOutput = 0;
|
||||
}
|
||||
return VSConstants.S_OK;
|
||||
}
|
||||
|
||||
private static string DoGenerate(string inputFileName, string inputFileContents, string defaultNamespace) {
|
||||
using (var xInput = new StringReader(inputFileContents)) {
|
||||
using (var xOut = new StringWriter()) {
|
||||
Cosmos.Compiler.XSharp.Generator.Execute(xInput, inputFileName, xOut, defaultNamespace);
|
||||
return xOut.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue