You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)?
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.
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.
Activity
fantoine commentedon May 22, 2016
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.hxmlfile 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_verwhich is automatically defined byjs.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_verwheremoduleis the named specified injs.extern.Extern<'<module>'>.Then, your extraParams.hxml should contains:
-D redis_default_ver=2.6I think it will change in the future because it's not very handy, but currently it works this way.
kevinresol commentedon May 22, 2016
Yeah.
Just one suggestion here. Now the
@:externjsmeta uses a list ofkey=valueparams which is slightly unnatural in my opinion. Actually we can use an anon obj to do that, for example:Then when you parse you just need to match a
EObjectDecland then get the fields from there.