daScript icon indicating copy to clipboard operation
daScript copied to clipboard

How to return an object or value from function in das script to cpp host program?

Open lvdpower opened this issue 2 years ago • 1 comments

How to return an object or value from function in das script to cpp host program?

C++ is calling das Context like this ctx.eval(fnTest, nullptr); It is not clear how to return a value from fnTest to host c++ program.

Thank you!

lvdpower avatar Aug 08 '22 23:08 lvdpower

If its passed by value - eval returns vec4f, which can be cast to the right type. if its passed by reference on the stack, eval's 3rd parameter is address of the buffer for the result.

    __forceinline vec4f eval ( const SimFunction * fnPtr, vec4f * args = nullptr, void * res = nullptr ) 

borisbat avatar Aug 09 '22 01:08 borisbat