Jump to content
Sign in to follow this  
markus_ja

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.

Share this post


Link to post
Share on other sites

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:
http://stackoverflow.com/q/21985657/267938

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Why not open source the tool, and publish it e.g. on github?

 

So that others may contribute to it, and use it at their own risk.

 

And support may be done by users.

Share this post


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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×