Exemplo n.º 1
0
 /// <summary>
 /// Allows the interface name to be specified explicitly.
 /// </summary>
 public InterfaceNativeType(NativeTypeDesc desc, TypeName typeName)
     : base(desc)
 {
     this.typeName = typeName;
     this.isVariant = false;
     this.indirections++;
 }
Exemplo n.º 2
0
        protected internal static void PrintNameTo(TypeName typeName, int indirections, ICodePrinter printer, PrintFlags flags)
        {
            if (printer == null) throw new ArgumentNullException(nameof(printer));
            string output;

            if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC)
            {
                output = typeName.PlainC;
            }
            else
            {
                output = typeName.WinApi;

                if (indirections > 0)
                {
                    switch (typeName.PointerPrefix)
                    {
                        case TypeName.PtrPrefix.P_Prefix:
                        {
                            output = "P" + output;
                            indirections--;
                            break;
                        }

                        case TypeName.PtrPrefix.LP_Prefix:
                        {
                            output = "LP" + output;
                            indirections--;
                            break;
                        }
                    }
                }
            }
            TypeName.PrintTo(printer, output);

            if (indirections > 0)
            {
                if (!output.EndsWith("*")) printer.Print(OutputType.Other, " ");
                while (indirections-- > 0)
                {
                    printer.Print(OutputType.Operator, "*");
                }
            }
        }
Exemplo n.º 3
0
 public PrimitiveNativeType(TypeName typeName, bool platform64bit)
     : this(typeName, 0, platform64bit)
 {
 }
Exemplo n.º 4
0
        public PrimitiveNativeType(NativeTypeDesc desc, UnmanagedType[] allowedUnmanagedTypes)
            : this(desc)
        {
            if (desc == null) throw new ArgumentNullException(nameof(desc));
            UnmanagedType unmng_type = ValidateUnmanagedType(desc, allowedUnmanagedTypes);

            if (desc.Type == typeof(bool))
            {
                // Boolean as I1 and I2 should print 'bool' as the plain C++ type
                if (unmng_type == UnmanagedType.I1) typeName = TypeName.I1_Bool;
                if (unmng_type == UnmanagedType.U1) typeName = TypeName.U1_Bool;
            }

            if (typeName.IsEmpty)
            {
                typeName = TypeName.GetTypeNameForUnmanagedType(unmng_type);
                Debug.Assert(!typeName.IsEmpty);
            }

            if (unmng_type == UnmanagedType.SysInt ||
                unmng_type == UnmanagedType.SysUInt)
            {
                // IntPtr and UIntPtr translate into "void *"
                indirections++;
            }
        }
Exemplo n.º 5
0
 public PrimitiveNativeType(TypeName typeName, int indirections, bool platform64bit)
 {
     this.typeName = typeName;
     this.platform64bit = platform64bit;
     this.indirections = indirections;
 }