Commit Graph

142 Commits

Author SHA1 Message Date
Benedikt Peetz 21b0ce1c01
feat(parser/bin): Allow `lex` as an alias to `tokenize` 2024-03-26 17:34:51 +01:00
Benedikt Peetz a4513e8c51
refactor(parser): Use predictable names for tokens 2024-03-26 17:34:49 +01:00
Benedikt Peetz add0d170eb
feat(parser): Add support for parsing attributes 2024-03-26 17:34:47 +01:00
Benedikt Peetz f1e9087f40
feat(parser/lexing): Desuger doc comments by running a regex on the file
Previously we actually supported parsing doc comments (`///`), but
replacing them before parsing allows for simplifications in the lexer.
Precisely, that means that we can add support for attributes without
having to maintain the doc comment parser.
2024-03-26 17:34:44 +01:00
Benedikt Peetz 18034e28de
refactor(macros/convertible_derive): Generate the `Convertible` Trait impl
Previously this was derived in the `trixy-types-derive` create, but this
is just making debugging harder and has thus been refactored.
2024-03-26 17:34:28 +01:00
Benedikt Peetz 938e038075
refactor(types/headers/string): Don't typedef a string type
This really does not add anything, and just using `const char*` directly
keeps things more clear.
2024-03-24 17:59:19 +01:00
Benedikt Peetz 17fd954e46
fix(macros/c_api/header): Format doc comments in a c-like way
Formatting them with `/// [Comment]` is a rust convention, c uses `/**
[Comment] */`.
2024-03-24 17:56:43 +01:00
Benedikt Peetz cd5b0c9ee4
refactor(example/main/c): Deduplicate error handling function 2024-03-24 17:52:36 +01:00
Benedikt Peetz 86d00608eb
build(cog.toml): Use `nix fmt` (treefmt) instead of only `cargo fmt` 2024-03-24 17:51:07 +01:00
Benedikt Peetz 7a95fa7d81
chore(.licensure.yml): Add license spdx identifier 2024-03-24 17:46:27 +01:00
Benedikt Peetz 2f7be6fe67
chore(.licensure.yml): Also add the license text to markdown files 2024-03-24 16:39:01 +01:00
Benedikt Peetz 5ce46a1568
fix(trixy/examples/main): Improve c code 2024-02-19 20:58:21 +01:00
Benedikt Peetz d904a19f48
style(treewide): Reformat with treefmt (`nix fmt`) 2024-02-19 20:53:11 +01:00
Benedikt Peetz 8104e802e7
build(update.sh): Add a shebang 2024-02-19 20:52:10 +01:00
Benedikt Peetz 7c27cdc0e0
fix(trixy-macros): Format the generated header with in the GNU style 2024-02-19 20:51:33 +01:00
Benedikt Peetz 1b8a33c919
build(flake): Add treefmt
This only adds this as nix module. So running `nix fmt` will now format
all files under the repo root.

If you want to run this as non-nix user feel free to take a look at the
generated `treefmt.toml`.
2024-02-19 20:48:50 +01:00
Benedikt Peetz 03f8eda241
style(treewide): Reformat 2024-02-19 16:15:18 +01:00
Benedikt Peetz 5a7bb00548
chore(treewide): Add the new license header 2024-02-19 16:13:55 +01:00
Benedikt Peetz 6e26bec209
build(licensure): Add c headers to known files 2024-02-19 16:13:53 +01:00
Benedikt Peetz 7ac6edb752
chore(treewide): Remove old license header
This was done with:
```bash
fd --type file . | xargs grep 'Copyright (C) 2023  The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>' | awk 'BEGIN{ FS=":"} {print $1}' | xargs sed -i '1,19d'
```
2024-02-19 16:13:48 +01:00
Benedikt Peetz 1a2267b748
build(licensure): Update to a better license template 2024-02-19 16:03:07 +01:00
Benedikt Peetz e52f74b0c1
feat(treewide): Finalize basic c API
See the example under `./example/main/` for more details.
2024-02-19 15:50:30 +01:00
Benedikt Peetz e205ea4625
docs(lib): Add a description to the oneshot-senders 2024-02-18 13:37:34 +01:00
Benedikt Peetz 80c6dd4057
build(update.sh): Add an update script 2024-02-18 13:37:09 +01:00
Benedikt Peetz 88aa3c3ad7
docs(trixy-parser): Update the railroad diagrams 2024-02-18 13:36:37 +01:00
Benedikt Peetz 86b946b540
fix(trixy-types): Conform to the api provided by the headers
See the previous commit for an explanation
2024-02-18 13:35:40 +01:00
Benedikt Peetz f699ca24a9
fix(trixy-types): Rework c header files
The old implementation tried to provide rust types in c—like the
result or option types. This implementation now removes this source of
complexity by ensuring, that these types are unwrapped on the rust->c
boundary.

