Example #1
0
        public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags)
        {
            Debug.Assert(printer != null && logPrinter != null);

            base.PrintTo(printer, logPrinter, flags);

            switch (arrayKind)
            {
            case ArrayKind.Invalid:
            {
                // void */PVOID
                PrimitiveNativeType.PrintNameTo(TypeName.Void, 1, printer, flags);
                break;
            }

            case ArrayKind.SafeArray:
            {
                // prefix with const if in-only
                if (isInOnly)
                {
                    printer.Print(OutputType.Keyword, "const");
                    printer.Print(OutputType.Other, " ");
                }

                // SAFEARRAY * or LPSAFEARRAY
                if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC)
                {
                    TypeName.PrintTo(printer, TypeName.SafeArray.PlainC);
                    printer.Print(OutputType.Other, " ");
                    printer.Print(OutputType.Operator, "*");
                }
                else
                {
                    TypeName.PrintTo(printer, "LP" + TypeName.SafeArray.WinApi);
                }
                break;
            }

            default:
            {
                elementType.PrintTo(printer, logPrinter, flags);
                break;
            }
            }

            if (indirections > 0)
            {
                // We'll suppress the [] suffix in this case; one indirection will be provided by the
                // element itself because the ByRefParam flag has been inherited by it.
                int stars = indirections;

                while (stars-- > 0)
                {
                    printer.Print(OutputType.Operator, "*");
                }
            }
        }