| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
If you want real Pythonic enums (that actually inherit from enum.Enum) you can reuse the P11X_DECLARE_ENUM macro I wrote in mplcairo. |
Sorry, something went wrong.
|
I can't say I understand all of that macro, but I can certainly copy it over if that's the way we want to go. |
Sorry, something went wrong.
|
(I don't really mind either way, but you mentioned that real enums may be better, so I suggested it. I can also try to explain better how it works...) |
Sorry, something went wrong.
|
The failure in the docs actually shows the confusion with the "just a bunch of constants" approach: matplotlib/galleries/examples/misc/ftface_props.py Lines 49 to 63 in 9675122 Only Bold and Italic are style flags; the rest are face flags, and checking them as they are here would always return False. Also, given that the enum values are bitfields already, not bit positions, the math there doesn't make sense. |
Sorry, something went wrong.
On second reading, I have some understanding of it all. It would be nice though if I could add a docstring to each class (as done here), and avoid the C++ enum (but I think I need this one for the variant to produce the deprecation anyway.) |
Sorry, something went wrong.
|
I guess to add a docstring you need to do something like p11x::enums[py_name].attr("__doc__") = ...; as there's no way to set it in the function-style API. |
Sorry, something went wrong.
Yep, looks like that worked nicely.
I started making a copy without the is_enum_v and hardcoding instead of underlying_type_t, but realized I still needed the enum for the deprecation, I think, so gave up on that. Would be nice to de-dupe, but at least the two copies are next to each other now. |
Sorry, something went wrong.
|
|
||
| The following constants are now part of `.ft2font.Kerning`: | ||
|
|
||
| - ``KERNING_DEFAULT`` |
There was a problem hiding this comment.
perhaps note that the new name doesn't include KERNING_; ditto for LOAD_.
Sorry, something went wrong.
There was a problem hiding this comment.
Done.
Sorry, something went wrong.
| auto const& [py_base_cls, pairs] = | ||
| spec.cast<std::pair<std::string, py::object>>(); | ||
| mod.attr(py::cast(py_name)) = spec = | ||
| py::module::import("pydoc").attr("locate")(py_base_cls)( |
There was a problem hiding this comment.
You can probably use pkgutil.resolve_name here instead of the older and undocumented pydoc.locate (though both would work).
Sorry, something went wrong.
There was a problem hiding this comment.
Or should we just hard-code this coming from enum (and only provide the class name to the macro)?
Sorry, something went wrong.
There was a problem hiding this comment.
That's probably fine too, anything works here...
Sorry, something went wrong.
There was a problem hiding this comment.
OK, I just did the hard-coding then, and added more explicit docs about it.
Sorry, something went wrong.
|
Ah, apparently using #ifdef in macro calls is undefined, and MSVC doesn't accept it. I'll just comment out the new ones until we update FreeType. |
Sorry, something went wrong.
|
If I've understood the remaining failure, MSVC doesn't expand __VA_ARGS__ in the P11X_ENUM_TYPE macro call to be multiple arguments, so everything falls apart after. I worked around that by just manually passing the type, unless you have any better ideas? |
Sorry, something went wrong.
You likely need to pass /Zc:preprocessor (or the older equivalent /experimental:preprocessor, which is what I use in mplcairo) (https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170) in extra_compile_args (or whatever that's called for meson). |
Sorry, something went wrong.
|
OK, I checked and /experimental:preprocessor should be old enough for us to depend on. |
Sorry, something went wrong.
|
We're passing now that AppVeyor has been updated. |
Sorry, something went wrong.
Port things to numpydoc, and add additional explanation where possible.
This follows some of the idea from matplotlib#9763, but is based on code from mplcairo. Co-authored-by: Antony Lee <anntzer.lee@gmail.com>
Unfortunately, FreeType doesn't define this as an enum of any sort, just as a bunch of macro `#define`s. So we have to make our own for pybind11 to bind.
|
sorry, took two tries to get the rebase right. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR summary
This does two things:
The Enum change still accepts plain integers, but raises a deprecation warning (as does accessing those constants from the module.) I have not written an API change note in case we don't want to do this. We may also want to mark the deprecation as pending.
PR checklist