Example #1
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);
            }
        }
Example #2
0
        public CPythonParameterInfo(TypeDatabase typeDb, Dictionary <string, object> parameterTable)
        {
            if (parameterTable != null)
            {
                object typeObj;

                if (parameterTable.TryGetValue("type", out typeObj))
                {
                    typeDb.LookupType(typeObj, (value) => _type = value);
                }
                _typeObj = typeObj;

                object nameObj;
                if (parameterTable.TryGetValue("name", out nameObj))
                {
                    _name = nameObj as string;
                }

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

                object defaultValueObj;
                if (parameterTable.TryGetValue("default_value", out defaultValueObj))
                {
                    _defaultValue = defaultValueObj as string;
                }

                object argFormatObj;
                if (parameterTable.TryGetValue("arg_format", out argFormatObj))
                {
                    switch (argFormatObj as string)
                    {
                    case "*": _isSplat = true; break;

                    case "**": _isKeywordSplat = true; break;
                    }
                }
            }
        }