https://github.com/devigned/veil
Veil is a code generator which exposes Golang packages via a generated C ABI that is consumed by host languages through FFI. Currently, Veil supports Python, but could be used with any FFI implementation. This is a work in progress.
https://github.com/devigned/veil
ast cffi ffi-bindings go golang python
Last synced: 5 months ago
JSON representation
Veil is a code generator which exposes Golang packages via a generated C ABI that is consumed by host languages through FFI. Currently, Veil supports Python, but could be used with any FFI implementation. This is a work in progress.
- Host: GitHub
- URL: https://github.com/devigned/veil
- Owner: devigned
- License: mit
- Created: 2017-06-01T17:23:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T16:47:11.000Z (about 8 years ago)
- Last Synced: 2025-05-07T13:05:24.612Z (5 months ago)
- Topics: ast, cffi, ffi-bindings, go, golang, python
- Language: Go
- Homepage:
- Size: 142 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Veil
[](https://travis-ci.org/devigned/veil)Veil is a code generator, which exposes Golang packages via a generated C ABI that is consumed by
host languages through FFI. Currently, Veil supports Python, but could be used with any FFI
implementation.Veil produces a C ABI from a Golang package by parsing the AST exposed by the Golang package
and building a CGo wrapper AST for the exposed functionality in the package. The CGo
wrapper AST is written to `main.go`, compiled, and used as the basis for FFI binding from the
consuming language.Veil has been built to comply with the Golang specification for Go code consumed via a C bridge
(see: https://golang.org/cmd/cgo/#hdr-Passing_pointers). The Veil bridge provides a 16 byte UUID as an
exposed pointer to the consuming language, which maps to the Golang pointer on the Go side of the
C bridge. No Golang pointers are shared across the Go to C bridge.**This is a work in progress. Please don't use this if you expect stability.**
## Other Languages
Adding support for other languages is a future goal of the project. If you are interested, visit
[./bind/python](./bind/python) and take a look at what the Python the binder does.
Pull requests are welcome.## Running Veil
- `make`
- `./bin/github.com/devigned/veil generate -p github.com/devigned/veil/_examples/helloworld`
- `cd ./output`
- run some python...
```python
import generated
print(generated.get_magic_number())
```## License
MIT LicenseCopyright (c) 2017 David Justice
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.