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

C# DeclarationContext类代码示例

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

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



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

示例1: IsNameSpaceStd

 private static bool IsNameSpaceStd(DeclarationContext declarationContext)
 {
     if (declarationContext == null)
         return false;
     var @namespace = declarationContext as Namespace;
     if (@namespace != null && @namespace.IsInline)
         return IsNameSpaceStd(declarationContext.Namespace);
     return declarationContext.OriginalName == "std";
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:9,代码来源:MarkSupportedClassTemplateSpecializationsPass.cs


示例2: 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


示例3: GenerateProperty

 private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
 {
     Class type = (Class) context;
     if (type.Properties.All(p => getter.Name != p.Name ||
             p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
     {
         Property property = new Property();
         property.Name = GetPropertyName(getter.Name);
         property.Namespace = type;
         property.QualifiedType = getter.OriginalReturnType;
         if (getter.IsOverride || (setter != null && setter.IsOverride))
         {
             Property baseVirtualProperty = type.GetRootBaseProperty(property);
             if (baseVirtualProperty.SetMethod == null)
                 setter = null;
         }
         property.GetMethod = getter;
         property.SetMethod = setter;
         property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
         if (property.ExplicitInterfaceImpl == null && setter != null)
         {
             property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
         }
         if (getter.Comment != null)
         {
             var comment = new RawComment();
             comment.Kind = getter.Comment.Kind;
             comment.BriefText = getter.Comment.BriefText;
             comment.Text = getter.Comment.Text;
             comment.FullComment = new FullComment();
             comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks);
             if (setter != null && setter.Comment != null)
             {
                 comment.BriefText += Environment.NewLine + setter.Comment.BriefText;
                 comment.Text += Environment.NewLine + setter.Comment.Text;
                 comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks);
             }
             property.Comment = comment;
         }
         type.Properties.Add(property);
         getter.IsGenerated = false;
         if (setter != null)
             setter.IsGenerated = false;
     }
 }
开发者ID:jijamw,项目名称:CppSharp,代码行数:45,代码来源:GetterSetterToPropertyAdvancedPass.cs


示例4: VisitDeclarationContext

 public override bool VisitDeclarationContext(DeclarationContext context)
 {
     return context.IsGenerated && !context.TranslationUnit.IsSystemHeader && base.VisitDeclarationContext(context);
 }
开发者ID:grbd,项目名称:QtSharp,代码行数:4,代码来源:GetCommentsFromQtDocsPass.cs


示例5: DeclarationContext

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


示例6: DeclarationContext

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


示例7: HandleQSignal

        private void HandleQSignal(DeclarationContext @class, Method method)
        {
            var expansions = method.AccessDecl.PreprocessedEntities.OfType<MacroExpansion>();
            if (expansions.All(e => e.Text != "Q_SIGNALS"))
            {
                return;
            }
            if (method.Parameters.Any())
            {
                Class decl;
                if (method.Parameters.Last().Type.TryGetClass(out decl) && decl.Name == "QPrivateSignal")
                {
                    method.Parameters.RemoveAt(method.Parameters.Count - 1);
                }
            }
            var functionType = method.GetFunctionType();

            var @event = new Event
                         {
                             OriginalDeclaration = method,
                             Name = method.Name,
                             OriginalName = method.OriginalName,
                             Namespace = method.Namespace,
                             QualifiedType = new QualifiedType(functionType),
                             Parameters = method.Parameters
                         };
            method.GenerationKind = GenerationKind.None;
            @class.Events.Add(@event);
            this.events.Add(@event);
        }
开发者ID:nanox,项目名称:QtSharp,代码行数:30,代码来源:GenerateSignalEventsPass.cs


示例8: VisitDeclarationContext

 public override bool VisitDeclarationContext(DeclarationContext context)
 {
     return context.IsGenerated && base.VisitDeclarationContext(context);
 }
开发者ID:nanox,项目名称:QtSharp,代码行数:4,代码来源:GetCommentsFromQtDocsPass.cs


示例9: __CreateInstance

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


示例10: CreateInterfaceProperty

 private static Property CreateInterfaceProperty(Property property, DeclarationContext @namespace)
 {
     var interfaceProperty = new Property(property) { Namespace = @namespace };
     if (property.GetMethod != null)
         interfaceProperty.GetMethod = new Method(property.GetMethod)
             {
                 OriginalFunction = property.GetMethod,
                 Namespace = @namespace
             };
     if (property.SetMethod != null)
         // handle indexers
         interfaceProperty.SetMethod = property.GetMethod == property.SetMethod ?
             interfaceProperty.GetMethod : new Method(property.SetMethod)
                 {
                     OriginalFunction = property.SetMethod,
                     Namespace = @namespace
                 };
     return interfaceProperty;
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:19,代码来源:MultipleInheritancePass.cs


示例11: DeclarationContext

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


示例12: GenerateProperty

 private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
 {
     var type = (Class) context;
     if (type.Properties.All(p => getter.Name != p.Name ||
         p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
     {
         var property = new Property
         {
             Access = getter.Access == AccessSpecifier.Public ||
                 (setter != null && setter.Access == AccessSpecifier.Public)
                 ? AccessSpecifier.Public
                 : AccessSpecifier.Protected,
             Name = GetPropertyName(getter.Name),
             Namespace = type,
             QualifiedType = getter.OriginalReturnType,
             OriginalNamespace = getter.OriginalNamespace
         };
         if (getter.IsOverride || (setter != null && setter.IsOverride))
         {
             var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
             if (baseVirtualProperty.SetMethod == null)
                 setter = null;
         }
         property.GetMethod = getter;
         property.SetMethod = setter;
         property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
         if (property.ExplicitInterfaceImpl == null && setter != null)
         {
             property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
         }
         if (getter.Comment != null)
         {
             property.Comment = CombineComments(getter, setter);
         }
         type.Properties.Add(property);
         getter.GenerationKind = GenerationKind.Internal;
         if (setter != null)
             setter.GenerationKind = GenerationKind.Internal;
     }
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:40,代码来源:GetterSetterToPropertyAdvancedPass.cs


示例13: GetFileForDeclarationContext

 private static string GetFileForDeclarationContext(DeclarationContext declarationContext)
 {
     if (string.IsNullOrEmpty(declarationContext.Name))
     {
         return "qtglobal.html";
     }
     StringBuilder fileNameBuilder = new StringBuilder(declarationContext.Name.ToLowerInvariant());
     if (declarationContext is Class && ((Class) declarationContext).IsInterface)
     {
         fileNameBuilder.Remove(0, 1);
     }
     Class parentClass = declarationContext.Namespace as Class;
     if (parentClass != null)
     {
         fileNameBuilder.Insert(0, string.Format("{0}-", parentClass.Name.ToLowerInvariant()));
     }
     fileNameBuilder.Append(".html");
     return fileNameBuilder.ToString();
 }
开发者ID:RodolpheFouquet,项目名称:QtSharp,代码行数:19,代码来源:Documentation.cs


示例14: GenerateProperty

            private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
            {
                var type = (Class) context;
                var name = GetPropertyName(getter.Name);
                if (type.Properties.Any(p => p.Name == name &&
                    p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
                    return;

                var property = new Property
                {
                    Access = getter.Access == AccessSpecifier.Public ||
                        (setter != null && setter.Access == AccessSpecifier.Public) ?
                            AccessSpecifier.Public : AccessSpecifier.Protected,
                    Name = name,
                    Namespace = type,
                    QualifiedType = getter.OriginalReturnType,
                    OriginalNamespace = getter.OriginalNamespace
                };
                if (getter.IsOverride || (setter != null && setter.IsOverride))
                {
                    var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
                    if (baseVirtualProperty == null && type.GetBaseMethod(getter, getTopmost: true).IsGenerated)
                        throw new Exception(string.Format(
                            "Property {0} has a base property null but its getter has a generated base method.",
                            getter.QualifiedOriginalName));
                    if (baseVirtualProperty != null && !baseVirtualProperty.IsVirtual)
                    {
                        // the only way the above can happen is if we are generating properties in abstract implementations
                        // in which case we can have less naming conflicts since the abstract base can also contain non-virtual properties
                        if (getter.SynthKind == FunctionSynthKind.AbstractImplCall)
                            return;
                        throw new Exception(string.Format(
                            "Base of property {0} is not virtual while the getter is.",
                            getter.QualifiedOriginalName));
                    }
                    if (baseVirtualProperty != null && baseVirtualProperty.SetMethod == null)
                        setter = null;
                }
                property.GetMethod = getter;
                property.SetMethod = setter;
                property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
                if (property.ExplicitInterfaceImpl == null && setter != null)
                {
                    property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
                }
                if (getter.Comment != null)
                {
                    property.Comment = CombineComments(getter, setter);
                }
                type.Properties.Add(property);
                getter.GenerationKind = GenerationKind.Internal;
                if (setter != null)
                    setter.GenerationKind = GenerationKind.Internal;
            }
开发者ID:tritao,项目名称:CppSharp,代码行数:54,代码来源:GetterSetterToPropertyAdvancedPass.cs


示例15: HandleQSignal

        private void HandleQSignal(DeclarationContext @class, Method method)
        {
            AccessSpecifierDecl access = method.AccessDecl;

            IEnumerable<MacroExpansion> expansions = access.PreprocessedEntities.OfType<MacroExpansion>();
            if (expansions.All(e => e.Text != "Q_SIGNALS"))
            {
                return;
            }
            if (method.Parameters.Any())
            {
                Declaration decl;
                if (method.Parameters.Last().Type.IsTagDecl(out decl) && decl.Name == "QPrivateSignal")
                {
                    method.Parameters.RemoveAt(method.Parameters.Count - 1);
                }
            }
            FunctionType functionType = method.GetFunctionType();

            Event @event = new Event
                            {
                                OriginalDeclaration = method,
                                Name = method.Name,
                                OriginalName = method.OriginalName,
                                Namespace = method.Namespace,
                                QualifiedType = new QualifiedType(functionType),
                                Parameters = method.Parameters
                            };
            method.IsGenerated = false;
            @class.Events.Add(@event);
            this.events.Add(@event);
        }
开发者ID:RodolpheFouquet,项目名称:QtSharp,代码行数:32,代码来源:GenerateSignalEventsPass.cs


示例16: VisitDeclarationContext

 public override bool VisitDeclarationContext(DeclarationContext context)
 {
     return false;
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:4,代码来源:CleanUnitPass.cs


示例17: DeclarationContext

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


示例18: __CopyValue

 private static void* __CopyValue(DeclarationContext.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(248);
     global::CppSharp.Parser.AST.DeclarationContext.__Internal.cctor_2(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:6,代码来源:CppSharp.CppParser.cs


示例19: DeclarationContext

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


示例20: GenerateDeclContext

        public void GenerateDeclContext(DeclarationContext decl)
        {
            // Generate all the type references for the module.
            foreach (var typeRef in decl.TypeReferences)
            {
                WriteLine(typeRef.FowardReference);
            }

            // Generate all the enum declarations for the module.
            foreach (var @enum in decl.Enums)
            {
                if ([email protected] || @enum.IsIncomplete)
                    continue;

                PushBlock(CLIBlockKind.Enum, @enum);
                GenerateEnum(@enum);
                PopBlock(NewLineKind.BeforeNextBlock);
            }

            // Generate all the typedef declarations for the module.
            GenerateTypedefs(decl);

            // Generate all the struct/class declarations for the module.
            foreach (var @class in decl.Classes)
            {
                if ([email protected] || @class.IsIncomplete)
                    continue;

                if (@class.IsOpaque)
                    continue;

                PushBlock(CLIBlockKind.Class, @class);
                GenerateClass(@class);
                PopBlock(NewLineKind.BeforeNextBlock);
            }

            if (decl.HasFunctions)
                GenerateFunctions(decl);

            foreach (var childNamespace in decl.Namespaces)
                GenerateNamespace(childNamespace);
        }
开发者ID:acklinr,项目名称:CppSharp,代码行数:42,代码来源:CLIHeadersTemplate.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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