-
Notifications
You must be signed in to change notification settings - Fork 611
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
[wpilib] Make robot base class functions protected #6645
base: main
Are you sure you want to change the base?
[wpilib] Make robot base class functions protected #6645
Conversation
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.
Changing functions from public to protected will break RobotPy and require workarounds to fix the resulting compilation errors.
I don't see why this is needed.
It prevents the user from doing obviously incorrect things. Why can't pybind11 handle protected methods? |
Why does it matter what the user does? How often does this come up? pybind11 can bind protected methods with a trampoline, but I think I would need an additional workaround to deal with protected constructors, as pybind11 tries to do the thing you're explicitly disabling -- instantiate the class from outside the class. |
This is precisely what we're trying to prevent the user from doing at the API design level. It's a trivial change in C++/Java, which is why I made this PR as opposed to leaving it alone. Pybind11 is the one overcomplicating it. Pybind11 shouldn't be instantiating the class directly; it should be inheriting from it instead. If that isn't possible in Pybind11, that seems like a pretty basic shortcoming of the tool. Perhaps those few classes should be written in Python instead so they can use inheritance as intended? |
41a056c
to
b5fb738
Compare
f2657ce
to
be7b72a
Compare
d9e02d8
to
53a57a5
Compare
Users should be inheriting from these classes instead of directly instantiating them.
53a57a5
to
3127ba9
Compare
Users should be inheriting from these classes instead of directly instantiating them.