Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1951 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
41 changed files with 131 additions and 4487 deletions
@ -1,3 +0,0 @@ |
|||||||
- dependencies should be maintained during editing |
|
||||||
- folding |
|
||||||
- autocomplete |
|
@ -1,91 +0,0 @@ |
|||||||
<AddIn name = "C++.NET Binding" |
|
||||||
author = "" |
|
||||||
copyright = "GPL" |
|
||||||
url = "http://www.icsharpcode.net" |
|
||||||
description = "" |
|
||||||
version = "1.0.0"> |
|
||||||
|
|
||||||
<Runtime> |
|
||||||
<Import assembly = "CPPNetBinding.dll"/> |
|
||||||
</Runtime> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/FileFilter"> |
|
||||||
<FileFilter id = "C++" |
|
||||||
insertafter="VBNET" |
|
||||||
insertbefore="AllFiles" |
|
||||||
name = "${res:SharpDevelop.FileFilter.CPPFiles}" |
|
||||||
extensions = "*.cpp,*.c,*.hpp,*.h"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/ProjectOptions/ConfigurationProperties"> |
|
||||||
<Condition activeproject="C++.NET"> |
|
||||||
<DialogPanel id = "CPPCodeGenerationPanel" |
|
||||||
label = "Code Generation" |
|
||||||
class = "CPPBinding.CPPCodeGenerationPanel"/> |
|
||||||
<!-- C++ compiler Options --> |
|
||||||
<DialogPanel id = "GeneralCPPOptionsPanel" |
|
||||||
label = "General C++ Compiler Options" |
|
||||||
class = "CPPBinding.GeneralCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "OptimizeCPPOptionsPanel" |
|
||||||
label = "Optimize C++ Compiler Options" |
|
||||||
class = "CPPBinding.OptimizeCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "PreProcessorCPPOptionsPanel" |
|
||||||
label = "PreProcessor C++ Compiler Options" |
|
||||||
class = "CPPBinding.PreProcessorCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "CodeGenerationCPPOptionsPanel" |
|
||||||
label = "Code Generation C++ Compiler Options" |
|
||||||
class = "CPPBinding.CodeGenerationCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "LanguageCPPOptionsPanel" |
|
||||||
label = "Language C++ Compiler Options" |
|
||||||
class = "CPPBinding.LanguageCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "PreCompiledHeaderCPPOptionsPanel" |
|
||||||
label = "PreCompiledHeaders C++ Compiler Options" |
|
||||||
class = "CPPBinding.PreCompiledHeaderCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "OutputFileCPPOptionsPanel" |
|
||||||
label = "Output C++ Compiler Options" |
|
||||||
class = "CPPBinding.OutputFileCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "InformationSearchCPPOptionsPanel" |
|
||||||
label = "InformationSearch C++ Compiler Options" |
|
||||||
class = "CPPBinding.InformationSearchCPPOptionsPanel"/> |
|
||||||
<DialogPanel id = "ExtendedCPPOptionsPanel" |
|
||||||
label = "Extended C++ Compiler Options" |
|
||||||
class = "CPPBinding.ExtendedCPPOptionsPanel"/> |
|
||||||
<!-- C++ linker Options --> |
|
||||||
<DialogPanel id = "GeneralLinkerOptionsPanel" |
|
||||||
label = "General C++ Linker Options" |
|
||||||
class = "CPPBinding.GeneralLinkerOptionsPanel"/> |
|
||||||
<DialogPanel id = "InputLinkerOptionsPanel" |
|
||||||
label = "Input C++ Linker Options" |
|
||||||
class = "CPPBinding.InputLinkerOptionsPanel"/> |
|
||||||
<DialogPanel id = "DebugLinkerOptionsPanel" |
|
||||||
label = "Debug C++ Linker Options" |
|
||||||
class = "CPPBinding.DebugLinkerOptionsPanel"/> |
|
||||||
<DialogPanel id = "SystemLinkerOptionsPanel" |
|
||||||
label = "System C++ Linker Options" |
|
||||||
class = "CPPBinding.SystemLinkerOptionsPanel"/> |
|
||||||
</Condition> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/AddIns/DefaultTextEditor/Formater"> |
|
||||||
<Condition textcontent = "C++.NET"> |
|
||||||
<Class id ="CPPFormatter" insertbefore="DefaultFormatter" class = "CSharpBinding.FormattingStrategy.CSharpFormattingStrategy"/> |
|
||||||
</Condition> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/Workspace/Icons"> |
|
||||||
<!-- C++ --> |
|
||||||
<Icon id = "C++Project" |
|
||||||
language = "C++.NET" |
|
||||||
resource = "C++.ProjectIcon"/> |
|
||||||
<Icon id = "C++File" |
|
||||||
extensions = ".cpp" |
|
||||||
resource = "C++.FileIcon"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/LanguageBindings"> |
|
||||||
<LanguageBinding id = "C++" |
|
||||||
supportedextensions = ".cpp" |
|
||||||
class = "CPPBinding.CPPLanguageBinding" /> |
|
||||||
</Path> |
|
||||||
|
|
||||||
</AddIn> |
|
@ -1,32 +0,0 @@ |
|||||||
using System.Reflection; |
|
||||||
using System.Runtime.CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("CPPNetBinding")] |
|
||||||
[assembly: AssemblyDescription("C++.NET language binding for #develop")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyCompany("www.icsharpcode.net")] |
|
||||||
[assembly: AssemblyProduct("")] |
|
||||||
[assembly: AssemblyCopyright("(c) 2004 Mike Krueger")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
// The assembly version has following format :
|
|
||||||
//
|
|
||||||
// Major.Minor.Build.Revision
|
|
||||||
//
|
|
||||||
// You can specify all values by your own or you can build default build and revision
|
|
||||||
// numbers with the '*' character (the default):
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.0.0.1")] |
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the
|
|
||||||
// .NET Framework documentation for more information about signing.
|
|
||||||
// This is not required, if you don't want signing let these attributes like they're.
|
|
||||||
[assembly: AssemblyDelaySign(false)] |
|
||||||
[assembly: AssemblyKeyFile("")] |
|
@ -1,565 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Text; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
using System.CodeDom.Compiler; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This class controls the compilation of C Sharp files and C Sharp projects
|
|
||||||
/// </summary>
|
|
||||||
public class CPPBindingCompilerManager |
|
||||||
{ |
|
||||||
private FileUtilityService _fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService)); |
|
||||||
private StringBuilder _inputFiles = new StringBuilder(); |
|
||||||
private StringBuilder _buildProcess = new StringBuilder(); |
|
||||||
private StringBuilder _results = new StringBuilder(); |
|
||||||
private bool _treatWarningsAsErrors; |
|
||||||
|
|
||||||
|
|
||||||
// we have 2 formats for the error output the csc gives :
|
|
||||||
// d:\vc\include\xstring(1466) : warning C4701: local variable '_Ptr' may be used without hav
|
|
||||||
readonly static Regex normalError = new Regex(@"(?<file>.*)\((?<line>\d+)\)\s+\:\s+(?<error>.+?)\s+(?<number>[\d\w]+):\s+(?<message>.*)", RegexOptions.Compiled); |
|
||||||
// cl : Command line error D2016 : '/clr' and '/ML' command-line options are incompatible
|
|
||||||
readonly static Regex generalError = new Regex(@"(?<error>.+)\s+(?<number>[\d\w]+)\s*:\s+(?<message>.*)", RegexOptions.Compiled); |
|
||||||
|
|
||||||
|
|
||||||
public string GetCompiledOutputName(string fileName) |
|
||||||
{ |
|
||||||
return Path.ChangeExtension(fileName, ".exe"); |
|
||||||
} |
|
||||||
|
|
||||||
public string GetCompiledOutputName(IProject project) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)project.ActiveConfiguration; |
|
||||||
return compilerparameters.OutputFile; |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCompile(string fileName) |
|
||||||
{ |
|
||||||
return Path.GetExtension(fileName) == ".cpp" || Path.GetExtension(fileName) == ".c" || Path.GetExtension(fileName) == ".cxx"; |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilerResult CompileFile(string filename, CPPCompilerParameters compilerparameters) |
|
||||||
{ |
|
||||||
|
|
||||||
if (!CanCompile(filename)) |
|
||||||
{ |
|
||||||
MessageBox.Show("File " + filename + " is not a source file.", "Compilation Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); |
|
||||||
return new DefaultCompilerResult(new CompilerResults(new TempFileCollection()), ""); |
|
||||||
} |
|
||||||
string output = ""; |
|
||||||
string error = ""; |
|
||||||
string exe = Path.ChangeExtension(filename, ".exe"); |
|
||||||
if (compilerparameters.OutputAssembly != null && compilerparameters.OutputAssembly.Length > 0) { |
|
||||||
exe = compilerparameters.OutputAssembly; |
|
||||||
} |
|
||||||
_treatWarningsAsErrors = compilerparameters.TreatWarningsAsErrors; |
|
||||||
string responseFileName = Path.GetTempFileName(); |
|
||||||
|
|
||||||
StreamWriter writer = new StreamWriter(responseFileName); |
|
||||||
|
|
||||||
writer.WriteLine("/nologo"); |
|
||||||
if (compilerparameters.UseManagedExtensions) |
|
||||||
{ |
|
||||||
writer.WriteLine("/clr"); |
|
||||||
} |
|
||||||
writer.WriteLine("/Fe\"" + exe + "\""); |
|
||||||
|
|
||||||
writer.WriteLine('"' + filename + '"'); |
|
||||||
|
|
||||||
TempFileCollection tf = new TempFileCollection(); |
|
||||||
|
|
||||||
writer.Close(); |
|
||||||
|
|
||||||
string compilerName = GetCompilerName(); |
|
||||||
string outstr = compilerName + " \"@" + responseFileName + "\""; |
|
||||||
string currDir = Directory.GetCurrentDirectory(); |
|
||||||
string intDir = compilerparameters.IntermediateDirectory; |
|
||||||
if (intDir == null || intDir.Length == 0) { |
|
||||||
intDir = compilerparameters.OutputDirectory; |
|
||||||
} |
|
||||||
|
|
||||||
Directory.SetCurrentDirectory(intDir); |
|
||||||
ICompilerResult result; |
|
||||||
try { |
|
||||||
Executor.ExecWaitWithCapture(outstr, currDir, tf, ref output, ref error); |
|
||||||
result = ParseOutput(tf, output, error); |
|
||||||
} |
|
||||||
catch (System.Runtime.InteropServices.ExternalException e) { |
|
||||||
ShowErrorBox(e); |
|
||||||
result = CreateErrorCompilerResult(tf, e); |
|
||||||
} |
|
||||||
finally { |
|
||||||
File.Delete(responseFileName); |
|
||||||
File.Delete(output); |
|
||||||
File.Delete(error); |
|
||||||
Directory.SetCurrentDirectory(currDir); |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
private void ShowErrorBox(System.Runtime.InteropServices.ExternalException e) |
|
||||||
{ |
|
||||||
MessageBox.Show("It seems cl.exe is not installed or not found.\n\nInstall compiler and set PATH environment variable.\n\nException: " + e, "Compile Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilerResult CompileProject(IProject project, bool force) |
|
||||||
{ |
|
||||||
_inputFiles = new StringBuilder(); |
|
||||||
_buildProcess = new StringBuilder(); |
|
||||||
_results = new StringBuilder(); |
|
||||||
|
|
||||||
CPPProject p = (CPPProject)project; |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
_treatWarningsAsErrors = compilerparameters.TreatWarningsAsErrors; |
|
||||||
|
|
||||||
CheckDirectory(Path.GetDirectoryName(compilerparameters.OutputFile)); |
|
||||||
CheckDirectory(Path.GetDirectoryName(compilerparameters.IntermediateDirectory)); |
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder(); |
|
||||||
|
|
||||||
ICompilerResult result; |
|
||||||
|
|
||||||
if (compilerparameters.PreCompileHeader) { |
|
||||||
result = InternalCompileProject(p, true, force); |
|
||||||
if (result != null) { |
|
||||||
output.Append(result.CompilerOutput); |
|
||||||
if (HasErrors(result)) { |
|
||||||
goto exit; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
result = InternalCompileProject(p, false, force); |
|
||||||
if (result != null) { |
|
||||||
output.Append(result.CompilerOutput); |
|
||||||
if (HasErrors(result)) { |
|
||||||
goto exit; |
|
||||||
} |
|
||||||
} |
|
||||||
if (result != null || !File.Exists(Path.GetFullPath(compilerparameters.OutputFile))) { |
|
||||||
result = LinkProject(p); |
|
||||||
output.Append(result.CompilerOutput); |
|
||||||
} |
|
||||||
exit: |
|
||||||
WriteResultFile(p); |
|
||||||
CompilerResults cr = result != null ? result.CompilerResults : new CompilerResults(new TempFileCollection()); |
|
||||||
return new DefaultCompilerResult(cr, output.ToString()); |
|
||||||
} |
|
||||||
|
|
||||||
private bool HasErrors(ICompilerResult compilerResult) |
|
||||||
{ |
|
||||||
bool result = false; |
|
||||||
if (compilerResult.CompilerResults.Errors.Count > 0) |
|
||||||
{ |
|
||||||
if (_treatWarningsAsErrors) |
|
||||||
{ |
|
||||||
result = true; |
|
||||||
} |
|
||||||
else { |
|
||||||
foreach (CompilerError error in compilerResult.CompilerResults.Errors) |
|
||||||
{ |
|
||||||
if (!error.IsWarning) |
|
||||||
{ |
|
||||||
result = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
private void CheckDirectory(string directory) |
|
||||||
{ |
|
||||||
if (!Directory.Exists(directory)) { |
|
||||||
Directory.CreateDirectory(directory); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void WriteResultFile(CPPProject p) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
string directory = Path.GetDirectoryName(compilerparameters.OutputFile); |
|
||||||
string resultFile = Path.Combine(directory, "BuildLog.html"); |
|
||||||
_results.Append("writing result file to : " + resultFile); |
|
||||||
|
|
||||||
StreamWriter writer = new StreamWriter(resultFile); |
|
||||||
writer.Write("<HTML><HEAD></HEAD><BODY>"); |
|
||||||
writer.Write("<TABLE WIDTH=100% BGCOLOR=LightBlue><TR><TD><FONT FACE=ARIAL SIZE=+3><B>Build Log from</B>: " + p.Name + "(" + compilerparameters.Name + ")</FONT></TABLE>"); |
|
||||||
writer.Write("Build started."); |
|
||||||
writer.Write("<TABLE WIDTH=100% BGCOLOR=LightBlue><TR><TD><FONT FACE=ARIAL SIZE=+2>Command Line</FONT></TD></TR></TABLE>"); |
|
||||||
writer.WriteLine(_inputFiles.ToString()); |
|
||||||
|
|
||||||
writer.Write("<TABLE WIDTH=100% BGCOLOR=LightBlue><TR><TD><FONT FACE=ARIAL SIZE=+2>Output</FONT></TD></TR></TABLE>"); |
|
||||||
writer.Write("<PRE>"); |
|
||||||
writer.WriteLine(_buildProcess.ToString()); |
|
||||||
writer.Write("</PRE>"); |
|
||||||
|
|
||||||
writer.Write("<TABLE WIDTH=100% BGCOLOR=LightBlue><TR><TD><FONT FACE=ARIAL SIZE=+2>Results</FONT></TD></TR></TABLE>"); |
|
||||||
writer.Write("<PRE>"); |
|
||||||
writer.WriteLine(_results.ToString()); |
|
||||||
writer.Write("</PRE>"); |
|
||||||
writer.Write("Build finished."); |
|
||||||
writer.Write("</BODY></HTML>"); |
|
||||||
writer.Close(); |
|
||||||
} |
|
||||||
|
|
||||||
#region COMPILER
|
|
||||||
private string GetCompilerName() |
|
||||||
{ |
|
||||||
return @"cl.exe"; |
|
||||||
} |
|
||||||
|
|
||||||
private string WriteCompilerParameters(CPPProject p, bool preCompiledHeader, bool force) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
StringBuilder sb = new StringBuilder(); |
|
||||||
|
|
||||||
sb.Append("/c\n"); |
|
||||||
|
|
||||||
if (compilerparameters.UseManagedExtensions) { |
|
||||||
sb.Append("/clr\n"); |
|
||||||
} |
|
||||||
string directory = Path.GetDirectoryName(compilerparameters.OutputFile); |
|
||||||
sb.Append("/Fo\""); |
|
||||||
sb.Append(directory); |
|
||||||
sb.Append("/\"\n"); |
|
||||||
|
|
||||||
IProjectService projectService = (IProjectService)ICSharpCode.Core.ServiceManager.Services.GetService(typeof(IProjectService)); |
|
||||||
ArrayList allProjects = Combine.GetAllProjects(projectService.CurrentOpenCombine); |
|
||||||
if (preCompiledHeader) { |
|
||||||
sb.Append(compilerparameters.GetPreCompiledHeaderOptions()); |
|
||||||
} else { |
|
||||||
sb.Append(compilerparameters.GetCompilerOptions()); |
|
||||||
} |
|
||||||
if (compilerparameters.AdditionalCompilerOptions != null && compilerparameters.AdditionalCompilerOptions.Length > 0) { |
|
||||||
foreach (string option in compilerparameters.AdditionalCompilerOptions.Split(';')) { |
|
||||||
sb.Append(option); |
|
||||||
sb.Append("\n"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
foreach (ProjectReference lib in p.ProjectReferences) { |
|
||||||
sb.Append("/FU\""); |
|
||||||
sb.Append(lib.GetReferencedFileName(p)); |
|
||||||
sb.Append("\"\n"); |
|
||||||
} |
|
||||||
|
|
||||||
switch (compilerparameters.ConfigurationType) { |
|
||||||
case ConfigurationType.Dll: |
|
||||||
sb.Append("/LD\n"); |
|
||||||
break; |
|
||||||
} |
|
||||||
bool includedFile = false; |
|
||||||
foreach (ProjectFile finfo in p.ProjectFiles) { |
|
||||||
if (finfo.Subtype != Subtype.Directory) { |
|
||||||
switch (finfo.BuildAction) { |
|
||||||
case BuildAction.Compile: |
|
||||||
if (CanCompile(finfo.Name)) |
|
||||||
{ |
|
||||||
string fileName = Path.GetFileNameWithoutExtension(Path.GetFullPath(finfo.Name)).ToLower(); |
|
||||||
string headerFile = Path.GetFileNameWithoutExtension(compilerparameters.preCompiledHeaderCPPOptions.HeaderFile).ToLower(); |
|
||||||
bool isPreHeader = fileName == headerFile; |
|
||||||
|
|
||||||
if (!(preCompiledHeader ^ isPreHeader)) { |
|
||||||
if (force || ShouldCompileFile(p, finfo.Name)) { |
|
||||||
includedFile = true; |
|
||||||
sb.Append("\""); |
|
||||||
sb.Append(Path.GetFullPath(finfo.Name)); |
|
||||||
sb.Append("\"\n"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (!includedFile) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
string responseFileName = Path.GetTempFileName(); |
|
||||||
StreamWriter writer = new StreamWriter(responseFileName, false); |
|
||||||
// string standardIncludes = Environment.GetEnvironmentVariable("INCLUDE");
|
|
||||||
// if (standardIncludes != null && standardIncludes.Length > 0) {
|
|
||||||
// writer.WriteLine("/I\"" + standardIncludes + "\"");
|
|
||||||
// }
|
|
||||||
|
|
||||||
writer.Write(sb.ToString()); |
|
||||||
writer.Close(); |
|
||||||
|
|
||||||
_inputFiles.Append("Creating temporary file "); |
|
||||||
_inputFiles.Append(responseFileName); |
|
||||||
_inputFiles.Append(" with following content:<BR>"); |
|
||||||
_inputFiles.Append("<PRE>"); |
|
||||||
_inputFiles.Append(sb.ToString()); |
|
||||||
_inputFiles.Append("</PRE>"); |
|
||||||
|
|
||||||
return responseFileName; |
|
||||||
} |
|
||||||
|
|
||||||
Hashtable lastCompiledFiles = new Hashtable(); |
|
||||||
|
|
||||||
private bool ShouldCompileFile(CPPProject p, string fileName) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
string directory = Path.GetDirectoryName(compilerparameters.OutputFile); |
|
||||||
string objectFile = Path.Combine(directory, Path.ChangeExtension(Path.GetFileName(fileName), ".obj")); |
|
||||||
if (!File.Exists(objectFile)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
string[] additinalIncludeDirs = compilerparameters.AdditionalCompilerOptions.Split(';'); |
|
||||||
ArrayList dirs = new ArrayList(additinalIncludeDirs.Length+1); |
|
||||||
dirs.Add(Path.GetDirectoryName(fileName)); |
|
||||||
foreach (string dir in additinalIncludeDirs) |
|
||||||
{ |
|
||||||
dirs.Add(dir); |
|
||||||
} |
|
||||||
|
|
||||||
DateTime lastWriteTime = new IncludeParser(fileName, dirs, true).Parse().GetLastWriteTime(); |
|
||||||
// DateTime lastWriteTime = File.GetLastWriteTime(fileName);
|
|
||||||
|
|
||||||
bool shouldCompile; |
|
||||||
if (lastCompiledFiles[fileName] == null) { |
|
||||||
shouldCompile = true; |
|
||||||
} else { |
|
||||||
shouldCompile = lastWriteTime != (DateTime)lastCompiledFiles[fileName]; |
|
||||||
} |
|
||||||
|
|
||||||
lastCompiledFiles[fileName] = lastWriteTime; |
|
||||||
return shouldCompile; |
|
||||||
} |
|
||||||
|
|
||||||
private ICompilerResult InternalCompileProject(CPPProject p, bool preCompiledHeader, bool force) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
|
|
||||||
string responseFileName = WriteCompilerParameters(p, preCompiledHeader, force); |
|
||||||
if (responseFileName == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
string output = String.Empty; |
|
||||||
string error = String.Empty; |
|
||||||
|
|
||||||
string compilerName = GetCompilerName(); |
|
||||||
string clstr = compilerName + " \"@" + responseFileName + "\""; |
|
||||||
|
|
||||||
TempFileCollection tf = new TempFileCollection(); |
|
||||||
|
|
||||||
string currDir = Directory.GetCurrentDirectory(); |
|
||||||
string intDir = compilerparameters.IntermediateDirectory; |
|
||||||
if (intDir == null || intDir.Length == 0) { |
|
||||||
intDir = compilerparameters.OutputDirectory; |
|
||||||
} |
|
||||||
_inputFiles.Append("Executing command: <C>" + clstr + "</C><hr>"); |
|
||||||
|
|
||||||
ICompilerResult result; |
|
||||||
try { |
|
||||||
Executor.ExecWaitWithCapture(clstr, tf, ref output, ref error); |
|
||||||
result = ParseOutput(tf, output, error); |
|
||||||
} |
|
||||||
catch (System.Runtime.InteropServices.ExternalException e) { |
|
||||||
ShowErrorBox(e); |
|
||||||
result = CreateErrorCompilerResult(tf, e); |
|
||||||
} |
|
||||||
finally { |
|
||||||
File.Delete(responseFileName); |
|
||||||
File.Delete(output); |
|
||||||
File.Delete(error); |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region LINKER
|
|
||||||
private string GetLinkerName() |
|
||||||
{ |
|
||||||
return @"link.exe"; |
|
||||||
} |
|
||||||
|
|
||||||
private string WriteLinkerOptions(CPPProject p) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(); |
|
||||||
|
|
||||||
string exe = compilerparameters.OutputFile; |
|
||||||
string dir = Path.GetDirectoryName(Path.GetFullPath(exe)); |
|
||||||
sb.Append("/OUT:\"");sb.Append(exe);sb.Append("\"\n"); |
|
||||||
foreach (ProjectFile finfo in p.ProjectFiles) { |
|
||||||
if (finfo.Subtype != Subtype.Directory) { |
|
||||||
switch (finfo.BuildAction) { |
|
||||||
case BuildAction.Compile: |
|
||||||
if (CanCompile(finfo.Name)) |
|
||||||
{ |
|
||||||
sb.Append('"'); |
|
||||||
sb.Append(Path.Combine(dir, |
|
||||||
Path.ChangeExtension(Path.GetFileName(finfo.Name), |
|
||||||
".obj"))); |
|
||||||
sb.Append("\"\n"); |
|
||||||
} |
|
||||||
break; |
|
||||||
case BuildAction.EmbedAsResource: |
|
||||||
sb.Append("/ASSEMBLYRESOURCE:\"");sb.Append(Path.GetFullPath(finfo.Name));sb.Append("\"\n"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
switch (compilerparameters.ConfigurationType) { |
|
||||||
case ConfigurationType.Dll: |
|
||||||
sb.Append("/DLL\n"); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
sb.Append(compilerparameters.GetLinkerOptionsForCompiler()); |
|
||||||
|
|
||||||
// write to response file
|
|
||||||
string responseFileName = Path.GetTempFileName(); |
|
||||||
StreamWriter writer = new StreamWriter(responseFileName); |
|
||||||
// string standardLibs = Environment.GetEnvironmentVariable("LIB");
|
|
||||||
// if (standardLibs != null && standardLibs.Length > 0) {
|
|
||||||
// foreach (string lib in standardLibs.Split(';')) {
|
|
||||||
// if (lib.Length > 0) {
|
|
||||||
// writer.WriteLine("/LIBPATH:\"" + lib + "\"");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
writer.Write(sb.ToString()); |
|
||||||
writer.Close(); |
|
||||||
|
|
||||||
_inputFiles.Append("Creating temporary file <C>" + responseFileName + "</C> with following content:<BR>"); |
|
||||||
_inputFiles.Append("<PRE>"); |
|
||||||
_inputFiles.Append(sb.ToString()); |
|
||||||
_inputFiles.Append("</PRE>"); |
|
||||||
return responseFileName; |
|
||||||
} |
|
||||||
|
|
||||||
private ICompilerResult LinkProject(CPPProject p) |
|
||||||
{ |
|
||||||
CPPCompilerParameters compilerparameters = (CPPCompilerParameters)p.ActiveConfiguration; |
|
||||||
|
|
||||||
string responseFileName = WriteLinkerOptions(p); |
|
||||||
|
|
||||||
string output = String.Empty; |
|
||||||
string error = String.Empty; |
|
||||||
|
|
||||||
string compilerName = GetLinkerName(); |
|
||||||
string clstr = compilerName + " \"@" + responseFileName + "\""; |
|
||||||
|
|
||||||
TempFileCollection tf = new TempFileCollection(); |
|
||||||
|
|
||||||
string currDir = Directory.GetCurrentDirectory(); |
|
||||||
string intDir = compilerparameters.IntermediateDirectory; |
|
||||||
if (intDir == null || intDir.Length == 0) { |
|
||||||
intDir = compilerparameters.OutputDirectory; |
|
||||||
} |
|
||||||
|
|
||||||
_inputFiles.Append("Executing command : <C>"); |
|
||||||
_inputFiles.Append(clstr); |
|
||||||
_inputFiles.Append("</C><hr>"); |
|
||||||
Executor.ExecWaitWithCapture(clstr, tf, ref output, ref error); |
|
||||||
|
|
||||||
ICompilerResult result = ParseOutput(tf, output, error); |
|
||||||
|
|
||||||
// File.Delete(responseFileName);
|
|
||||||
File.Delete(output); |
|
||||||
File.Delete(error); |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ICompilerResult CreateErrorCompilerResult(TempFileCollection tf, System.Runtime.InteropServices.ExternalException e) |
|
||||||
{ |
|
||||||
CompilerError error = new CompilerError(); |
|
||||||
error.Line = 0; |
|
||||||
error.FileName = ""; |
|
||||||
error.IsWarning = false; |
|
||||||
error.ErrorNumber = ""; |
|
||||||
error.ErrorText = e.Message; |
|
||||||
CompilerResults cr = new CompilerResults(tf); |
|
||||||
cr.Errors.Add(error); |
|
||||||
return new DefaultCompilerResult(cr, ""); |
|
||||||
} |
|
||||||
|
|
||||||
private void InternalParseOutputFile(StringBuilder compilerOutput, CompilerResults cr, string file) |
|
||||||
{ |
|
||||||
StreamReader sr = new StreamReader(File.OpenRead(file), Encoding.Default); |
|
||||||
|
|
||||||
// skip fist whitespace line
|
|
||||||
sr.ReadLine(); |
|
||||||
|
|
||||||
|
|
||||||
while (true) { |
|
||||||
string curLine = sr.ReadLine(); |
|
||||||
_buildProcess.Append(curLine); |
|
||||||
_buildProcess.Append("\n"); |
|
||||||
compilerOutput.Append(curLine); |
|
||||||
compilerOutput.Append('\n'); |
|
||||||
if (curLine == null) { |
|
||||||
break; |
|
||||||
} |
|
||||||
curLine = curLine.Trim(); |
|
||||||
if (curLine.Length == 0) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
CompilerError error = new CompilerError(); |
|
||||||
|
|
||||||
// try to match standard errors
|
|
||||||
Match match = normalError.Match(curLine); |
|
||||||
if (match.Success) { |
|
||||||
error.Line = Int32.Parse(match.Result("${line}")); |
|
||||||
try { |
|
||||||
error.FileName = Path.GetFullPath(match.Result("${file}")); |
|
||||||
} catch (Exception) { |
|
||||||
error.FileName = ""; |
|
||||||
} |
|
||||||
error.IsWarning = match.Result("${error}").EndsWith("warning"); |
|
||||||
error.ErrorNumber = match.Result("${number}"); |
|
||||||
error.ErrorText = match.Result("${message}"); |
|
||||||
} else { |
|
||||||
match = generalError.Match(curLine); // try to match general csc errors
|
|
||||||
if (match.Success) { |
|
||||||
error.IsWarning = match.Result("${error}").EndsWith("warning"); |
|
||||||
error.ErrorNumber = match.Result("${number}"); |
|
||||||
error.ErrorText = match.Result("${message}"); |
|
||||||
} else { // give up and skip the line
|
|
||||||
continue; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
cr.Errors.Add(error); |
|
||||||
} |
|
||||||
sr.Close(); |
|
||||||
} |
|
||||||
|
|
||||||
private ICompilerResult ParseOutput(TempFileCollection tf, string outputFile, string errorFile) |
|
||||||
{ |
|
||||||
StringBuilder compilerOutput = new StringBuilder(); |
|
||||||
CompilerResults cr = new CompilerResults(tf); |
|
||||||
InternalParseOutputFile(compilerOutput, cr, outputFile); |
|
||||||
InternalParseOutputFile(compilerOutput, cr, errorFile); |
|
||||||
return new DefaultCompilerResult(cr, compilerOutput.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,74 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Collections; |
|
||||||
using System.Reflection; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Xml; |
|
||||||
using System.CodeDom.Compiler; |
|
||||||
using System.Threading; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This class describes the main functionalaty of a language codon
|
|
||||||
/// </summary>
|
|
||||||
public class CPPBindingExecutionManager |
|
||||||
{ |
|
||||||
public void Execute(string filename, bool debug) |
|
||||||
{ |
|
||||||
string exe = Path.ChangeExtension(filename, ".exe"); |
|
||||||
ProcessStartInfo psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c " + "\"" + exe + "\"" + " & pause"); |
|
||||||
psi.WorkingDirectory = Path.GetDirectoryName(exe); |
|
||||||
psi.UseShellExecute = false; |
|
||||||
try { |
|
||||||
Process p = new Process(); |
|
||||||
p.StartInfo = psi; |
|
||||||
p.Start(); |
|
||||||
} catch (Exception) { |
|
||||||
throw new ApplicationException("Can't execute " + "\"" + exe + "\"\n(.NET bug? Try restaring SD or manual start)"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Execute(IProject project, bool debug) |
|
||||||
{ |
|
||||||
CPPCompilerParameters parameters = (CPPCompilerParameters)project.ActiveConfiguration; |
|
||||||
|
|
||||||
|
|
||||||
string exe = ((CPPCompilerParameters)project.ActiveConfiguration).OutputFile; |
|
||||||
|
|
||||||
//string args = ((CPPCompilerParameters)project.ActiveConfiguration).CommandLineParameters;
|
|
||||||
string args = ""; |
|
||||||
|
|
||||||
ProcessStartInfo psi; |
|
||||||
string runtimeStarter = String.Empty; |
|
||||||
|
|
||||||
psi = new ProcessStartInfo(runtimeStarter + "\"" + exe + "\""); |
|
||||||
psi.Arguments = args; |
|
||||||
|
|
||||||
try { |
|
||||||
psi.WorkingDirectory = Path.GetDirectoryName(exe); |
|
||||||
psi.UseShellExecute = false; |
|
||||||
|
|
||||||
Process p = new Process(); |
|
||||||
p.StartInfo = psi; |
|
||||||
p.Start(); |
|
||||||
} catch (Exception) { |
|
||||||
throw new ApplicationException("Can't execute " + "\"" + exe + "\""); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,95 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Collections; |
|
||||||
using System.Reflection; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Xml; |
|
||||||
using System.CodeDom.Compiler; |
|
||||||
using System.Threading; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
public class CPPLanguageBinding : ILanguageBinding |
|
||||||
{ |
|
||||||
public const string LanguageName = "C++.NET"; |
|
||||||
|
|
||||||
CPPBindingCompilerManager compilerManager = new CPPBindingCompilerManager(); |
|
||||||
CPPBindingExecutionManager executionManager = new CPPBindingExecutionManager(); |
|
||||||
|
|
||||||
public string Language { |
|
||||||
get { |
|
||||||
return LanguageName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Execute(string filename, bool debug) |
|
||||||
{ |
|
||||||
Debug.Assert(executionManager != null); |
|
||||||
executionManager.Execute(filename, debug); |
|
||||||
} |
|
||||||
|
|
||||||
public void Execute(IProject project, bool debug) |
|
||||||
{ |
|
||||||
Debug.Assert(executionManager != null); |
|
||||||
executionManager.Execute(project, debug); |
|
||||||
} |
|
||||||
|
|
||||||
public string GetCompiledOutputName(string fileName) |
|
||||||
{ |
|
||||||
Debug.Assert(compilerManager != null); |
|
||||||
return compilerManager.GetCompiledOutputName(fileName); |
|
||||||
} |
|
||||||
|
|
||||||
public string GetCompiledOutputName(IProject project) |
|
||||||
{ |
|
||||||
Debug.Assert(compilerManager != null); |
|
||||||
return compilerManager.GetCompiledOutputName(project); |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCompile(string fileName) |
|
||||||
{ |
|
||||||
Debug.Assert(compilerManager != null); |
|
||||||
return compilerManager.CanCompile(fileName); |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilerResult CompileFile(string fileName) |
|
||||||
{ |
|
||||||
MessageBox.Show("Cannot compile a single file. Create a project first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilerResult CompileProject(IProject project) |
|
||||||
{ |
|
||||||
return CompileProject(project, false); |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilerResult RecompileProject(IProject project) |
|
||||||
{ |
|
||||||
return CompileProject(project, true); |
|
||||||
} |
|
||||||
|
|
||||||
public IProject CreateProject(ProjectCreateInformation info, XmlElement projectOptions) |
|
||||||
{ |
|
||||||
return new CPPProject(info, projectOptions); |
|
||||||
} |
|
||||||
|
|
||||||
private ICompilerResult CompileProject(IProject project, bool force) |
|
||||||
{ |
|
||||||
Debug.Assert(compilerManager != null); |
|
||||||
return compilerManager.CompileProject(project, force); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,218 +0,0 @@ |
|||||||
//
|
|
||||||
// -*- C# -*-
|
|
||||||
//
|
|
||||||
// Author: Roman Taranchenko
|
|
||||||
// Copyright: (c) 2004 Roman Taranchenko
|
|
||||||
// Copying Policy: GNU General Public License
|
|
||||||
//
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
|
|
||||||
public interface IDependence |
|
||||||
{ |
|
||||||
|
|
||||||
string Name |
|
||||||
{ |
|
||||||
get; |
|
||||||
} |
|
||||||
|
|
||||||
DependenceTree DependsOn |
|
||||||
{ |
|
||||||
get; |
|
||||||
} |
|
||||||
|
|
||||||
DependenceTree Children |
|
||||||
{ |
|
||||||
get; |
|
||||||
} |
|
||||||
|
|
||||||
void Add(IDependence dependence); |
|
||||||
|
|
||||||
DateTime GetLastWriteTime(); |
|
||||||
|
|
||||||
bool Exists |
|
||||||
{ |
|
||||||
get; |
|
||||||
} |
|
||||||
|
|
||||||
bool Contains(IDependence dep); |
|
||||||
|
|
||||||
bool Contains(string dep); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public class SourceFile: IDependence |
|
||||||
{ |
|
||||||
|
|
||||||
private string _name; |
|
||||||
private DependenceTree _dependences = new DependenceTree(); |
|
||||||
|
|
||||||
public SourceFile(string name) |
|
||||||
{ |
|
||||||
_name = name; |
|
||||||
} |
|
||||||
|
|
||||||
public string Name |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return _name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public DependenceTree Children |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return _dependences; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public DependenceTree DependsOn |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DependenceTree listOfNames = new DependenceTree(); |
|
||||||
FillListOfNames(this, listOfNames); |
|
||||||
return listOfNames; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Add(IDependence dependence) |
|
||||||
{ |
|
||||||
_dependences.Add(dependence); |
|
||||||
} |
|
||||||
|
|
||||||
private static void FillListOfNames(IDependence dependence, DependenceTree list) |
|
||||||
{ |
|
||||||
foreach (IDependence dep in dependence.Children) |
|
||||||
{ |
|
||||||
list.Add(dep); |
|
||||||
FillListOfNames(dep, list); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public DateTime GetLastWriteTime() |
|
||||||
{ |
|
||||||
DateTime result = DateTime.MinValue; |
|
||||||
if (Exists) |
|
||||||
{ |
|
||||||
result = File.GetLastWriteTime(_name); |
|
||||||
foreach (IDependence dep in _dependences) |
|
||||||
{ |
|
||||||
DateTime dt = dep.GetLastWriteTime(); |
|
||||||
if (dt.CompareTo(result) > 0) |
|
||||||
{ |
|
||||||
result = dt; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
public bool Exists |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return File.Exists(_name); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return _name; |
|
||||||
} |
|
||||||
|
|
||||||
public bool Contains(IDependence dep) |
|
||||||
{ |
|
||||||
return Contains(dep.Name); |
|
||||||
} |
|
||||||
|
|
||||||
public bool Contains(string dep) |
|
||||||
{ |
|
||||||
if (_name.Equals(dep)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
return _dependences.Contains(dep); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class DependenceTree: IEnumerable |
|
||||||
{ |
|
||||||
|
|
||||||
private SortedList _list; |
|
||||||
|
|
||||||
public DependenceTree() |
|
||||||
{ |
|
||||||
_list = new SortedList(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Add(IDependence value) |
|
||||||
{ |
|
||||||
if (!Contains(value)) |
|
||||||
{ |
|
||||||
_list.Add(value.Name, value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IDependence Get(string name) |
|
||||||
{ |
|
||||||
return (IDependence) _list.GetByIndex(_list.IndexOfKey(name)); |
|
||||||
} |
|
||||||
|
|
||||||
public IDependence Get(IDependence dep) |
|
||||||
{ |
|
||||||
return Get(dep.Name); |
|
||||||
} |
|
||||||
|
|
||||||
public bool Contains(IDependence dep) |
|
||||||
{ |
|
||||||
return Contains(dep.Name); |
|
||||||
} |
|
||||||
|
|
||||||
public bool Contains(string name) |
|
||||||
{ |
|
||||||
return _list.ContainsKey(name); |
|
||||||
} |
|
||||||
|
|
||||||
public IEnumerator GetEnumerator() |
|
||||||
{ |
|
||||||
return new DependenceTreeEnumerator(_list.GetEnumerator()); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
class DependenceTreeEnumerator: IEnumerator |
|
||||||
{ |
|
||||||
private IDictionaryEnumerator _enum; |
|
||||||
|
|
||||||
public DependenceTreeEnumerator(IDictionaryEnumerator e) |
|
||||||
{ |
|
||||||
_enum = e; |
|
||||||
} |
|
||||||
|
|
||||||
public object Current |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return ((DictionaryEntry)_enum.Current).Value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool MoveNext() |
|
||||||
{ |
|
||||||
return _enum.MoveNext(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Reset() |
|
||||||
{ |
|
||||||
_enum.Reset(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,343 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Drawing; |
|
||||||
using System.Text; |
|
||||||
|
|
||||||
using ICSharpCode.TextEditor; |
|
||||||
using ICSharpCode.TextEditor.Document; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace CPPBinding.FormattingStrategy |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This class handles the auto and smart indenting in the textbuffer while
|
|
||||||
/// you type.
|
|
||||||
/// </summary>
|
|
||||||
public class CSharpFormattingStrategy : DefaultFormattingStrategy |
|
||||||
{ |
|
||||||
public CSharpFormattingStrategy() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Define CSharp specific smart indenting for a line :)
|
|
||||||
/// </summary>
|
|
||||||
protected override int SmartIndentLine(TextArea textArea, int lineNr) |
|
||||||
{ |
|
||||||
if (lineNr > 0) { |
|
||||||
LineSegment lineAbove = textArea.Document.GetLineSegment(lineNr - 1); |
|
||||||
string lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove).Trim(); |
|
||||||
|
|
||||||
LineSegment curLine = textArea.Document.GetLineSegment(lineNr); |
|
||||||
string curLineText = textArea.Document.GetText(curLine.Offset, curLine.Length).Trim(); |
|
||||||
|
|
||||||
if ((lineAboveText.EndsWith(")") && curLineText.StartsWith("{")) || // after for, while, etc.
|
|
||||||
(lineAboveText.EndsWith("else") && curLineText.StartsWith("{"))) // after else
|
|
||||||
{ |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1); |
|
||||||
textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText); |
|
||||||
return indentation.Length; |
|
||||||
} |
|
||||||
|
|
||||||
if (curLineText.StartsWith("}")) { // indent closing bracket.
|
|
||||||
int closingBracketOffset = TextUtilities.SearchBracketBackward(textArea.Document, curLine.Offset + textArea.Document.GetText(curLine.Offset, curLine.Length).IndexOf('}') - 1, '{', '}'); |
|
||||||
if (closingBracketOffset == -1) { // no closing bracket found -> autoindent
|
|
||||||
return AutoIndentLine(textArea, lineNr); |
|
||||||
} |
|
||||||
|
|
||||||
string indentation = GetIndentation(textArea, textArea.Document.GetLineNumberForOffset(closingBracketOffset)); |
|
||||||
|
|
||||||
textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText); |
|
||||||
return indentation.Length; |
|
||||||
} |
|
||||||
|
|
||||||
if (lineAboveText.EndsWith(";")) { // expression ended, reset to valid indent.
|
|
||||||
int closingBracketOffset = TextUtilities.SearchBracketBackward(textArea.Document, curLine.Offset + textArea.Document.GetText(curLine.Offset, curLine.Length).IndexOf('}') - 1, '{', '}'); |
|
||||||
|
|
||||||
if (closingBracketOffset == -1) { // no closing bracket found -> autoindent
|
|
||||||
return AutoIndentLine(textArea, lineNr); |
|
||||||
} |
|
||||||
|
|
||||||
int closingBracketLineNr = textArea.Document.GetLineNumberForOffset(closingBracketOffset); |
|
||||||
LineSegment closingBracketLine = textArea.Document.GetLineSegment(closingBracketLineNr); |
|
||||||
string closingBracketLineText = textArea.Document.GetText(closingBracketLine.Offset, closingBracketLine.Length).Trim(); |
|
||||||
|
|
||||||
string indentation = GetIndentation(textArea, closingBracketLineNr); |
|
||||||
|
|
||||||
// special handling for switch statement formatting.
|
|
||||||
if (closingBracketLineText.StartsWith("switch")) { |
|
||||||
if (lineAboveText.StartsWith("break;") || |
|
||||||
lineAboveText.StartsWith("goto") || |
|
||||||
lineAboveText.StartsWith("return")) { |
|
||||||
// nothing
|
|
||||||
} else { |
|
||||||
indentation += ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document); |
|
||||||
} |
|
||||||
} |
|
||||||
indentation += ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document); |
|
||||||
|
|
||||||
textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText); |
|
||||||
return indentation.Length; |
|
||||||
} |
|
||||||
|
|
||||||
if (lineAboveText.EndsWith("{") || // indent opening bracket.
|
|
||||||
lineAboveText.EndsWith(":") || // indent case xyz:
|
|
||||||
(lineAboveText.EndsWith(")") && // indent single line if, for ... etc
|
|
||||||
(lineAboveText.StartsWith("if") || |
|
||||||
lineAboveText.StartsWith("while") || |
|
||||||
lineAboveText.StartsWith("for"))) || |
|
||||||
lineAboveText.EndsWith("else")) { |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1) + ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document); |
|
||||||
textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText); |
|
||||||
return indentation.Length; |
|
||||||
} else { |
|
||||||
// try to indent linewrap
|
|
||||||
ArrayList bracketPos = new ArrayList(); |
|
||||||
for (int i = 0; i < lineAboveText.Length; ++i) { // search for a ( bracket that isn't closed
|
|
||||||
switch (lineAboveText[i]) { |
|
||||||
case '(': |
|
||||||
bracketPos.Add(i); |
|
||||||
break; |
|
||||||
case ')': |
|
||||||
if (bracketPos.Count > 0) { |
|
||||||
bracketPos.RemoveAt(bracketPos.Count - 1); |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (bracketPos.Count > 0) { |
|
||||||
int bracketIndex = (int)bracketPos[bracketPos.Count - 1]; |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1); |
|
||||||
|
|
||||||
for (int i = 0; i <= bracketIndex; ++i) { // insert enough spaces to match
|
|
||||||
indentation += " "; // brace start in the next line
|
|
||||||
} |
|
||||||
|
|
||||||
textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText); |
|
||||||
return indentation.Length; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return AutoIndentLine(textArea, lineNr); |
|
||||||
} |
|
||||||
|
|
||||||
bool NeedCurlyBracket(string text) |
|
||||||
{ |
|
||||||
int curlyCounter = 0; |
|
||||||
|
|
||||||
bool inString = false; |
|
||||||
bool inChar = false; |
|
||||||
|
|
||||||
bool lineComment = false; |
|
||||||
bool blockComment = false; |
|
||||||
|
|
||||||
for (int i = 0; i < text.Length; ++i) { |
|
||||||
switch (text[i]) { |
|
||||||
case '\r': |
|
||||||
case '\n': |
|
||||||
lineComment = false; |
|
||||||
break; |
|
||||||
case '/': |
|
||||||
if (blockComment) { |
|
||||||
Debug.Assert(i > 0); |
|
||||||
if (text[i - 1] == '*') { |
|
||||||
blockComment = false; |
|
||||||
} |
|
||||||
} |
|
||||||
if (!inString && !inChar && i + 1 < text.Length) { |
|
||||||
if (!blockComment && text[i + 1] == '/') { |
|
||||||
lineComment = true; |
|
||||||
} |
|
||||||
if (!lineComment && text[i + 1] == '*') { |
|
||||||
blockComment = true; |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
case '"': |
|
||||||
if (!(inChar || lineComment || blockComment)) { |
|
||||||
inString = !inString; |
|
||||||
} |
|
||||||
break; |
|
||||||
case '\'': |
|
||||||
if (!(inString || lineComment || blockComment)) { |
|
||||||
inChar = !inChar; |
|
||||||
} |
|
||||||
break; |
|
||||||
case '{': |
|
||||||
if (!(inString || inChar || lineComment || blockComment)) { |
|
||||||
++curlyCounter; |
|
||||||
} |
|
||||||
break; |
|
||||||
case '}': |
|
||||||
if (!(inString || inChar || lineComment || blockComment)) { |
|
||||||
--curlyCounter; |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
return curlyCounter > 0; |
|
||||||
} |
|
||||||
|
|
||||||
bool IsInsideStringOrComment(TextArea textArea, LineSegment curLine, int cursorOffset) |
|
||||||
{ |
|
||||||
// scan cur line if it is inside a string or single line comment (//)
|
|
||||||
bool isInsideString = false; |
|
||||||
bool isInsideComment = false; |
|
||||||
for (int i = curLine.Offset; i < cursorOffset; ++i) { |
|
||||||
char ch = textArea.Document.GetCharAt(i); |
|
||||||
if (ch == '"') { |
|
||||||
isInsideString = !isInsideString; |
|
||||||
} |
|
||||||
if (ch == '/' && i + 1 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '/') { |
|
||||||
isInsideComment = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return isInsideString || isInsideComment; |
|
||||||
} |
|
||||||
|
|
||||||
bool IsInsideDocumentationComment(TextArea textArea, LineSegment curLine, int cursorOffset) |
|
||||||
{ |
|
||||||
// scan cur line if it is inside a string or single line comment (//)
|
|
||||||
bool isInsideString = false; |
|
||||||
bool isInsideComment = false; |
|
||||||
for (int i = curLine.Offset; i < cursorOffset; ++i) { |
|
||||||
char ch = textArea.Document.GetCharAt(i); |
|
||||||
if (ch == '"') { |
|
||||||
isInsideString = !isInsideString; |
|
||||||
} |
|
||||||
if (!isInsideString) { |
|
||||||
if (ch == '/' && i + 2 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '/' && textArea.Document.GetCharAt(i + 2) == '/') { |
|
||||||
isInsideComment = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return isInsideComment; |
|
||||||
} |
|
||||||
|
|
||||||
public override int FormatLine(TextArea textArea, int lineNr, int cursorOffset, char ch) // used for comment tag formater/inserter
|
|
||||||
{ |
|
||||||
LineSegment curLine = textArea.Document.GetLineSegment(lineNr); |
|
||||||
LineSegment lineAbove = lineNr > 0 ? textArea.Document.GetLineSegment(lineNr - 1) : null; |
|
||||||
|
|
||||||
//// local string for curLine segment
|
|
||||||
string curLineText=""; |
|
||||||
|
|
||||||
if (ch != '\n' && ch != '>') { |
|
||||||
if (IsInsideStringOrComment(textArea, curLine, cursorOffset)) { |
|
||||||
return 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
switch (ch) { |
|
||||||
case '>': |
|
||||||
if (IsInsideDocumentationComment(textArea, curLine, cursorOffset)) { |
|
||||||
curLineText = textArea.Document.GetText(curLine.Offset, curLine.Length); |
|
||||||
int column = textArea.Caret.Offset - curLine.Offset; |
|
||||||
int index = Math.Min(column - 1, curLineText.Length - 1); |
|
||||||
|
|
||||||
while (index >= 0 && curLineText[index] != '<') { |
|
||||||
--index; |
|
||||||
if(curLineText[index] == '/') |
|
||||||
return 0; // the tag was an end tag or already
|
|
||||||
} |
|
||||||
|
|
||||||
if (index > 0) { |
|
||||||
StringBuilder commentBuilder = new StringBuilder(""); |
|
||||||
for (int i = index; i < curLineText.Length && i < column && !Char.IsWhiteSpace(curLineText[ i]); ++i) { |
|
||||||
commentBuilder.Append(curLineText[ i]); |
|
||||||
} |
|
||||||
string tag = commentBuilder.ToString().Trim(); |
|
||||||
if (!tag.EndsWith(">")) { |
|
||||||
tag += ">"; |
|
||||||
} |
|
||||||
if (!tag.StartsWith("/")) { |
|
||||||
textArea.Document.Insert(textArea.Caret.Offset, "</" + tag.Substring(1)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
case '}': |
|
||||||
case '{': |
|
||||||
return textArea.Document.FormattingStrategy.IndentLine(textArea, lineNr); |
|
||||||
case '\n': |
|
||||||
if (lineNr <= 0) { |
|
||||||
return IndentLine(textArea, lineNr); |
|
||||||
} |
|
||||||
|
|
||||||
if (textArea.TextEditorProperties.AutoInsertCurlyBracket) { |
|
||||||
string oldLineText = TextUtilities.GetLineAsString(textArea.Document, lineNr - 1); |
|
||||||
if (oldLineText.EndsWith("{")) { |
|
||||||
if (NeedCurlyBracket(textArea.Document.TextContent)) { |
|
||||||
textArea.Document.Insert(curLine.Offset + curLine.Length, "\n}"); |
|
||||||
IndentLine(textArea, lineNr + 1); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove); |
|
||||||
//// curLine might have some text which should be added to indentation
|
|
||||||
curLineText = ""; |
|
||||||
if (curLine.Length > 0) { |
|
||||||
curLineText = textArea.Document.GetText(curLine.Offset,curLine.Length); |
|
||||||
} |
|
||||||
|
|
||||||
LineSegment nextLine = lineNr + 1 < textArea.Document.TotalNumberOfLines ? textArea.Document.GetLineSegment(lineNr + 1) : null; |
|
||||||
string nextLineText = lineNr + 1 < textArea.Document.TotalNumberOfLines ? textArea.Document.GetText(nextLine.Offset, nextLine.Length) : ""; |
|
||||||
|
|
||||||
if (lineAbove.HighlightSpanStack != null && lineAbove.HighlightSpanStack.Count > 0) { |
|
||||||
if (!((Span)lineAbove.HighlightSpanStack.Peek()).StopEOL) { // case for /* style comments
|
|
||||||
int index = lineAboveText == null ? -1 : lineAboveText.IndexOf("/*"); |
|
||||||
|
|
||||||
if (index > 0) { |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1); |
|
||||||
for (int i = indentation.Length; i < index; ++ i) { |
|
||||||
indentation += ' '; |
|
||||||
} |
|
||||||
//// adding curline text
|
|
||||||
textArea.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + " * "+curLineText); |
|
||||||
return indentation.Length + 3+curLineText.Length; |
|
||||||
} |
|
||||||
|
|
||||||
index = lineAboveText.IndexOf("*"); |
|
||||||
if (index > 0) { |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1); |
|
||||||
for (int i = indentation.Length; i < index; ++ i) { |
|
||||||
indentation += ' '; |
|
||||||
} |
|
||||||
//// adding curline if present
|
|
||||||
textArea.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + "* "+curLineText); |
|
||||||
return indentation.Length + 2 + curLineText.Length; |
|
||||||
} |
|
||||||
} else { // don't handle // lines, because they're only one lined comments
|
|
||||||
int indexAbove = lineAboveText.IndexOf("///"); |
|
||||||
int indexNext = nextLineText.IndexOf("///"); |
|
||||||
if (indexAbove > 0 && (indexNext != -1 || indexAbove + 4 < lineAbove.Length)) { |
|
||||||
string indentation = GetIndentation(textArea, lineNr - 1); |
|
||||||
for (int i = indentation.Length; i < indexAbove; ++ i) { |
|
||||||
indentation += ' '; |
|
||||||
} |
|
||||||
//// adding curline text if present
|
|
||||||
textArea.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + "/// " + curLineText); |
|
||||||
return indentation.Length + 4 /*+ curLineText.Length*/; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return IndentLine(textArea, lineNr); |
|
||||||
} |
|
||||||
return 0; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,152 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Drawing; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.ExternalTool; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
public abstract class AbstractCPPConfigPanel : AbstractOptionPanel |
|
||||||
{ |
|
||||||
protected CPPCompilerParameters compilerParameters; |
|
||||||
protected System.Windows.Forms.PropertyGrid grid = new System.Windows.Forms.PropertyGrid(); |
|
||||||
|
|
||||||
protected abstract void SetGridObject(); |
|
||||||
|
|
||||||
public override void LoadPanelContents() |
|
||||||
{ |
|
||||||
compilerParameters = (CPPCompilerParameters)((Properties)CustomizationObject).Get("Config"); |
|
||||||
|
|
||||||
grid.Dock = DockStyle.Fill; |
|
||||||
SetGridObject(); |
|
||||||
Controls.Add(grid); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool StorePanelContents() |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class CPPCodeGenerationPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters; |
|
||||||
} |
|
||||||
} |
|
||||||
#region compiler panels
|
|
||||||
public class GeneralCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.generalCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
public class OptimizeCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.optimizeCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
public class PreProcessorCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.preProcessorCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class CodeGenerationCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.codeGenerationCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class LanguageCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.languageCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class PreCompiledHeaderCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.preCompiledHeaderCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class OutputFileCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.outputFileCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class InformationSearchCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.informationSearchCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class ExtendedCPPOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.extendedCPPOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
public class GeneralLinkerOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.generalLinkerOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
public class InputLinkerOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.inputLinkerOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
public class DebugLinkerOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.debugLinkerOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class SystemLinkerOptionsPanel : AbstractCPPConfigPanel |
|
||||||
{ |
|
||||||
protected override void SetGridObject() |
|
||||||
{ |
|
||||||
grid.SelectedObject = this.compilerParameters.systemLinkerOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
@ -1,123 +0,0 @@ |
|||||||
//
|
|
||||||
// -*- C# -*-
|
|
||||||
//
|
|
||||||
// Author: Roman Taranchenko
|
|
||||||
// Copyright: (c) 2004 Roman Taranchenko
|
|
||||||
// Copying Policy: GNU General Public License
|
|
||||||
//
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Description of IncludeParser.
|
|
||||||
/// </summary>
|
|
||||||
public class IncludeParser |
|
||||||
{ |
|
||||||
private IDependence _owner; |
|
||||||
private IList _includeDirectories; |
|
||||||
private bool _onlyProjectInclude; |
|
||||||
|
|
||||||
public IncludeParser(IDependence owner, IList includeDirectories, bool onlyProjectInclude) |
|
||||||
{ |
|
||||||
_includeDirectories = includeDirectories; |
|
||||||
_owner = owner; |
|
||||||
_onlyProjectInclude = onlyProjectInclude; |
|
||||||
} |
|
||||||
|
|
||||||
public IncludeParser(String fileName, IList includeDirectories, bool onlyProjectInclude) |
|
||||||
{ |
|
||||||
_includeDirectories = includeDirectories; |
|
||||||
_owner = new SourceFile(fileName); |
|
||||||
_onlyProjectInclude = onlyProjectInclude; |
|
||||||
} |
|
||||||
|
|
||||||
public IDependence Parse() |
|
||||||
{ |
|
||||||
ParseFile(_owner); |
|
||||||
return _owner; |
|
||||||
} |
|
||||||
|
|
||||||
private void ParseFile(IDependence parent) |
|
||||||
{ |
|
||||||
if (!parent.Exists) |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
ArrayList includes = new ArrayList(); |
|
||||||
StreamReader reader = File.OpenText(parent.Name); |
|
||||||
using (reader) |
|
||||||
{ |
|
||||||
string line = null; |
|
||||||
while ((line = reader.ReadLine()) != null) |
|
||||||
{ |
|
||||||
line = line.TrimStart(' ', '\t'); |
|
||||||
if (line.StartsWith("#include")) |
|
||||||
{ |
|
||||||
IDependence include = GetInclude(line); |
|
||||||
if (include != null) |
|
||||||
{ |
|
||||||
includes.Add(include); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
foreach (IDependence include in includes) |
|
||||||
{ |
|
||||||
parent.Add(include); |
|
||||||
ParseFile(include); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private IDependence GetInclude(string line) |
|
||||||
{ |
|
||||||
IDependence result = null; |
|
||||||
int start = -1, end = -1; |
|
||||||
bool quotes = false; |
|
||||||
|
|
||||||
// find first index
|
|
||||||
for (int i = 8; i < line.Length; ++i) |
|
||||||
{ |
|
||||||
if (!_onlyProjectInclude && line[i] == '<') |
|
||||||
{ |
|
||||||
start = i+1; |
|
||||||
break; |
|
||||||
} |
|
||||||
if (line[i] == '"') |
|
||||||
{ |
|
||||||
start = i+1; |
|
||||||
quotes = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// find second index
|
|
||||||
if (start > 0 && start + 1 < line.Length) |
|
||||||
{ |
|
||||||
end = line.IndexOf(quotes ? '"' : '>', start + 1); |
|
||||||
} |
|
||||||
|
|
||||||
// create include
|
|
||||||
if (start > 0 && end > start) |
|
||||||
{ |
|
||||||
string includeName = line.Substring(start, end-start); |
|
||||||
foreach (string dir in _includeDirectories) |
|
||||||
{ |
|
||||||
string fullName = Path.Combine(dir, includeName); |
|
||||||
if (!_owner.Contains(fullName) && File.Exists(fullName)) |
|
||||||
{ |
|
||||||
result = new SourceFile(fullName); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Collections; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
|
||||||
|
|
||||||
namespace CPPBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This class describes a C Sharp project and it compilation options.
|
|
||||||
/// </summary>
|
|
||||||
public class CPPProject : AbstractProject |
|
||||||
{ |
|
||||||
public override string ProjectType { |
|
||||||
get { |
|
||||||
return CPPLanguageBinding.LanguageName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public CPPProject() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override IConfiguration CreateConfiguration() |
|
||||||
{ |
|
||||||
return new CPPCompilerParameters(); |
|
||||||
} |
|
||||||
|
|
||||||
public CPPProject(ProjectCreateInformation info, XmlElement projectOptions) |
|
||||||
{ |
|
||||||
if (info != null) { |
|
||||||
Name = info.ProjectName; |
|
||||||
Configurations.Add(CreateConfiguration("Debug")); |
|
||||||
Configurations.Add(CreateConfiguration("Release")); |
|
||||||
|
|
||||||
foreach (CPPCompilerParameters parameter in Configurations) { |
|
||||||
parameter.OutputDirectory = info.BinPath + Path.DirectorySeparatorChar + parameter.Name; |
|
||||||
parameter.IntermediateDirectory = info.BinPath + Path.DirectorySeparatorChar + parameter.Name; |
|
||||||
parameter.OutputAssembly = Name; |
|
||||||
if (projectOptions != null) { |
|
||||||
if (projectOptions.Attributes["ConfigurationType"] != null) { |
|
||||||
parameter.ConfigurationType = (ConfigurationType)Enum.Parse(typeof(ConfigurationType), projectOptions.Attributes["ConfigurationType"].InnerText); |
|
||||||
} |
|
||||||
} |
|
||||||
parameter.OutputFile = parameter.OutputDirectory + Path.DirectorySeparatorChar + Name + (parameter.ConfigurationType == ConfigurationType.Dll ? ".dll" : ".exe"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,22 +0,0 @@ |
|||||||
<?xml version="1.0"?> |
|
||||||
<Template author="Roman Taranchenko" version="1.0"> |
|
||||||
|
|
||||||
<Config |
|
||||||
name = "${res:Templates.File.EmptyFile.Name}" |
|
||||||
icon = "C++.File.EmptyFile" |
|
||||||
category = "C++" |
|
||||||
defaultname = "Empty${Number}.cpp" |
|
||||||
language = "C++.NET"/> |
|
||||||
|
|
||||||
<Description>${res:Templates.File.EmptyFile.Description}</Description> |
|
||||||
|
|
||||||
<Files> |
|
||||||
<File name="${FullName}" language="C++.NET"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
|
|
||||||
]]></File> |
|
||||||
</Files> |
|
||||||
|
|
||||||
<AdditionalOptions/> |
|
||||||
</Template> |
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@ |
|||||||
<?xml version="1.0"?> |
|
||||||
<Template author="Roman Taranchenko" version="1.0"> |
|
||||||
|
|
||||||
<Config |
|
||||||
name = "${res:Templates.File.HeaderFile.Name}" |
|
||||||
icon = "C++.File.EmptyFile" |
|
||||||
category = "C++" |
|
||||||
defaultname = "Empty${Number}.h" |
|
||||||
language = "C++.NET"/> |
|
||||||
|
|
||||||
<Description>${res:Templates.File.HeaderFile.Description}</Description> |
|
||||||
|
|
||||||
<Files> |
|
||||||
<File name="${FullName}" language="C++.NET"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
|
|
||||||
]]></File> |
|
||||||
</Files> |
|
||||||
|
|
||||||
<AdditionalOptions/> |
|
||||||
</Template> |
|
||||||
|
|
||||||
|
|
@ -1,84 +0,0 @@ |
|||||||
<?xml version="1.0"?> |
|
||||||
<Template originator = "Mike Krueger" |
|
||||||
created = "06/10/2001" |
|
||||||
lastModified = "02/01/2003"> |
|
||||||
|
|
||||||
<!-- Template Header --> |
|
||||||
<TemplateConfiguration> |
|
||||||
<Name>${res:Templates.Project.ConsoleProject.Name}</Name> |
|
||||||
<Category>C++.NET</Category> |
|
||||||
<Icon>C++.Project.DOSProject</Icon> |
|
||||||
<LanguageName>C++.NET</LanguageName> |
|
||||||
<Description>${res:Templates.Project.ConsoleProject.Description}</Description> |
|
||||||
</TemplateConfiguration> |
|
||||||
|
|
||||||
<!-- Actions --> |
|
||||||
<Actions> |
|
||||||
<Open filename = "Main.cpp"/> |
|
||||||
</Actions> |
|
||||||
|
|
||||||
<!-- Template Content --> |
|
||||||
<Combine name = "${ProjectName}" directory = "."> |
|
||||||
<Options> |
|
||||||
<StartupProject>${ProjectName}</StartupProject> |
|
||||||
</Options> |
|
||||||
|
|
||||||
<Project name = "${ProjectName}" directory = "."> |
|
||||||
<Options/> |
|
||||||
<Files> |
|
||||||
<File name="Main.cpp"><![CDATA[#include "Main.h" |
|
||||||
|
|
||||||
int main() |
|
||||||
{ |
|
||||||
System::Console::WriteLine("Hello World!"); |
|
||||||
} |
|
||||||
|
|
||||||
]]></File> |
|
||||||
<File name="Main.h"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
#include "StdAfx.h" |
|
||||||
|
|
||||||
|
|
||||||
]]></File> |
|
||||||
<File name="StdAfx.h"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
#pragma once |
|
||||||
#using <mscorlib.dll> |
|
||||||
|
|
||||||
]]></File> |
|
||||||
<File name="AssemblyInfo.cpp"><![CDATA[#include"StdAfx.h" |
|
||||||
using namespace System::Reflection; |
|
||||||
using namespace System::Runtime::CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following |
|
||||||
// attributes. |
|
||||||
// |
|
||||||
// change them to the information which is associated with the assembly |
|
||||||
// you compile. |
|
||||||
|
|
||||||
[assembly: AssemblyTitle("")]; |
|
||||||
[assembly: AssemblyDescription("")]; |
|
||||||
[assembly: AssemblyConfiguration("")]; |
|
||||||
[assembly: AssemblyCompany("")]; |
|
||||||
[assembly: AssemblyProduct("")]; |
|
||||||
[assembly: AssemblyCopyright("")]; |
|
||||||
[assembly: AssemblyTrademark("")]; |
|
||||||
[assembly: AssemblyCulture("")]; |
|
||||||
|
|
||||||
// The assembly version has following format : |
|
||||||
// |
|
||||||
// Major.Minor.Build.Revision |
|
||||||
// |
|
||||||
// You can specify all values by your own or you can build default build and revision |
|
||||||
// numbers with the '*' character (the default): |
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.*")]; |
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the |
|
||||||
// .NET Framework documentation for more information about signing. |
|
||||||
// This is not required, if you don't want signing let these attributes like they're. |
|
||||||
[assembly: AssemblyDelaySign(false)]; |
|
||||||
[assembly: AssemblyKeyFile("")]; |
|
||||||
]]></File> |
|
||||||
</Files> |
|
||||||
</Project> |
|
||||||
</Combine> |
|
||||||
</Template> |
|
@ -1,18 +0,0 @@ |
|||||||
<?xml version="1.0"?> |
|
||||||
<Template originator = "Roman Taranchenko" |
|
||||||
created = "14/03/2004" |
|
||||||
lastModified = "14/03/2004"> |
|
||||||
|
|
||||||
<!-- Template Header --> |
|
||||||
<TemplateConfiguration> |
|
||||||
<Name>${res:Templates.Project.EmptyProject.Name}</Name> |
|
||||||
<Category>C++.NET</Category> |
|
||||||
<Icon>C++.Project.EmptyProject</Icon> |
|
||||||
<LanguageName>C++.NET</LanguageName> |
|
||||||
<Description>${res:Templates.Project.EmptyProject.Description}</Description> |
|
||||||
</TemplateConfiguration> |
|
||||||
|
|
||||||
<Combine name = "${ProjectName}" directory = "."> |
|
||||||
<Project name = "${ProjectName}" directory = "."/> |
|
||||||
</Combine> |
|
||||||
</Template> |
|
@ -1,107 +0,0 @@ |
|||||||
<?xml version="1.0"?> |
|
||||||
<Template originator = "Mike Krueger" |
|
||||||
created = "06/10/2001" |
|
||||||
lastModified = "02/01/2003"> |
|
||||||
|
|
||||||
<!-- Template Header --> |
|
||||||
<TemplateConfiguration> |
|
||||||
<Name>${res:Templates.Project.WindowsApplication.Name}</Name> |
|
||||||
<Category>C++.NET</Category> |
|
||||||
<Icon>C++.Project.Form</Icon> |
|
||||||
<LanguageName>C++.NET</LanguageName> |
|
||||||
<Description>${res:Templates.Project.WindowsApplication.Description}</Description> |
|
||||||
</TemplateConfiguration> |
|
||||||
|
|
||||||
<!-- Actions --> |
|
||||||
<Actions> |
|
||||||
<Open filename = "MainForm.cpp"/> |
|
||||||
</Actions> |
|
||||||
|
|
||||||
<!-- Template Content --> |
|
||||||
<Combine name = "${ProjectName}" directory = "."> |
|
||||||
<Options> |
|
||||||
<StartupProject>${ProjectName}</StartupProject> |
|
||||||
</Options> |
|
||||||
|
|
||||||
<Project name = "${ProjectName}" directory = "."> |
|
||||||
<Options/> |
|
||||||
<Files> |
|
||||||
<File name="MainForm.cpp"><![CDATA[#include "MainForm.h" |
|
||||||
|
|
||||||
MainForm::MainForm() |
|
||||||
{ |
|
||||||
InitializeComponents(); |
|
||||||
} |
|
||||||
|
|
||||||
void MainForm::InitializeComponents() |
|
||||||
{ |
|
||||||
this->SuspendLayout(); |
|
||||||
this->Name = "MainForm"; |
|
||||||
this->Text = "This is my form"; |
|
||||||
this->Size = System::Drawing::Size(300, 300); |
|
||||||
this->ResumeLayout(false); |
|
||||||
} |
|
||||||
|
|
||||||
int main() |
|
||||||
{ |
|
||||||
System::Windows::Forms::Application::Run(new MainForm()); |
|
||||||
}]]></File> |
|
||||||
<File name="MainForm.h"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
#pragma once |
|
||||||
#include "StdAfx.h" |
|
||||||
|
|
||||||
public __gc class MainForm : public System::Windows::Forms::Form |
|
||||||
{ |
|
||||||
public: |
|
||||||
MainForm(); |
|
||||||
private: |
|
||||||
void InitializeComponents(); |
|
||||||
}; |
|
||||||
|
|
||||||
]]></File> |
|
||||||
<File name="StdAfx.h"><![CDATA[${StandardHeader.C++.NET} |
|
||||||
#pragma once |
|
||||||
|
|
||||||
#using <mscorlib.dll> |
|
||||||
#using <System.dll> |
|
||||||
#using <System.Drawing.dll> |
|
||||||
#using <System.Windows.Forms.dll> |
|
||||||
]]></File> |
|
||||||
<File name="AssemblyInfo.cpp"><![CDATA[#include"StdAfx.h" |
|
||||||
using namespace System::Reflection; |
|
||||||
using namespace System::Runtime::CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following |
|
||||||
// attributes. |
|
||||||
// |
|
||||||
// change them to the information which is associated with the assembly |
|
||||||
// you compile. |
|
||||||
|
|
||||||
[assembly: AssemblyTitle("")]; |
|
||||||
[assembly: AssemblyDescription("")]; |
|
||||||
[assembly: AssemblyConfiguration("")]; |
|
||||||
[assembly: AssemblyCompany("")]; |
|
||||||
[assembly: AssemblyProduct("")]; |
|
||||||
[assembly: AssemblyCopyright("")]; |
|
||||||
[assembly: AssemblyTrademark("")]; |
|
||||||
[assembly: AssemblyCulture("")]; |
|
||||||
|
|
||||||
// The assembly version has following format : |
|
||||||
// |
|
||||||
// Major.Minor.Build.Revision |
|
||||||
// |
|
||||||
// You can specify all values by your own or you can build default build and revision |
|
||||||
// numbers with the '*' character (the default): |
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.*")]; |
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the |
|
||||||
// .NET Framework documentation for more information about signing. |
|
||||||
// This is not required, if you don't want signing let these attributes like they're. |
|
||||||
[assembly: AssemblyDelaySign(false)]; |
|
||||||
[assembly: AssemblyKeyFile("")]; |
|
||||||
]]></File> |
|
||||||
</Files> |
|
||||||
</Project> |
|
||||||
</Combine> |
|
||||||
</Template> |
|
@ -1,37 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Markus Palme" email="MarkusPalme@gmx.de"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Drawing; |
|
||||||
using System.Collections; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Gui.Dialogs; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
using ICSharpCode.Core.AddIns; |
|
||||||
using ICSharpCode.Core.AddIns.Codons; |
|
||||||
using ICSharpCode.Core.Properties; |
|
||||||
|
|
||||||
namespace Plugins.RegExpTk { |
|
||||||
|
|
||||||
public class RegExpTkCommand : AbstractMenuCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
RegExpTkDialog dialog = new RegExpTkDialog(); |
|
||||||
dialog.ShowDialog(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class RegExpTkDialog : Form |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue