-
Notifications
You must be signed in to change notification settings - Fork 270
[WIP] Interoperability with other Python binding frameworks #1140
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
base: master
Are you sure you want to change the base?
Changes from all commits
036c91c
26971e0
940500d
6769a72
54c5e11
2c5e718
4fb9c85
245fa5a
6fe43c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,15 +189,16 @@ struct type_caster<T, enable_if_t<std::is_arithmetic_v<T> && !is_std_char_v<T>>> | |
|
|
||
| template <typename T> | ||
| struct type_caster<T, enable_if_t<std::is_enum_v<T>>> { | ||
| NB_INLINE bool from_python(handle src, uint8_t flags, cleanup_list *) noexcept { | ||
| NB_INLINE bool from_python(handle src, uint8_t flags, cleanup_list *cleanup) noexcept { | ||
| int64_t result; | ||
| bool rv = enum_from_python(&typeid(T), src.ptr(), &result, flags); | ||
| bool rv = enum_from_python(&typeid(T), src.ptr(), &result, sizeof(T), | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the Why did we not need it before? |
||
| flags, cleanup); | ||
| value = (T) result; | ||
| return rv; | ||
| } | ||
|
|
||
| NB_INLINE static handle from_cpp(T src, rv_policy, cleanup_list *) noexcept { | ||
| return enum_from_cpp(&typeid(T), (int64_t) src); | ||
| return enum_from_cpp(&typeid(T), (int64_t) src, sizeof(T)); | ||
| } | ||
|
|
||
| NB_TYPE_CASTER(T, const_name<T>()) | ||
|
|
@@ -504,6 +505,8 @@ template <typename Type_> struct type_caster_base : type_caster_base_tag { | |
| } else { | ||
| const std::type_info *type_p = | ||
| (!has_type_hook && ptr) ? &typeid(*ptr) : nullptr; | ||
| if (type_p && (void *) ptr != dynamic_cast<void *>(ptr)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need |
||
| type_p = nullptr; // don't try to downcast from a non-primary base | ||
| return nb_type_put_p(type, type_p, ptr, policy, cleanup); | ||
| } | ||
| } | ||
|
|
||
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.
Let's remove this "-local" terminology if the metabind feature is opt-in and rather name things the other way around.