🎉 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.28.0 is out

Started by
3 comments, last by BlackMoons 10 years, 7 months ago

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

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

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)

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

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 Andreas!

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.

Lead Coder/Game Designer for Brutal Nature: http://BrutalNature.com

This topic is closed to new replies.

Advertisement