2017-12-16 AngelScript 2.32.0
A new version is out. The most significant changes in this version are:
- The string factory has changed to an interface. This is done so that the application can create the string constants at compile time rather than at runtime. This also reduces memory consumption as the script engine doesn't have to keep a copy of the string constants.
- Improved support for registering types that rely on composition. Now registered class methods and properties can directly refer to member components without the need for wrappers.
- Introduction of the 'external' keyword to explicitly tell the compiler that a script entity is external and must have been compiled and shared by an existing module.
- Compiler can now determine the type of initialization lists based on the use, so when there is no ambiguity it is no longer necessary to explicitly inform the type.
2017-11-15 AngelScript WIP
I've changed how string literals are handled in the script engine. Now the compiler evaluates them at compile time and stores a pointer to the application native string type in the byte code. This avoids the need to create new instances of strings every time a script uses a string literal, which in turn translates to a performance improvement.
A new asIStringFactory interface is used to perform the compile time evaluation. This also allows the application to keep track of the used string literals, and store them in a common pool to reduce memory consumption for duplicate string literals. With the factory interface there is also no need for the script engine to keep an internal copy of the string literals thus reducing memory consumption even further.
Since the byte code now stores the pointer to the actual string object, the byte code instruction asBC_STR has no use anymore, and with that the restriction of a 2^16 maximum amount of string literals is eliminated.
Besides the above benefits I should also be able to take this a step further as the compiler now knows that the life time of a string literal is guaranteed, so it should take advantage of that and avoid making unnecessary copies when passing string literals to functions, etc. Though this improvement has not yet been implemented.
For existing scripts there shouldn't be any changes, except if the application currently registers the string factory to return a non-const string object instance. As the string literals are now evaluated at compile time it is no longer possible to have them treated as non-const, still I've made it so that the compiler can when needed implicitly convert to a non-const instance by making a local copy of the string literal at run-time.
As the changes have been quite extensive, I decided to make it possible to temporarily turn off these changes until all bugs have been rooted out. To turn off the changes look for the #define AS_NEWSTRING in angelscript.h and comment out that line. Before I make the official release (hopefully before the end of the year) I'll remove this option completely.
Let me know if you encounter any problems with this, so I can have it corrected before the official release.