@+& fails
Hey
I've got this case where I want to pass a reference of an object out of a method through a reference argument. I.e. I have something like this:
bool Raycast(blah, blah, Entity* &hitEntity, blah, blah)
{
...
hitEntity = someEntity;
...
}
I'd kinda like to register this to AngelScript like "Raycast(blah, Entity@+ &out, blah)", but it seems the engine won't accept that.
Is there some better way of doing this? My current workaround is a wrapper that just increases the reference counter to the passed entity instead, and just register it as "Raycast(blah, Entity@ &out, blah)", but I'd rather not have to do that.
Thanks in advance
The autohandles haven't been implemented to support this case. I'll see if I can make this work for a future version.
Regards,
Andreas
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
i've noticed too that defining a script function with an object passed as reference to a handle (@&), when accessing the object, i get a segfault in the vm instead of getting an exception... i dunnow if i'm doing something wrong or the @& case isn't handled correctly...
References to handles should work just fine. What Dentoid reported however is not yet supported.
Would it be possible for you to provide an example that reproduces the access violation?
Would it be possible for you to provide an example that reproduces the access violation?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
i think i'm a bit cludging with the library possibilities, i can't post the
initial script that made me discover this (it's in angeljuice), but i've taken
the test_scriptstring.cpp and i've modified those bits:
original working file
this is working also
this is reporting a test failed
this is segfaulting
ah, trying to make the test_features in linux (gnuc makefile) with revision 76 the TestFor unit test is left out in the makefile itself (so it will not compile), and adding that it will not pass the unit testing at all...
initial script that made me discover this (it's in angeljuice), but i've taken
the test_scriptstring.cpp and i've modified those bits:
original working file
engine->RegisterGlobalFunction("void set(string@)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(@a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
this is working also
engine->RegisterGlobalFunction("void set(string@)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
this is reporting a test failed
engine->RegisterGlobalFunction("void set(string@ &in)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(@a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
this is segfaulting
engine->RegisterGlobalFunction("void set(string@ &in)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
ah, trying to make the test_features in linux (gnuc makefile) with revision 76 the TestFor unit test is left out in the makefile itself (so it will not compile), and adding that it will not pass the unit testing at all...
engine->RegisterGlobalFunction("void set(string@)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
This is working because AngelScript implicitly converts the argument to a handle.
engine->RegisterGlobalFunction("void set(string@ ∈)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(@a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
This is not working because you need to change the SetString() implementation. You're now actually receiving a pointer to a pointer to a asCScriptString object.
engine->RegisterGlobalFunction("void set(string@ ∈)", asFUNCTION(SetString), asCALL_GENERIC); // ... printOutput = ""; engine->ExecuteString(0, "string a; set(a); print(a);"); if( printOutput != "Handle to a string" ) fail = true;
This should probably have given the same error as the previous, as the compiler should have implicitly converted the argument to a reference to a handle. I'll have to verify why that didn't work.
Ah, the TestFor is currently reproducing a bug in AngelScript that I need to fix. You'll need to skip this test for now.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
yes i know that i need to modify the SetString emthod as is changed the way the object is passed on that function, that's obvious. but i was just stating that instead of exiting with an exception like the third test, the fourth case was reporting a segmentation fault (but imho test 3 and 4 are equals, even if the compiler converts the variable or not).
;)
;)
I cannot reproduce this problem with the latest revision (77). I probably fixed it with one of the other bug fixes I've made.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement