Example #1
0
        public override bool VisitMethodDecl(Method method)
        {
            if (!VisitDeclaration(method))
            {
                return(false);
            }

            if (method.IsImplicit)
            {
                return(false);
            }

            PushBlock(BlockKind.Method, method);

            TypePrinter.PushContext(TypePrinterContextKind.Native);

            var returnTypeName = method.ReturnType.Visit(TypePrinter);

            Write($"public {returnTypeName} {GetCMethodIdentifier(method)}(");
            Write(TypePrinter.VisitParameters(method.Parameters, hasNames: true).ToString());
            Write(");");

            TypePrinter.PopContext();

            PopBlock(NewLineKind.Never);
            return(true);
        }
Example #2
0
        public override bool VisitMethodDecl(Method method)
        {
            PushBlock(BlockKind.Method, method);

            var @class = method.Namespace as Class;

            Write($"public {method.ReturnType} {CCodeGenerator.GetMethodIdentifier(method)}(");
            Write(TypePrinter.VisitParameters(method.Parameters, hasNames: true).ToString());
            Write(");");

            PopBlock(NewLineKind.Never);
            return(true);
        }
Example #3
0
        public override void GenerateMethodSpecifier(Method method, Class @class)
        {
            var keywords = new List <string>();

            if (method.IsGeneratedOverride())
            {
                Write("@Override");
                NewLine();
            }

            keywords.Add(AccessIdentifier(method.Access));

            if (@method.IsFinal)
            {
                keywords.Add("final");
            }

            if (method.IsStatic)
            {
                keywords.Add("static");
            }

            if (method.IsPure)
            {
                keywords.Add("abstract");
            }

            keywords = keywords.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
            if (keywords.Count != 0)
            {
                Write("{0} ", string.Join(" ", keywords));
            }

            var functionName = GetMethodIdentifier(method);

            if (method.IsConstructor || method.IsDestructor)
            {
                Write("{0}(", functionName);
            }
            else
            {
                Write("{0} {1}(", method.ReturnType, functionName);
            }

            Write("{0}", TypePrinter.VisitParameters(method.Parameters, hasNames: true));

            Write(")");
        }