-
Notifications
You must be signed in to change notification settings - Fork 773
Constructor argument matching supports simple int to (float|double) types #239
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2a2c9c7
added intial test that illustrates how int->double conversion works i…
sigbjorn 78dca29
ease windows development, - default settings after checkout reflectin…
sigbjorn af1b937
added method tests for simple promotions int->float, int->double
sigbjorn 24baadf
extending test to cover negative outcome of bool->double|float
sigbjorn bde4258
adding default ct to challenge the matching mechanism
sigbjorn c8c8d8c
merged extra tests
sigbjorn a65d793
adding test, and print-out warning for the not yet implemented feature
sigbjorn e698b57
added more test for illustrating super/sub-class and argument passing…
sigbjorn 1fd75b3
fixed py 2.7 syntax for super, plus fixed typo
sigbjorn fb9b21e
reverted the .sln to unmodified state
sigbjorn 9e1d72b
reverting changes to runtime and clrmodule projects
sigbjorn 0e2cd12
Reverting changes to Console, embed_tests and testing .csproj files
sigbjorn e58d5b2
Hopefully fixed py 2.6 issues
sigbjorn 8602823
Merge branch 'ct_arg_match_fix' of https://github.com/sigbjorn/python…
sigbjorn bdbaa62
SimplePromotableType simplified, returns true if src is int-type and …
sigbjorn 478b632
Merge branch 'master' into ct_arg_match_fix
sigbjorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
added intial test that illustrates how int->double conversion works i…
…n calling a constructor, prior to the change in the methodbinder.cs, this test failed, since the no-match in ct. was failing silently, now it works. Next step is to give exception when ct args do not match
- Loading branch information
commit 2a2c9c71ec0c6e54d95ca0a950dccbf07d323d1b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,28 @@ namespace Python.Test | |
| //======================================================================== | ||
| // These classes support the CLR constructor unit tests. | ||
| //======================================================================== | ||
|
|
||
| public class AConstrucorTest | ||
|
Member
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. Typo. |
||
| { | ||
| public string name; | ||
| public AConstrucorTest(string n) { name = n; } | ||
| } | ||
| public class LinkConstructorTest | ||
| { | ||
| public LinkConstructorTest() | ||
| { | ||
| DefaultCtCalled = true; | ||
| } | ||
| public LinkConstructorTest(AConstrucorTest a,double matchMe,AConstrucorTest b) | ||
| { | ||
| MatchMe = matchMe; | ||
| a1 = a; | ||
| a2 = b; | ||
| } | ||
| public bool DefaultCtCalled; | ||
| public double MatchMe; | ||
| public AConstrucorTest a1; | ||
| public AConstrucorTest a2; | ||
| } | ||
| public class EnumConstructorTest | ||
| { | ||
| public TypeCode value; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is a bit arbitrary, isn't it? A 64bit integer fits in neither
doublenorfloat, so why make this distinction here?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so it merely answers if its possible to do the conversion.
The real conversion is attempted later, using standard python.net conversion
that hopefully do the best effort, throws, etc. if there are numerical problems representing the one from the other.
We could even drop the test, and just do the python.net conversion, - that would kind of be consistent with what happen, I think, to usual function arguments. If that conversion fail, then it's not promotable.
The reason to be distinct on a numerical type is that we want to be as precise as possible.
And yes, - given that there is both and int and a double constructor, we should select the one with closest match. (Requires rewrite, or redirect logic to some function that already do this ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sigbjorn as far as I'm aware there is no logic for resolution order in pythonnet for multiple matches due to complexity it brings into code-base:
#217
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point was that _dis_allowing the conversion
long -> floatdoesn't make sense as the conversionlong -> doubleis also lossy (64 vs 53). So either we allow all of those or none.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, then we could try the approach I suggested in my initial comment, - just use the standard conversion function inside pythonnet. That's wider approach, but there is a hope it's consistently used for argument conversions, and thus we can terminate this discussion, since then the arguments to a constructor undergoes (almost) the same rules as an ordinary pythonnet function.
I am on vacation now, but can try to see if its possible to get in touch with a computer long enough to produce the change.