Sign in to follow this  
WitchLord

AngelScript 2.2.0 + bug fix (2005/06/10)

Recommended Posts

I've uploaded the latest official version, with new interesting features. The biggest change is the added support for script declared structures. With this the scripts can be more powerful and flexible. The drawback is that the application will have to do a little garbage collection once in a while, but this is done with a simple call to the GarbageCollect() method. Another great addition, though simpler, is the new compiler flag AS_MAX_PORTABILITY. When compiling the library with this flag, the library should work on just about any compiler/platform that can compile standard C++ code. Object handles has also become easier to use. The script compiler can now automatically convert objects to their handles where it is unambiguous. The VM can also automatically take care of the AddRef()/Release() calls for the application when passing to or returning handles from application functions. The next step is to allow the scripts to pass the script declared structure to the application for storage. This will allow the scripts to extend not only the functionality but also the data in the application. [Edited by - WitchLord on June 10, 2005 3:01:49 PM]

Share this post


Link to post
Share on other sites
I'm compiling the 'game engine' for my game using AS 2.2.0 but I'm experiencing some problems during script compilation. Seems something has changed in the syntax. The problem appears to be related to registered types used with constants.

Script Extract:

<span class="cpp-comment">
:
:
// online scores
//const String URL_SITE = "http://localhost/sb";
const String URL_SITE = "http://www.sharkbaitgames.com";
const String URL_GET_HISCORES = URL_SITE + "/get_hiscores.php";
const String URL_CAN_SUBMIT_HISCORE = URL_SITE + "/can_submit_hiscore.php";
const String URL_SUBMIT_HISCORE = URL_SITE + "/submit_hiscore.php";
:
:
</span>

Compilation error:

<span class="cpp-comment">
script\Constants.as (40, 33) : Info : Compiling const String URL_GET_HISCORES
script\Constants.as (40, 42) : Error : Reference is temporary
script\Constants.as (40, 42) : Error : Can't implicitly convert from '<unrecognized token>' to 'String'.
script\Constants.as (41, 39) : Info : Compiling const String URL_CAN_SUBMIT_HISCORE
script\Constants.as (41, 48) : Error : Reference is temporary
script\Constants.as (41, 48) : Error : Can't implicitly convert from '<unrecognized token>' to 'String'.
script\Constants.as (42, 35) : Info : Compiling const String URL_SUBMIT_HISCORE
script\Constants.as (42, 44) : Error : Reference is temporary
script\Constants.as (42, 44) : Error : Can't implicitly convert from '<unrecognized token>' to 'String'.
script\Initialise.as (95, 1) : Info : Compiling void SetInternetUrls(GameContext@)
script\Initialise.as (97, 33) : Error : Use of uninitialized global variable 'URL_GET_HISCORES'.
script\Initialise.as
</span>

Share this post


Link to post
Share on other sites
I can successfully compile the constant strings using the exact same declarations that you show here. In this case I'm using the asCScriptString that comes with the add on.

My guess is that something is not right with your registered add behaviour, since it is only those lines that fail.

Have you registered the add behaviour to take const strings? I.e:


r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD,
"string@ f(const string &in, const string &in)",
asFUNCTIONPR(operator +, (const asCScriptString &, const asCScriptString &),
asCScriptString*), asCALL_CDECL); assert( r >= 0 );


If you haven't let me know how you did register the add behaviour, since it would be a bug in AngelScript that didn't report it as an error.

Actually it might also the way you have registered the string factory. Could you show me the declaration that you used for the string factory?

Regards,
Andreas

Share this post


Link to post
Share on other sites
The first confirmed bug has been found by AlphaDog. When passing a script array by handle to a script function and then accessing the elements, the compiler produces byte code that may crash the application with memory access violations. The bug fix can be found here:

http://www.gamedev.net/community/forums/topic.asp?topic_id=324825

Share this post


Link to post
Share on other sites
Witchlord,

At the moment I'm away from my development machine (I am in Singapore for my honeymoon :)) so I am not in a position to check. I'm not sure but I don't think I added specific Add behaviour for constant strings. What I can tell you is that I am using my own registered version of std::string. I guess I now need to treat my string registration more rigorously. I will let you know once I return home next month!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks. I can't help it... must.. log.. on. :)
P.S. Replying from Kuala Lumpur right now.

Share this post


Link to post
Share on other sites
Ok.. back home :)

Up to AS 2.1.0 I was basically ignoring const declarations altogerther as they were not supported, so I am unaware as to the scale of the changes I'll need to do to work with AS 2.2.0.

My Add behaviour is defined to take a non-constant parameter. I have tried registering a second Add behaviour that takes 'const std::string &otherString' but couldn't get it to work and I also tried replacing the non-const version with the const version - same problem.

My string factory is defined as follows:
std::string String_Create (asUINT length, const char *s)
{
return std::string(s);
}

Should it be defined to return a const string?

Hope the above helps!
Thanks

[edit]
Ok, I think I solved the problem. I've had a look at asScriptString and noticed that the Assign, Add and AddAssign all use constant parameter refs - I've modified my own accordingly and all's working!
[/edit]


[Edited by - SharkBait on June 30, 2005 4:28:51 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this