• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# QualifiedType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中QualifiedType的典型用法代码示例。如果您正苦于以下问题:C# QualifiedType类的具体用法?C# QualifiedType怎么用?C# QualifiedType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QualifiedType类属于命名空间,在下文中一共展示了QualifiedType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IsStdType

        private bool IsStdType(QualifiedType type)
        {
            var typePrinter = new CppTypePrinter(Driver.TypeDatabase);
            var typeName = type.Visit(typePrinter);

            return typeName.Contains("std::");
        }
开发者ID:KonajuGames,项目名称:CppSharp,代码行数:7,代码来源:ParserGen.cs


示例2: VisitFunctionDecl

        public override bool VisitFunctionDecl(Function function)
        {
            if (!VisitDeclaration(function))
                return false;

            if (function.IsReturnIndirect)
            {
                var indirectParam = new Parameter()
                    {
                        Kind = ParameterKind.IndirectReturnType,
                        QualifiedType = function.ReturnType,
                        Name = "return",
                    };

                function.Parameters.Insert(0, indirectParam);
                function.ReturnType = new QualifiedType(new BuiltinType(
                    PrimitiveType.Void));
            }

            if (function.HasThisReturn)
            {
                // This flag should only be true on methods.
                var method = (Method) function;
                var classType = new QualifiedType(new TagType(method.Namespace),
                    new TypeQualifiers {IsConst = true});
                function.ReturnType = new QualifiedType(new PointerType(classType));
            }

            // TODO: Handle indirect parameters

            return true;
        }
开发者ID:corefan,项目名称:CppSharp,代码行数:32,代码来源:CheckAbiParameters.cs


示例3: ChangeToInterfaceType

 private static void ChangeToInterfaceType(QualifiedType type)
 {
     var tagType = type.Type.SkipPointerRefs() as TagType;
     if (tagType != null)
     {
         var @class = tagType.Declaration as Class;
         if (@class != null)
         {
             var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class);
             if (@interface != null)
                 tagType.Declaration = @interface;
         }
     }
 }
开发者ID:corefan,项目名称:CppSharp,代码行数:14,代码来源:ParamTypeToInterfacePass.cs


示例4: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (!method.IsConstructor)
                return false;
            if (method.IsCopyConstructor)
                return false;
            if (method.Parameters.Count != 1)
                return false;
            var parameter = method.Parameters[0];
            // TODO: disable implicit operators for C++/CLI because they seem not to be support parameters
            if (!Driver.Options.IsCSharpGenerator)
            {
                var pointerType = parameter.Type as PointerType;
                if (pointerType != null && !pointerType.IsReference)
                    return false;
            }
            var qualifiedPointee = parameter.Type.SkipPointerRefs();
            Class castFromClass;
            if (qualifiedPointee.TryGetClass(out castFromClass))
            {
                var castToClass = method.OriginalNamespace as Class;
                if (castToClass == null)
                    return false;
                if (castFromClass == castToClass)
                    return false;
            }

            var operatorKind = method.IsExplicit
                ? CXXOperatorKind.ExplicitConversion
                : CXXOperatorKind.Conversion;
            var qualifiedCastToType = new QualifiedType(new TagType(method.Namespace));
            var conversionOperator = new Method
            {
                Name = Operators.GetOperatorIdentifier(operatorKind),
                Namespace = method.Namespace,
                Kind = CXXMethodKind.Conversion,
                SynthKind = FunctionSynthKind.ComplementOperator,
                ConversionType = qualifiedCastToType,
                ReturnType = qualifiedCastToType,
                OperatorKind = operatorKind
            };
            var p = new Parameter(parameter);
            Class @class;
            if (p.Type.SkipPointerRefs().TryGetClass(out @class))
                p.QualifiedType = new QualifiedType(new TagType(@class), parameter.QualifiedType.Qualifiers);
            p.DefaultArgument = null;
            conversionOperator.Parameters.Add(p);
            ((Class) method.Namespace).Methods.Add(conversionOperator);
            return true;
        }
开发者ID:nalkaro,项目名称:CppSharp,代码行数:50,代码来源:ConstructorToConversionOperatorPass.cs


