-
Notifications
You must be signed in to change notification settings - Fork 754
Operator overloads support #1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5130aaa
0d0ca87
253f9c7
8cdb61c
c26e589
3222a54
550ff31
eab8edc
c2be3f1
581a047
e11327f
35be4bc
f19c281
d7f52d2
5855a1b
e7da0bc
a376838
6923a78
4c992d8
8cce61d
09a2047
41bd07f
10ccf1e
5682e0c
5f45c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,7 +472,14 @@ private static ClassInfo GetClassInfo(Type type) | |
ci.members[name] = ob; | ||
if (mlist.Any(OperatorMethod.IsOperatorMethod)) | ||
{ | ||
ci.members[OperatorMethod.GetPyMethodName(name)] = ob; | ||
string pyName = OperatorMethod.GetPyMethodName(name); | ||
string pyNameReverse = pyName.Insert(2, "r"); | ||
christabella marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MethodInfo[] forwardMethods, reverseMethods; | ||
OperatorMethod.FilterMethods(mlist, out forwardMethods, out reverseMethods); | ||
lostmsu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Only methods where the left operand is the declaring type. | ||
ci.members[pyName] = new MethodObject(type, name, forwardMethods); | ||
// Only methods where only the right operand is the declaring type. | ||
ci.members[pyNameReverse] = new MethodObject(type, name, reverseMethods); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if there are no reverseMethods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently it will just create a method that's never used; I can fix that by adding a hasReverse field in the SlotDefinition struct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if C# reverse operator isn't defined, so the Python reverse name will have an empty method list in MethodObject So if a user calls Another unrelated issue is that of doing unnecessary work, if the Python slot doesn't support reverse e.g. unary operators ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is also possible to have no "forward" methods. If no reverse methods are defined, the corresponding slot should not be set. Same for forward.
Not sure what you mean. There's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, I've just put a check then to not set the slot method if the method list is empty |
||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.