当前位置: 首页>>代码示例>>C#>>正文


C# AST.Method类代码示例

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


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

示例1: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (!base.VisitMethodDecl(method))
            {
                return false;
            }

            if (!method.IsConstructor && (method.Name.EndsWith("Event", StringComparison.Ordinal) || method.Name == "event") &&
                method.Parameters.Count == 1)
            {
                var type = method.Parameters[0].Type;
                type = type.GetFinalPointee() ?? type;
                Class @class;
                if (type.TryGetClass(out @class) && @class.Name.EndsWith("Event", StringComparison.Ordinal))
                {
                    var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1);
                    method.Name = "on" + name;
                    Method baseMethod;
                    if (!method.IsOverride ||
                        (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null ||
                        baseMethod.IsPure)
                    {
                        this.events.Add(method);
                        this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName);
                    }
                }
            }
            return true;
        }
开发者ID:grbd,项目名称:QtSharp,代码行数:29,代码来源:GenerateEventEventsPass.cs

示例2: CanOverride

 static bool CanOverride(Method method, Method @override)
 {
     return method.OriginalName == @override.OriginalName &&
            method.ReturnType == @override.ReturnType &&
            method.Parameters.SequenceEqual(@override.Parameters,
                new ParameterTypeComparer());
 }
开发者ID:farawayzheng,项目名称:CppSharp,代码行数:7,代码来源:VTables.cs

示例3: VisitMethodDecl

 public override bool VisitMethodDecl(Method method)
 {
     if (!method.IsConstructor && (method.Name.EndsWith("Event") || method.Name == "event") &&
         method.Parameters.Count == 1 && method.Parameters[0].Type.ToString().EndsWith("Event") &&
         method.OriginalName != "widgetEvent")
     {
         Event @event = new Event();
         if (method.Name.StartsWith("on"))
         {
             @event.Name = method.Name.Substring(2);
         }
         else
         {
             @event.Name = method.Name;
         }
         @event.OriginalDeclaration = method;
         @event.Namespace = method.Namespace;
         @event.Parameters.AddRange(method.Parameters);
         method.Namespace.Events.Add(@event);
         this.events.Add(@event);
         if (!method.Name.StartsWith("on"))
             method.Name = "on" + char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1);
     }
     return base.VisitMethodDecl(method);
 }
开发者ID:YekMX,项目名称:QtSharp,代码行数:25,代码来源:GenerateEventEventsPass.cs

示例4: CheckNonVirtualInheritedFunctions

        public void CheckNonVirtualInheritedFunctions(Class @class, Class originalClass = null)
        {
            if (originalClass == null)
                originalClass = @class;

            foreach (BaseClassSpecifier baseSpecifier in @class.Bases)
            {
                var @base = baseSpecifier.Class;
                if (@base.IsInterface) continue;

                var nonVirtualOffset = ComputeNonVirtualBaseClassOffset(originalClass, @base);
                if (nonVirtualOffset == 0)
                    continue;

                foreach (var method in @base.Methods.Where(method =>
                    !method.IsVirtual && (method.Kind == CXXMethodKind.Normal)))
                {
                    Console.WriteLine(method);

                    var adjustedMethod = new Method(method)
                    {
                        SynthKind = FunctionSynthKind.AdjustedMethod,
                        AdjustedOffset = nonVirtualOffset,
                    };

                    originalClass.Methods.Add(adjustedMethod);
                }

                CheckNonVirtualInheritedFunctions(@base, originalClass);
            }
        }
开发者ID:corefan,项目名称:CppSharp,代码行数:31,代码来源:MultipleInheritancePass.cs

示例5: GenerateToString

 void GenerateToString(Class @class, Block block, Method method)
 {
     needsStreamInclude = true;
     block.WriteLine("std::ostringstream os;");
     block.WriteLine("os << *NativePtr;");
     block.Write("return clix::marshalString<clix::E_UTF8>(os.str());");
 }
开发者ID:tritao,项目名称:CppSharp,代码行数:7,代码来源:ObjectOverridesPass.cs

示例6: CanOverride

 public static bool CanOverride(this Method @override, Method method)
 {
     return (method.OriginalName == @override.OriginalName &&
         method.ReturnType == @override.ReturnType &&
         method.Parameters.SequenceEqual(@override.Parameters, ParameterTypeComparer.Instance)) ||
         (@override.IsDestructor && method.IsDestructor && method.IsVirtual);
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:7,代码来源:FunctionExtensions.cs

示例7: VisitMethodDecl

 public override bool VisitMethodDecl(Method method)
 {
     if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator &&
         !method.Ignore)
         DistributeMethod(method);
     return base.VisitMethodDecl(method);
 }
开发者ID:jijamw,项目名称:CppSharp,代码行数:7,代码来源:GetterSetterToPropertyAdvancedPass.cs

示例8: VisitMethodDecl

 public override bool VisitMethodDecl(Method method)
 {
     if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator &&
         method.IsGenerated && !method.IsSynthetized)
         DistributeMethod(method);
     return base.VisitMethodDecl(method);
 }
开发者ID:kitsilanosoftware,项目名称:CppSharp,代码行数:7,代码来源:GetterSetterToPropertyAdvancedPass.cs

