-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from kornilova-l/documentation
Update documentation
- Loading branch information
Showing
14 changed files
with
323 additions
and
273 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,14 @@ lazy val samples = project | |
) | ||
|
||
lazy val tools = project in file("tools") | ||
|
||
lazy val docs = project | ||
.in(file("docs")) | ||
.enablePlugins(GhpagesPlugin, ParadoxSitePlugin) | ||
.settings( | ||
paradoxTheme := Some(builtinParadoxTheme("generic")), | ||
paradoxProperties in Paradox ++= Map( | ||
"github.base_url" -> "https://github.com/kornilova-l/scala-native-bindgen/tree/master/" | ||
), | ||
git.remoteRepo := "[email protected]:kornilova-l/scala-native-bindgen.git" | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Command Line Usage | ||
|
||
Calling the tool is pretty easy, you need to specify the file(s) and the name of the created bindings. | ||
|
||
```sh | ||
scala-native-bindgen --name uv /usr/include/uv.h -- | ||
``` | ||
|
||
Running the previous command wild also yield warnings along with the translation. To keep only the bindings please redirect the output to a file like this: | ||
|
||
```sh | ||
scala-native-bindgen --name uv /usr/include/uv.h -- > uv.scala | ||
``` | ||
|
||
## Bindgen Options | ||
|
||
| Option | Description | | ||
|----------------------|---------------------------------------------------------------------------------| | ||
| `--link` | Library to link with, e.g. `--link` uv for libuv. | | ||
| `--no-link` | Library does not require linking. | | ||
| `--name` | Scala object name that contains bindings. Default value set to library name. | | ||
| `--package` | Package name of generated Scala file. | | ||
| `--exclude-prefix` | Functions and unused typedefs will be removed if their names have given prefix. | | ||
| `--extra-arg` | Additional argument to append to the compiler command line. | | ||
| `--extra-arg-before` | Additional argument to prepend to the compiler command line. | |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Scala Native Bindgen | ||
|
||
@@@ index | ||
|
||
* [Obtaining Bindgen](obtaining-bindgen/index.md) | ||
* [Command Line Usage](command-line-usage/index.md) | ||
* [Limitations](limitations/index.md) | ||
* [Using Generated Bindings](using-generated-bindings/README.md) | ||
|
||
@@@ | ||
|
||
This tool generates Scala Native bindings from C headers. | ||
It's built upon clang and [LibTooling] and thus respects the conventions of clang-tools. | ||
|
||
## License | ||
|
||
This project is distributed under the Scala license. | ||
@github[See LICENSE.txt for details](/LICENSE.txt) | ||
|
||
[LibTooling]: https://clang.llvm.org/docs/LibTooling.html |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## Limitations | ||
|
||
There are multiple unsupported cases that should be considered when generating bindings: | ||
|
||
1. Currently bindgen does not support passing structs by value. | ||
For example, it will not be possible to call these two functions from Scala Native code: | ||
|
||
```c | ||
struct MyStruct { | ||
int a; | ||
}; | ||
|
||
struct MyStruct returnStruct(); | ||
|
||
void handleStruct(struct MyStruct mystr); | ||
``` | ||
To support such cases one should generate bindings for C wrapper functions that use pointers to structs instead of actual structs. | ||
2. `#define`s for literals and variables are supported. For other types of `#define`s, | ||
write wrapper functions that return defined values. | ||
|
||
```c | ||
// Supported | ||
#define ESC 0x1b /* Defines for numerical and string literals. */ | ||
extern const int pi_const; | ||
#define PI pi_const /* Defines aliasing extern variables. */ | ||
|
||
// Not supported (non-exhaustive list) | ||
#define COLS (getenv("COLS") ? atoi(getenv("COLS")) : 80) | ||
#define MAX(a, b) (a > b ? a : b) | ||
``` | ||
|
||
3. There is no way to reuse already generated bindings. | ||
Bindgen outputs bindings also for headers that were included in a given header. See @github[#2](#2). | ||
4. Type qualifiers `const`, `volatile` and `restrict` are not supported. | ||
5. Extern variables are read-only. See @github[scala-native/scala-native#202](scala-native/scala-native#202). |
Oops, something went wrong.