Browse Source

Use the qualified pointee type when printing/visiting pointer types.

pull/705/head
Joao Matos 9 years ago
parent
commit
23b17c4df4
  1. 9
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 8
      src/Generator/Generators/CLI/CLITypePrinter.cs
  3. 4
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  4. 10
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

9
src/Generator/Generators/CLI/CLIMarshal.cs

@ -167,7 +167,7 @@ namespace CppSharp.Generators.CLI
return true; return true;
} }
return pointer.Pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
private string MarshalStringToManaged(string varName, BuiltinType type) private string MarshalStringToManaged(string varName, BuiltinType type)
@ -553,22 +553,21 @@ namespace CppSharp.Generators.CLI
{ {
if (Context.Function == null) if (Context.Function == null)
Context.Return.Write("&"); Context.Return.Write("&");
return pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
var finalPointee = pointer.GetFinalPointee(); var finalPointee = pointer.GetFinalPointee();
if (finalPointee.IsPrimitiveType()) if (finalPointee.IsPrimitiveType())
{ {
var cppTypePrinter = new CppTypePrinter(); var cppTypePrinter = new CppTypePrinter();
var cppTypeName = pointer.Visit(cppTypePrinter, var cppTypeName = pointer.Visit(cppTypePrinter, quals);
pointer.GetFinalQualifiedPointee().Qualifiers);
Context.Return.Write("({0})", cppTypeName); Context.Return.Write("({0})", cppTypeName);
Context.Return.Write(Context.Parameter.Name); Context.Return.Write(Context.Parameter.Name);
return true; return true;
} }
return pointer.Pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
public override bool VisitMemberPointerType(MemberPointerType member, public override bool VisitMemberPointerType(MemberPointerType member,

8
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -161,12 +161,12 @@ namespace CppSharp.Generators.CLI
var param = TypePrinterContext.Parameter; var param = TypePrinterContext.Parameter;
bool isRefParam = param != null && (param.IsOut || param.IsInOut); bool isRefParam = param != null && (param.IsOut || param.IsInOut);
if (isRefParam) if (isRefParam)
return pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
if (pointee.IsPrimitiveType(PrimitiveType.Void)) if (pointee.IsPrimitiveType(PrimitiveType.Void))
return "::System::IntPtr"; return "::System::IntPtr";
var result = pointee.Visit(this, quals); var result = pointer.QualifiedPointee.Visit(this);
return !isRefParam && result == "::System::IntPtr" ? "void**" : result + "*"; return !isRefParam && result == "::System::IntPtr" ? "void**" : result + "*";
} }
@ -184,13 +184,13 @@ namespace CppSharp.Generators.CLI
return string.Format("{0}*", typeName); return string.Format("{0}*", typeName);
} }
return pointer.Pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
public string VisitMemberPointerType(MemberPointerType member, public string VisitMemberPointerType(MemberPointerType member,
TypeQualifiers quals) TypeQualifiers quals)
{ {
return member.Pointee.Visit(this); return member.QualifiedPointee.Visit(this);
} }
public string VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals) public string VisitBuiltinType(BuiltinType builtin, TypeQualifiers quals)

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

@ -186,7 +186,7 @@ namespace CppSharp.Generators.CSharp
return true; return true;
} }
return pointer.Pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
private string MarshalStringToManaged(string varName, BuiltinType type) private string MarshalStringToManaged(string varName, BuiltinType type)
@ -600,7 +600,7 @@ namespace CppSharp.Generators.CSharp
return true; return true;
} }
return pointer.Pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
private string MarshalStringToUnmanaged(string varName) private string MarshalStringToUnmanaged(string varName)

10
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -311,7 +311,7 @@ namespace CppSharp.Generators.CSharp
var param = TypePrinterContext.Parameter; var param = TypePrinterContext.Parameter;
bool isRefParam = param != null && (param.IsOut || param.IsInOut); bool isRefParam = param != null && (param.IsOut || param.IsInOut);
if (isManagedContext && isRefParam) if (isManagedContext && isRefParam)
return pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
if (pointee.IsPrimitiveType(PrimitiveType.Void)) if (pointee.IsPrimitiveType(PrimitiveType.Void))
return IntPtrType; return IntPtrType;
@ -322,7 +322,7 @@ namespace CppSharp.Generators.CSharp
// Do not allow strings inside primitive arrays case, else we'll get invalid types // Do not allow strings inside primitive arrays case, else we'll get invalid types
// like string* for const char **. // like string* for const char **.
allowStrings = isRefParam; allowStrings = isRefParam;
var result = pointee.Visit(this, quals); var result = pointer.QualifiedPointee.Visit(this);
allowStrings = true; allowStrings = true;
return !isRefParam && result.Type == IntPtrType ? "void**" : result + "*"; return !isRefParam && result.Type == IntPtrType ? "void**" : result + "*";
@ -335,9 +335,9 @@ namespace CppSharp.Generators.CSharp
var param = TypePrinterContext.Parameter; var param = TypePrinterContext.Parameter;
if (isManagedContext && param != null && (param.IsOut || param.IsInOut) if (isManagedContext && param != null && (param.IsOut || param.IsInOut)
&& pointee == finalPointee) && pointee == finalPointee)
return pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
return pointee.Visit(this, quals) + "*"; return pointer.QualifiedPointee.Visit(this) + "*";
} }
Class @class; Class @class;
@ -348,7 +348,7 @@ namespace CppSharp.Generators.CSharp
return IntPtrType; return IntPtrType;
} }
return pointee.Visit(this, quals); return pointer.QualifiedPointee.Visit(this);
} }
public CSharpTypePrinterResult VisitMemberPointerType(MemberPointerType member, public CSharpTypePrinterResult VisitMemberPointerType(MemberPointerType member,

Loading…
Cancel
Save