Compare commits

..

30 Commits

Author SHA1 Message Date
Benedikt Peetz bbd6bd60bb
chore(c_test): Remove the POC
The feature is implemented, thus it has served it's purpose.
2024-05-20 15:31:09 +02:00
Benedikt Peetz ca0efecfde
chore(treewide): Add missing license headers 2024-05-20 15:31:08 +02:00
Benedikt Peetz 051e15b0ed
fix(example/main): Update to use the new result type 2024-05-20 15:31:06 +02:00
Benedikt Peetz a33aa053d2
feat(src): Add real and working support for results
Every `Result` is now -- on demand -- instantiated (i.e. the generic types
are replaced with the concretely specified ones). And can thus simply be
exported to c.
2024-05-20 15:31:05 +02:00
Benedikt Peetz 5d3afa3c5a
build(update.sh): Don't always perform the expensive `upgrade` 2024-05-20 15:31:04 +02:00
Benedikt Peetz 527727cbd3
docs(grammar.pdf): Regenerate with new landscape ebnf2pdf script 2024-05-20 15:31:02 +02:00
Benedikt Peetz 5a3f337057
fix(src/parsing): Remove the extra `error` attribute keyword
This keyword marked an enum as being an error, which is exactly what
`derive(Error)` already does. Thus this extra attribute keyword has been
removed and the `error` name has been used to rename the `msg` attribute
keyword, to be in-line with what `thiserror` does.
2024-05-20 15:31:01 +02:00
Benedikt Peetz d27eea711a
tests(error_derive): Init 2024-05-20 15:31:01 +02:00
Benedikt Peetz 4feae61a76
fix(parser/unchecked/attributes): Correctly enforce an identifier in `derive`
The ebnf grammar specifies an identifier (namely “Error” in the
`derive` attribute.), while the parser expected a string literal there.
2024-05-20 15:30:58 +02:00
Benedikt Peetz 9d14d2e061
refactor(example/main/.cargo/config): Add a `.toml` extension
Cargo is deprecating the old name (i.e. without the `.toml` extension).
2024-05-20 15:30:54 +02:00
Benedikt Peetz ecb8d4d2f0
build(treewide): Update 2024-05-20 15:30:54 +02:00
Benedikt Peetz 6a4c224c64
tests(results): Add a test for results 2024-05-20 15:30:53 +02:00
Benedikt Peetz 5dbc5e676d
docs(c_test): Add a poc regarding results in c 2024-05-20 15:30:51 +02:00
Benedikt Peetz 31493968b5 tests(src/types/newtypes): Test if a full round-trip works 2024-05-04 21:10:35 +02:00
Benedikt Peetz c2ef7d0a59 tests(tests): Update to new String wrapper 2024-05-04 10:40:17 +02:00
Benedikt Peetz df146b3fa6 chore(version): v0.1.1 2024-05-04 10:26:23 +02:00
Benedikt Peetz b750bb8495 chore(version): v0.1.0 2024-05-04 10:24:33 +02:00
Benedikt Peetz d57beeebd4 build(cog): Avoid building the project with nix, as this fails 2024-05-04 10:23:59 +02:00
Benedikt Peetz ec11a129bd fix(gitignore): Don't ignore the `Cargo.lock` file 2024-05-04 10:22:46 +02:00
Benedikt Peetz ddd9255c2e build(cog): Remove wrong toml header 2024-05-04 10:22:03 +02:00
Benedikt Peetz 07c38468ce chore(treewide): Renew copyright headers 2024-05-04 10:20:25 +02:00
Benedikt Peetz c7b8fb3f86 build(cog): Use new `renew_copyright_header` script 2024-05-04 10:19:57 +02:00
Benedikt Peetz 0a60c894d2 feat!(src/macros): Store allocation location in all strings
This makes it possible to automatically free the string in the correct
way expected by both c and rust.
Rust strings can now just be freed by the rust allocator, whilst c
strings are forgotten, so that the c allocator may free them.

BREAKING CHANGE: All usage of explicit mentions `std::string::String`
                 in your `handle_cmd` function will need to be replaced
                 by `trixy::types::newtypes::String`. Otherwise these
                 types should provide the same methods.
2024-05-04 10:12:20 +02:00
Benedikt Peetz 86427b0c1a refactor(src/macros/generate/host): Merge host generation in one module 2024-05-04 08:23:36 +02:00
Benedikt Peetz 0774ac2124 chore(Cargo.toml): Add further required metadata 2024-05-03 20:02:17 +02:00
Benedikt Peetz 475e7edadf chore(Cargo.toml): Add required metadata 2024-05-03 19:32:44 +02:00
Benedikt Peetz 366efd8331
docs(README): Mention the binary 2024-03-27 23:04:14 +01:00
Benedikt Peetz 1e078fa46d
tests(types): Update to represent a minimal change in the library 2024-03-27 23:03:45 +01:00
Benedikt Peetz 06c61ade54
docs(README): Add 2024-03-27 22:53:08 +01:00
Benedikt Peetz 6bed2a843a
fix(example/main): Ignore generated api.rs debugging file 2024-03-27 22:36:26 +01:00
5 changed files with 12 additions and 54 deletions

2
Cargo.lock generated
View File

