internal CPythonFunctionOverload(
            CPythonParameterInfo[] parameters,
            IEnumerable<IPythonType> returnType,
            bool isMethod
        ) {
            _parameters = EmptyParameters;

            if (parameters != null) {
                if (isMethod) {
                    if (parameters.Length > 1) {
                        _parameters = parameters.Skip(1).ToArray();
                    }
                } else {
                    _parameters = parameters;
                }
            }

            _retType = returnType.ToList();
        }
Beispiel #2
0
        public CPythonFunctionOverload(TypeDatabase typeDb, Dictionary <string, object> argInfo, bool isMethod)
        {
            if (argInfo != null)
            {
                object         args;
                IList <object> argList;
                if (argInfo.TryGetValue("args", out args))
                {
                    argList = (IList <object>)args;
                    if (argList != null)
                    {
                        if (argList.Count == 0 || (isMethod && argList.Count == 1))
                        {
                            _parameters = EmptyParameters;
                        }
                        else
                        {
                            _parameters = new CPythonParameterInfo[isMethod ? argList.Count - 1 : argList.Count];
                            for (int i = 0; i < _parameters.Length; i++)
                            {
                                _parameters[i] = new CPythonParameterInfo(typeDb, (isMethod ? argList[i + 1] : argList[i]) as Dictionary <string, object>);
                            }
                        }
                    }
                }

                object docObj;
                if (argInfo.TryGetValue("doc", out docObj))
                {
                    _doc = docObj as string;
                }

                if (argInfo.TryGetValue("return_doc", out docObj))
                {
                    _returnDoc = docObj as string;
                }

                object retTypeObj;
                argInfo.TryGetValue("ret_type", out retTypeObj);

                typeDb.LookupType(retTypeObj, (value) => _retType = value);
            }
        }