This project generates cross platform C# bindings for Dan Engelbrecht longtail library. longtail.
Run the entire build pipeline to sync with the latest version of Longtail. Delete the LONGTAIL_VERSION file in the root folder of the repo to force the pipeline to run.
.\build.ps1 # windows
./build.sh # mac/linux
Version 0.4.2 of longtail - 0.4.2
Implemented
- Generates bindings for all structs, enums, functions, function pointers
- Supports .NET 8.0-preview on platforms Linux, MacOS(arm64) and Windows x64
- Automatic documentation for function pointers with the original names of parameters
Working on
- Copy the comments from the API functions and generate C# comments in the LongtailLibrary.cs file
- Managed abstrations (hide all unsafe code behind easy to use managed functions and classes)
- Task based interfaces for IStorage and IBlockStore (will probably be named IAsyncBlockStore and IAsyncStorage) for easy .NET IO (which is mostly async code).
- More tests for both CodeGen and Longtail
Known issues
- Currently using type
ulong
forsize_t
. This works but it's not correct, it should benuint
(orUIntPtr
in older versions of .NET) - Hardcoded paths for longtail inside code gen (can be overriden with calling the project with arguments)
- Some pointer references does not have a fixed size, so we can't convert them to a managed safe type in an easy way. (will continue to investigate that)
- Some APIs have not been implemented as managed functions yet.
Comments on function pointers might be a bit different from original. This happens because it binds the type to the parent.
// The comment
// int Longtail_BlockStore_PreflightGetFunc(struct Longtail_BlockStoreAPI* block_store_api, unsigned int block_count, const unsigned long long int* block_hashes, struct Longtail_AsyncPreflightStartedAPI* optional_async_complete_api)
// The c# code
public delegate* unmanaged[Cdecl]<Longtail_BlockStoreAPI*, uint, ulong*, Longtail_AsyncPreflightStartedAPI*, int> PreflightGet;
// The original function pointer
typedef int (*Longtail_BlockStore_PreflightGetFunc)(struct Longtail_BlockStoreAPI* block_store_api, uint32_t block_count, const TLongtail_Hash* block_hashes, struct Longtail_AsyncPreflightStartedAPI* optional_async_complete_api);
- Tool to update dll/so files and run the code gen on the latest version from github.
- Parser, bindings, type handling etc
- Extensions and helpers for the generated bindings. These are updated manually.
- Longtail.cs contains all structs, enums etc
- LongtailLibrary.cs contains all the longtail functions found in longtail.h (and all other h files in the repo)
- Full upsync and downsync sample with a FileSystem block store.