DWScript 2.2 beta

Delphi Web Script 2.2 is now in “beta”, and a DWS 2.2 Beta zip (337 kb)  is available.

No new features are expected up to the next stage (RC), only improvements to unit tests, to reach the psychological 90% code coverage milestone.

Changes since 2.2 preview 4:

  • extended “for in” syntax to work on all array types
  • support dynamic arrays new pseudo-method “IndexOf(item[, fromIndex])”
  • extended “in” operator to test presence of an item in an array: “item in dynamicArray” & “item not in dynamicArray”
  • support scoped enumerations for Delphi compatibility (“TMyEnum.Enum1”)
  • support “@” operator for explicitly obtaining function pointers
  • added TdwsBreakpointableLines class, which provides info about all source lines upon which a breakpoint is possible (useful for IDE “blue dots” support f.i.)
  • optimizations for “var” parameters and passing var parameters as var parameters
  • introduced minor optimization for multiple string concatenation (str1+str2+str3+…)
  • fixed dynamic array’s pseudo-method “.Add()” for arrays of delegates
  • improved unit tests coverage, various fixes (thanks again to Alexey Kazantsev)

For the curious ones looking at the SVN, there are actually other improvements and additions, but those aren’t ready just yet, and won’t be part of 2.2, but of 2.3.

Taming the Chrome Web Store

Chromium LogoWell, “taming” is probably too ambitious given the jungle that the Chrome Web Store is, especially as this post is restricted to publishing a standalone DWScript/JavaScript app into the Web Store in a few simple steps.

Interestingly enough, it seems that publishing Metro apps for Windows 8 will follow a similar process, according to the developer preview.

I’ll use the Flock Demo as an illustration, and turn it into a packaged app, that lives in Chrome and can be access off-line.

(more…)

Interfaces, build system, try..except..finally

There has been two major additions to Delphi Script in the SVN.

Interfaces

You can now declare, implement and use pure-interfaces in DWScript.

  • Same syntax as Delphi, minus the GUID
  • All classes from TObject can directly implement interfaces (no need to implement IUnknown or derive from TInterfacedObject)
  • interface properties are supported
  • “is” can be used to test if an interface is another interface or can be cast to a class
  • “as” can be used to cast between classes and interfaces (in all directions)
  • “implements” can be used to determine if a class implements a particular interface

The “implements” operator was introduced for OO purity, since “obj is interface” is somewhat of an heresy from an OO point of view, so you’re encouraged to lobby for “obj implements interface” 😉

Finally, you can also acquire a function pointer/delegate from an interface method (something that Delphi doesn’t support, as of XE).

Build system

The “unit” support which was previously mentioned as experimental can now be considered operational.

DWScript supports classic Pascal units, with “unit”, an “interface” and “implementation” section, and when compiling a unit it enforces the usual restrictions, so you also have “type” blocks, as disambiguating type declarations is not necessary within a unit.

To feed unit’s code to the compiler, you can either use the “virtual file system” approach, or just handle the new OnNeedUnit event. In that event you have a choice of providing either raw source code or “ready-made” unit in the form of an IdwsUnit.

Other changes

  • the combined try..except..finally statement (ala Oxygen) is now supported
  • fixes + new tests for RTTI-based exposition
  • records, classes & interface symbols have been unified as TStructuredSymbol, TRecordSymbol got its TMemberSymbol replaced by TFieldSymbol
  • a variety of minor fixes and enhancements

Sampling profiler for DWS, units, other changes

Here is the periodic news roundup for DWScript from the SVN side:

  • a new TdwsSamplingDebugger class is available, it’s a debugger for Delphi Web Script whose purpose is to offer sample profiling information for script execution.
  • experimental support for units, with classic pascal “unit”, “interface” & “implementation” sections.
  • experimental support for explicit “uses” import statements.
  • block commenting styles (* … *) and /* … */ are now supported.
  • ^ and ^= are now accepted as binary and compound-assignment operator overloading.
  • new standard functions: IntPower, DateToISO8601, DateTimeToISO8601.