private static CSharpFunctionExtern MapFunctionExtern(ClangFunctionExtern clangFunctionExtern) { var name = clangFunctionExtern.Name; var originalCodeLocationComment = MapOriginalCodeLocationComment(clangFunctionExtern.CodeLocation); var returnType = MapType(clangFunctionExtern.ReturnType); var callingConvention = MapFunctionCallingConvention(clangFunctionExtern.CallingConvention); var parameters = MapFunctionExternParameters(clangFunctionExtern.Parameters); var result = new CSharpFunctionExtern( name, originalCodeLocationComment, callingConvention, returnType, parameters); return(result); }
private static MethodDeclarationSyntax CreateExternMethod(CSharpFunctionExtern cSharpFunctionExtern) { var functionName = cSharpFunctionExtern.Name; var functionReturnTypeName = cSharpFunctionExtern.ReturnType.Name; var functionReturnType = ParseTypeName(functionReturnTypeName); var functionCallingConvention = CallingConvention(cSharpFunctionExtern.CallingConvention); var functionParameters = cSharpFunctionExtern.Parameters; var methodParameters = CreateMethodParameters(functionParameters); var method = MethodDeclaration(functionReturnType, functionName) .WithDllImportAttribute(functionName, functionCallingConvention) .WithModifiers(TokenList( Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.ExternKeyword))) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) .AddParameterListParameters(methodParameters.ToArray()) .WithLeadingTrivia(Comment(cSharpFunctionExtern.CodeLocationComment)); return(method); }