You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm making Python bindings for ImGui and trying to find a way to bind some function arguments with less boilerplate.
I'm facing an enum pattern where enums are declared with normal C++ enums, but functions using the enum are in fact not using the enum type but rather an int typedef. Here's how the code looks like:
Note how the int typedef ImGuiButtonFlags is used, and not ImGuiButtonFlags_. Since flags is really just an int, Nanobind has no idea that flags is supposed to be typdef ButtonFlags.
This leads to a fair bit of boilerplate in InvisibleButton bindings definition:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I'm making Python bindings for ImGui and trying to find a way to bind some function arguments with less boilerplate.
I'm facing an enum pattern where enums are declared with normal C++ enums, but functions using the enum are in fact not using the enum type but rather an int typedef. Here's how the code looks like:
I can get the above translated into a Python IntFlag enum. This part is fine:
Here's how these types are used in ImGui:
Note how the int typedef
ImGuiButtonFlags
is used, and notImGuiButtonFlags_
. Sinceflags
is really just an int, Nanobind has no idea thatflags
is supposed to be typdefButtonFlags
.This leads to a fair bit of boilerplate in
InvisibleButton
bindings definition:This pattern is repeated many times over in the ImGui API.
I wonder if there's a better way to express this, without having to write those lambda wrappers for each API function that uses flags like above?
Beta Was this translation helpful? Give feedback.
All reactions