Skip to content

Commit f19c281

Browse files
committed
Address @tminka's comments.
1 parent 35be4bc commit f19c281

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/embed_tests/TestOperator.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ public void Dispose()
2121
PythonEngine.Shutdown();
2222
}
2323

24-
public class SampleClass
25-
{
26-
public int VoidCall() => 10;
27-
28-
public int Foo(int a, int b = 10) => a + b;
29-
}
30-
3124
public class OperableObject
3225
{
3326
public int Num { get; set; }

src/runtime/methodbinder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,6 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
343343
int kwargsMatched;
344344
int defaultsNeeded;
345345
bool isOperator = OperatorMethod.IsOperatorMethod(mi); // e.g. op_Addition is defined for OperableObject
346-
if (isOperator )
347-
{
348-
var a = 0;
349-
a++;
350-
}
351346
if (!MatchesArgumentCount(pynargs, pi, kwargDict, isOperator, out paramsArray, out defaultArgList, out kwargsMatched, out defaultsNeeded))
352347
{
353348
continue;

src/runtime/operatormethod.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ namespace Python.Runtime
99
{
1010
internal static class OperatorMethod
1111
{
12-
// Maps the compiled method name in .NET CIL (e.g. op_Addition) to
13-
// the equivalent Python operator (e.g. __add__) as well as the offset
14-
// that identifies that operator's slot (e.g. nb_add) in heap space.
12+
/// <summary>
13+
/// Maps the compiled method name in .NET CIL (e.g. op_Addition) to
14+
/// the equivalent Python operator (e.g. __add__) as well as the offset
15+
/// that identifies that operator's slot (e.g. nb_add) in heap space.
16+
/// </summary>
1517
public static Dictionary<string, SlotDefinition> OpMethodMap { get; private set; }
1618
public readonly struct SlotDefinition
1719
{
@@ -27,6 +29,10 @@ public SlotDefinition(string methodName, int typeOffset)
2729

2830
static OperatorMethod()
2931
{
32+
// .NET operator method names are documented at:
33+
// https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/operator-overloads
34+
// Python operator methods and slots are documented at:
35+
// https://docs.python.org/3/c-api/typeobj.html
3036
// TODO: Rich compare, inplace operator support
3137
OpMethodMap = new Dictionary<string, SlotDefinition>
3238
{

0 commit comments

Comments
 (0)