Sunday, January 20, 2019

Node modules with Delphi and Free Pascal

chakracore-delphi now comes with NodeSample, a new sample console application showing (as of now very limited) support for Node modules. Included are:

The sample only shows how Node modules can be resolved and used in Delphi and Free Pascal applications. It doesn't implement Node's event loop or any of its internal modules or native bindings like path, fs or http; any scripts referencing them will - for now - raise an exception.

Tuesday, January 15, 2019

WebAssembly with Delphi and ChakraCore

chakracore-delphi now contains WasmSample, a new sample project using ChakraCore to load and run a WebAssembly module (in this case, an implementation of Conway's Game of Life).

It's based on Colin Eberhardt's blog post Writing WebAssembly By Hand (you can run the code in your browser here).

Sunday, November 11, 2018

Inheritance with chakracore-delphi

I've just pushed some updates to chakracore-delphi.

A new feature worth mentioning is support for inheritance (I mean Javascript-style, "prototypical inheritance") in both directions. Suppose the following hierarchy:

First, here is Shape the "superclass", defined in Javascript:

Next comes Circle, a "subclass" of Shape, defined in Javascript as well:

The following is Rectangle, defined in Pascal, as a "subclass" of Shape:

Here's Square, defined in Javascript again, as a "subclass" of Rectangle:

And finally here are the tests, demonstrating that
- (Javascript) Circle descends from (Javascript) Shape
- (Pascal) Rectangle descends from (Javascript) Shape
- (Javascript) Square descends from (Pascal) Rectangle

As always, you can grab the latest code on GitHub. Cheers!