[Pas2js] js2pas? (a h2pas equivalent but for JS)

Michael Van Canneyt michael at freepascal.org
Sun Feb 17 10:09:05 CET 2019



On Sat, 16 Feb 2019, silvioprog wrote:

> Hello,
>
> I've imported some SVG classes to my Web.pas unit (I'll send it as patch
> soon), so I decided to import all SVG classes to make them available in
> pas2js, however, there are a lot of classes, so it would be hard to import
> it by hand. Take a look at the section "Related pages for SVG" at this like:
>
> https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
>
> So, I have a question. Is there some automated tool (even in JS/Bash etc.)
> or a Lazarus wizard which I could use to import those classes?

fpc/pas2js comes with a webidl2pas tool.  You can use that to implement the
necessary classes using the IDL at:
https://www.w3.org/TR/SVG/idl.html

But do not put it in web.pas, but a separate websvg unit, so it can be
regenerated from source when needed.

Be warned, WebIDL is somewhat tricky. There are 2 versions, 1 and 2, which
are not compatible. The tool has a switch to select the version.

Michael.


More information about the Pas2js mailing list