@ -291,7 +291,7 @@ dependencies = [
[[package]] [[package]]
name = "trixy" name = "trixy"
version = "0.2.1" version = "0.1.1"
dependencies = [ dependencies = [
"clap", "clap",
"convert_case", "convert_case",

View File

@ -20,7 +20,7 @@
[package] [package]
name = "trixy" name = "trixy"
version = "0.2.1" version = "0.1.1"
edition = "2021" edition = "2021"
description = "A rust crate used to generate multi-language apis for your application" description = "A rust crate used to generate multi-language apis for your application"
license = "LGPL-3.0-or-later" license = "LGPL-3.0-or-later"

51
NEWS.md
View File

@ -24,56 +24,7 @@ If not, see <https://www.gnu.org/licenses/>.
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
- - - ______________________________________________________________________
## v0.2.1 - 2024-05-20
#### Bug Fixes
- **(src/types/traits/convert_trait)** Remove unneeded imports - (5253e59) - Benedikt Peetz
- - -
## v0.2.0 - 2024-05-20
#### Bug Fixes
- **(example/main)** Update to use the new result type - (1f0b9c6) - Benedikt Peetz
- **(example/main)** Ignore generated `api.rs` debugging file - (ed4a113) - *soispha*
- **(gitignore)** Don't ignore the `Cargo.lock` file - (c9622c1) - Benedikt Peetz
- **(parser/unchecked/attributes)** Correctly enforce an identifier in `derive` - (4f84605) - Benedikt Peetz
- **(src/parsing)** Remove the extra `error` attribute keyword - (650d577) - Benedikt Peetz
#### Build system
- **(NEWS.md)** Restore separator - (243a89b) - Benedikt Peetz
- **(cog)** Avoid building the project with nix, as this fails - (5f9ef33) - Benedikt Peetz
- **(cog)** Remove wrong toml header - (ecfdb0a) - Benedikt Peetz
- **(cog)** Use new `renew_copyright_header` script - (1984217) - Benedikt Peetz
- **(flake)** Ignore correct changelog file - (477b9e1) - Benedikt Peetz
- **(treewide)** Update - (83ba3b4) - Benedikt Peetz
- **(update.sh)** Don't always perform the expensive `upgrade` - (ee8e860) - Benedikt Peetz
#### Documentation
- **(README)** Mention the binary - (6c64180) - *soispha*
- **(README)** Add - (c787aa2) - *soispha*
- **(c_test)** Add a poc regarding results in c - (7034cf7) - Benedikt Peetz
- **(grammar.pdf)** Regenerate with new landscape ebnf2pdf script - (c6dc9db) - Benedikt Peetz
#### Features
- **(src)** Add real and working support for results - (9000c1d) - Benedikt Peetz
- **(src/macros)** Store allocation location in all stringsThis makes it possible to automatically free the string in the correctway expected by both c and rust.Rust strings can now just be freed by the rust allocator, whilst cstrings are forgotten, so that the c allocator may free them.BREAKING CHANGE: All usage of explicit mentions `std::string::String` in your `handle_cmd` function will need to be replaced by `trixy::types::newtypes::String`. Otherwise these types should provide the same methods. - (2e92028) - Benedikt Peetz
#### Miscellaneous Chores
- **(Cargo.toml)** Add further required metadata - (4d76282) - Benedikt Peetz
- **(Cargo.toml)** Add required metadata - (cc788a9) - Benedikt Peetz
- **(c_test)** Remove the POC - (d1f31c2) - Benedikt Peetz
- **(treewide)** Add missing license headers - (1677f5c) - Benedikt Peetz
- **(treewide)** Renew copyright headers - (447370d) - Benedikt Peetz
- **(version)** v0.1.1 - (601d82d) - Benedikt Peetz
- **(version)** v0.1.0 - (994b3de) - Benedikt Peetz
#### Refactoring
- **(example/main/.cargo/config)** Add a `.toml` extension - (9953b50) - Benedikt Peetz
- **(src/macros/generate/host)** Merge host generation in one module - (0f131c9) - Benedikt Peetz
#### Tests
- **(error_derive)** Init - (7e2cbb4) - Benedikt Peetz
- **(results)** Add a test for results - (e57bd40) - Benedikt Peetz
- **(src/types/newtypes)** Test if a full round-trip works - (7bced94) - Benedikt Peetz
- **(tests)** Update to new String wrapper - (1599631) - Benedikt Peetz
- **(types)** Update to represent a minimal change in the library - (91adaa2) - *soispha*
- - -
## v0.1.0 - 2024-05-04 ## v0.1.0 - 2024-05-04

View File

@ -176,7 +176,7 @@
}; };
settings = { settings = {
global.excludes = ["NEWS.md"]; global.excludes = ["CHANGELOG.md"];
formatter = { formatter = {
clang-format = { clang-format = {
options = ["--style" "GNU"]; options = ["--style" "GNU"];

View File

@ -22,7 +22,14 @@
use crate::types::error::{self, TypeConversionError}; use crate::types::error::{self, TypeConversionError};
use log::warn; use log::warn;
use std::ffi::{c_char, CString}; use std::{
error::Error,
ffi::{c_char, CString},
mem::ManuallyDrop,
ptr,
};
use super::errno;
/// Convert a value into a data structure that we can send directly to c. /// Convert a value into a data structure that we can send directly to c.
pub trait Convertible pub trait Convertible