Browse Source

Removed the option for abstract impls enabling them by default for the C# generator.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/502/head
Dimitar Dobrev 10 years ago
parent
commit
77369b50c5
  1. 2
      src/Generator/Driver.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  3. 18
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  4. 1
      src/Generator/Options.cs
  5. 2
      tests/Basic/Basic.cs
  6. 1
      tests/CSharpTemp/CSharpTemp.cs
  7. 2
      tests/TypeMaps/TypeMaps.cs

2
src/Generator/Driver.cs

@ -265,7 +265,7 @@ namespace CppSharp @@ -265,7 +265,7 @@ namespace CppSharp
TranslationUnitPasses.AddPass(new FixDefaultParamValuesOfOverridesPass());
}
if (Options.GenerateAbstractImpls)
if (Options.IsCSharpGenerator)
TranslationUnitPasses.AddPass(new GenerateAbstractImplementationsPass());
if (Options.GenerateInterfacesForMultipleInheritance)

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

@ -264,9 +264,7 @@ namespace CppSharp.Generators.CSharp @@ -264,9 +264,7 @@ namespace CppSharp.Generators.CSharp
// if the class is an abstract impl, use the original for the object map
var qualifiedClass = QualifiedIdentifier(originalClass);
var type = qualifiedClass +
(Context.Driver.Options.GenerateAbstractImpls && originalClass.IsAbstract ?
"Internal" : "");
var type = string.Format("{0}{1}", qualifiedClass, originalClass.IsAbstract ? "Internal" : "");
if (returnType.IsAddress())
Context.Return.Write(HandleReturnedPointer(@class, type, qualifiedClass));

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

@ -648,7 +648,7 @@ namespace CppSharp.Generators.CSharp @@ -648,7 +648,7 @@ namespace CppSharp.Generators.CSharp
Write("internal ");
Write("unsafe ");
if (Driver.Options.GenerateAbstractImpls && @class.IsAbstract)
if (@class.IsAbstract)
Write("abstract ");
if (@class.IsStatic)
@ -806,7 +806,7 @@ namespace CppSharp.Generators.CSharp @@ -806,7 +806,7 @@ namespace CppSharp.Generators.CSharp
if (decl is Function)
{
var function = decl as Function;
if (isAbstract && Driver.Options.GenerateAbstractImpls)
if (isAbstract)
{
Write(";");
PopBlock(NewLineKind.BeforeNextBlock);
@ -946,7 +946,7 @@ namespace CppSharp.Generators.CSharp @@ -946,7 +946,7 @@ namespace CppSharp.Generators.CSharp
if (decl is Function)
{
var function = decl as Function;
if (isAbstract && Driver.Options.GenerateAbstractImpls)
if (isAbstract)
{
Write(";");
PopBlock(NewLineKind.BeforeNextBlock);
@ -1159,7 +1159,7 @@ namespace CppSharp.Generators.CSharp @@ -1159,7 +1159,7 @@ namespace CppSharp.Generators.CSharp
// check if overriding a property from a secondary base
if (prop.IsOverride && @class.GetRootBaseProperty(prop, true) != null)
Write("override ");
else if (prop.IsPure && Driver.Options.GenerateAbstractImpls)
else if (prop.IsPure)
Write("abstract ");
else if (prop.IsVirtual)
Write("virtual ");
@ -2024,8 +2024,7 @@ namespace CppSharp.Generators.CSharp @@ -2024,8 +2024,7 @@ namespace CppSharp.Generators.CSharp
// check if overriding a function from a secondary base
var isOverride = method.IsOverride && @class.GetRootBaseMethod(method, true) != null;
if (method.IsVirtual && !isOverride && !method.IsOperator &&
(!Driver.Options.GenerateAbstractImpls || !method.IsPure))
if (method.IsVirtual && !isOverride && !method.IsOperator && !method.IsPure)
Write("virtual ");
var isBuiltinOperator = method.IsOperator &&
@ -2041,7 +2040,7 @@ namespace CppSharp.Generators.CSharp @@ -2041,7 +2040,7 @@ namespace CppSharp.Generators.CSharp
Write("override ");
}
if (Driver.Options.GenerateAbstractImpls && method.IsPure)
if (method.IsPure)
Write("abstract ");
var functionName = GetMethodIdentifier(method);
@ -2062,8 +2061,7 @@ namespace CppSharp.Generators.CSharp @@ -2062,8 +2061,7 @@ namespace CppSharp.Generators.CSharp
Write(")");
if (method.SynthKind == FunctionSynthKind.DefaultValueOverload && method.IsConstructor &&
!(Driver.Options.GenerateAbstractImpls && method.IsPure))
if (method.SynthKind == FunctionSynthKind.DefaultValueOverload && method.IsConstructor && !method.IsPure)
{
Write(" : this({0})",
string.Join(", ",
@ -2072,7 +2070,7 @@ namespace CppSharp.Generators.CSharp @@ -2072,7 +2070,7 @@ namespace CppSharp.Generators.CSharp
p => p.Ignore ? p.DefaultArgument.String : p.Name)));
}
if (Driver.Options.GenerateAbstractImpls && method.IsPure)
if (method.IsPure)
{
Write(";");
PopBlock(NewLineKind.BeforeNextBlock);

1
src/Generator/Options.cs

@ -93,7 +93,6 @@ namespace CppSharp @@ -93,7 +93,6 @@ namespace CppSharp
public bool GenerateFunctionTemplates;
public bool GeneratePartialClasses;
public bool GenerateVirtualTables;
public bool GenerateAbstractImpls;
public bool GenerateInterfacesForMultipleInheritance;
public bool GenerateInternalImports;
public bool GenerateClassMarshals;

2
tests/Basic/Basic.cs

@ -22,8 +22,6 @@ namespace CppSharp.Tests @@ -22,8 +22,6 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver)
{
if (driver.Options.IsCSharpGenerator)
driver.Options.GenerateAbstractImpls = true;
driver.Options.GenerateVirtualTables = true;
driver.Options.GenerateCopyConstructors = true;
driver.Options.MarshalCharAsManagedChar = true;

1
tests/CSharpTemp/CSharpTemp.cs

@ -106,7 +106,6 @@ namespace CppSharp.Tests @@ -106,7 +106,6 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver)
{
driver.Options.GenerateAbstractImpls = true;
driver.Options.GenerateInterfacesForMultipleInheritance = true;
driver.Options.GeneratePropertiesAdvanced = true;
driver.Options.GenerateVirtualTables = true;

2
tests/TypeMaps/TypeMaps.cs

@ -15,8 +15,6 @@ namespace CppSharp.Tests @@ -15,8 +15,6 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver)
{
if (driver.Options.IsCSharpGenerator)
driver.Options.GenerateAbstractImpls = true;
driver.Options.GenerateVirtualTables = true;
driver.Options.GenerateCopyConstructors = true;
driver.Options.MarshalCharAsManagedChar = true;

Loading…
Cancel
Save