Advertisement Jump to content
Sign in to follow this  
WitchLord

AngelScript 2.28.0 is out

This topic is 1893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

With this version I've spent a lot of time to redesign how the initialization lists work. Previously they could only be used for arrays, but now the application can register a list factory, or list constructor for value types, and declare a pattern that should be used by the compiler. The compiler will also build a single buffer with all the value and pass a pointer to that buffer to the factory or the constructor. This makes it much more effective to copy the values into the object in comparison with the previous use of the index operator.

 

The new initialization lists are a lot more versatile, and I've used this to implement a list factory for the dictionary add-on that takes name-value pairs, and also a list constructor for the complex math type to show how it is done.

 

Hopefully this will make AngelScript much more useful as a data language, i.e. where the scripts are used to setup data besides just for logic.

 

There is of course a lot more than can still be improved with regards to the initialization lists, and I'll continue to work on this over the upcoming releases. Some examples of future improvements are the ability to use initialization lists in regular expressions, and more rules that can be given to declare the expected list pattern.

 

The release brings several other minor improvements too, so please verify the change list to get the details.

 

Regards,

Andreas

Share this post


Link to post
Share on other sites
Advertisement

Hi Andreas,

 

you're doing a great job as always!

 

However, upon upgrading to AS 2.28.0 I noticed that our code doesn't compile anymore. The reason being is that starting with some later AS versions, the asSFuncPtr doesn't have implicit default constructor anymore and thus it can not be used as a member of another structure with implicit default constructor. That wouldn't be a problem if only C++ allowed initializer list to be used for classes with defined user defined constructors. And we use initializer lists a lot:

typedef struct asBehavior_s
{
	asEBehaviours behavior;
	const char * declaration;
	asSFuncPtr funcPointer;
	asECallConvTypes callConv;
} asBehavior_t;
...
static const asBehavior_t astrace_ObjectBehaviors[] =
{
	{ asBEHAVE_CONSTRUCT, ASLIB_FUNCTION_DECL(void, f, ()), asFUNCTION(objectTrace_DefaultConstructor), asCALL_CDECL_OBJLAST },
	{ asBEHAVE_CONSTRUCT, ASLIB_FUNCTION_DECL(void, f, (const cTrace &in)), asFUNCTION(objectTrace_CopyConstructor), asCALL_CDECL_OBJLAST },

	ASLIB_BEHAVIOR_NULL
};

With AngelScript 2.28 the following code doesn't compile because:

 

1>g_ascript.cpp(51): warning C4510: 'asBehavior_s' : default constructor could not be generated
1>          g_ascript.cpp(46) : see declaration of 'asBehavior_s'
1>g_ascript.cpp(51): warning C4610: struct 'asBehavior_s' can never be instantiated - user defined constructor required

 

Provinding the struct with explicit default constructor breaks initializer lists we use for the astrace_ObjectBehaviors array and the likes.

 

Any recommendations on what we should do? We'd rather not give up the nifty iniailizer lists, changing asFuncPtr to have implicit default constructor looks like a better option, what do you think?

asSFuncPtr(asBYTE f)

to

asSFuncPtr(asBYTE f = 0)
Edited by _Vicious_

Share this post


Link to post
Share on other sites

Yes, there is no reason for not having a default constructor in the asSFuncPtr. Your suggestion is as good as any. I'll have it checked it.

 

I'll also be sure to add a test case similar to your way of initializing the engine to avoid breaking this in the future.

 

Thanks,

Andreas

Share this post


Link to post
Share on other sites

Very cool. I must say I use angelscript to define a lot of data in my program. Its so wonderful being able to define functions and constants to fill in some of that data. Makes rebalancing the entire game a snap.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!