-
Notifications
You must be signed in to change notification settings - Fork 56
[refactor] Add helpers to wrap member SimpleArray #25
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
Conversation
* Add SimpleArray::swap(). * Create modmesh::python::makeSimpleArray to create SimpleArray from ndarray (pybind11::array_t) buffer. * Use a more concuse declaration to return reference from lambda.
|
|
||
| struct | ||
| MODMESH_PYTHON_WRAPPER_VISIBILITY | ||
| ConcreteBufferNdarrayRemover : ConcreteBuffer::remover_type |
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.
Move the remover to the common file.
| }; /* end struct ConcreteBufferNdarrayRemover */ | ||
|
|
||
| template < typename T > | ||
| static SimpleArray<T> makeSimpleArray(pybind11::array_t<T> & ndarr) |
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.
Helper function to convert from pybind11::array_t to SimpleArray while sharing the buffer.
| #undef DECL_MM_PYBIND_CLASS_METHOD | ||
|
|
||
| template < typename Func > | ||
| wrapper_type & expose_SimpleArray(char const * name, Func && f) |
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.
Wrapper helper for SimpleArray member accessors.
| std::swap(self.coord(), sarr); | ||
| } | ||
| ) | ||
| .expose_SimpleArray("coord", [](wrapped_type & self) -> decltype(auto) { return self.coord(); }) |
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.
Use decltype(auto) to make the line shorter.
|
|
||
| OneTimeInitializer<T> & operator()( | ||
| OneTimeInitializer<T> & operator() | ||
| ( |
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.
Fix style.
modmesh::python::makeSimpleArrayto create SimpleArray from ndarray (pybind11::array_t) buffer.