🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

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

Started by
9 comments, last by WitchLord 19 years ago
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]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
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>
tIDE Tile Map Editorhttp://tide.codeplex.com
I had to change the way implicit conversions were handled by the compiler. It seems that I may have mistakedly broken it for this case.

I'll look in to it right away.

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 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 ∈, const string ∈)",            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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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!
tIDE Tile Map Editorhttp://tide.codeplex.com
Congratulations on the wedding!! [grin]

What are you doing posting in the forums while on the honeymoon? [wink]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks. I can't help it... must.. log.. on. :)
P.S. Replying from Kuala Lumpur right now.
That was me.. forgot to log in.. my bad!
Anyway. the posts are OT so feel free to remove them.
tIDE Tile Map Editorhttp://tide.codeplex.com
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]
tIDE Tile Map Editorhttp://tide.codeplex.com

This topic is closed to new replies.

Advertisement