Skip to content

Commit 634892e

Browse files
committed
Simplified the printing of pointers in C#.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 695a753 commit 634892e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/Generator/Generators/CSharp/CSharpTypePrinter.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,8 @@ public override TypePrinterResult VisitPointerType(PointerType pointer,
185185
if (MarshalKind == MarshalKind.NativeField)
186186
return IntPtrType;
187187

188-
var pointee = pointer.Pointee;
189-
190-
if (pointee is FunctionType)
191-
{
192-
var function = pointee as FunctionType;
193-
return string.Format("{0}", function.Visit(this, quals));
194-
}
188+
if (pointer.Pointee is FunctionType)
189+
return pointer.Pointee.Visit(this, quals);
195190

196191
var isManagedContext = ContextKind == TypePrinterContextKind.Managed;
197192

@@ -206,11 +201,10 @@ public override TypePrinterResult VisitPointerType(PointerType pointer,
206201
if (Options.Encoding == Encoding.Unicode ||
207202
Options.Encoding == Encoding.BigEndianUnicode)
208203
return string.Format("[MarshalAs(UnmanagedType.LPWStr)] string");
209-
throw new NotSupportedException(string.Format("{0} is not supported yet.",
210-
Options.Encoding.EncodingName));
204+
throw new NotSupportedException($"{Options.Encoding.EncodingName} is not supported yet.");
211205
}
212206

213-
var desugared = pointee.Desugar();
207+
var pointee = pointer.Pointee.Desugar();
214208

215209
// From http://msdn.microsoft.com/en-us/library/y31yhkeb.aspx
216210
// Any of the following types may be a pointer type:
@@ -243,7 +237,7 @@ public override TypePrinterResult VisitPointerType(PointerType pointer,
243237
}
244238

245239
Enumeration @enum;
246-
if (desugared.TryGetEnum(out @enum))
240+
if (pointee.TryGetEnum(out @enum))
247241
{
248242
// Skip one indirection if passed by reference
249243
if (isManagedContext && Parameter != null && (Parameter.IsOut || Parameter.IsInOut)
@@ -254,7 +248,7 @@ public override TypePrinterResult VisitPointerType(PointerType pointer,
254248
}
255249

256250
Class @class;
257-
if ((desugared.IsDependent || desugared.TryGetClass(out @class))
251+
if ((pointee.IsDependent || pointee.TryGetClass(out @class))
258252
&& ContextKind == TypePrinterContextKind.Native)
259253
{
260254
return IntPtrType;

0 commit comments

Comments
 (0)