Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clean dllImport calls in Runtime #403

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

Merged
merged 5 commits into from
Feb 28, 2017
Merged

Conversation

vmuriart
Copy link
Contributor

What does this implement/fix? Explain your changes.

Simplify calls to dllImport by removing arguments that are default, not-applicable, or redundant.

Does this close any currently open issues?

n/a

Any other comments?

The clean-up exposes where CharSet is actually needed to marshal Strings.

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 to AUTHORS
  • Updated the CHANGELOG

@vmuriart vmuriart force-pushed the Clean-DllImport branch 2 times, most recently from 7d78a71 to 7403a3c Compare February 26, 2017 22:46
@codecov
Copy link

codecov bot commented Feb 26, 2017

Codecov Report

Merging #403 into master will increase coverage by 0.11%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master    #403      +/-   ##
=========================================
+ Coverage   63.38%   63.5%   +0.11%     
=========================================
  Files          61      61              
  Lines        5277    5264      -13     
  Branches      863     861       -2     
=========================================
- Hits         3345    3343       -2     
+ Misses       1713    1701      -12     
- Partials      219     220       +1
Flag Coverage Δ
#Embedded_Tests 33.09% <100%> (+0.04%)
#Python_Tests 60.13% <100%> (+0.17%)
#Setup_Linux 74.5% <100%> (ø)
#Setup_Windows 70.5% <100%> (ø)
Impacted Files Coverage Δ
src/runtime/runtime.cs 80.74% <100%> (-3.64%)
src/runtime/pytuple.cs 71.42% <0%> (-14.29%)
src/runtime/pysequence.cs 17.64% <0%> (-5.89%)
src/runtime/debughelper.cs 0% <0%> (ø)
src/runtime/pythonexception.cs 66.07% <0%> (ø)
src/runtime/converter.cs 77.89% <0%> (ø)
src/runtime/CustomMarshaler.cs
src/runtime/interop36.cs 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01a35cb...5b3f58a. Read the comment docs.

@den-run-ai
Copy link
Contributor

@vmuriart isn't explicit better than implicit? Can you at least add the docs which show the default calling conventions?

@vmuriart
Copy link
Contributor Author

Each commit message has a reference to the links.

@den-run-ai
Copy link
Contributor

sorry, i still don't see any links. this SO answer mentions to declare cdecl: http://stackoverflow.com/a/15664100/2230844

@vmuriart
Copy link
Contributor Author

I just realized you asked for the callingconventions one specifically, looks like i skipped that one sorry.
https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.callingconvention(v=vs.110).aspx

In terms of explicit vs implicit. It's way overengineered, and makes the code less legible. I am all for including them if they are necessary but in most cases they aren't. Fixing the marshal issue became alot simpler after I completed this pr because it made alot more sense where we were actually needing to use it.

@vmuriart
Copy link
Contributor Author

CallingConvention is the only one I am still debating if we actually need to keep. It seems that for our use case it isn't necessary, but I'm ok removing that part from this pr and revisiting it later.

@vmuriart
Copy link
Contributor Author

http://stackoverflow.com/a/6511236/5208670 suggest that we are ok without it. None of the calls python API that I've seen have vargs, and those that may we can add the calling convention to them (and would distinguish them from the rest)

@den-run-ai
Copy link
Contributor

BTW, default calling convention for pinvoke is stdcall, but cdecl is more compatible across various compilers.

@vmuriart vmuriart merged commit 67b3181 into pythonnet:master Feb 28, 2017
@vmuriart vmuriart deleted the Clean-DllImport branch February 28, 2017 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants