Browse Source

Revert "Threw an exception when there are parsing errors, and handled it in the test clients."

This reverts commit 01e872b30d.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/600/head
Dimitar Dobrev 10 years ago
parent
commit
48fece6aa1
  1. 15
      examples/SDL/SDL.cs
  2. 12
      src/Core/Parser/ParserException.cs
  3. 73
      src/CppParser/Bindings/ParserGen.cs
  4. 16
      src/CppParser/Bootstrap/Bootstrap.cs
  5. 3
      src/Generator/Driver.cs
  6. 15
      tests/CLI/CLI.cs
  7. 12
      tests/CSharp/CSharp.cs
  8. 15
      tests/Common/Common.cs
  9. 13
      tests/Encodings/Encodings.cs
  10. 12
      tests/NamespacesBase/NamespacesBase.cs
  11. 15
      tests/NamespacesDerived/NamespacesDerived.cs
  12. 13
      tests/StandardLib/StandardLib.cs
  13. 15
      tests/TypeMaps/TypeMaps.cs
  14. 15
      tests/VTables/VTables.cs

15
examples/SDL/SDL.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System;
using CppSharp.AST;
using CppSharp.AST;
using CppSharp.Passes;
namespace CppSharp
@ -67,17 +66,9 @@ namespace CppSharp @@ -67,17 +66,9 @@ namespace CppSharp
static class Program
{
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new SDL());
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new SDL());
}
}
}

12
src/Core/Parser/ParserException.cs

@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
using System;
namespace CppSharp
{
public class ParserException : Exception
{
public ParserException(string message)
: base(message)
{
}
}
}

73
src/CppParser/Bindings/ParserGen.cs

@ -149,51 +149,42 @@ namespace CppSharp @@ -149,51 +149,42 @@ namespace CppSharp
{
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
if (Platform.IsWindows)
{
if (Platform.IsWindows)
{
Console.WriteLine("Generating the C++/CLI parser bindings for Windows...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CLI, "i686-pc-win32-msvc",
CppAbi.Microsoft));
Console.WriteLine();
Console.WriteLine("Generating the C# parser bindings for Windows...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "i686-pc-win32-msvc",
CppAbi.Microsoft));
Console.WriteLine();
}
var osxHeadersPath = Path.Combine(GetSourceDirectory("build"), @"headers\osx");
if (Directory.Exists(osxHeadersPath) || Platform.IsMacOS)
{
Console.WriteLine("Generating the C# parser bindings for OSX...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "i686-apple-darwin12.4.0",
CppAbi.Itanium));
Console.WriteLine();
Console.WriteLine("Generating the C# parser bindings for OSX...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-apple-darwin12.4.0",
CppAbi.Itanium));
Console.WriteLine();
}
if (Directory.Exists(LINUX_INCLUDE_BASE_DIR))
{
Console.WriteLine("Generating the C# parser bindings for Linux...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-linux-gnu",
CppAbi.Itanium));
Console.WriteLine();
}
return 0;
Console.WriteLine("Generating the C++/CLI parser bindings for Windows...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CLI, "i686-pc-win32-msvc",
CppAbi.Microsoft));
Console.WriteLine();
Console.WriteLine("Generating the C# parser bindings for Windows...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "i686-pc-win32-msvc",
CppAbi.Microsoft));
Console.WriteLine();
}
catch (ArgumentException)
var osxHeadersPath = Path.Combine(GetSourceDirectory("build"), @"headers\osx");
if (Directory.Exists(osxHeadersPath) || Platform.IsMacOS)
{
Console.WriteLine("Generating the C# parser bindings for OSX...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "i686-apple-darwin12.4.0",
CppAbi.Itanium));
Console.WriteLine();
Console.WriteLine("Generating the C# parser bindings for OSX...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-apple-darwin12.4.0",
CppAbi.Itanium));
Console.WriteLine();
}
if (Directory.Exists(LINUX_INCLUDE_BASE_DIR))
{
return 1;
Console.WriteLine("Generating the C# parser bindings for Linux...");
ConsoleDriver.Run(new ParserGen(GeneratorKind.CSharp, "x86_64-linux-gnu",
CppAbi.Itanium));
Console.WriteLine();
}
}
}

16
src/CppParser/Bootstrap/Bootstrap.cs

@ -75,19 +75,11 @@ namespace CppSharp @@ -75,19 +75,11 @@ namespace CppSharp
{
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
Console.WriteLine("Generating parser bootstrap code...");
ConsoleDriver.Run(new Bootstrap());
Console.WriteLine();
return 0;
}
catch (ArgumentException)
{
return 1;
}
Console.WriteLine("Generating parser bootstrap code...");
ConsoleDriver.Run(new Bootstrap());
Console.WriteLine();
}
}

