-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[geometry] Add RenderEngine support for shared_ptr (#22353)
Because we allow implementations of RenderEngine as Python subclasses, we cannot assume that the deleter associated with a call to Clone is `delete get()`, i.e., the return type of unique_ptr<RenderEngine> is incompatible with Python implementations. Instead, we add a template argument to Clone() to select between unique_ptr and shared_ptr (retaining the default of unique_ptr), add another NVI hook for the shared_ptr flavor, switch our bindings to use shared_ptr, and change all of our internal C++ call sites (just one -- in GeometryState) to opt-in to shared_ptr so that Python subclasses can be safely manipulated from C++. We also now allow Python implementations to implement the canonical pythonic spelling of the "__deepcopy__" method, instead of the weird DoClone spelling. Engines subclasses implemented in C++ do not need to change; their override of NVI DoClone for unique_ptr will keep working indefinitely. This commit contains one breaking change: If downstream C++ code was calling RenderEngine::Clone and the runtime type of the object was a downstream Python subclass of RenderEngine, then the call will now throw an exception. The C++ call must be updated to opt-in to the shared_ptr template argument.
- Loading branch information
1 parent
fe9454d
commit 2fd6673
Showing
13 changed files
with
367 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.