Browse Source

Make -a command line optional, fix #include's, disable warnings.

pull/1/head
Tarmo Pikaro 14 years ago committed by triton
parent
commit
d4e80fe566
  1. 9
      src/Generator/CodeGenerator.cs
  2. 16
      src/Generator/Generators/CLI/CLIHelpers.cs
  3. 8
      src/Generator/Transforms/Transform.cs

9
src/Generator/CodeGenerator.cs

@ -185,8 +185,7 @@ namespace Cxxi @@ -185,8 +185,7 @@ namespace Cxxi
if (string.IsNullOrWhiteSpace(path))
{
Console.WriteLine("Error: no assembly provided");
return false;
return true;
}
try
@ -221,6 +220,12 @@ namespace Cxxi @@ -221,6 +220,12 @@ namespace Cxxi
if (!ParseCommandLineOptions(args, options))
return;
// We need to know absolute pathes in order to determine correct include pathes.
for (int i = 0; i < options.IncludeDirs.Count; i++)
{
if (options.IncludeDirs[i] == ".") options.IncludeDirs[i] = Directory.GetCurrentDirectory();
}
ILibrary library = null;
if (!ParseLibraryAssembly(options.Assembly, out library))
return;

16
src/Generator/Generators/CLI/CLIHelpers.cs

@ -404,12 +404,24 @@ namespace Cxxi.Generators.CLI @@ -404,12 +404,24 @@ namespace Cxxi.Generators.CLI
public void GenerateStart()
{
Transform.GenerateStart(this);
if( Transform == null)
{
WriteLine("//----------------------------------------------------------------------------");
WriteLine("// This is autogenerated code by cxxi-generator.");
WriteLine("// Do not edit this file or all your changes will be lost after re-generation.");
WriteLine("//----------------------------------------------------------------------------");
if( FileExtension == "cpp" )
WriteLine(@"#include ""interop.h"" // marshalString");
}else
Transform.GenerateStart(this);
}
public void GenerateAfterNamespaces()
{
Transform.GenerateAfterNamespaces(this);
if (Transform != null)
Transform.GenerateAfterNamespaces(this);
}
public void GenerateSummary(string comment)

8
src/Generator/Transforms/Transform.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace Cxxi.Passes
{
@ -21,6 +22,7 @@ namespace Cxxi.Passes @@ -21,6 +22,7 @@ namespace Cxxi.Passes
string GetIncludePath(string filePath)
{
string includePath = filePath;
string ShortestIncludePath = filePath;
foreach (var path in Options.IncludeDirs)
{
@ -29,11 +31,11 @@ namespace Cxxi.Passes @@ -29,11 +31,11 @@ namespace Cxxi.Passes
string inc = filePath.Substring(path.Length);
if (inc.Length < includePath.Length)
includePath = inc;
if (inc.Length < includePath.Length && inc.Length < ShortestIncludePath.Length)
ShortestIncludePath = inc;
}
return includePath.TrimStart(new char[] { '\\', '/' });
return "..\\" + ShortestIncludePath.TrimStart(new char[] { '\\', '/' });
}
void TransformModule(TranslationUnit unit)

Loading…
Cancel
Save