public override bool VisitFunctionDecl(Function function)
        {
            if (!VisitDeclaration(function))
            {
                return(false);
            }

            // push function declaration as current scope for parameters and return type
            DeclarationStack.Push(function);
            try
            {
                function.Attributes.Add(SuppressUnmanagedSecAttrib);
                ApplyDllImportAttribute(function);
                QualifiedType returnType = function.ReturnType;

                if (returnType.Type != null)
                {
                    VisitReturnType(( FunctionType )function.FunctionType.Type);
                }

                foreach (Parameter parameter in function.Parameters)
                {
                    parameter.Visit(this);
                }

                return(true);
            }
            finally
            {
                DeclarationStack.Pop( );
            }
        }
        public override bool VisitParameterDecl(Parameter parameter)
        {
            var scope = DeclarationStack.Peek( );

            // mapped settings override any implicit handling
            if (TryGetTransformInfo(scope.Name, parameter.Name, out YamlBindingTransform xform))
            {
                ApplyParameterMarshaling(parameter, xform);
            }
            else
            {
                ApplyImplicitParamsUsage(parameter);
            }

            return(true);
        }
        // visit delegate types by pushing the type onto the declaration stack
        // as the current scope for parameter handling etc... The typedef for
        // a function pointer has the name (FunctionType has no name )
        public override bool VisitTypedefDecl(TypedefDecl typedef)
        {
            if (typedef.IsDelegateTypeDef( ))
            {
                DeclarationStack.Push(typedef);
                try
                {
                    return(base.VisitTypedefDecl(typedef));
                }
                finally
                {
                    DeclarationStack.Pop( );
                }
            }

            return(true);
        }
        private bool VisitReturnType(FunctionType signature)
        {
            var scope = DeclarationStack.Peek( );

            if (TryGetTransformInfo(scope.Name, out YamlBindingTransform xform))
            {
                signature.ReturnType = xform.TransformType(signature.ReturnType);
                scope.Attributes.AddRange(xform.Attributes);
                if (scope is Function f)
                {
                    // sadly the CppSharp AST treats Function.ReturnType distinct from Function.FunctionType.ReturnType.
                    f.ReturnType = signature.ReturnType;
                }
            }

            return(true);
        }