Jump to content

JavaScript Wrapper Generator

Recommended Posts

Is it planed to implement a JavaScript to ObejctPascal Wrapper generator tool? Where I can just select a JavaScript file (which I want to use in SMS), and that tool generates the Pascal Wrapper classes for me.


That would reduce development time a lot. Especially when using 3rd party UI controlls in SMS.

Link to post
Share on other sites
  • Administrators

JavaScript is too unstructured to be parsed in any useful way.
Thus the usefulness of Smart ;-)

TypeScipt, however, is much better. TypeScript is a typed superset of JavaScript, and when TS was introduced a couple of years ago, developers started to collect several type definitions in a public repository.

A complete list over supported projects can be found at https://github.com/borisyankov/DefinitelyTyped

And guess what...
We do have a tool that generates Smart Pascal classes from these TypeScript definitions :-D

However, the tool is still for internal use because it's still missing a few issues, and it's not really stable enough for public release. :-(

BUT. If you find the project you would like to wrap in the TypeScript library above, then let us know. We will gladly run it trough the converter to see how it goes.

This was also demonstrated in this SO question:

Link to post
Share on other sites
  • 4 weeks later...

We also have a tool to convert WebIDL to Smart/DWS Pascal.


However, this wrapper is not very error tolerant so far. This and the fact that most WebIDL is not according to the specification, but rather informative, is the reason why we don't ship it so far. If we would ship it, we would probably need to support it. Instead we prefer to run the tool for a requested set by ourself an publish the reviewed (and hopefully tested) code by ourself.

Link to post
Share on other sites

Actually we're talking about two different tools here.

Wrapper generator for TypeScript files (written in Smart itself, by André)

Wrapper generator for WebIDL code (written in Delphi, by me)

While I can not speak about the first here, I can do about the second. Initially it was meant as an IDE tool extension (hence written in Delphi). However, it turned out that WebIDL is rather an informative language (structure) than a perfectly interpretable language (in particular attributes can be nearly everything, even comment like sentences). This means, it did not turn out to be quite useful to add this to the IDE as it will produce many errors for badly written WebIDL code (and trust me, most APIs have [had!] errors).


On the other hand a tool like this is quite valuable to hint the editors so that they get the APIs fixed. And this is one of the reasons, why we want to keep this internal. Another reason is the fact that the number of files containing WebIDL is little and we can easily translate every requested files on our own.


However, the code is currently (an unpublished) part of DWS. Its development falls under the licensing of the JS codegen. Our internal tool still requires external libraries (to fetch and extract the WebIDL from HTML API specifications).


Eventually we could rewrite (and release) the wrapper as Smart application (similar to the other wrapper) as the code we used in Delphi is freely available for JavaScript. Though - at the moment - we don't have resources for this.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...