Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Basic operator overloads support#907

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
amos402 wants to merge4 commits intopythonnet:masterfromamos402:operator

Conversation

amos402
Copy link
Member

@amos402amos402 commentedJul 5, 2019
edited
Loading

What does this implement/fix? Explain your changes.

Support the operator for objects.

I found this code from my branch before, not only support the operator but also refactored theMethodBinder.@lostmsu I realized we just did the same thing. But a little different was I intended to support the method likefoo(int x = 0, params object[] bar) can be call withfoo(1,1,1), you can see the change from the pytest. I think we need to discuss how to merge them.
I develop it base on Python3, some test cases may fail on 2 now.

Does this close any currently open issues?

#906

Any other comments?

...

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself toAUTHORS
  • Updated theCHANGELOG

Copy link
Member

@lostmsulostmsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Completed initial pass with some comments.

{
if (tp == null)
{
yield break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this should throw instead, and the caller should explicitly handlenull case.

MethodInfo method;
try
{
method = t.MakeGenericMethod(tp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You canyield return right here

amos402 reacted with thumbs up emoji
}
catch (ArgumentException)
{
method = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You cancontinue right here

Type param = pi[n].ParameterType;

if (!param.IsGenericParameter && !IsNullableOf(sig, param) &&
!param.IsAssignableFrom(sig))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you explain what this method was supposed to be doing, and what your change enables it to do now? It is actually not clear what genericTp and sigTp represent from their names :(

christabella reacted with confused emoji

public static void FixupSlots(IntPtr pyType, Type clrType)
{
IntPtr tp_as_number = Marshal.ReadIntPtr(pyType, TypeOffset.tp_as_number);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This does not seem to be used anywhere

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

😂opps, some methods are just used in my code, so it maybe not used here.

{
throw new PythonException();
}
OperatorMethod.FixupSlots(type, clrType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should not the fixup happen before PyType_Ready?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It could be.

Copy link
Member

@lostmsulostmsuJul 6, 2019
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@amos402 FromPython doc:

Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots from a type’s base class. Return 0 on success, or return -1 and sets an exception on error.

Unfortunately, the description does not clarify if the behavior could change in the future :/ I'd try to moveFixupSlots up, and see if it works that way.

assert result[0] == 'one'
assert result[1] == 'two'
assert result[2] == 'three'
# Skip these temporally cause of the changes of array parameter calling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this change not ready?
.NET permits arrays to be passed in place ofparams object[] arguments. If it was allowed previously, but is not after your change, it removes a feature, which should not be done.

return OpMethodMap.ContainsKey(methodName);
}

public static bool IsPyOperatorMethod(string pyMethodName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This method seems to be unused.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks like this was used later for delegates support?joonhwan@b154475

@tminka
Copy link
Contributor

Fixes#1312

@christabellachristabella mentioned this pull requestDec 16, 2020
4 tasks
@christabella
Copy link
Contributor

Could be closed in favour of the updated version at#1324

@lostmsulostmsu closed thisJan 7, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lostmsulostmsulostmsu requested changes

@christabellachristabellachristabella left review comments

@tminkatminkatminka left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@amos402@tminka@christabella@lostmsu@filmor

[8]ページ先頭

©2009-2025 Movatter.jp