3
src/Generator/Driver.cs

@ -14,6 +14,7 @@ using CppSharp.Types; @@ -14,6 +14,7 @@ using CppSharp.Types;
using Microsoft.CSharp;
using CppSharp.Parser;
using System.CodeDom;
using System;
namespace CppSharp
{
@ -474,7 +475,7 @@ namespace CppSharp @@ -474,7 +475,7 @@ namespace CppSharp
if (!driver.ParseCode())
{
Log.Error("CppSharp has encountered an error while parsing code.");
throw new ParserException("Error parsing code.");
return;
}
if (!options.Quiet)

15
tests/CLI/CLI.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System;
using CppSharp.AST;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Utils;
@ -23,17 +22,9 @@ namespace CppSharp.Tests @@ -23,17 +22,9 @@ namespace CppSharp.Tests
{
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new CLITestsGenerator(GeneratorKind.CLI));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new CLITestsGenerator(GeneratorKind.CLI));
}
}
}

12
tests/CSharp/CSharp.cs

@ -157,17 +157,9 @@ namespace CppSharp.Tests @@ -157,17 +157,9 @@ namespace CppSharp.Tests
RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext);
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new CSharpTestsGenerator(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new CSharpTestsGenerator(GeneratorKind.CSharp));
}
}
}

15
tests/Common/Common.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using System.Linq;
using CppSharp.AST;
using CppSharp.Generators;
@ -79,18 +78,10 @@ namespace CppSharp.Tests @@ -79,18 +78,10 @@ namespace CppSharp.Tests
e => string.IsNullOrEmpty(e.Name)).Name = "RenamedEmptyEnum";
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new CommonTestsGenerator(GeneratorKind.CLI));
ConsoleDriver.Run(new CommonTestsGenerator(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new CommonTestsGenerator(GeneratorKind.CLI));
ConsoleDriver.Run(new CommonTestsGenerator(GeneratorKind.CSharp));
}
}
}

13
tests/Encodings/Encodings.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using System.Text;
using CppSharp.AST;
using CppSharp.Generators;
@ -23,17 +22,9 @@ namespace CppSharp.Tests @@ -23,17 +22,9 @@ namespace CppSharp.Tests
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new EncodingsTestsGenerator(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new EncodingsTestsGenerator(GeneratorKind.CSharp));
}
}
}

12
tests/NamespacesBase/NamespacesBase.cs

@ -33,17 +33,9 @@ namespace CppSharp.Tests @@ -33,17 +33,9 @@ namespace CppSharp.Tests
}
public class NamespacesBase {
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
}
}
}

15
tests/NamespacesDerived/NamespacesDerived.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
@ -41,18 +40,10 @@ namespace CppSharp.Tests @@ -41,18 +40,10 @@ namespace CppSharp.Tests
public class NamespacesDerived {
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
ConsoleDriver.Run(new NamespacesDerivedTests(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
ConsoleDriver.Run(new NamespacesDerivedTests(GeneratorKind.CSharp));
}
}

13
tests/StandardLib/StandardLib.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Utils;
@ -17,17 +16,9 @@ namespace CppSharp.Tests @@ -17,17 +16,9 @@ namespace CppSharp.Tests
ctx.SetClassAsValueType("IntWrapperValueType");
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new StandardLibTestsGenerator(GeneratorKind.CLI));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new StandardLibTestsGenerator(GeneratorKind.CLI));
}
}
}

15
tests/TypeMaps/TypeMaps.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using System.Linq;
using CppSharp.AST;
using CppSharp.Generators;
@ -28,18 +27,10 @@ namespace CppSharp.Tests @@ -28,18 +27,10 @@ namespace CppSharp.Tests
ctx.IgnoreClassWithName("IgnoredType");
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CLI));
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CLI));
ConsoleDriver.Run(new TypeMaps(GeneratorKind.CSharp));
}
}
}

15
tests/VTables/VTables.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using System;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
@ -24,18 +23,10 @@ namespace CppSharp.Tests @@ -24,18 +23,10 @@ namespace CppSharp.Tests
}
public static int Main(string[] args)
public static void Main(string[] args)
{
try
{
ConsoleDriver.Run(new VTableTests(GeneratorKind.CLI));
ConsoleDriver.Run(new VTableTests(GeneratorKind.CSharp));
return 0;
}
catch (ArgumentException)
{
return 1;
}
ConsoleDriver.Run(new VTableTests(GeneratorKind.CLI));
ConsoleDriver.Run(new VTableTests(GeneratorKind.CSharp));
}
}
}

Loading…
Cancel
Save