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 11 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
TranslationUnitPasses.AddPass(new FixDefaultParamValuesOfOverridesPass()); TranslationUnitPasses.AddPass(new FixDefaultParamValuesOfOverridesPass());
} }
if (Options.GenerateAbstractImpls) if (Options.IsCSharpGenerator)
TranslationUnitPasses.AddPass(new GenerateAbstractImplementationsPass()); TranslationUnitPasses.AddPass(new GenerateAbstractImplementationsPass());
if (Options.GenerateInterfacesForMultipleInheritance) if (Options.GenerateInterfacesForMultipleInheritance)

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

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

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

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

1
src/Generator/Options.cs

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

2
tests/Basic/Basic.cs

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

1
tests/CSharpTemp/CSharpTemp.cs

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

2
tests/TypeMaps/TypeMaps.cs

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

Loading…
Cancel
Save