autobindings/README.md

53 lines
3.3 KiB
Markdown
Raw Normal View History

2023-02-23 18:14:27 +00:00
# Cwtch Autobindings
2023-02-23 18:18:52 +00:00
Automatically generate [Cwtch](https://git.openprivacy.ca/cwtch.im/cwtch) C-Bindings from a high-level specification.
Note for the Flutter-based Cwtch UI Application see: https://git.openprivacy.ca/cwtch.im/cwtch-ui
2023-02-23 18:14:27 +00:00
## Building
go mod download
go run generate/generate_bindings.go
make linux // alternatively windows, android, macos
2023-02-23 18:26:16 +00:00
**NOTE:** Autobindings currently depends on an unreleased version of Cwtch (`cwtch.im/cwtch v0.18.10-0.20230221235514-49e0d849fa3e`).
2023-02-23 18:14:27 +00:00
## Spec File Format
The current Cwtch Bindings Specification is defined in [spec](./spec)
Supported function prototypes:
2023-02-23 18:14:51 +00:00
* `app <Function Name> <Args>` - an application-level function, called on global `Application`
* `profile <Function Name> <Args>` - a profile-level function, takes `profile` as an implicit first argument
2023-02-23 18:16:59 +00:00
* `json(profile) <Function Name> <Args>` - a profile-level function, takes `profile` as an implicit first argument and returns a json blob that must be freed by the calling library (see [MEMORY](./MEMORY.md))
2023-02-23 18:14:51 +00:00
* `@profile-experiment <Function Name> <Experiment> <Args>`- an experimental profile-level function, takes `profile` as an implicit first argument, experiment must implement cwtch Functionality interface
2023-02-23 18:16:59 +00:00
* `@(json)profile-experiment <Function Name> <Experiment> <Args>` - am experimental profile-level function, takes `profile` as an implicit first argument and returns a json blob that must be freed by the calling (see [MEMORY](./MEMORY.md)) library, , experiment must implement cwtch Functionality interface
2023-02-23 18:14:27 +00:00
Supported argument prototypes:
2023-02-23 18:14:51 +00:00
* `profile` - a cwtch profile identifier
* `conversation` - a cwtch conversation identifier
* `message` - a cwtch message identifier
* `int:<name>` - a generic integer argument (with optional name)
* `bool:<name>` - a generic boolean argument (with optional name)
* `string:<name>` - a generic string argument (with optional name)
2023-02-23 18:14:27 +00:00
All arguments must be defined in the order they are specified by the underlying Cwtch library function.
Other directives:
2023-02-23 18:14:51 +00:00
* `import <go pkg>` - includes an additional go importin the compiled lib.go (needed for experiments)
2023-02-23 18:16:59 +00:00
* Functions that start with `Enhanced` are automatically stripped of that prefix for their binding names e.g. `EnhancedGetMessage` generated a binding `c_GetMessage` - for certain functions Cwtch has two potential calling options `<Function>` and `Enhanced<Function>`. "Enhanced" in this case means that the response is optimised for calling by a user-facing application by e.g. directly making a number of calls under the hood and returning a json blob of the results.
## Support Cwtch Development
We couldn't do what we do without all the wonderful community support we get, from [one-off donations](https://openprivacy.ca/donate) to [recurring support via Patreon](https://www.patreon.com/openprivacy).
If you want to see us move faster on some of these goals and are in a position to, please [donate](https://openprivacy.ca/donate). If you happen to be at a company that wants to do more for the community and this aligns, please consider donating or sponsoring a developer.
Donations of **$5 or more** can opt to receive stickers as a thank-you gift!
For more information about donating to Open Privacy and claiming a thank you gift [please visit the Open Privacy Donate page](https://openprivacy.ca/donate/).