From db2e796f356e48daf093617268b50f77e72f3ec6 Mon Sep 17 00:00:00 2001 From: zillemarco Date: Thu, 12 Oct 2017 11:03:09 +0200 Subject: [PATCH] Fixed error --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 9221ae05b5..ed081edee5 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -167,7 +167,8 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals) return true; } - if (finalPointee.IsPrimitiveType(out PrimitiveType primitive) || finalPointee.IsEnumType()) + PrimitiveType primitive; + if (finalPointee.IsPrimitiveType(out primitive) || finalPointee.IsEnumType()) { if (isRefParam) { @@ -267,7 +268,8 @@ public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) var decl = typedef.Declaration; - if (decl.Type is FunctionType functionType || decl.Type.IsPointerTo(out functionType)) + var functionType = decl.Type as FunctionType; + if (functionType != null || decl.Type.IsPointerTo(out functionType)) { var ptrName = Generator.GeneratedIdentifier("ptr") + Context.ParameterIndex; @@ -595,7 +597,9 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals) var param = Context.Parameter; var isRefParam = param != null && (param.IsInOut || param.IsOut); var finalPointee = pointer.GetFinalPointee(); - bool finalPointeeIsPrimitiveType = finalPointee.IsPrimitiveType(out PrimitiveType primitive); + + PrimitiveType primitive; + bool finalPointeeIsPrimitiveType = finalPointee.IsPrimitiveType(out primitive); if (CSharpTypePrinter.IsConstCharString(pointee) && isRefParam) {