https://github.com/ppebb/libclang-lua
Lua binding for libclang's C/C++ API, the Clang compiler API to access the AST of C/C++ source files.
https://github.com/ppebb/libclang-lua
Last synced: about 1 year ago
JSON representation
Lua binding for libclang's C/C++ API, the Clang compiler API to access the AST of C/C++ source files.
- Host: GitHub
- URL: https://github.com/ppebb/libclang-lua
- Owner: ppebb
- Created: 2025-01-12T03:35:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T06:10:50.000Z (over 1 year ago)
- Last Synced: 2025-01-24T08:15:25.598Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libclang-lua
Lua bindings for libclang. Docs soon.
This project is a hard fork of
[luaclang-parser](https://github.com/mkottman/luaclang-parser/) with most
functions renamed, and many functions added. It fills in some gaps of the
libclang api by accessing the internal C++ types directly.
## Compiling
This project requires Lua 5.4 and Clang. Libclang is usually built and
installed alongside the Clang compiler, but some distributions may have a
separate libclang-XX-dev package (see #1). These can be obtained from your
distribution's package manager.
Note that this project has only been tested with Clang-18, earlier versions may
not compile (versions 15 and below are missing required headers), and later
versions may have affected functionality. Your mileage may vary.
This project requires CMake for compilation. Ensure you have CMake >= 3.18.
Then run the following from the project root to compile:
```bash
$ mkdir build; cd build
$ cmake ..
$ make
```
## Type Definitions
There are included type definitions in `libclang-lua-types.lua` for use with
LuaLS. They will not be automatically picked up by LuaLS, so you will need to
point to them using `workspace.library` (see [LuaLS
docs](https://luals.github.io/wiki/definition-files/)).
Because libclang-lua is directly required as a shared object, LuaLS does not
know what type it returns, so annotate the require with `--- @type Clang`
## Examples
While no examples are contained within this repository,
[cosmo-stub-generator](https://github.com/ppebb/cosmo-stub-generator) provides
an example of nearly every function in the project and their use. See
`src/generate.lua`.