Пример #1
0
        public bool GenerateTypedef(TypedefDecl typedef)
        {
            if (typedef.Ignore)
            {
                return(false);
            }

            FunctionType function;

            if (typedef.Type.IsPointerTo <FunctionType>(out function))
            {
                PushBlock(CLIBlockKind.Typedef, typedef);
                GenerateDeclarationCommon(typedef);

                WriteLine("public {0};",
                          string.Format(TypePrinter.VisitDelegate(function),
                                        SafeIdentifier(typedef.Name)));
                PopBlock(NewLineKind.BeforeNextBlock);

                return(true);
            }
            else if (typedef.Type.IsEnumType())
            {
                // Already handled in the parser.
            }
            else
            {
                Console.WriteLine("Unhandled typedef type: {0}", typedef);
            }

            return(false);
        }
Пример #2
0
        public bool GenerateTypedef(TypedefDecl typedef)
        {
            if (typedef.Ignore)
            {
                return(false);
            }

            FunctionType function;

            if (typedef.Type.IsPointerTo(out function))
            {
                PushBlock(CLIBlockKind.Typedef, typedef);
                GenerateDeclarationCommon(typedef);

                var insideClass = typedef.Namespace is Class;

                WriteLine("{0}{1};",
                          !insideClass ? "public " : "",
                          string.Format(TypePrinter.VisitDelegate(function),
                                        SafeIdentifier(typedef.Name)));
                PopBlock(NewLineKind.BeforeNextBlock);

                return(true);
            }

            return(false);
        }
Пример #3
0
        public bool GenerateTypedef(TypedefNameDecl typedef)
        {
            if (!typedef.IsGenerated)
            {
                return(false);
            }

            FunctionType function;

            if (typedef.Type.IsPointerTo(out function))
            {
                PushBlock(CLIBlockKind.Typedef, typedef);
                GenerateDeclarationCommon(typedef);

                var insideClass = typedef.Namespace is Class;

                var attributedType = typedef.Type.GetPointee() as AttributedType;
                if (attributedType != null)
                {
                    var equivalentFunctionType = attributedType.Equivalent.Type as FunctionType;
                    var callingConvention      = equivalentFunctionType.CallingConvention.ToInteropCallConv();
                    if (callingConvention != System.Runtime.InteropServices.CallingConvention.Winapi)
                    {
                        WriteLine("[{0}({1}::{2})] ",
                                  "System::Runtime::InteropServices::UnmanagedFunctionPointer",
                                  "System::Runtime::InteropServices::CallingConvention",
                                  callingConvention);
                    }
                }

                WriteLine("{0}{1};",
                          !insideClass ? "public " : "",
                          string.Format(TypePrinter.VisitDelegate(function),
                                        typedef.Name));
                PopBlock(NewLineKind.BeforeNextBlock);

                return(true);
            }

            return(false);
        }
Пример #4
0
        public bool GenerateTypedef(TypedefNameDecl typedef)
        {
            if (!typedef.IsGenerated)
            {
                return(false);
            }

            var functionType = typedef.Type as FunctionType;

            if (functionType != null || typedef.Type.IsPointerTo(out functionType))
            {
                PushBlock(BlockKind.Typedef, typedef);
                GenerateDeclarationCommon(typedef);

                var insideClass = typedef.Namespace is Class;

                var attributedType    = typedef.Type.GetPointee().Desugar();
                var callingConvention = attributedType == null && functionType != null
                    ? functionType.CallingConvention
                    : ((FunctionType)attributedType).CallingConvention;
                var interopCallConv = callingConvention.ToInteropCallConv();
                if (interopCallConv != System.Runtime.InteropServices.CallingConvention.Winapi)
                {
                    WriteLine("[System::Runtime::InteropServices::UnmanagedFunctionPointer" +
                              "(System::Runtime::InteropServices::CallingConvention::{0})] ",
                              interopCallConv);
                }

                WriteLine("{0}{1};",
                          !insideClass ? "public " : "",
                          string.Format(TypePrinter.VisitDelegate(functionType).ToString(),
                                        typedef.Name));
                PopBlock(NewLineKind.BeforeNextBlock);

                return(true);
            }

            return(false);
        }