Browse Source

Reworked the method generation in the CLI backend to use blocks.

pull/34/merge
triton 12 years ago
parent
commit
75e650aa3b
  1. 16
      src/Generator/Generators/CLI/CLISourcesTemplate.cs

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

@ -122,8 +122,6 @@ namespace CppSharp.Generators.CLI @@ -122,8 +122,6 @@ namespace CppSharp.Generators.CLI
continue;
GenerateMethod(method, @class);
NewLine();
}
if (@class.IsRefType)
@ -574,9 +572,9 @@ namespace CppSharp.Generators.CLI @@ -574,9 +572,9 @@ namespace CppSharp.Generators.CLI
public void GenerateMethod(Method method, Class @class)
{
GenerateDeclarationCommon(method);
PushBlock(CLIBlockKind.Method, method);
if (method.Kind == CXXMethodKind.Constructor || method.Kind == CXXMethodKind.Destructor)
if (method.IsConstructor || method.IsDestructor)
Write("{0}::{1}(", QualifiedIdentifier(@class), SafeIdentifier(method.Name));
else
Write("{0} {1}::{2}(", method.ReturnType, QualifiedIdentifier(@class),
@ -586,8 +584,8 @@ namespace CppSharp.Generators.CLI @@ -586,8 +584,8 @@ namespace CppSharp.Generators.CLI
WriteLine(")");
if (method.Kind == CXXMethodKind.Constructor)
GenerateClassConstructorBase(@class, method);
if (method.IsConstructor)
GenerateClassConstructorBase(@class, isIntPtr: false, method: method);
WriteStartBraceIndent();
@ -598,7 +596,7 @@ namespace CppSharp.Generators.CLI @@ -598,7 +596,7 @@ namespace CppSharp.Generators.CLI
if (@class.IsRefType)
{
if (method.Kind == CXXMethodKind.Constructor)
if (method.IsConstructor)
{
if (!@class.IsAbstract)
{
@ -615,7 +613,7 @@ namespace CppSharp.Generators.CLI @@ -615,7 +613,7 @@ namespace CppSharp.Generators.CLI
}
else if (@class.IsValueType)
{
if (method.Kind != CXXMethodKind.Constructor)
if (!method.IsConstructor)
GenerateFunctionCall(method, @class);
else
GenerateValueTypeConstructorCall(method, @class);
@ -624,7 +622,9 @@ namespace CppSharp.Generators.CLI @@ -624,7 +622,9 @@ namespace CppSharp.Generators.CLI
SkipImpl:
PopBlock();
WriteCloseBraceIndent();
PopBlock(NewLineKind.Always);
}
private void GenerateValueTypeConstructorCall(Method method, Class @class)

Loading…
Cancel
Save