Пример #1
0
        private bool IsValidCall(string[] argNames, object[] defaultVals)
        {
            for (int i = 0; i < argNames.Length; i++)
            {
                if (!haveArg[i])
                {
                    if (defaultVals != null && i < defaultVals.Length && defaultVals[i] != DBNull.Value)
                    {
                        realArgs[i] = defaultVals[i];
                        haveArg[i]  = true;
                    }
                    else
                    {
                        int realDefaultsCount = 0;
                        for (int d = 0; d < GetNormalArgumentsCount(); d++)
                        {
                            if (defaultVals[d] != DBNull.Value)
                            {
                                realDefaultsCount++;
                            }
                        }

                        error = PythonFunction.TypeErrorForIncorrectArgumentCount(methodName, GetNormalArgumentsCount(), realDefaultsCount, arguments.Length - kwNames.Length, paramArrayIndex != -1, true);
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #2
0
        protected Exception BadArgumentError(int count)
        {
            int min = Int32.MaxValue;
            int max = Int32.MinValue;

            for (int i = 0; i < targets.Length; i++)
            {
                ParameterInfo[] pis = targets[i].GetParameters();

                if (min > pis.Length)
                {
                    min = pis.Length;
                }
                if (max < pis.Length)
                {
                    max = pis.Length;
                }

                for (int j = 0; j < pis.Length; j++)
                {
                    if (ReflectionUtil.IsParamArray(pis[j]))
                    {
                        max = Int32.MaxValue;
                        if (min == pis.Length)
                        {
                            min--;
                        }
                    }
                    else if (ReflectionUtil.IsParamDict(pis[j]))
                    {
                        max = Int32.MaxValue;
                        if (min == pis.Length)
                        {
                            min--;
                        }
                    }
                }
            }

            if (min == max)
            {
                throw PythonFunction.TypeErrorForIncorrectArgumentCount(FriendlyName, min, 0, count);
            }
            else if (max == Int32.MaxValue)
            {
                throw PythonFunction.TypeErrorForIncorrectArgumentCount(FriendlyName, min, 0, count, true, false);
            }
            else
            {
                throw PythonFunction.TypeErrorForIncorrectArgumentCount(FriendlyName, max, max - min, count);
            }
        }
Пример #3
0
        private Exception BadArgumentError(int realArgCount)
        {
            int            argCount = 1;
            int            defaults = 0;
            PythonFunction funcfunc = func as PythonFunction;

            if (funcfunc != null)
            {
                argCount = funcfunc.ArgCount;
            }

            throw PythonFunction.TypeErrorForIncorrectArgumentCount(this.Name, argCount, defaults, realArgCount);
        }
Пример #4
0
 protected override Exception BadArgumentError(int count)
 {
     throw PythonFunction.TypeErrorForIncorrectArgumentCount(Name, nparams, defaults.Length, count, argListPos != -1, false);
 }