Closed glebnovodran closed 6 months ago
Yes it should, thank you for pointing this out I am fixing it right now.
On Mon, Jan 15, 2024 at 12:53 PM Glib Novodran @.***> wrote:
@jingoro2112 https://github.com/jingoro2112 , could you please tell if this construction is supposed to work still?
function SOME_STATE_FUNC() { //... newState = "some string"; newStateDuration = 0.0; resetCollision = false; // ... res[] = {newState, newStateDuration, resetCollision}; return res; }
It used to work with v3.0.0, but has stopped to work with the recent changes. The WRValue returned by wr_callFunction or by wr_returnValueFromLastCall is not recognized as an array anymore.
— Reply to this email directly, view it on GitHub https://github.com/jingoro2112/wrench/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALIKAZ3KRDO5MWKDWFDNKTYOVUJ5AVCNFSM6AAAAABB3UI54OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DENBXGI2TKMA . You are receiving this because you were mentioned.Message ID: @.***>
Thank you for the prompt response, Curt. By the way, in the light of the future possible code changes, what do you see as a better way to obtain a result value from the function call? wr_returnValueFromLastCall was in and out of the header file, if I am not mistaken, so I am not sure what is better to rely on?
This has been fixed, and your example added as part of the test suite. Sorry for the confusion. In all cases the return value is available directly from the wr_callFuncton(...) call:
function arrayCheck()
{
newState = "some string";
newStateDuration = 0.0;
resetCollision = false;
res[] = { newState, newStateDuration, resetCollision };
return res;
}
Might be accessed:
WRValue* V = wr_callFunction( context, "arrayCheck" );
if ( V )
{
assert( V->isWrenchArray() );
char someString[256];
assert( WRstr(V->indexArray(context, 0, false)->asString(someString)) == "some string" );
assert( V->indexArray(context, 1, false)->asFloat() == 0.0f );
assert( V->indexArray(context, 2, false)->asInt() == 0);
assert( !V->indexArray(context, 3, false) );
assert( V->indexArray(context, 3, true)->asInt() == 0 );
}
Thank you, Curt.
@jingoro2112 , could you please tell if this construction is supposed to work still? https://github.com/glebnovodran/roam_bench/blob/9b90df43ec7af6ae93d649d31dfb550ca6a5d52b/src/acts/acts.w#L50
It used to work with v3.0.0, but has stopped to work with the recent changes. The WRValue returned by wr_callFunction or by wr_returnValueFromLastCall is not recognized as an array anymore.