Skip to content
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

Is there a posibility to return a custom type to python #11

Closed
circinusX1 opened this issue Aug 26, 2022 · 1 comment
Closed

Is there a posibility to return a custom type to python #11

circinusX1 opened this issue Aug 26, 2022 · 1 comment

Comments

@circinusX1
Copy link

circinusX1 commented Aug 26, 2022

Hi,
Great job, easy integration. Thank you.

What work around I have to make to return an object instance from a C++
function to python ?

class A{
public:
        A(){}
        ~A(){}
        void method(){ printf("%s\n",__FUNCTION__)};
};

A a;
/*
 ...
*/
A& Another::returnA(){
    return a;
}

/*
 ...
*/
e.regClass<Another()>("Another")..regMethod(&Another::returnA,"returnA");
e.regClass<A()>("A")..regMethod(&A::method,"method");

PY, something like

another = ffpython.Another()
theA = another.returnA()
theA.method()

Yields errors as:

ffpython/ffpython.h: In instantiation of ‘PyObject* ff::ScriptMethodImpl<RET (CLASS_TYPE::*)()>::handleRun() [with CLASS_TYPE = AeProcess; RET = AeDriver&; PyObject = _object]’:
ffpython/ffpython.h:1390:23:   required from here
fpython/ffpython.h:1392:48: error: incomplete type ‘ff::ScriptCppOps<A&>’ used in nested name specifier
 1392 |         return ScriptCppOps<RET>::scriptFromCpp(((CLASS_TYPE*)pobjArg->*func)());
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~









@circinusX1
Copy link
Author

Fixed, I return a pointer and works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant