Add a C++ wrapper around TC FFI

This uses CMake to build a simple Rust library (in `src/tc/rust`) that
just re-exports everything from the `taskchampion-lib` crate.

The C++ wrappers then wrap this into C++ objects with proper lifecycle
maintenance, in the `tc` namespace.

The C++ wrappers are incomplete, and missing methods are tagged with
"TODO".  These will be added as needed.
This commit is contained in:
Dustin J. Mitchell 2022-03-12 22:07:42 +00:00 committed by Tomas Babej
parent fd03169314
commit 8c30400af3
32 changed files with 1760 additions and 30 deletions

View file

@ -11,7 +11,7 @@ Taskwarrior and Taskserver use the same branching model.
## Git Branching
Git allows arbitrary and low-cost branching, which means that any branching model can be used.
A new Git repository has one branch, the default branch, named `master`, but even this is not required.
A new Git repository has one branch, the default branch, named `stable`, but even this is not required.
[![master](master.png)](master.png)

View file

@ -0,0 +1,29 @@
# Rust and C++
Taskwarrior has historically been a C++ project, but as part of an [ongoing effort to replace its storage backend](https://github.com/GothenburgBitFactory/taskwarrior/issues/2770) it now includes a Rust library called TaskChampion.
To develop Taskwarrior, you will need both a [C++ compiler and tools](./development.md), and a [Rust toolchain](https://www.rust-lang.org/tools/install).
However, most tasks will only require you to be familiar with one of the two languages.
## TaskChampion
TaskChampion implements storage and access to "replicas" containing a user's tasks.
It defines an abstract model for this data, and also provides a simple Rust API for manipulating replicas.
It also defines a method of synchronizing replicas and provides an implementation of that method in the form of a sync server.
TaskChampion provides a C interface via the `taskchampion-lib` crate.
Other applications, besides Taskwarrior, can use TaskChampion to manage tasks.
Applications written in Rust can use the `taskchampion` crate, while those in other languages may use the `taskchampion-lib` crate.
Taskwarrior is just one application using the TaskChampion interface.
You can build Taskchampion locally by simply running `cargo build` in the root of this repository.
The implementation, including more documentation, is in the [`rust`](../../rust) subdirectory.
## Taskwarrior's use of TaskChampion
Taskwarrior's interface to TaskChampion has a few laters:
* The skeletal Rust crate in [`src/tc/rust`](../../src/tc/rust) brings the symbols from `taskchampion-lib` under CMake's management.
The corresponding header file is included from [`rust/lib`](../../rust/lib).
All of these symbols are placed in the C++ namespace, `tc::ffi`.
* C++ wrappers for the types from `taskchampion-lib` are defined in [`src/tc`](../../src/tc), ensuring memory safety (with `unique_ptr`) and adding methods corresponding to the Rust API's methods.
The wrapper types are in the C++ namespace, `tc`.

View file

@ -7,12 +7,13 @@ For all other documenation, see https://taskwarrior.org.
## Contributing to Taskwarrior
* [How to become an Open Source Contributor](./contrib/first_time)
* [Contributing to Taskwarrior](./contrib/contribute)
* [Developing Taskwarrior](./contrib/development)
* [Building Taskwarrior](./contrib/build)
* [Coding Style](./contrib/coding_style)
* [Branching Model](./contrib/branching)
* [How to become an Open Source Contributor](./contrib/first_time.md)
* [Contributing to Taskwarrior](./contrib/contribute.md)
* [Developing Taskwarrior](./contrib/development.md)
* [Building Taskwarrior](./contrib/build.md)
* [Coding Style](./contrib/coding_style.md)
* [Branching Model](./contrib/branching.md)
* [Rust and C++](./contrib/rust-and-c++.md)
## RFC's
@ -21,14 +22,14 @@ This is where design documents (RFCs) are kept.
Although these documents are less formal than [IETF RFCs](https://www.ietf.org/rfc) they serve a similar purpose.
These documents apply only to the Taskwarrior family of products, and are placed here to invite comment before designs finalize.
- [General Plans](./rfcs/plans)
- [Rules System](./rfcs/rules)
- [Full DOM Support ](./rfcs/dom)
- [Work Week Support](./rfcs/workweek)
- [Recurrence](./rfcs/recurrence)
- [Taskwarrior JSON Format](./rfcs/task)
- [CLI Updates ](./rfcs/cli)
- [Taskserver Sync Protocol](./rfcs/protocol)
- [Taskserver Message Format](./rfcs/request)
- [Taskserver Sync Algorithm](./rfcs/sync)
- [Taskserver Client](./rfcs/client)
- [General Plans](./rfcs/plans.md)
- [Rules System](./rfcs/rules.md)
- [Full DOM Support ](./rfcs/dom.md)
- [Work Week Support](./rfcs/workweek.md)
- [Recurrence](./rfcs/recurrence.md)
- [Taskwarrior JSON Format](./rfcs/task.md)
- [CLI Updates ](./rfcs/cli.md)
- [Taskserver Sync Protocol](./rfcs/protocol.md)
- [Taskserver Message Format](./rfcs/request.md)
- [Taskserver Sync Algorithm](./rfcs/sync.md)
- [Taskserver Client](./rfcs/client.md)