Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/_csv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ public void writerow(CodeContext/*!*/ context, object sequence) {

_rec.Append(_dialect.lineterminator);

PythonOps.CallWithContext(context, _writeline, _rec.ToString());
PythonCalls.Call(context, _writeline, _rec.ToString());
}

[Documentation(@"writerows(sequence of sequences)
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/_ctypes/SimpleCData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void __init__(CodeContext/*!*/ context, object value) {
}

if (__float__ != null) {
value = PythonOps.CallWithContext(context, __float__);
value = PythonCalls.Call(context, __float__);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/core/IronPython.Modules/_datetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ public double timestamp() {
public static datetime strptime(CodeContext/*!*/ context, [NotNone] PythonType cls, [NotNone] string date_string, [NotNone] string format) {
var module = context.LanguageContext.GetStrptimeModule();
var _strptime_datetime = PythonOps.GetBoundAttr(context, module, "_strptime_datetime");
return (datetime)PythonOps.CallWithContext(context, _strptime_datetime, cls, date_string, format)!;
return (datetime)PythonCalls.Call(context, _strptime_datetime, cls, date_string, format)!;
}

#region IRichComparable Members
Expand Down Expand Up @@ -1503,7 +1503,7 @@ public virtual string tzname(object? dt) {
public PythonTuple __reduce__(CodeContext/*!*/ context) {
object? args = PythonTuple.EMPTY;
if (PythonOps.TryGetBoundAttr(context, this, "__getinitargs__", out var getinitargs)) {
args = PythonOps.CallWithContext(context, getinitargs);
args = PythonCalls.Call(context, getinitargs);
}

if (GetType() == typeof(tzinfo) ||
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/_operator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public PythonTuple __reduce__(CodeContext context) {
public object? Call(CodeContext/*!*/ context, object? param) {
object method = PythonOps.GetBoundAttr(context, param, _name);
if (_dict == null) {
return PythonOps.CallWithContext(context, method, _args);
return PythonCalls.Call(context, method, _args);
} else {
return PythonCalls.CallWithKeywordArgs(context, method, _args, _dict);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public static double lgamma(double v0) {
public static object? trunc(CodeContext/*!*/ context, object? value) {
object? func;
if (PythonOps.TryGetBoundAttr(value, "__trunc__", out func)) {
return PythonOps.CallWithContext(context, func);
return PythonCalls.Call(context, func);
} else {
throw PythonOps.TypeError("type {0} doesn't define __trunc__ method", PythonOps.GetPythonTypeName(value));
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/pyexpat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public void ParseFile(CodeContext context, object file) {
if (!PythonOps.TryGetBoundAttr(context, file, "read", out object _readMethod))
throw PythonOps.TypeError("argument must have 'read' attribute");

object readResult = PythonOps.CallWithContext(context, _readMethod);
object readResult = PythonCalls.Call(context, _readMethod);
if (readResult is Bytes b) {
using (var stream = new MemoryStream(b.UnsafeByteArray, writable: false)) {
var settings = new XmlReaderSettings() { DtdProcessing = DtdProcessing.Parse, XmlResolver = null };
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/re.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void PerformModuleReload(PythonContext/*!*/ context, PythonDiction
var module = context.GetCopyRegModule();
if (module != null) {
var pickle = PythonOps.GetBoundAttr(context.SharedContext, module, "pickle");
PythonOps.CallWithContext(context.SharedContext, pickle, DynamicHelpers.GetPythonTypeFromType(typeof(Pattern)), dict["_pickle"]);
PythonCalls.Call(context.SharedContext, pickle, DynamicHelpers.GetPythonTypeFromType(typeof(Pattern)), dict["_pickle"]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/IronPython.Modules/time.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ public static string strftime(CodeContext/*!*/ context, [NotNone] string format,
public static object? strptime(CodeContext/*!*/ context, [NotNone] string @string) {
var module = context.LanguageContext.GetStrptimeModule();
var _strptime_time = PythonOps.GetBoundAttr(context, module, "_strptime_time");
return PythonOps.CallWithContext(context, _strptime_time, @string);
return PythonCalls.Call(context, _strptime_time, @string);
}

public static object? strptime(CodeContext/*!*/ context, [NotNone] string @string, [NotNone] string format) {
var module = context.LanguageContext.GetStrptimeModule();
var _strptime_time = PythonOps.GetBoundAttr(context, module, "_strptime_time");
return PythonOps.CallWithContext(context, _strptime_time, @string, format);
return PythonCalls.Call(context, _strptime_time, @string, format);
}

internal static string strftime(CodeContext/*!*/ context, string format, DateTime dt, int? microseconds, TimeZoneInfo? tzinfo = null, bool errorOnF = false) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython/Modules/_fileio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public FileIO(CodeContext/*!*/ context, [NotNone] string name, [NotNone] string
}
}
} else { // opener is not null
object? fdobj = PythonOps.CallWithContext(context, opener, name, flags);
object? fdobj = PythonCalls.Call(context, opener, name, flags);
if (fdobj is int fd) {
if (fd < 0) {
throw PythonOps.ValueError("opener returned {0}", fd);
Expand Down
6 changes: 3 additions & 3 deletions src/core/IronPython/Modules/_io.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public virtual BigInteger readinto(CodeContext/*!*/ context, object buf) {
object setter;
if (PythonOps.TryGetBoundAttr(buf, "__setitem__", out setter)) {
for (int i = 0; i < data.Count; i++) {
PythonOps.CallWithContext(context, setter, i, data[i]);
PythonCalls.Call(context, setter, i, data[i]);
}
GC.KeepAlive(this);
return data.Count;
Expand Down Expand Up @@ -2707,7 +2707,7 @@ private object GetEncoder(CodeContext/*!*/ context) {
throw PythonOps.LookupError(_encoding);
}

_encoder = PythonOps.CallWithContext(context, factory, _errors);
_encoder = PythonCalls.Call(context, factory, _errors);
return _encoder;
}

Expand All @@ -2718,7 +2718,7 @@ private object GetDecoder(CodeContext/*!*/ context) {
throw PythonOps.LookupError(_encoding);
}

_decoder = PythonOps.CallWithContext(context, factory, _errors);
_decoder = PythonCalls.Call(context, factory, _errors);
if (_readUniversal) {
_decoder = new IncrementalNewlineDecoder(_decoder, _readTranslate, "strict");
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/IronPython/Runtime/ClrModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,9 @@ public object Call(CodeContext context, params object[] args) {
ValidateArgs(args);

if (_inst != null) {
return PythonOps.CallWithContext(context, _func, ArrayUtils.Insert(_inst, args));
return PythonCalls.Call(context, _func, ArrayUtils.Insert(_inst, args));
} else {
return PythonOps.CallWithContext(context, _func, args);
return PythonCalls.Call(context, _func, args);
}
}

Expand Down Expand Up @@ -762,7 +762,7 @@ private void ValidateReturn(object ret) {
#region ICallableWithCodeContext Members
[SpecialName]
public object Call(CodeContext context, params object[] args) {
object ret = PythonOps.CallWithContext(
object ret = PythonCalls.Call(
context,
_func,
_inst != null ? ArrayUtils.Insert(_inst, args) : args);
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython/Runtime/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Map(CodeContext context, object? func, [NotNone] params object[] iterable
public bool MoveNext() {
if (_enumerator is null) {
if (_enumerators.All(x => x.MoveNext())) {
Current = PythonOps.CallWithContext(_context, _func, _enumerators.Select(x => x.Current).ToArray());
Current = PythonCalls.Call(_context, _func, _enumerators.Select(x => x.Current).ToArray());
return true;
}
} else if (_enumerator.MoveNext()) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython/Runtime/Operations/ArrayOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static object __new__(CodeContext context, PythonType pythonType, object
if (!PythonOps.TryGetBoundAttr(items, "__len__", out object? lenFunc))
throw PythonOps.TypeErrorForBadInstance("expected object with __len__ function, got {0}", items);

int len = context.LanguageContext.ConvertToInt32(PythonOps.CallWithContext(context, lenFunc));
int len = context.LanguageContext.ConvertToInt32(PythonCalls.Call(context, lenFunc));

Array res = @base == 0 ?
Array.CreateInstance(type, len) : Array.CreateInstance(type, [len], [@base]);
Expand Down
6 changes: 3 additions & 3 deletions src/core/IronPython/Runtime/Operations/ObjectOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDic
// A derived class overrode __reduce__ but not __reduce_ex__, so call
// specialized __reduce__ instead of generic __reduce_ex__.
// (see the "The __reduce_ex__ API" section of PEP 307)
return PythonOps.CallWithContext(context, myReduce, self)!;
return PythonCalls.Call(context, myReduce, self)!;
}
}

Expand Down Expand Up @@ -325,7 +325,7 @@ private static HashSet<PythonType> NativelyPickleableTypes {
internal static object? ReduceProtocol0(CodeContext/*!*/ context, object self) {
var copyreg = context.LanguageContext.GetCopyRegModule();
var _reduce_ex = PythonOps.GetBoundAttr(context, copyreg, "_reduce_ex");
return PythonOps.CallWithContext(context, _reduce_ex, self, 0);
return PythonCalls.Call(context, _reduce_ex, self, 0);
}

/// <summary>
Expand All @@ -347,7 +347,7 @@ private static PythonTuple ReduceProtocol2(CodeContext/*!*/ context, object self

if (PythonOps.TryGetBoundAttr(context, myType, "__getnewargs__", out object? getNewArgsCallable)) {
// TypeError will bubble up if __getnewargs__ isn't callable
if (!(PythonOps.CallWithContext(context, getNewArgsCallable, self) is PythonTuple newArgs)) {
if (!(PythonCalls.Call(context, getNewArgsCallable, self) is PythonTuple newArgs)) {
throw PythonOps.TypeError("__getnewargs__ should return a tuple");
}
funcArgs = new object[1 + newArgs.Count];
Expand Down
18 changes: 14 additions & 4 deletions src/core/IronPython/Runtime/Operations/PythonOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ internal static bool TryInvokeLengthHint(CodeContext context, object? sequence,
return false;
}

[Obsolete("Use PythonCalls.Call")]
public static object? CallWithContext(CodeContext/*!*/ context, object? func, params object?[] args) {
return PythonCalls.Call(context, func, args);
}
Expand All @@ -979,9 +980,10 @@ internal static bool TryInvokeLengthHint(CodeContext context, object? sequence,
/// that supports calling with 'this'. If not, the 'this' object is dropped
/// and a normal call is made.
/// </summary>
[Obsolete("Use PythonCalls.Call")]
public static object? CallWithContextAndThis(CodeContext/*!*/ context, object? func, object? instance, params object?[] args) {
// drop the 'this' and make the call
return CallWithContext(context, func, args);
return PythonCalls.Call(context, func, args);
}

[Obsolete("Use ObjectOperations instead")]
Expand All @@ -995,7 +997,7 @@ internal static bool TryInvokeLengthHint(CodeContext context, object? sequence,
foreach (object? arg in PythonOps.GetCollection(argsTuple))
largs.Add(arg);
}
return CallWithContext(context, func, largs.ToArray());
return PythonCalls.Call(context, func, largs.ToArray());
} else {
List<object?> largs;

Expand Down Expand Up @@ -1195,10 +1197,18 @@ public static bool TryDeleteUserDescriptor(object o, object instance) {
out _);
}

public static object? Invoke(CodeContext/*!*/ context, object? target, string name) {
return PythonCalls.Call(context, PythonOps.GetBoundAttr(context, target, name));
}

public static object? Invoke(CodeContext/*!*/ context, object? target, string name, object? arg0) {
return PythonCalls.Call(context, PythonOps.GetBoundAttr(context, target, name), arg0);
}

public static object? Invoke(CodeContext/*!*/ context, object? target, string name, object? arg0, object? arg1) {
return PythonCalls.Call(context, PythonOps.GetBoundAttr(context, target, name), arg0, arg1);
}

public static object? Invoke(CodeContext/*!*/ context, object? target, string name, params object?[] args) {
return PythonCalls.Call(context, PythonOps.GetBoundAttr(context, target, name), args);
}
Expand Down Expand Up @@ -3420,7 +3430,7 @@ public static void Warn(CodeContext/*!*/ context, PythonType category, string me
if (warn == null) {
PythonOps.PrintWithDest(context, pc.SystemStandardError, $"warning: {category.Name}: {message}");
} else {
PythonOps.CallWithContext(context, warn, message, category);
PythonCalls.Call(context, warn, message, category);
}
}

Expand All @@ -3436,7 +3446,7 @@ public static void ShowWarning(CodeContext/*!*/ context, PythonType category, st
if (warn == null) {
PythonOps.PrintWithDest(context, pc.SystemStandardError, $"{filename}:{lineNo}: {category.Name}: {message}");
} else {
PythonOps.CallWithContext(context, warn, message, category, filename ?? "", lineNo);
PythonCalls.Call(context, warn, message, category, filename ?? "", lineNo);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/IronPython/Runtime/Operations/PythonTypeOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ internal static object CallParams(CodeContext/*!*/ context, PythonType cls, para
}

internal static object CallWorker(CodeContext/*!*/ context, PythonType dt, object[] args) {
object newObject = PythonOps.CallWithContext(context, GetTypeNew(context, dt), ArrayUtils.Insert<object>(dt, args));
object newObject = PythonCalls.Call(context, GetTypeNew(context, dt), ArrayUtils.Insert<object>(dt, args));

if (ShouldInvokeInit(dt, DynamicHelpers.GetPythonType(newObject), args.Length)) {
PythonOps.CallWithContext(context, GetInitMethod(context, dt, newObject), args);
PythonCalls.Call(context, GetInitMethod(context, dt, newObject), args);

AddFinalizer(context, dt, newObject);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython/Runtime/Types/PythonType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,7 @@ public object SetAttr(CallSite site, object self, TValue value) {

object res;
if (_slot.TryGetValue(_context, self, ipo.PythonType, out res)) {
return PythonOps.CallWithContext(_context, res, _name, value);
return PythonCalls.Call(_context, res, _name, value);
}

return TypeError(ipo);
Expand Down