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

Loading…
Cancel
Save