Browse Source

Code formatting fixes.

pull/492/head
triton 10 years ago
parent
commit
95c34277a3
  1. 4
      src/Generator/AST/Utils.cs
  2. 23
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

4
src/Generator/AST/Utils.cs

@ -39,7 +39,7 @@ namespace CppSharp.AST
if (method.Access == AccessSpecifier.Private && !method.IsOverride && !method.IsExplicitlyGenerated) if (method.Access == AccessSpecifier.Private && !method.IsOverride && !method.IsExplicitlyGenerated)
return true; return true;
//Ignore copy constructor if a base class don't has or has a private copy constructor // Ignore copy constructor if a base class don't has or has a private copy constructor
if (method.IsCopyConstructor) if (method.IsCopyConstructor)
{ {
if (!options.GenerateCopyConstructors) if (!options.GenerateCopyConstructors)
@ -55,7 +55,7 @@ namespace CppSharp.AST
if (copyConstructor == null if (copyConstructor == null
|| copyConstructor.Access == AccessSpecifier.Private || copyConstructor.Access == AccessSpecifier.Private
|| !copyConstructor.IsDeclared) || !copyConstructor.IsDeclared)
return true; return true;
} }
} }
} }

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

@ -99,7 +99,8 @@ namespace CppSharp.Generators.CSharp
get { return "cs"; } get { return "cs"; }
} }
public CSharpTextTemplate(Driver driver, IEnumerable<TranslationUnit> units, CSharpTypePrinter typePrinter, CSharpExpressionPrinter expressionPrinter) public CSharpTextTemplate(Driver driver, IEnumerable<TranslationUnit> units,
CSharpTypePrinter typePrinter, CSharpExpressionPrinter expressionPrinter)
: base(driver, units) : base(driver, units)
{ {
TypePrinter = typePrinter; TypePrinter = typePrinter;
@ -487,7 +488,7 @@ namespace CppSharp.Generators.CSharp
{ {
foreach (var field in @class.Fields) foreach (var field in @class.Fields)
{ {
GenerateClassField(field); GenerateClassField(field);
} }
} }
@ -500,8 +501,7 @@ namespace CppSharp.Generators.CSharp
GenerateClassInternalHead(@class); GenerateClassInternalHead(@class);
WriteStartBraceIndent(); WriteStartBraceIndent();
var typePrinter = TypePrinter; TypePrinter.PushContext(CSharpTypePrinterContextKind.Native);
typePrinter.PushContext(CSharpTypePrinterContextKind.Native);
GenerateClassFields(@class, GenerateClassInternalsField, true); GenerateClassFields(@class, GenerateClassInternalsField, true);
if (@class.IsGenerated) if (@class.IsGenerated)
@ -512,18 +512,17 @@ namespace CppSharp.Generators.CSharp
var functions = GatherClassInternalFunctions(@class); var functions = GatherClassInternalFunctions(@class);
foreach (var function in functions) foreach (var function in functions)
{
GenerateInternalFunction(function); GenerateInternalFunction(function);
}
} }
typePrinter.PopContext(); TypePrinter.PopContext();
WriteCloseBraceIndent(); WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
} }
private IEnumerable<Function> GatherClassInternalFunctions(Class @class, bool includeCtors = true) private IEnumerable<Function> GatherClassInternalFunctions(Class @class,
bool includeCtors = true)
{ {
var functions = new List<Function>(); var functions = new List<Function>();
if (@class.IsValueType) if (@class.IsValueType)
@ -780,7 +779,8 @@ namespace CppSharp.Generators.CSharp
return Tuple.Create(library, decl.Mangled); return Tuple.Create(library, decl.Mangled);
} }
private void GeneratePropertySetter<T>(QualifiedType returnType, T decl, Class @class, bool isAbstract = false) private void GeneratePropertySetter<T>(QualifiedType returnType, T decl,
Class @class, bool isAbstract = false)
where T : Declaration, ITypedDecl where T : Declaration, ITypedDecl
{ {
if (!(decl is Function || decl is Field) ) if (!(decl is Function || decl is Field) )
@ -886,7 +886,7 @@ namespace CppSharp.Generators.CSharp
if (marshal.Context.Return.StringBuilder.Length > 0) if (marshal.Context.Return.StringBuilder.Length > 0)
{ {
WriteLine("{0} = {1};", ctx.ReturnVarName, marshal.Context.Return); WriteLine("{0} = {1};", ctx.ReturnVarName, marshal.Context.Return);
} }
if (arrayType != null && @class.IsValueType) if (arrayType != null && @class.IsValueType)
@ -936,7 +936,8 @@ namespace CppSharp.Generators.CSharp
} }
} }
private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl, Class @class, bool isAbstract = false) private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl,
Class @class, bool isAbstract = false)
where T : Declaration, ITypedDecl where T : Declaration, ITypedDecl
{ {
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);

Loading…
Cancel
Save