Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting started for a new extern #1

Open
kevinresol opened this issue May 22, 2016 · 2 comments
Open

Getting started for a new extern #1

kevinresol opened this issue May 22, 2016 · 2 comments

Comments

@kevinresol
Copy link
Member

I am planning to write the nodejs extern for redis. But I am not exactly sure how to get started. Are there any guides explaining the use of metadata (e.g. @:externjs) and the interfaces (e.g. js.extern.Extern)?

@fantoine
Copy link
Contributor

Hi, currently there are no guides available. However it looks like you got the whole thing in this repo. :)

You should also add an extraParams.hxml file to specify the default version (major.minor) of the library to use (for instance).
It let you define the version of the library to use if it's not overriden by the project configuration.
It's only useful if your extern can be available for multiple versions of a library.

This is the case for Validator where some methods changed in version 5.
I use a macro constant validator_ver which is automatically defined by js.extern.Extern.
If this value is defined in your project, so it will use it. Otherwise it will use validator_default_ver.
The default variable constant should have this name: <module>_default_ver where module is the named specified in js.extern.Extern<'<module>'>.

Then, your extraParams.hxml should contains:

-D redis_default_ver=2.6

I think it will change in the future because it's not very handy, but currently it works this way.

@kevinresol
Copy link
Member Author

kevinresol commented May 22, 2016

Yeah.

Just one suggestion here. Now the @:externjs meta uses a list of key=value params which is slightly unnatural in my opinion. Actually we can use an anon obj to do that, for example:

@:externjs({
  namespace: true,
  global: 'redis'
})

Then when you parse you just need to match a EObjectDecl and then get the fields from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants