Permalink
Browse files

Generated properties of supported template specialisations.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jul 12, 2017
1 parent 9f4d501 commit 3a3d003eb8e0817f9984afa19c0fa9c7e78416d2
Showing with 4 additions and 8 deletions.
  1. +0 −1 src/Generator/Passes/GetterSetterToPropertyPass.cs
  2. +4 −7 src/Generator/Types/Std/Stdlib.cs
@@ -335,7 +335,6 @@ public GetterSetterToPropertyPass()
VisitOptions.VisitClassFields = false;
VisitOptions.VisitClassProperties = false;
VisitOptions.VisitClassMethods = false;
VisitOptions.VisitClassTemplateSpecializations = false;
VisitOptions.VisitNamespaceEnums = false;
VisitOptions.VisitNamespaceTemplates = false;
VisitOptions.VisitNamespaceTypedefs = false;
@@ -94,15 +94,13 @@ public override void CSharpMarshalToManaged(CSharpMarshalContext ctx)
{
var type = ctx.ReturnType.Type.Desugar();
ClassTemplateSpecialization basicString = GetBasicString(type);
Declaration c_str = basicString.Methods.FirstOrDefault(m => m.OriginalName == "c_str");
if (!c_str.IsGenerated)
c_str = basicString.Properties.First(p => p.OriginalName == "c_str");
var c_str = basicString.Properties.First(p => p.OriginalName == "c_str");
var typePrinter = new CSharpTypePrinter(ctx.Context);
if (type.IsAddress() || ctx.Declaration is Field)
{
ctx.Return.Write("{0}.{1}({2}).{3}{4}",
ctx.Return.Write("{0}.{1}({2}).{3}",
basicString.Visit(typePrinter), Helpers.CreateInstanceIdentifier,
ctx.ReturnVarName, c_str.Name, c_str is Method ? "()" : string.Empty);
ctx.ReturnVarName, c_str.Name);
}
else
{
@@ -111,8 +109,7 @@ public override void CSharpMarshalToManaged(CSharpMarshalContext ctx)
varBasicString, basicString.Visit(typePrinter),
Helpers.CreateInstanceIdentifier, ctx.ReturnVarName);
ctx.Before.WriteStartBraceIndent();
ctx.Return.Write("{0}.{1}{2}", varBasicString, c_str.Name,
c_str is Method ? "()" : string.Empty);
ctx.Return.Write($"{varBasicString}.{c_str.Name}");
ctx.HasCodeBlock = true;
}
}

0 comments on commit 3a3d003

Please sign in to comment.