示例5: CheckType

        /// <summary>
        /// Generates a new typedef for the given type if necessary and returns the new type.
        /// </summary>
        /// <param name="namespace">The namespace the typedef will be added to.</param>
        /// <param name="type">The type to check.</param>
        /// <returns>The new type.</returns>
        private QualifiedType CheckType(DeclarationContext @namespace, QualifiedType type)
        {
            if (type.Type.IsDependent)
                return type;

            var pointerType = type.Type as PointerType;
            if (pointerType == null)
                return type;

            var functionType = pointerType.Pointee as FunctionType;
            if (functionType == null)
                return type;

            List<Typedef> typedefs;
            if (!allTypedefs.TryGetValue(@namespace.QualifiedName, out typedefs))
            {
                typedefs = new List<Typedef>();
                allTypedefs.Add(@namespace.QualifiedName, typedefs);
            }

            var typedef = FindMatchingTypedef(typedefs, functionType);
            if (typedef == null)
            {
                for (int i = 0; i < functionType.Parameters.Count; i++)
                {
                    functionType.Parameters[i].Name = string.Format("_{0}", i);
                }

                typedef = new TypedefDecl
                {
                    Access = AccessSpecifier.Public,
                    Name = string.Format("__AnonymousDelegate{0}", typedefs.Count),
                    Namespace = @namespace,
                    QualifiedType = type,
                    IsSynthetized = true
                };
                typedefs.Add(new Typedef
                {
                    Context = @namespace,
                    Declaration = typedef
                });
            }

            var typedefType = new TypedefType
            {
                Declaration = typedef
            };
            return new QualifiedType(typedefType);
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:55,代码来源:GenerateAnonymousDelegatesPass.cs


示例6: ChangeToInterfaceType

 private static void ChangeToInterfaceType(ref QualifiedType type)
 {
     var tagType = (type.Type.GetFinalPointee() ?? type.Type) as TagType;
     if (tagType != null)
     {
         var @class = tagType.Declaration as Class;
         if (@class != null)
         {
             var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class);
             if (@interface != null)
             {
                 type.Type = (Type) type.Type.Clone();
                 ((TagType) (type.Type.GetFinalPointee() ?? type.Type)).Declaration = @interface;
             }
         }
     }
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:17,代码来源:ParamTypeToInterfacePass.cs


示例7: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (AlreadyVisited(method) || !method.IsGenerated || !method.IsConstructor ||
                method.IsCopyConstructor || method.Parameters.Count != 1)
                return false;

            var parameter = method.Parameters[0];
            // TODO: disable implicit operators for C++/CLI because they seem not to be support parameters
            if (!Driver.Options.IsCSharpGenerator)
            {
                var pointerType = parameter.Type as PointerType;
                if (pointerType != null && !pointerType.IsReference)
                    return false;
            }
            var qualifiedPointee = parameter.Type.GetFinalPointee() ?? parameter.Type;
            Class castFromClass;
            var castToClass = method.OriginalNamespace as Class;
            if (qualifiedPointee.TryGetClass(out castFromClass))
            {
                if (castToClass == null || castToClass.IsAbstract)
                    return false;
                if (ConvertsBetweenDerivedTypes(castToClass, castFromClass))
                    return false;
            }
            if (castToClass != null && castToClass.IsAbstract)
                return false;
            var operatorKind = method.IsExplicit
                ? CXXOperatorKind.ExplicitConversion
                : CXXOperatorKind.Conversion;
            var qualifiedCastToType = new QualifiedType(new TagType(method.Namespace));
            var conversionOperator = new Method
            {
                Name = Operators.GetOperatorIdentifier(operatorKind),
                Namespace = method.Namespace,
                Kind = CXXMethodKind.Conversion,
                SynthKind = FunctionSynthKind.ComplementOperator,
                ConversionType = qualifiedCastToType,
                ReturnType = qualifiedCastToType,
                OperatorKind = operatorKind,
                IsExplicit = method.IsExplicit
            };
            conversionOperator.Parameters.Add(new Parameter(parameter) { DefaultArgument = null });
            ((Class) method.Namespace).Methods.Add(conversionOperator);
            return true;
        }
开发者ID:knomad,项目名称:CppSharp,代码行数:45,代码来源:ConstructorToConversionOperatorPass.cs


示例8: VisitFunctionDecl

        public override bool VisitFunctionDecl(Function function)
        {
            if (!VisitDeclaration(function))
                return false;

            if (function.IsReturnIndirect)
            {
                var indirectParam = new Parameter()
                    {
                        Kind = ParameterKind.IndirectReturnType,
                        QualifiedType = function.ReturnType,
                        Name = "return",
                    };

                function.Parameters.Insert(0, indirectParam);
                function.ReturnType = new QualifiedType(new BuiltinType(
                    PrimitiveType.Void));
            }

            var method = function as Method;

            if (function.HasThisReturn)
            {
                // This flag should only be true on methods.
                var classType = new QualifiedType(new TagType(method.Namespace),
                    new TypeQualifiers {IsConst = true});
                function.ReturnType = new QualifiedType(new PointerType(classType));
            }

            // Deleting destructors (default in v-table) accept an i32 bitfield as a
            // second parameter.in MS ABI.
            if (method != null && method.IsDestructor && Driver.Options.IsMicrosoftAbi)
            {
                method.Parameters.Add(new Parameter
                {
                    Kind = ParameterKind.ImplicitDestructorParameter,
                    QualifiedType = new QualifiedType(new BuiltinType(PrimitiveType.Int)),
                    Name = "delete"
                });
            }

            // TODO: Handle indirect parameters

            return true;
        }
