Browse Source

Removed unnecessary Desugar() calls when testing whether or not a type is primitive.

The extension method IsPrimitiveType does the desugaring - see 55bbba46dd.
pull/225/head
Elias Holzer 12 years ago
parent
commit
3144976349
  1. 2
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 2
      src/Generator/Generators/CLI/CLISourcesTemplate.cs
  3. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  4. 2
      src/Generator/Passes/CheckIgnoredDecls.cs

2
src/Generator/Generators/CLI/CLIMarshal.cs

@ -501,7 +501,7 @@ namespace CppSharp.Generators.CLI @@ -501,7 +501,7 @@ namespace CppSharp.Generators.CLI
}
PrimitiveType primitive;
if (decl.Type.Desugar().IsPrimitiveType(out primitive))
if (decl.Type.IsPrimitiveType(out primitive))
{
Context.Return.Write("(::{0})", typedef.Declaration.QualifiedOriginalName);
}

2
src/Generator/Generators/CLI/CLISourcesTemplate.cs

@ -970,7 +970,7 @@ namespace CppSharp.Generators.CLI @@ -970,7 +970,7 @@ namespace CppSharp.Generators.CLI
if (Driver.Options.MarshalCharAsManagedChar)
{
foreach (var param in method.Parameters.Where(
p => p.Type.Desugar().IsPrimitiveType(PrimitiveType.Int8)))
p => p.Type.IsPrimitiveType(PrimitiveType.Int8)))
{
WriteLine("if ({0} < System::Char::MinValue || {0} > System::SByte::MaxValue)", param.Name);
WriteLineIndent(

4
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -2105,7 +2105,7 @@ namespace CppSharp.Generators.CSharp @@ -2105,7 +2105,7 @@ namespace CppSharp.Generators.CSharp
if (Driver.Options.MarshalCharAsManagedChar)
{
foreach (var param in method.Parameters.Where(
p => p.Type.Desugar().IsPrimitiveType(PrimitiveType.Int8)))
p => p.Type.IsPrimitiveType(PrimitiveType.Int8)))
{
WriteLine("if ({0} < char.MinValue || {0} > sbyte.MaxValue)", param.Name);
WriteLineIndent(
@ -2690,7 +2690,7 @@ namespace CppSharp.Generators.CSharp @@ -2690,7 +2690,7 @@ namespace CppSharp.Generators.CSharp
WriteLineIndent("EntryPoint=\"{0}\")]", function.Mangled);
if (function.ReturnType.Type.Desugar().IsPrimitiveType(PrimitiveType.Bool))
if (function.ReturnType.Type.IsPrimitiveType(PrimitiveType.Bool))
WriteLine("[return: MarshalAsAttribute(UnmanagedType.I1)]");
var @params = new List<string>();

2
src/Generator/Passes/CheckIgnoredDecls.cs

@ -342,7 +342,7 @@ namespace CppSharp.Passes @@ -342,7 +342,7 @@ namespace CppSharp.Passes
var arrayType = type as ArrayType;
PrimitiveType primitive;
if (arrayType != null && arrayType.SizeType == ArrayType.ArraySize.Constant &&
!arrayType.Type.Desugar().IsPrimitiveType(out primitive) &&
!arrayType.Type.IsPrimitiveType(out primitive) &&
!arrayType.Type.Desugar().IsPointerToPrimitiveType())
{
msg = "unsupported";

Loading…
Cancel
Save