/// <summary> /// Default implementation of [] semantics for reflected types. /// </summary> public virtual IntPtr type_subscript(IntPtr idx) { Type[] types = Runtime.PythonArgsToTypeArray(idx); if (types == null) { return(Exceptions.RaiseTypeError("type(s) expected")); } if (!type.Valid) { return(Exceptions.RaiseTypeError(type.DeletedMessage)); } Type target = GenericUtil.GenericForType(type.Value, types.Length); if (target != null) { Type t = target.MakeGenericType(types); ManagedType c = ClassManager.GetClass(t); Runtime.XIncref(c.pyHandle); return(c.pyHandle); } return(Exceptions.RaiseTypeError($"{type.Value.Namespace}.{type.Name} does not accept {types.Length} generic parameters")); }
/// <summary> /// Default implementation of [] semantics for reflected types. /// </summary> public virtual IntPtr type_subscript(IntPtr idx) { Type[] types = Runtime.PythonArgsToTypeArray(idx); if (types == null) { return(Exceptions.RaiseTypeError("type(s) expected")); } Type target = GenericUtil.GenericForType(type, types.Length); if (target != null) { Type t = target.MakeGenericType(types); ManagedType c = ClassManager.GetClass(t); Runtime.XIncref(c.pyHandle); return(c.pyHandle); } return(Exceptions.RaiseTypeError("no type matches params")); }