开发者ID:xistoso,项目名称:CppSharp,代码行数:45,代码来源:CheckAbiParameters.cs


示例9: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (!method.IsConstructor)
                return false;
            if (method.IsCopyConstructor)
                return false;
            if (method.Parameters.Count != 1)
                return false;
            var parameter = method.Parameters[0];
            var parameterType = parameter.Type as PointerType;
            if (parameterType == null)
                return false;
            if (!parameterType.IsReference)
                return false;
            var qualifiedPointee = parameterType.QualifiedPointee;
            Class castFromClass;
            if (!qualifiedPointee.Type.TryGetClass(out castFromClass))
                return false;
            var castToClass = method.OriginalNamespace as Class;
            if (castToClass == null)
                return false;
            if (castFromClass == castToClass)
                return false;

            var operatorKind = method.IsExplicit
                ? CXXOperatorKind.ExplicitConversion
                : CXXOperatorKind.Conversion;
            var castToType = new TagType(castToClass);
            var qualifiedCastToType = new QualifiedType(castToType);
            var conversionOperator = new Method()
            {
                Name = Operators.GetOperatorIdentifier(operatorKind),
                Namespace = castFromClass,
                Kind = CXXMethodKind.Conversion,
                IsSynthetized = true,
                ConversionType = qualifiedCastToType,
                ReturnType = qualifiedCastToType
            };
            conversionOperator.OperatorKind = operatorKind;

            castFromClass.Methods.Add(conversionOperator);
            return true;
        }
开发者ID:kitsilanosoftware,项目名称:CppSharp,代码行数:43,代码来源:ConstructorToConversionOperatorPass.cs


示例10: GetInterfaceType

 private static QualifiedType GetInterfaceType(QualifiedType type)
 {
     var tagType = type.Type as TagType;
     if (tagType == null)
     {
         var pointerType = type.Type as PointerType;
         if (pointerType != null)
             tagType = pointerType.Pointee as TagType;
     }
     if (tagType != null)
     {
         var @class = tagType.Declaration as Class;
         if (@class != null)
         {
             var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class);
             if (@interface != null)
                 return new QualifiedType(new TagType(@interface));
         }
     }
     return type;
 }
开发者ID:jijamw,项目名称:CppSharp,代码行数:21,代码来源:ParamTypeToInterfacePass.cs


