https://github.com/geod24/libsodiumd
Simple D bindings for libsodium
https://github.com/geod24/libsodiumd
Last synced: 5 months ago
JSON representation
Simple D bindings for libsodium
- Host: GitHub
- URL: https://github.com/geod24/libsodiumd
- Owner: Geod24
- License: other
- Created: 2019-01-22T09:32:13.000Z (over 7 years ago)
- Default Branch: upstream-1.0.18
- Last Pushed: 2024-05-23T23:05:31.000Z (about 2 years ago)
- Last Synced: 2025-01-30T03:42:42.915Z (over 1 year ago)
- Language: D
- Size: 39.1 KB
- Stars: 4
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Libsodiumd: D bindings for libsodium
[](https://code.dlang.org/packages/libsodiumd)
Currently supported version: v1.0.18 (released 2019-05-31)
Those bindings are simple translation from C to D.
They are simple, stupid, unnanotated - minimal modification has been applied
to make sure any new release does not lead to excessive work.
## Usage / Documentation
This wrapper provide a `package` file, just like `#include "sodium.h"`.
Just `import libsodium;` to get all available symbols.
Some unittests are available in said package file.
For a more comprehensive documentation, refer directly to [libsodium's doc](https://libsodium.gitbook.io/doc/).
## Binding generation
The bindings were generated with the following procedure:
- Install [dstep](https://github.com/jacob-carlborg/dstep).
- Clone the [official repository](https://github.com/jedisct1/libsodium/).
- Checkout the required version
- Translate C headers to D modules:
```sh
find "$LIBSODIUM_REPO/src/libsodium/include/sodium" -maxdepth 1 -xtype f -name '*.h' \
-exec ${DSTEP} --collision-action=ignore --skip randombytes_salsa20_implementation '{}' \; \
-exec sh -c 'mv $(dirname "$0")/*.d ${LIBSODIUMD_PACKAGE}' {} \;
```
With `$DSTEP`, `$LIBSODIUM_REPO` and `$LIBSODIUMD_PACKAGE` being the dstep binary and path to git repositories, respectively.
Then, a few manual adjustment were made:
- `mv source/libsodium/export.d source/libsodium/export_.d` as it conflicts with a D keyword
- Module documentation, module name, and standard import were added:
```sh
for file in $(find source/libsodium -name "*.d")
do
echo "\
/*******************************************************************************
D language bindings for libsodium's $(basename $file | cut -d'.' -f1).h
License: ISC (see LICENSE.txt)
*******************************************************************************/
module libsodium.$(basename $file | cut -d'.' -f1);
@nogc nothrow:
import libsodium.export_;
" | cat - $file > $file.tmp && mv $file.tmp $file
done
```
- Turn `ULL` constants into `UL`:
```sh
for file in $(find source/libsodium -name "*.d")
do
sed -i '' -e 's/([[:digit:]])ULL/\1UL/g' $file
done
```
- Try to compile and add missing imports
- Generate `source/libsodium/package_.d`