/// <summary> /// Returns the overloads for a normal .NET type /// </summary> private OverloadResult[] GetClrOverloads() { Type clrType = ClrModule.GetClrType(_type); // just a normal .NET type... var ctors = clrType.GetConstructors(BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance); var overloads = new OverloadResult[ctors.Length]; for (int i = 0; i < ctors.Length; i++) { // TODO: Docs, python type name var parameters = ctors[i].GetParameters(); bool hasContext = parameters.Length > 0 && parameters[0].ParameterType == typeof(CodeContext); var paramResult = new ParameterResult[hasContext ? parameters.Length - 1 : parameters.Length]; for (int j = 0; j < paramResult.Length; j++) { var curParam = parameters[j + (hasContext ? 1 : 0)]; // TODO: Docs paramResult[j] = BuiltinFunctionOverloadResult.GetParameterResultFromParameterInfo(curParam); } overloads[i] = new SimpleOverloadResult(paramResult, PythonType.Get__name__(_type), ""); } return(overloads); }
private SimpleOverloadResult GetInitOverloadResult(OverloadResult overload) { var doc = overload.Documentation; return(new SimpleOverloadResult( overload.Parameters.RemoveFirst(), ClassDefinition.Name, String.IsNullOrEmpty(doc) ? Documentation : doc )); }
private OverloadResult GetNewOverloadResult(OverloadResult overload) { var doc = overload.Documentation; return(new OverloadResult( overload.Parameters.RemoveFirst(), ClassDefinition.Name, string.IsNullOrEmpty(doc) ? Documentation : doc, overload.ReturnType )); }
public BuiltinFunctionValue(ProjectEntry projectEntry, string name, OverloadResult[] overloads, string documentation = null, ExpandoValue prototype = null) : base(projectEntry, prototype, name) { _name = name; _documentation = documentation; _overloads = overloads; Add("length", projectEntry.Analyzer.GetConstant(1.0).Proxy); Add("name", projectEntry.Analyzer.GetConstant(name).Proxy); Add("arguments", projectEntry.Analyzer._nullInst.Proxy); Add("caller", projectEntry.Analyzer._nullInst.Proxy); projectEntry.Analyzer.AnalysisValueCreated(typeof(BuiltinFunctionValue)); }
public SpecializedFunctionValue(ProjectEntry projectEntry, string name, CallDelegate func, OverloadResult[] overloads, string documentation = null, ExpandoValue prototype = null) : base(projectEntry, name, overloads, documentation, prototype) { _func = func; }
public ClassBuiltinFunctionValue(ProjectEntry projectEntry, string name, OverloadResult[] overloads, string documentation = null) : base(projectEntry, name, overloads, documentation) { }
private SimpleOverloadResult GetNewOverloadResult(OverloadResult overload) { var doc = overload.Documentation; return new SimpleOverloadResult( overload.Parameters.RemoveFirst(), ClassDefinition.Name, String.IsNullOrEmpty(doc) ? ClassDefinition.Body.Documentation : doc ); }
/// <summary> /// Returns the overloads for a normal .NET type /// </summary> private OverloadResult[] GetClrOverloads() { Type clrType = ClrModule.GetClrType(_type); // just a normal .NET type... var ctors = clrType.GetConstructors(BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance); var overloads = new OverloadResult[ctors.Length]; for (int i = 0; i < ctors.Length; i++) { // TODO: Docs, python type name var parameters = ctors[i].GetParameters(); bool hasContext = parameters.Length > 0 && parameters[0].ParameterType == typeof(CodeContext); var paramResult = new ParameterResult[hasContext ? parameters.Length - 1 : parameters.Length]; for (int j = 0; j < paramResult.Length; j++) { var curParam = parameters[j + (hasContext ? 1 : 0)]; // TODO: Docs paramResult[j] = BuiltinFunctionOverloadResult.GetParameterResultFromParameterInfo(curParam); } overloads[i] = new SimpleOverloadResult(paramResult, PythonType.Get__name__(_type), ""); } return overloads; }