示例11: GetOrCreateProperty

        Property GetOrCreateProperty(Class @class, string name, QualifiedType type)
        {
            var prop = @class.Properties.FirstOrDefault(property => property.Name == name
                && property.QualifiedType.Equals(type));

            var prop2 = @class.Properties.FirstOrDefault(property => property.Name == name);

            if (prop == null && prop2 != null)
                Driver.Diagnostics.Debug("Property {0}::{1} already exists (type: {2})",
                    @class.Name, name, type.Type.ToString());

            if (prop != null)
                return prop;

            prop = new Property
            {
                Name = name,
                Namespace = @class,
                QualifiedType = type
            };

            @class.Properties.Add(prop);
            return prop;
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:24,代码来源:GetterSetterToPropertyPass.cs


示例12: __CopyValue

 private static void* __CopyValue(QualifiedType.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(8);
     *(QualifiedType.__Internal*) ret = native;
     return ret.ToPointer();
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:6,代码来源:CppSharp.CppParser.cs


示例13: GetUnderlyingType

 private static Type GetUnderlyingType(QualifiedType type)
 {
     TagType tagType = type.Type as TagType;
     if (tagType != null)
         return type.Type;
     // TODO: we should normally check pointer types for const;
     // however, there's some bug, probably in the parser, that returns IsConst = false for "const Type& arg"
     // so skip the check for the time being
     PointerType pointerType = type.Type as PointerType;
     return pointerType != null ? pointerType.Pointee : type.Type;
 }
开发者ID:jijamw,项目名称:CppSharp,代码行数:11,代码来源:GetterSetterToPropertyAdvancedPass.cs


示例14: QualifiedType

 internal QualifiedType(QualifiedType.Internal native)
     : this(&native)
 {
 }
开发者ID:kidleon,项目名称:CppSharp,代码行数:4,代码来源:AST.cs


示例15: GenerateDelegateSignature

        private string GenerateDelegateSignature(IEnumerable<Parameter> @params, QualifiedType returnType)
        {
            var typePrinter = new CSharpTypePrinter(Driver);
            typePrinter.PushContext(CSharpTypePrinterContextKind.Native);

            var typesBuilder = new StringBuilder();
            if (!returnType.Type.IsPrimitiveType(PrimitiveType.Void))
            {
                typesBuilder.Insert(0, returnType.Type.CSharpType(typePrinter));
                typesBuilder.Append('_');
            }
            foreach (var parameter in @params)
            {
                typesBuilder.Append(parameter.CSharpType(typePrinter));
                typesBuilder.Append('_');
            }
            if (typesBuilder.Length > 0)
                typesBuilder.Remove(typesBuilder.Length - 1, 1);
            var delegateName = typesBuilder.Replace("global::System.", string.Empty).Replace(
                "*", "Ptr").Replace('.', '_').ToString();
            if (returnType.Type.IsPrimitiveType(PrimitiveType.Void))
                delegateName = "Action_" + delegateName;
            else
                delegateName = "Func_" + delegateName;

            typePrinter.PopContext();
            return delegateName;
        }
开发者ID:galek,项目名称:CppSharp,代码行数:28,代码来源:DelegatesPass.cs


示例16: __CreateInstance

 public static QualifiedType __CreateInstance(QualifiedType.Internal native)
 {
     return new QualifiedType(native);
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:4,代码来源:AST.cs


示例17: QualifiedType

 protected QualifiedType(QualifiedType.Internal* native, bool skipVTables = false)
 {
     if (native == null)
         return;
     __Instance = new global::System.IntPtr(native);
 }
开发者ID:CSRedRat,项目名称:CppSharp,代码行数:6,代码来源:AST.cs


示例18: QualifiedType

 private QualifiedType(QualifiedType.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:6,代码来源:AST.cs


示例19: GenerateDelegateSignature

        private string GenerateDelegateSignature(IEnumerable<Parameter> @params, QualifiedType returnType)
        {
            TypePrinter.PushContext(CSharpTypePrinterContextKind.Native);
            CSharpTypePrinter.AppendGlobal = false;
            var typesBuilder = new StringBuilder();
            if (!returnType.Type.IsPrimitiveType(PrimitiveType.Void))
            {
                typesBuilder.Insert(0, returnType.Type.CSharpType(TypePrinter));
                typesBuilder.Append('_');
            }
            foreach (var parameter in @params)
            {
                typesBuilder.Append(parameter.CSharpType(TypePrinter));
                typesBuilder.Append('_');
            }
            if (typesBuilder.Length > 0)
                typesBuilder.Remove(typesBuilder.Length - 1, 1);
            var delegateName = Helpers.FormatTypesStringForIdentifier(typesBuilder);
            if (returnType.Type.IsPrimitiveType(PrimitiveType.Void))
                delegateName = "Action_" + delegateName;
            else
                delegateName = "Func_" + delegateName;

            TypePrinter.PopContext();
            CSharpTypePrinter.AppendGlobal = true;
            return delegateName;
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:27,代码来源:DelegatesPass.cs


示例20: GatherInternalParams

        public static IEnumerable<Parameter> GatherInternalParams(this Function function,
            bool isItaniumLikeAbi, bool universalDelegate = false)
        {
            var @params = new List<Parameter>();

            var method = function as Method;
            var isInstanceMethod = method != null && !method.IsStatic;

            var pointer = new QualifiedType(new PointerType(new QualifiedType(new BuiltinType(PrimitiveType.Void))));

            if (isInstanceMethod && !isItaniumLikeAbi)
            {
                @params.Add(new Parameter
                    {
                        QualifiedType = pointer,
                        Name = "instance"
                    });
            }

            if (!function.HasIndirectReturnTypeParameter &&
                isInstanceMethod && isItaniumLikeAbi)
            {
                @params.Add(new Parameter
                    {
                        QualifiedType = pointer,
                        Name = "instance"
                    });
            }

            var i = 0;
            foreach (var param in function.Parameters.Where(p => p.Kind != ParameterKind.OperatorParameter))
            {
                @params.Add(new Parameter
                    {
                        QualifiedType = universalDelegate && param.Kind == ParameterKind.IndirectReturnType ?
                            pointer : param.QualifiedType,
                        Kind = param.Kind,
                        Usage = param.Usage,
                        Name = universalDelegate ? "arg" + ++i : param.Name
                    });

                if (param.Kind == ParameterKind.IndirectReturnType &&
                    isInstanceMethod && isItaniumLikeAbi)
                {
                    @params.Add(new Parameter
                        {
                            QualifiedType = pointer,
                            Name = "instance"
                        });
                }
            }

            if (method != null && method.IsConstructor)
            {
                var @class = (Class) method.Namespace;
                if (!isItaniumLikeAbi && @class.Layout.HasVirtualBases)
                {
                    @params.Add(new Parameter
                        {
                            QualifiedType = new QualifiedType(new BuiltinType(PrimitiveType.Int)),
                            Name = "__forBases"
                        });
                }
            }

            return @params;
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:67,代码来源:FunctionExtensions.cs



注:本文中的QualifiedType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Quality类代码示例发布时间:2022-05-24
下一篇:
C# QualifiedName类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap