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

C# TypeQualifiers类代码示例

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

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



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

示例1: VisitArrayType

        public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
        {
            TypeMap typeMap;
            if (TypeMapDatabase.FindTypeMap(array, out typeMap) && typeMap.IsIgnored)
            {
                Ignore();
                return false;
            }

            if (array.SizeType != ArrayType.ArraySize.Constant)
                return true;

            var arrayElemType = array.Type.Desugar();

            Class @class;
            if (arrayElemType.TryGetClass(out @class) && @class.IsRefType)
                return true;

            PrimitiveType primitive;
            if ((arrayElemType.IsPrimitiveType(out primitive) && primitive != PrimitiveType.LongDouble) ||
                arrayElemType.IsPointerToPrimitiveType())
                return true;

            Ignore();
            return false;
        }
开发者ID:ymlai87416,项目名称:CppSharp,代码行数:26,代码来源:Types.cs


示例2: VisitPrimitiveType

 public override bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals)
 {
     // we do not support long double yet because its high-level representation is often problematic
     if (type == PrimitiveType.LongDouble)
     {
         Ignore();
         return false;
     }
     return base.VisitPrimitiveType(type, quals);
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:10,代码来源:Types.cs


示例3: VisitTypedefType

        public override bool VisitTypedefType(TypedefType typedef,
            TypeQualifiers quals)
        {
            TypeMap typeMap;
            if (TypeMapDatabase.FindTypeMap(typedef, out typeMap)
                && typeMap.IsIgnored)
            {
                Ignore();
                return false;
            }

            return base.VisitTypedefType(typedef, quals);
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:13,代码来源:Types.cs


示例4: VisitTemplateSpecializationType

        public override bool VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals)
        {
            if (AlreadyVisited(template) || template.Template.Access == AccessSpecifier.Private)
                return false;

            if (template.Arguments.Select(a => a.Type.Type.Desugar()).All(t => t.IsAddress() && !t.GetFinalPointee().IsDependent))
            {
                var cppTypePrinter = new CppTypePrinter { PrintScopeKind = CppTypePrintScopeKind.Qualified };
                templateInstantiations.Add(string.Format("{0}<{1}>", template.Template.Name,
                    string.Join(", ", template.Arguments.Select(a => a.Type.Type.Visit(cppTypePrinter)))));
            }

            return true;
        }
开发者ID:acklinr,项目名称:CppSharp,代码行数:14,代码来源:GenerateTemplatesCodePass.cs


示例5: VisitArrayType

        public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
        {
            if (!VisitType(array, quals))
                return false;

            switch (array.SizeType)
            {
                case ArrayType.ArraySize.Constant:
                    var supportBefore = Context.SupportBefore;
                    supportBefore.WriteLine("if ({0} != nullptr)", Context.ArgName);
                    supportBefore.WriteStartBraceIndent();
                    supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size);
                    supportBefore.WriteLineIndent("{0}[i] = {1}[i]{2};",
                        Context.ReturnVarName, Context.ArgName,
                        array.Type.IsPointerToPrimitiveType(PrimitiveType.Void) ? ".ToPointer()" : string.Empty);
                    supportBefore.WriteCloseBraceIndent();
                    break;
                default:
                    Context.Return.Write("null");
                    break;
            }
            return true;
        }
开发者ID:corefan,项目名称:CppSharp,代码行数:23,代码来源:CLIMarshal.cs


示例6: TypeQualifiers

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


示例7: __CreateInstance

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


示例8: TypeQualifiers

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


示例9: __CopyValue

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


示例10: TypeQualifiers

 internal TypeQualifiers(TypeQualifiers.Internal* native)
     : this(new global::System.IntPtr(native))
 {
 }
开发者ID:kidleon,项目名称:CppSharp,代码行数:4,代码来源:AST.cs


示例11: TypeQualifiers

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


