Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

AngelScript 2.26.1


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Andreas Jonsson   Moderators   -  Reputation: 3263

Like
3Likes
Like

Posted 03 March 2013 - 10:45 AM

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

Sponsor:

#2 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 03 March 2013 - 11:58 AM

any foo = 42;


#3 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 04 March 2013 - 12:34 AM

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 :)


#4 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 04 March 2013 - 04:01 PM

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!


Edited by saejox, 04 March 2013 - 04:05 PM.


#5 Andreas Jonsson   Moderators   -  Reputation: 3263

Like
0Likes
Like

Posted 04 March 2013 - 04:32 PM

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

#6 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 04 March 2013 - 04:54 PM

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 :) .



#7 Andreas Jonsson   Moderators   -  Reputation: 3263

Like
0Likes
Like

Posted 04 March 2013 - 05:18 PM

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

#8 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 04 March 2013 - 05:38 PM

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 :)



#9 Andreas Jonsson   Moderators   -  Reputation: 3263

Like
0Likes
Like

Posted 04 March 2013 - 07:05 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS