Links

Categories

Tags


« | Main | »

JewelScript 1.1.3.32 changes log

By Jewe | November 2, 2012

This post lists all changes made to the project since it’s previous public release, version 1.0.3.13. The newest change is on top of the list.

New features and improvements

Revised built-in exception interface

The built-in exception interface has been improved. The unnecessary constructors have been removed from the interface, and support for exception strings has been added by adding a getMessage() method.

See Changes To Exception Interface for an example.

New control flow statements: clause and goto

The clause-statement allows you to structure the function’s body into sections and the new goto-statement allows you to jump into them. More information on clauses can be found here: Controlling the flow with ‘clauses’.

Added automatic ‘factorization’ of interfaces

Operator new can now automatically instantiate all implementors of a given interface and return them in an array. See Building Object Factories for more information.

New API functions

JCLForwardClass() can be used to forward declare a class programmatically.

JCLImportClass() can be used to import a class programmatically.

JILGetImplementors() can be used to get a list of all classes that implement a given interface.

NTLIsValidTypeID() can be used to check if a type-id is valid.

Improved inheritance model

Methods and accessors can now be derived from a base class by adding them to an interface and combining interface implementation with hybrid inheritance. This adds almost true inheritance to Jewelscript. Learn all about it in Improved Inheritance Model and Accessor Inheritance.

Added support for ‘continue’

You probably never noticed, but there was no continue-statement in JewelScript. Why I’ve added it, can be read in Please ‘continue’.

Changed built-in “processor” delegate type

The processor delegate used for the built-in classes has been changed. The const modifier has been removed from the argument list to avoid unnecessary copying of every item in the container.

function var MyArrayProcessor(const var element, var args)
{
    MyClass obj = element; // implicit conversion from const to non-const
                           // 'element' is implicitly copied

    if (obj.Name == "Astley")
        return null;

    return obj;            // but we probably didn't want to copy all elements
                           // we just wanted to filter out 'Astley'
}

This is a processor delegate for an array of MyClass objects. It’s purpose is to filter out all MyClass elements that have “Astley” as their name. All other elements should be returned untouched.

However, since the function argument was declared constant, the language required that the object was copied. Otherwise we would have a non-constant reference to an object that must remain constant.

So in essence, this delegate creates a new copy of all array elements, which wasn’t our intention. We just wanted to filter out Astley. Thus, I have removed the const modifier from the delegate declaration.

Added support for import pathes

It is now possible to define library pathes to the JewelScript compiler. Until now, the import statement always assumed the current working directory when importing script files from the local file system.

However, this proved to be too restrictive when developers wanted to create and share libraries of script classes between projects. The import statement would only allow you to access scripts from the current working directory or any folders below – but not above it in the directory hierarchy.

To make building a “standard class library” for shared code easier, the new API Function JCLAddImportPath() has been added. This function allows you to register any amount of pathes to the compiler, under a user defined keyword. When using this keyword as the first argument in an import statement, this will tell the import statement to look up the script under the associated directory path.

For example, the API call

JCLAddImportPath(pVM, "System", "C:\\Program Files\\MyApplication\\Scripts");

will allow you to use this statement in your scripts

import System.Console.Application;

which will load and compile the script “C:\Program Files\MyApplication\Scripts\Console\Application.jc”.

This new feature is entirely optional. Whether it is useful to you, depends on the nature of your application. It is still possible to access scripts relative to the current working directory, even when using this feature.

Additions to built-in types

array

method int indexOf(var item, const int index);

string

method int containsAnyOf(const string[] keywords);
method int containsAllOf(const string[] keywords);
method stringMatch[] matchString(const string[] keywords);
method stringMatch[] matchArray(const string[] strings);

stringMatch (new built-in class)

accessor int matchStart ();
accessor int matchLength ();
accessor int arrayIndex ();

table

method int cleanup();

Other bug fixes and improvements

– fix: set-accessors now work with delegates
– fix: global constants in native class declarations work again
– fix: runtime now gets blocked when entering JILTermVM()
– fix: hybrid inheritance would also inherit anonymous local functions, leading to crashes
– fix: JILTable was storing NULL-Handles as items, which lead to inconsistencies
– fix: accessor methods should now properly perform automatic type conversion
– fix: string literal with an invalid character value now produces compile-time error
– fix: imported native types were not incrementally initialized, leading to crash when using multiple compile & run cycles
– fix: global class constant not found when passed to a function of the same class, unless the full qualified function name was given
– fix: compiler option “warning-level” could not be set to 4
– fix: built-in table class did not respond to garbage collector MARK event
– fix: in certain cases, when you passed a constant defined in a class to a function of the same class, you still had to specify the full qualified name of the constant
– fix: wrong error message when compiling function argument that is an undefined identifier
– fix: operator new initializer block not working after copy-constructor
– fix: declaring class with native modifier forced it to have a constructor
– fix: it is no longer possible to instantiate and use classes declared native
– fix: it is no longer possible to redeclare a class / interface using different modifiers
– fix: you can no longer combine native class declaration with hybrid

Topics: docs | Comments Off on JewelScript 1.1.3.32 changes log

Comments are closed.