示例12: VisitArrayType

        public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
        {
            if (!VisitType(array, quals))
                return false;

            Class @class;
            switch (array.SizeType)
            {
                case ArrayType.ArraySize.Constant:
                    var supportBefore = Context.SupportBefore;
                    string value = Generator.GeneratedIdentifier("value");
                    supportBefore.WriteLine("{0}[] {1} = null;", array.Type, value, array.Size);
                    supportBefore.WriteLine("if ({0} != null)", Context.ReturnVarName);
                    supportBefore.WriteStartBraceIndent();
                    supportBefore.WriteLine("{0} = new {1}[{2}];", value, array.Type, array.Size);
                    supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size);
                    if (array.Type.IsPointerToPrimitiveType(PrimitiveType.Void))
                        supportBefore.WriteLineIndent("{0}[i] = new global::System.IntPtr({1}[i]);",
                            value, Context.ReturnVarName);
                    else if (array.Type.Desugar().TryGetClass(out @class) && @class.IsRefType)
                        supportBefore.WriteLineIndent("{0}[i] = {1}.{2}(*(({1}.Internal*)&({3}[i * sizeof({1}.Internal)])));",
                            value, array.Type, Helpers.CreateInstanceIdentifier, Context.ReturnVarName);
                    else
                        supportBefore.WriteLineIndent("{0}[i] = {1}[i];", value, Context.ReturnVarName);
                    supportBefore.WriteCloseBraceIndent();
                    Context.Return.Write(value);
                    break;
                case ArrayType.ArraySize.Variable:
                    Context.Return.Write("null");
                    break;
            }

            return true;
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:34,代码来源:CSharpMarshal.cs


示例13: VisitTypedefType

        public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
        {
            if (!VisitType(typedef, quals))
                return false;

            var decl = typedef.Declaration;

            FunctionType func;
            if (decl.Type.IsPointerTo<FunctionType>(out func))
            {
                VisitDelegateType(func, typedef.Declaration.OriginalName);
                return true;
            }

            return decl.Type.Visit(this);
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:16,代码来源:CSharpMarshal.cs


示例14: VisitTemplateParameterType

 public override bool VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals)
 {
     Context.Return.Write(param.Parameter.Name);
     return true;
 }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:5,代码来源:CSharpMarshal.cs