示例9: VisitFunctionDecl

        public override bool VisitFunctionDecl(Function function)
        {
            if (function.Ignore || !function.IsOperator)
                return false;

            var param = function.Parameters[0];

            Class @class;
            if (!FunctionToInstanceMethodPass.GetClassParameter(param, out @class))
                return false;

            // Create a new fake method so it acts as a static method.

            var method = new Method(function)
            {
                Namespace = @class,
                Kind = CXXMethodKind.Operator,
                OperatorKind = function.OperatorKind,
                SynthKind = FunctionSynthKind.NonMemberOperator,
                OriginalFunction = null,
                IsStatic = true
            };

            function.ExplicityIgnored = true;

            @class.Methods.Add(method);

            Driver.Diagnostics.Debug("Function converted to operator: {0}::{1}",
                @class.Name, function.Name);

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

示例10: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (!base.VisitMethodDecl(method))
                return false;

            if (method.IsPure && method.IsOperator)
                method.ExplicitlyIgnore();

            return true;
        }
开发者ID:tritao,项目名称:CppSharp,代码行数:10,代码来源:IgnoreAbstractOperatorsPass.cs

示例11: VisitMethodDecl

        public override bool VisitMethodDecl(Method decl)
        {
            if (ASTUtils.CheckIgnoreMethod(decl))
                return false;

            if (!AlreadyVisited(decl) && decl.ExplicitInterfaceImpl == null)
                CheckDuplicate(decl);

            return false;
        }
开发者ID:jijamw,项目名称:CppSharp,代码行数:10,代码来源:CheckDuplicatedNamesPass.cs

示例12: VisitFunctionDecl

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

            // Check if this function can be converted.
            if (function.Parameters.Count == 0)
                return false;

            var classParam = function.Parameters[0];

            Class @class;
            if (!GetClassParameter(classParam, out @class))
                return false;

            // If we reach here, it means the first parameter is of class type.
            // This means we can change the function to be an instance method.

            // Clean up the name of the function now that it will be an instance method.
            if (!function.Name.StartsWith(@class.Name))
                return false;

            function.Name = function.Name.Substring(@class.Name.Length);
            function.ExplicitlyIgnore();

            // Create a new fake method so it acts as an instance method.
            var method = new Method
                {
                    Namespace = @class,
                    OriginalNamespace = function.Namespace,
                    Name = function.Name,
                    OriginalName = function.OriginalName,
                    Mangled = function.Mangled,
                    Access = AccessSpecifier.Public,
                    Kind = CXXMethodKind.Normal,
                    ReturnType = function.ReturnType,
                    Parameters = function.Parameters,
                    CallingConvention = function.CallingConvention,
                    IsVariadic = function.IsVariadic,
                    IsInline = function.IsInline,
                    Conversion = MethodConversionKind.FunctionToInstanceMethod
                };

            if (Options.GeneratorKind == GeneratorKind.CSharp)
                method.Parameters = method.Parameters.Skip(1).ToList();

            @class.Methods.Add(method);

            Diagnostics.Debug("Function converted to instance method: {0}::{1}", @class.Name,
                function.Name);

            return true;
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:53,代码来源:FunctionToInstanceMethodPass.cs

示例13: VisitMethodDecl

        public override bool VisitMethodDecl(Method method)
        {
            if (!VisitDeclaration(method))
                return false;

            if (ASTUtils.CheckIgnoreMethod(method, Driver.Options))
                return false;

            var @class = method.Namespace as Class;

            if (@class == null || @class.IsIncomplete)
                return false;

            if (method.IsConstructor)
                return false;

            if (method.IsSynthetized)
                return false;

            if (IsGetter(method))
            {
                var name = method.Name.Substring("get".Length);
                var prop = GetOrCreateProperty(@class, name, method.ReturnType);
                prop.GetMethod = method;
                prop.Access = method.Access;

                // Do not generate the original method now that we know it is a getter.
                method.GenerationKind = GenerationKind.Internal;

                Driver.Diagnostics.Debug("Getter created: {0}::{1}", @class.Name, name);

                return false;
            }

            if (IsSetter(method) && IsValidSetter(method))
            {
                var name = method.Name.Substring("set".Length);

                var type = method.Parameters[0].QualifiedType;
                var prop = GetOrCreateProperty(@class, name, type);
                prop.SetMethod = method;
                prop.Access = method.Access;

                // Ignore the original method now that we know it is a setter.
                method.GenerationKind = GenerationKind.Internal;

                Driver.Diagnostics.Debug("Setter created: {0}::{1}", @class.Name, name);

                return false;
            }

            return false;
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:53,代码来源:GetterSetterToPropertyPass.cs

示例14: VisitMethodDecl

 public override bool VisitMethodDecl(Method method)
 {
     if (method.IsOverride && !method.IsSynthetized)
     {
         Method rootBaseMethod = ((Class) method.Namespace).GetBaseMethod(method);
         for (int i = 0; i < method.Parameters.Count; i++)
         {
             method.Parameters[i].DefaultArgument = rootBaseMethod.Parameters[i].DefaultArgument;
         }
     }
     return base.VisitMethodDecl(method);
 }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:12,代码来源:FixDefaultParamValuesOfOverridesPass.cs

示例15: VisitMethodDecl

        public override bool VisitMethodDecl(Method decl)
        {
            if (!VisitDeclaration(decl))
                return false;

            if (ASTUtils.CheckIgnoreMethod(decl, Driver.Options))
                return false;

            if (decl.ExplicitInterfaceImpl == null)
                CheckDuplicate(decl);

            return false;
        }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:13,代码来源:CheckDuplicatedNamesPass.cs


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