[Pas2js] Descending a Pascal class from a JS Function

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jun 30 10:31:30 CEST 2020


On Tue, 30 Jun 2020 00:12:26 +0200
Mattias Gaertner via Pas2js <pas2js at lists.freepascal.org> wrote:

>[...]
> pas2js trunk now supports descending a Pascal class from such a JS
> Function.

Note that pas2js checks for an ancestor class with external name
'Function'. You don't need to use TJSFunction from unit JS. If you don't
like to drag in all the TJSFunction/TJSObject members, you can use:

type
  TJSMinimalFunction = class external name 'Function'
  end;

  TFrameworkFuncClass = class external name
  'FWFunc'(TJSMinimalFunction)
    constructor New;
  end;

  TMyDescendant = class(TFrameworkFuncClass)
  end;

Analog: If you want to descend from a JS Object, which is not a Function
you can do:

type
  TFrameworkObject = class external name 'FWObject'
  end;

  TMyDescendant = class(TFrameworkObject)
  end;


Mattias


More information about the Pas2js mailing list