-
Notifications
You must be signed in to change notification settings - Fork 29
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
Non-void methods using call by reference #89
Comments
@voneiden do you need some specific function(s)? If so, I can add a workaround for 7.6.3. Eventually, I'd like to merge your PR or develop something similar, but not in the nearest feature. |
@adam-urbanczyk I'm good as is at the moment thanks, no need to include temporary workarounds. |
Just wanted to bump this issue. Also, following the current implementation I am assuming you would have something like: int F(int &arg1); Turning into def F() -> Tuple[int, int]: ... Although I don't know if OCCT has any def F(int) -> Tuple[int, int]: ... would be more appropriate. An alternative solution which would require less drastic API changes (for better or worse) would be to either support the builtin ctypes solution for this (https://docs.python.org/3/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference) (which for some reason PyBind11 does not support), or to introduce a custom python object which handles this and your code generation could take into account (pseudocode): class Ref:
def __init__(self, value): self.value = value m.def("F", [](py::object arg1_ref) { return F(arg1_ref.value);}); a = Ref(0)
F(a) |
Just ran into this issue while trying to use One "overload" is this:
In this case the parameters: I am not sure if this was previously known, but I am able to partially workaround by creating p.s. |
There are quite a few methods in OCP that use call by reference but return a value instead of void. The current implementation of pywrap classifies functions as call by reference only when the return is void.
One example in OCP is the GeomLib_Tool.Parameter_s function - the computation result is stored in the 4th argument and the function returns a Standard_Boolean indicating whether the function succeeded in finding a value. However because the function does not return void, it's not classified as call by reference and therefore the actual computed value is not accessible from callers side.
I've opened an issue to CadQuery/pywrap#45 and a draft PR CadQuery/pywrap#46 demonstrating a possible solution (only for functions returning Standard_Boolean). This solution adds the boolean return value to the tuple returned by the wrapper.
A downside in implementing a change like this is that it breaks backwards compatibility as some functions return signature will change.
The text was updated successfully, but these errors were encountered: