This repository was archived by the owner on Mar 21, 2026. It is now read-only.
Use ffi-napi, ref-napi, and related Node.js NAPI packages - #19
Open
joelpurra wants to merge 8 commits into
Open
Conversation
> Represents a type that was referred to using an elaborated type keyword, e.g., `struct S`, or via a qualified name, e.g.,` N::M::type`, or both. - Supporting Elaborated types allows for a greatly expanded library generation. - Can be used by `ffi-generate` (with Elaborated type support) to regenerate the `lib/dynamic_clang.js`; see the `llvm-clang-6.0` branch. See - https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html - https://github.com/joelpurra/node-libclang/tree/llvm-clang-6.0 - https://github.com/joelpurra/node-ffi-generate/tree/support-elaborated-type
- Generated using `node-ffi-generate` with elaborated type support.
- Uses `clang-6.0`, which was released 2018-03-08.
- Has not been tested with older `clang`/`llvm` versions.
- Built on Ubuntu 19.10 Eoan using from `node-ffi-generate` with support for Elaborated types.
```shell
ln --symbolic --force "$(which "llvm-config-6.0")" "${HOME}/bin/llvm-config"
llvm-config --version
LD_LIBRARY_PATH="$(llvm-config --libdir)" node ./lib/generateffi.js
```
NOTE: move the generated `newclang.js` to replace `lib/dynamic_clang.js`.
See
- https://releases.llvm.org/6.0.0/docs/ReleaseNotes.html
- https://en.wikipedia.org/wiki/Clang
- https://github.com/tjfontaine/node-ffi-generate
- https://github.com/joelpurra/node-ffi-generate/tree/support-elaborated-type
- The code executes on `clang-6.0`. - The fix makes it possible to use `clang-9`, the current major release. See - https://clang.llvm.org/
- Uses `clang-9` to regenerate support for itself.
- Version 9 is the most recent major version, released 2019-09-19.
- Has additional methods not supported by `clang-6.0` (the only other version tested).
- Dynamically targeting the right version might be possible, but also requires more effort in generation and tests.
- Cross-generation between versions might be possible.
- Built on Ubuntu 19.10 Eoan using from `node-ffi-generate` with support for Elaborated types.
```shell
ln --symbolic --force "$(which "llvm-config-9")" "${HOME}/bin/llvm-config"
llvm-config --version
LD_LIBRARY_PATH="$(llvm-config --libdir)" node ./lib/generateffi.js
```
NOTE: move the generated `newclang.js` to replace `lib/dynamic_clang.js`.
See
- https://releases.llvm.org/9.0.0/docs/ReleaseNotes.html
- https://en.wikipedia.org/wiki/Clang
- https://github.com/tjfontaine/node-ffi-generate
- The original `ffi`, `ref`, and `ref-*` packages are outdated and unmaintained. - Fixes build/compatibility problems with Node.js v12+. - Uses `node-ffi-napi`. - Uses the dependency injection (DI, `-di` suffix) versions of `ref-*` with `ref-napi`. - Tested with Node.js v10 and v12, the currently supported LTS versions. See - https://github.com/node-ffi-napi - https://github.com/nodejs/Release
- Functions used in callbacks need to store an external reference to avoid getting garbage collected. - This patch by @atishay is a backport of the fix in the original `ffi`, which was removed by the `ffi-napi` maintainer. - Revert to using the official version published to npm when the fix is in place. See - node-ffi-napi/node-ffi-napi#56 - atishay/node-ffi-napi@40443ca
Author
|
Forked and fixed quite a few more things, might help someone: https://github.com/node-ffi-packager/node-libclang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forked and fixed quite a few more things: https://github.com/node-ffi-packager/node-libclang
Note: includes commits from previous pull-requests. Should be merged to
masterone by one, but wanted to showcase the stepwise progress and allow for feedback.ffi,ref, andref-*packages are outdated and unmaintained.node-ffi-napi.-disuffix) versions ofref-*withref-napi.See