Esempio n. 1
0
        public void GenerateFunction(Function function, DeclarationContext @namespace)
        {
            if (!function.IsGenerated || CLIHeaders.FunctionIgnored(function))
            {
                return;
            }

            GenerateDeclarationCommon(function);

            var classSig = string.Format("{0}::{1}", QualifiedIdentifier(@namespace),
                                         TranslationUnit.FileNameWithoutExtension);

            Write("{0} {1}::{2}(", function.ReturnType, classSig,
                  function.Name);

            for (var i = 0; i < function.Parameters.Count; ++i)
            {
                var param = function.Parameters[i];
                Write("{0}", CTypePrinter.VisitParameter(param));
                if (i < function.Parameters.Count - 1)
                {
                    Write(", ");
                }
            }

            WriteLine(")");
            WriteOpenBraceAndIndent();

            GenerateFunctionCall(function);

            UnindentAndWriteCloseBrace();
        }
Esempio n. 2
0
        public string GenerateParametersList(List <Parameter> parameters)
        {
            var types = new List <string>();

            foreach (var param in parameters)
            {
                types.Add(CTypePrinter.VisitParameter(param).ToString());
            }
            return(string.Join(", ", types));
        }
Esempio n. 3
0
        public void GenerateMethodParameters(Method method)
        {
            for (var i = 0; i < method.Parameters.Count; ++i)
            {
                if (method.Conversion == MethodConversionKind.FunctionToInstanceMethod &&
                    i == 0)
                {
                    continue;
                }

                var param = method.Parameters[i];
                Write("{0}", CTypePrinter.VisitParameter(param));
                if (i < method.Parameters.Count - 1)
                {
                    Write(", ");
                }
            }
        }
Esempio n. 4
0
        public override bool VisitFunctionDecl(Function function)
        {
            if (!function.IsGenerated || CppHeaders.FunctionIgnored(function))
            {
                return(false);
            }

            PushBlock(BlockKind.Function, function);

            GenerateDeclarationCommon(function);

            var returnType = function.ReturnType.Visit(CTypePrinter);

            var name = function.Visit(CTypePrinter);

            Write($"{returnType} ({name})(");

            for (var i = 0; i < function.Parameters.Count; ++i)
            {
                var param = function.Parameters[i];
                Write($"{CTypePrinter.VisitParameter(param)}");
                if (i < function.Parameters.Count - 1)
                {
                    Write(", ");
                }
            }

            WriteLine(")");
            WriteOpenBraceAndIndent();

            GenerateFunctionCall(function);

            UnindentAndWriteCloseBrace();

            PopBlock(NewLineKind.BeforeNextBlock);

            return(true);
        }