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


C# Function.ExplicitlyIgnore方法代码示例

本文整理汇总了C#中System.Function.ExplicitlyIgnore方法的典型用法代码示例。如果您正苦于以下问题:C# Function.ExplicitlyIgnore方法的具体用法?C# Function.ExplicitlyIgnore怎么用?C# Function.ExplicitlyIgnore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Function的用法示例。


在下文中一共展示了Function.ExplicitlyIgnore方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateName

        private bool UpdateName(Function function)
        {
            if (function.TranslationUnit.Module != null)
                Generator.CurrentOutputNamespace = function.TranslationUnit.Module.OutputNamespace;

            var @params = function.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType)
                                .Select(p => p.QualifiedType.ToString());
            // Include the conversion type in case of conversion operators
            var method = function as Method;
            if (method != null &&
                method.IsOperator &&
                (method.OperatorKind == CXXOperatorKind.Conversion ||
                 method.OperatorKind == CXXOperatorKind.ExplicitConversion))
                @params = @params.Concat(new[] { method.ConversionType.ToString() });
            var signature = string.Format("{0}({1})", function.Name, string.Join( ", ", @params));
            signature = FixSignatureForConversions(function, signature);

            if (Count == 0)
                Count++;

            if (!methodSignatures.ContainsKey(signature))
            {
                methodSignatures.Add(signature, 0);
                return false;
            }

            var methodCount = ++methodSignatures[signature];

            if (Count < methodCount + 1)
                Count = methodCount + 1;

            if (function.IsOperator)
            {
                // TODO: turn into a method; append the original type (say, "signed long")
                // of the last parameter to the type so that the user knows which overload is called
                diagnostics.Warning("Duplicate operator {0} ignored", function.Name);
                function.ExplicitlyIgnore();
            }
            else if (method != null && method.IsConstructor)
            {
                diagnostics.Warning("Duplicate constructor {0} ignored", function.Name);
                function.ExplicitlyIgnore();
            }
            else
                function.Name += methodCount.ToString(CultureInfo.InvariantCulture);
            return true;
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:47,代码来源:CheckDuplicatedNamesPass.cs

示例2: VisitFunctionDecl

        public override bool VisitFunctionDecl(Function function)
        {
            if (function.GenerationKind == GenerationKind.None)
                return false;

            if (function.Parameters.Any(param => IsStdType(param.QualifiedType)))
            {
                function.ExplicitlyIgnore();
                return false;
            }

            return true;
        }
开发者ID:KonajuGames,项目名称:CppSharp,代码行数:13,代码来源:ParserGen.cs

示例3: CheckDefaultParameters

        static bool CheckDefaultParameters(Function function, Function overload)
        {
            var commonParameters = Math.Min(function.Parameters.Count, overload.Parameters.Count);

            var i = 0;
            for (; i < commonParameters; ++i)
            {
                var funcParam = function.Parameters[i];
                var overloadParam = overload.Parameters[i];

                if (!funcParam.QualifiedType.Equals(overloadParam.QualifiedType))
                    return false;
            }

            for (; i < function.Parameters.Count; ++i)
            {
                var funcParam = function.Parameters[i];
                if (!funcParam.HasDefaultValue)
                    return false;
            }

            for (; i < overload.Parameters.Count; ++i)
            {
                var overloadParam = overload.Parameters[i];
                if (!overloadParam.HasDefaultValue)
                    return false;
            }

            if (function.Parameters.Count > overload.Parameters.Count)
                overload.ExplicitlyIgnore();
            else
                function.ExplicitlyIgnore();

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

示例4: VisitFunctionDecl

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

            var ret = function.ReturnType;

            string msg;
            if (HasInvalidType(ret.Type, out msg))
            {
                function.ExplicitlyIgnore();
                Log.Debug("Function '{0}' was ignored due to {1} return decl",
                    function.Name, msg);
                return false;
            }

            foreach (var param in function.Parameters)
            {
                if (HasInvalidDecl(param, out msg))
                {
                    function.ExplicitlyIgnore();
                    Log.Debug("Function '{0}' was ignored due to {1} param",
                        function.Name, msg);
                    return false;
                }

                if (HasInvalidType(param.Type, out msg))
                {
                    function.ExplicitlyIgnore();
                    Log.Debug("Function '{0}' was ignored due to {1} param",
                        function.Name, msg);
                    return false;
                }

                var decayedType = param.Type.Desugar() as DecayedType;
                if (decayedType != null)
                {
                    function.ExplicitlyIgnore();
                    Log.Debug("Function '{0}' was ignored due to unsupported decayed type param",
                        function.Name);
                    return false;
                }

                if (param.Kind == ParameterKind.IndirectReturnType)
                {
                    Class retClass;
                    param.Type.Desugar().TryGetClass(out retClass);
                    if (retClass == null)
                    {
                        function.ExplicitlyIgnore();
                        Log.Debug(
                            "Function '{0}' was ignored due to an indirect return param not of a tag type",
                            function.Name);
                        return false;
                    }
                }
            }

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

示例5: CheckSingleParameterPointerConstnessForAmbiguity

        private static bool CheckSingleParameterPointerConstnessForAmbiguity(
            Function function, Function overload)
        {
            var functionParams = function.Parameters.Where(
                p => p.Kind == ParameterKind.Regular).ToList();
            // It's difficult to handle this case for more than one parameter
            // For example, if we have:
            //     void f(float&, const int&);
            //     void f(const float&, int&);
            // what should we do? Generate both? Generate the first one encountered?
            // Generate the one with the least amount of "complex" parameters?
            // So let's just start with the simplest case for the time being
            if (functionParams.Count != 1)
                return false;
            var overloadParams = overload.Parameters.Where(
                p => p.Kind == ParameterKind.Regular).ToList();
            if (overloadParams.Count != 1)
                return false;

            var parameterFunction = functionParams[0];
            var parameterOverload = overloadParams[0];

            var pointerParamFunction = parameterFunction.Type.Desugar() as PointerType;
            var pointerParamOverload = parameterOverload.Type.Desugar() as PointerType;

            if (pointerParamFunction == null || pointerParamOverload == null)
                return false;

            if (!pointerParamFunction.GetPointee().Equals(pointerParamOverload.GetPointee()))
                return false;

            if (parameterFunction.IsConst && !parameterOverload.IsConst)
            {
                function.ExplicitlyIgnore();
                return true;
            }

            if (parameterOverload.IsConst && !parameterFunction.IsConst)
            {
                overload.ExplicitlyIgnore();
                return true;
            }

            if (pointerParamFunction.Modifier == PointerType.TypeModifier.RVReference &&
                pointerParamOverload.Modifier != PointerType.TypeModifier.RVReference)
            {
                function.ExplicitlyIgnore();
                return true;
            }

            if (pointerParamFunction.Modifier != PointerType.TypeModifier.RVReference &&
                pointerParamOverload.Modifier == PointerType.TypeModifier.RVReference)
            {
                overload.ExplicitlyIgnore();
                return true;
            }

            return false;
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:59,代码来源:CheckAmbiguousFunctions.cs


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