public bool GenerateTypedef(TypedefNameDecl typedef) { if (!typedef.IsGenerated) { return(false); } var functionType = typedef.Type as FunctionType; if (functionType != null || typedef.Type.IsPointerTo(out functionType)) { PushBlock(BlockKind.Typedef, typedef); GenerateDeclarationCommon(typedef); var insideClass = typedef.Namespace is Class; var attributedType = typedef.Type.GetPointee().Desugar(); var callingConvention = attributedType == null && functionType != null ? functionType.CallingConvention : ((FunctionType)attributedType).CallingConvention; var interopCallConv = callingConvention.ToInteropCallConv(); if (interopCallConv != System.Runtime.InteropServices.CallingConvention.Winapi) { WriteLine("[System::Runtime::InteropServices::UnmanagedFunctionPointer" + "(System::Runtime::InteropServices::CallingConvention::{0})] ", interopCallConv); } var visibility = !insideClass ? "public " : string.Empty; var result = CTypePrinter.VisitDelegate(functionType); result.Name = typedef.Name; WriteLine($"{visibility}{result};"); PopBlock(NewLineKind.BeforeNextBlock); return(true); } return(false); }
public override bool VisitTypedefNameDecl(TypedefNameDecl typedef) { if (!typedef.IsGenerated) { return(false); } var functionType = typedef.Type as FunctionType; if (functionType != null || typedef.Type.IsPointerTo(out functionType)) { PushBlock(BlockKind.Typedef, typedef); GenerateDeclarationCommon(typedef); var @delegate = string.Format(CTypePrinter.VisitDelegate(functionType), typedef.Name); WriteLine($"{@delegate};"); PopBlock(NewLineKind.BeforeNextBlock); return(true); } return(false); }