Merge branch 'master' of https://github.com/genotrance/nimterop
This commit is contained in:
commit
9fc0bb99b3
3 changed files with 10 additions and 9 deletions
13
README.md
13
README.md
|
|
@ -1,7 +1,9 @@
|
|||
[](https://gitter.im/nimgen/Lobby)
|
||||
[](https://gitter.im/nimterop/Lobby)
|
||||
[](https://ci.appveyor.com/project/genotrance/nimterop-8jcj7/branch/master)
|
||||
[](https://travis-ci.org/nimterop/nimterop)
|
||||
|
||||
Detailed documentation [here](https://nimterop.github.io/nimterop/theindex.html).
|
||||
|
||||
Nimterop is a [Nim](https://nim-lang.org/) package that aims to make C/C++ interop seamless
|
||||
|
||||
Nim has one of the best FFI you can find - importing C/C++ is supported out of the box. All you need to provide is type and proc definitions for Nim to interop with C/C++ binaries. Generation of these wrappers is easy for simple libraries but quickly gets out of hand. [c2nim](https://github.com/nim-lang/c2nim) greatly helps here by parsing and converting C/C++ into Nim but is limited due to the complex and constantly evolving C/C++ grammar. [nimgen](https://github.com/genotrance/nimgen) mainly focuses on automating the wrapping process and fills some holes but is again limited to c2nim's capabilities.
|
||||
|
|
@ -25,8 +27,9 @@ nimble install nimterop -y
|
|||
```
|
||||
or:
|
||||
```bash
|
||||
git clone http://github.com/genotrance/nimterop && cd nimterop
|
||||
nimble install -y
|
||||
git clone http://github.com/nimterop/nimterop && cd nimterop
|
||||
nimble develop -y
|
||||
nimble build
|
||||
```
|
||||
|
||||
This will download and install nimterop in the standard Nimble package location, typically `~/.nimble`. Once installed, it can be imported into any Nim program. Note that the `~/.nimble/bin` directory needs to be added to the `PATH` for nimterop to work.
|
||||
|
|
@ -50,8 +53,6 @@ Refer to the ```tests``` directory for examples on how the library can be used.
|
|||
|
||||
The `toast` binary can also be used directly on the CLI. The `--help` flag provides more details.
|
||||
|
||||
Detailed documentation is available: [cimport](https://genotrance.github.io/nimterop/cimport.html), [plugin](https://genotrance.github.io/nimterop/plugin.html), [git](https://genotrance.github.io/nimterop/git.html)
|
||||
|
||||
__Implementation Details__
|
||||
|
||||
In order to use the tree-sitter C library, it has to be compiled into a separate binary called `toast` (to AST) since the Nim VM doesn't yet support FFI. `toast` takes a C/C++ file and runs it through the tree-sitter API which returns an AST data structure. This can then be printed out to stdout in a Lisp S-Expression format or the relevant Nim wrapper output. This content can be saved to a `.nim` file and imported if so desired.
|
||||
|
|
@ -68,4 +69,4 @@ Nimterop depends on [tree-sitter](http://tree-sitter.github.io/tree-sitter/) and
|
|||
|
||||
__Feedback__
|
||||
|
||||
Nimterop is a work in progress and any feedback or suggestions are welcome. It is hosted on [GitHub](https://github.com/genotrance/nimterop) with an MIT license so issues, forks and PRs are most appreciated.
|
||||
Nimterop is a work in progress and any feedback or suggestions are welcome. It is hosted on [GitHub](https://github.com/nimterop/nimterop) with an MIT license so issues, forks and PRs are most appreciated.
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ proc getToast(fullpath: string, recurse: bool = false): string =
|
|||
|
||||
cmd.add &" {fullpath.quoteShell}"
|
||||
echo cmd
|
||||
# see https://github.com/genotrance/nimterop/issues/69
|
||||
# see https://github.com/nimterop/nimterop/issues/69
|
||||
(result, ret) = gorgeEx(cmd, cache=getCacheValue(fullpath))
|
||||
doAssert ret == 0, getToastError(result)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ macro cDefine*(name: static string, val: static string = ""): untyped =
|
|||
result = newNimNode(nnkStmtList)
|
||||
|
||||
var str = name
|
||||
# todo: see https://github.com/genotrance/nimterop/issues/100 for
|
||||
# todo: see https://github.com/nimterop/nimterop/issues/100 for
|
||||
# edge case of empty strings
|
||||
if val.nBl:
|
||||
str &= &"={val.quoteShell}"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# see https://github.com/genotrance/nimterop/issues/79
|
||||
# see https://github.com/nimterop/nimterop/issues/79
|
||||
|
||||
when (NimMajor, NimMinor, NimPatch) < (0, 19, 9):
|
||||
# clean this up once upgraded; adapted from std/time_t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue