Skip to content
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

Review/tp transparent handles #583

Merged
merged 9 commits into from
Nov 20, 2018
Merged

Conversation

tpaviot
Copy link
Owner

@tpaviot tpaviot commented Nov 18, 2018

Follows PR #581 from @rainman110

The OCCT handle smart pointer API is a C++ specific detail and should not be exposed to Python. Instead it should be completely invisible. This PR almost completely removes Handles_ from pythonOCC.

This makes the use of pythonOCC much cleaner and less verbose!

I used the std::shared_ptr swig library as a basis for the implementation.
To be compatible with most of the "old" code, GetHandle() and GetObject() methods still exist but do nothing except from a deprecation warning. In general, I tried to make sure that the code is backwards compatible as possible.

I adapted already the unit tests to not include the legacy code. The demos are working unmodified but should be adapted to avoid deprecation warnings.

The only thing that is not backwards compatible is, when previously an Null-Handle was returned - e.g. a non successful computation. Before, the object was a handle but .IsNull() was true. Now, it is a None type, which is more Pythonic.

The "magic" is implemeted in new swig typemaps in OccHandle.i.

Closes #539

Examples have been refactored accordingly see https://github.com/tpaviot/pythonocc-demos

The OCCT handle smart pointer API is a C++ specific detail
and should not be exposed to Python. Instead it should be
completely invisible.
I used the std::shared_ptr swig library as a basis for the
implementation.
To be compatible with most of the "old" code, GetHandle() and
GetObject() methods still exist but do nothing except from
a deprecation warning. In general, I tried to make sure
that the code is backwards compatible as possible.

Closes #539

Updated SWIG files
@tpaviot tpaviot force-pushed the review/tp-transparent-handles branch from 82c95a5 to 1a1bafb Compare November 18, 2018 16:35
@tpaviot tpaviot force-pushed the review/tp-transparent-handles branch from 7b5280c to 1fdaa07 Compare November 19, 2018 13:46
@tpaviot tpaviot force-pushed the review/tp-transparent-handles branch from 013adcf to ee8f6d5 Compare November 20, 2018 05:45
@tpaviot
Copy link
Owner Author

tpaviot commented Nov 20, 2018

Merging, thanks @rainman110

@tpaviot tpaviot merged commit 85d15cd into master Nov 20, 2018
@tpaviot tpaviot deleted the review/tp-transparent-handles branch November 20, 2018 10:38
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.

None yet

2 participants