-
Notifications
You must be signed in to change notification settings - Fork 56
refactor wrapper of SimpleArray #123
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
|
I think this logic, copying array, doesn't need to be inside the wrapper, the wrapper should just "wrap" things? |
cpp/modmesh/buffer/TypeBroadcast.hpp
Outdated
| * POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #include <pybind11/pybind11.h> |
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.
Code using pybind11 should live in the python/ sub-directory. Otherwise, pure C++ code will include the Python.h (like here). Python.h alters a lot of things, requires to be included before everything else, and should not be included for pure C++ code.
cpp/modmesh/buffer/TypeBroadcast.cpp
Outdated
| namespace modmesh | ||
| { | ||
|
|
||
| static void TypeBroadCast<T>::check_shape(SimpleArray<T> const & arr_out, |
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 is incorrect to put template implementation in a cpp file: https://stackoverflow.com/questions/115703/storing-c-template-function-definitions-in-a-cpp-file . While forceful instantiation may be a workaround (but I do not like it), you do not do it either.
|
@yungyuc please take a look, also the failed CI is not my problem I thought. |
| namespace python | ||
| { | ||
|
|
||
| template <typename T /* original type */, typename D /* for destination 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.
I feel we have a better way to implement this using helper code in pybind11, but it's a good step forward to move the code to a distinct file!
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.
could you provide some examples about "helper code in pybind11"?
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.
it's a good step forward to move the code to a distinct file!
ya, now the wrapper looks more clear. :)
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.
@yungyuc Could you answer the question above, I am curious about it. thanks!
I just pull the master, please squash the PR when you merge it. |
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.
Please rebase. If you want to squash you can do it as you rebase. For this simple refactor it does not make sense to have pull from master.
|
I've rebased it. |
|
LGTM. Thanks. |
move
TypeBroadcastoutside wrapper