Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5130aaa
Overload operators except for bit shifts and default args.
christabella Dec 16, 2020
0d0ca87
Remove params array tests since they are unrelated to operator overlo…
christabella Dec 17, 2020
253f9c7
Fix type bug; rename variables pynargs etc.
christabella Dec 17, 2020
8cdb61c
Remove unused variables and add comments.
christabella Dec 17, 2020
c26e589
Add comments and remove unused in operatormethod.cs
christabella Dec 18, 2020
3222a54
Address review by @lostmsu; Add forward operator test.
christabella Dec 20, 2020
550ff31
Add forward operator tests (OpObj, int).
christabella Dec 21, 2020
eab8edc
Address @amos402's comment on raising branch.
christabella Dec 21, 2020
c2be3f1
Add operator overload and rename pynargs, clrnargs
christabella Dec 21, 2020
581a047
Revert variable renames
christabella Dec 22, 2020
e11327f
Update AUTHORS and CHANGELOG
christabella Dec 22, 2020
35be4bc
Revert rename to pynargs
christabella Dec 23, 2020
f19c281
Address @tminka's comments.
christabella Dec 23, 2020
d7f52d2
Remove whitespace
christabella Dec 23, 2020
5855a1b
Fix nits
christabella Dec 24, 2020
e7da0bc
Support reverse binary operations
christabella Dec 28, 2020
a376838
Use reverse instead of forward (semantics)
christabella Dec 29, 2020
6923a78
Address @tminka's comments
christabella Dec 30, 2020
4c992d8
Support unary neg and pos operators
christabella Dec 30, 2020
8cce61d
Remove isOperator from MatchesArgumentCount (simplify), add test.
christabella Jan 4, 2021
09a2047
Revert "Remove isOperator from MatchesArgumentCount (simplify)"
christabella Jan 4, 2021
41bd07f
Properly remove isOperator from MatchesArgumentCount (@tminka comment)
christabella Jan 4, 2021
10ccf1e
Update changelog.
christabella Jan 4, 2021
5682e0c
Add ones complement and modulo tests (@tminka comment)
christabella Jan 4, 2021
5f45c70
Merge branch 'master' into feat/operator-overloads
lostmsu Jan 5, 2021
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
Prev Previous commit
Next Next commit
Address @amos402's comment on raising branch.
  • Loading branch information
christabella committed Dec 23, 2020
commit eab8edcc4e470b1ad15358fd7a7ae38c24e499ab
24 changes: 12 additions & 12 deletions src/runtime/methodbinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,18 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters,
}
else if (pynargs < clrnargs && (!paramsArray || pynargs == clrnargs - 1))
{
// every parameter past 'positionalArgumentCount' must have either
// a corresponding keyword argument or a default parameter, unless
// the method is an operator or accepts a params array (which cannot
// have a default value)
match = true;
// operator methods will have 2 CLR args but only one Python arg,
// since Python operator methods are bound
if (isOperator)
{
// return early since a C# operator method cannot have
// keyword args, default args, or params arrays (exclusive cases)
return match;
}
// every parameter past 'positionalArgumentCount' must have either
// a corresponding keyword arg or a default param, unless the method
// method accepts a params array (which cannot have a default value)
defaultArgList = new ArrayList();
for (var v = pynargs; v < clrnargs; v++)
{
Expand All @@ -723,18 +730,11 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters,
defaultArgList.Add(parameters[v].GetDefaultValue());
defaultsNeeded++;
}
else if (!isOperator && !paramsArray)
else if (!paramsArray)
{
// this is separate above because an operator method cannot have
// keyword args, default args, or params arrays (exclusive cases)
match = false;
}
}
if (isOperator && defaultArgList.Count == 0)
{
// If no default arguments were provided for an operable object.
defaultArgList = null;
}
}
else if (pynargs > clrnargs && clrnargs > 0 &&
Attribute.IsDefined(parameters[clrnargs - 1], typeof(ParamArrayAttribute)))
Expand Down