AngelScript 2.26.1

Started by
7 comments, last by WitchLord 11 years, 2 months ago

This new release brings several important bug fixes to problems that could cause crashes and other unexpected behaviours in some situations. It's highly recommended that the upgrade is made as soon as possible.

Besides the bug fixes this version also brings support for multiple subtypes in templates (Thanks Amer Koleci), support for native calling conventions with Linux and arm processors (Thanks Carlos Luna), and support for octal and binary literals (Thanks ketmar).

The script compiler has been enhanced to finally support implicit conversion from primitive types to registered value types by allowing the compiler to call the appropriate constructor. This has been a frequent request from users.

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

Advertisement

any foo = 42;

Now we just need to find the question :)

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

Sorry, it seems i deleted the question while tagging the code. Let me rewrite a better one smile.png


The script compiler has been enhanced to finally support implicit conversion from primitive types to registered value types by allowing the compiler to call the appropriate constructor.

Does this mean if i have constructor for a type like this "any(int val)" then i can call this?


any foo = 42;

I looked in tests folder but could not find new tests for this feature. It's committed in rev1568 but there are no new tests.

Implementing it like this did not give any fruit.


int r = engine->RegisterObjectType("any", sizeof(Any), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);assert(r >= 0);    
r = engine->RegisterObjectBehaviour("any", asBEHAVE_CONSTRUCT, "void f(uint)", asFUNCTIONPR(Any::CreateAny, (unsigned int, Any*),void), asCALL_CDECL_OBJLAST); assert(r >= 0);

compile error: There is not copy operator for the type any available


Adding an opAssign method works tho.

Thanks!

Hmm. This currently doesn't work because the compiler would first implicitly convert 42 into an instance of any, and then assign that instance of any to the declared variable. It won't initialize the declared variable directly with the constructor that takes uint. If you add an opAssign that takes an 'any' it should work though.

Quite frankly, I think this is a 'border case'. I mean, the use of copy constructor, or in this case the constructor that takes an uint to initialize the variable would just be an optimization that the compiler could make. Since the any type doesn't have the assignment operator it probably shouldn't be allowed to be initialized with this syntax.

I didn't add a lot of new tests for this change, because the code mostly already existed. I mostly only enabled the path to allow implicit cast from primitive to value type. All the rest of the logic for when and where implicit casts are used is still the same.

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 understand. I thought that's a bug.

opAssign would do nicely.

I have another small question,

Why is scriptany addon implemented as GC collected ?

Wouldn't a value type be enough.

I'm not a pro at garbage collection sorry for my noobiness :) .

Way back when I implemented CScriptAny, I decided to make the object a reference type, allow a handle to it be passed around.

It would definitely be possible to implement the type as a value type too, but then when passing the type around it would have to be as copies which would be more expensive.

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

Way back when I implemented CScriptAny, I decided to make the object a reference type, allow a handle to it be passed around.

It would definitely be possible to implement the type as a value type too, but then when passing the type around it would have to be as copies which would be more expensive.

I think i can write a 8 bytes any for both 64bits and 32bits. That wouldn't be slow to copy.

I'll write a value type any and benchmark it :)

The problem is not the container itself, but what it contains. If it holds a value type, then that value needs to be copied together with the container, if it holds a reference type, then that reference needs to be increased, and so on.

But, by all means, do the benchmark. I'd love to be proven wrong :)

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