This first commit changes the header files to conform to the new api.
2024-02-18 13:30:03 +01:00
Benedikt Peetz a077ef1466
fix(trixy-parser): Remove the `void` type 2024-02-18 13:27:31 +01:00
Benedikt Peetz dc8a7ecb33
test(trixy-parser): Restore test functionality after nasp -> mod rename 2024-02-18 13:17:34 +01:00
Benedikt Peetz 3e59d53b8b
build(flake): De-duplicate the `flake.lock` file 2024-02-18 13:11:33 +01:00
Benedikt Peetz b6799877bb
feat(trixy-parser): Adapt Trixy to be a complete subset of rust
This changes two important things:
- Firstly it renames the `nasp` keyword to `mod`:
        This change removes the not required deviation from rust.
- Secondly it removes the semicolon after an enumeration or structure
  declaration, which is pointless in these positions.
2024-02-17 19:54:43 +01:00
Benedikt Peetz b3c6a4c1a1
feat(treewide): Add broken Vec<E>, Result<T,E> and Option<T> types to c api
These are implemented right now by simply casting the generic arguments
to void pointers and providing a `type_id` field in every struct
denoting the original type.

This implementation, whilst being extremely unwieldy to work with on
the c side, also fails in a lot of fundamental ways:
   1. The `type_id` enum *can* never really support user defined
      types because we would already need it to provide the c to rust
      value conversion.

   2. Even without custom user types the type conversion is extremely
      hard to correctly implement in a somewhat performant way: A vector
      passed from c code to rust would need to completely reallocated
      *one element at a time*. And this only works if the c side has
      correctly cast the void pointer to the vectors data before accessing
      it, as any other way would have lead to possible unaligned data
      (which the rust side had to account for).

   3. The c api is just simply bad in this state:
      You have to always look at the Trixy file to even be able to deal
      with the data the api returns (that is: There is no mention of
      a results generics in the c header).  Additionally the question
      arises if these types should even be leaked into the c code because
      than c just becomes a worse version of rust, which undermines the
      whole reason of providing a c api in the first place.

One way to fix all these issues would be to change the way generics are
handled by using unions instead of the void pointer and trying to avoid
leaking these rust types in c as far as possible.
This approach would require a lot less binding code (both on the c and
rust side), but also would make the rust based c-header-gen-code harder,
as it would then be required to turn a `Vec<String>` to a `char **` (and
obviously a whole wrapper struct with size and string length), whilst
turning a `Vec<char>` to a `char*` differentiating it from a `string_t`.
2023-12-28 10:28:58 +01:00
Benedikt Peetz b9e26418ad
fix(trixy): Use public reexports 2023-12-26 12:18:58 +01:00
Benedikt Peetz 21e1b75193
chore(treewide): Move the trixy subcrates under one trixy crate 2023-12-26 12:14:08 +01:00
Benedikt Peetz 7d1a41aca9
feat(treewide): Provide a c api 2023-12-25 22:23:52 +01:00
Benedikt Peetz 0744c8468d
chore(treewide): Add license headers 2023-12-24 11:30:03 +01:00
Benedikt Peetz ed96a50bd4
feat(trixy-macros): Add rust host code generation 2023-12-24 11:28:30 +01:00
Benedikt Peetz 1d49bdf2cf
docs(parser/generate_docs): Move shebang to first line 2023-12-23 19:04:34 +01:00
Benedikt Peetz 03f24503b7
chore(treewide): Add license headers 2023-12-23 18:57:10 +01:00
Benedikt Peetz cc50ec2655
build(.licensure.yml): Update to really be usable 2023-12-23 18:56:06 +01:00
Benedikt Peetz 22904c9bae
build(treewide): Add relevant configuration for releases 2023-12-23 18:35:38 +01:00
Benedikt Peetz 233fa3e1b5
chore: Initial commit
This not the "real" first commit, the others are in the trinitrix/core
repository, made before the split-up took place
2023-12-23 16:07:17 +01:00