示例15: VisitPointerType

        public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
        {
            if (!VisitType(pointer, quals))
                return false;

            var param = Context.Parameter;
            var isRefParam = param != null && (param.IsInOut || param.IsOut);

            var pointee = pointer.Pointee.Desugar();
            bool marshalPointeeAsString = CSharpTypePrinter.IsConstCharString(pointee) && isRefParam;

            if (CSharpTypePrinter.IsConstCharString(pointer) || marshalPointeeAsString)
            {
                if (param.IsOut)
                {
                    Context.Return.Write("IntPtr.Zero");
                    CSharpContext.ArgumentPrefix.Write("&");
                }
                else if (param.IsInOut)
                {
                    Context.Return.Write(MarshalStringToUnmanaged(Context.Parameter.Name));
                    CSharpContext.ArgumentPrefix.Write("&");
                }
                else
                {
                    Context.Return.Write(MarshalStringToUnmanaged(Context.Parameter.Name));
                    CSharpContext.Cleanup.WriteLine("Marshal.FreeHGlobal({0});", Context.ArgName);
                }
                return true;
            }

            if (pointee is FunctionType)
            {
                var function = pointee as FunctionType;
                return VisitDelegateType(function, function.ToString());
            }

            Class @class;
            if (pointee.TryGetClass(out @class) && @class.IsValueType)
            {
                if (Context.Parameter.Usage == ParameterUsage.Out)
                {
                    Context.SupportBefore.WriteLine("var {0} = new {1}.Internal();",
                        Generator.GeneratedIdentifier(Context.ArgName), @class.Name);
                }
                else
                {
                    Context.SupportBefore.WriteLine("var {0} = {1}.{2};",
                            Generator.GeneratedIdentifier(Context.ArgName),
                            Context.Parameter.Name,
                            Helpers.InstanceIdentifier);
                }

                Context.Return.Write("new global::System.IntPtr(&{0})",
                    Generator.GeneratedIdentifier(Context.ArgName));
                return true;
            }

            var finalPointee = pointer.GetFinalPointee();
            PrimitiveType primitive;
            if (finalPointee.IsPrimitiveType(out primitive) || finalPointee.IsEnumType())
            {
                // From MSDN: "note that a ref or out parameter is classified as a moveable
                // variable". This means we must create a local variable to hold the result
                // and then assign this value to the parameter.

                if (isRefParam)
                {
                    var typeName = Type.TypePrinterDelegate(finalPointee);

                    if (param.IsInOut)
                        Context.SupportBefore.WriteLine("{0} _{1} = {1};", typeName, param.Name);
                    else
                        Context.SupportBefore.WriteLine("{0} _{1};", typeName, param.Name);

                    Context.Return.Write("&_{0}", param.Name);
                }
                else
                    Context.Return.Write(Context.Parameter.Name);

                return true;
            }

            return pointer.Pointee.Visit(this, quals);
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:85,代码来源:CSharpMarshal.cs


示例16: VisitFunctionType

        public override bool VisitFunctionType(FunctionType type,
            TypeQualifiers quals)
        {
            var currentUniqueName = this.uniqueName;
            this.uniqueName = 0;
            var ret = base.VisitFunctionType(type, quals);
            this.uniqueName = currentUniqueName;

            return ret;
        }
开发者ID:xistoso,项目名称:CppSharp,代码行数:10,代码来源:CleanInvalidDeclNamesPass.cs


示例17: __CopyValue

 private static global::System.IntPtr __CopyValue(TypeQualifiers.Internal native)
 {
     global::System.IntPtr ret = Marshal.AllocHGlobal(3);
     *(TypeQualifiers.Internal*) ret = native;
     return ret;
 }
开发者ID:vovkasm,项目名称:CppSharp,代码行数:6,代码来源:AST.cs


示例18: VisitFunctionType

        public override bool VisitFunctionType(FunctionType function, TypeQualifiers quals)
        {
            var ptrName = Generator.GeneratedIdentifier("ptr") + Context.ParameterIndex;

            Context.SupportBefore.WriteLine("var {0} = {1};", ptrName,
                Context.ReturnVarName);

            Context.Return.Write("({1})Marshal.GetDelegateForFunctionPointer({0}, typeof({1}))",
                ptrName, function.ToString());
            return true;
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:11,代码来源:CSharpMarshal.cs


示例19: TypeQualifiers

 private TypeQualifiers(TypeQualifiers.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
开发者ID:KonajuGames,项目名称:CppSharp,代码行数:5,代码来源:AST.cs


示例20: VisitPrimitiveType

        public override bool VisitPrimitiveType(PrimitiveType primitive, TypeQualifiers quals)
        {
            switch (primitive)
            {
                case PrimitiveType.Void:
                    return true;
                case PrimitiveType.Bool:
                case PrimitiveType.Char:
                case PrimitiveType.UChar:
                case PrimitiveType.Short:
                case PrimitiveType.UShort:
                case PrimitiveType.Int:
                case PrimitiveType.UInt:
                case PrimitiveType.Long:
                case PrimitiveType.ULong:
                case PrimitiveType.LongLong:
                case PrimitiveType.ULongLong:
                case PrimitiveType.Float:
                case PrimitiveType.Double:
                case PrimitiveType.WideChar:
                case PrimitiveType.Null:
                    Context.Return.Write(Context.ReturnVarName);
                    return true;
                case PrimitiveType.Char16:
                    return false;
            }

            throw new NotImplementedException();
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:29,代码来源:CSharpMarshal.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TypeRef类代码示例发布时间:2022-05-24
下一篇:
C# TypeParameters类代码示例发布时间: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