Compare commits

..

5 Commits

Author SHA1 Message Date
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
29 changed files with 224 additions and 258 deletions

View File

@ -1,2 +1,3 @@
# Reason # Reason
This is not a cargo example, as its needs a full build.rs step. This is not a cargo example, as its needs a full build.rs step.

View File

@ -1,23 +1,23 @@
/* /*
* Copyright (C) 2023 - 2024: * Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org> * The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
* *
* This file is part of the Trixy crate for Trinitrix. * This file is part of the Trixy crate for Trinitrix.
* *
* Trixy is free software: you can redistribute it and/or modify * Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as * it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of * published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program. * and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "../dist/interface.h" #include "../dist/interface.h"
#include <assert.h> #include <assert.h>
@ -25,45 +25,49 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define println(args...) \ #define println(args...) \
printf("(plugin): "); \ printf ("\33[32;1m(plugin):\33[0m \33[34;1m"); \
printf(args); \ printf (args); \
printf("\n"); \ printf ("\n\33[0m"); \
fflush(stdout); fflush (stdout);
#define eprintln(args...) \ #define eprintln(args...) \
printf("(plugin): "); \ printf ("\33[32;1m(plugin):\33[0m\33[31;1m "); \
printf(args); \ printf (args); \
printf("\n"); \ printf ("\n\33[0m"); \
fflush(stdout); fflush (stdout);
int p_main() { int
plugin_main ()
{
// You can simply call functions .. // You can simply call functions ..
outstanding("James"); outstanding ("James");
// .. but they check their inputs: // .. but they check their inputs:
// This call for example will fail, as a null pointer isn't supported. // This call for example will fail, as a null pointer isn't supported.
// //
// A error will be signaled by a 0 return code, then the error can be obtained // A error will be signaled by a 0 return code, then the error can be
// with the `last_error_length` and `last_error_message` functions // obtained with the `last_error_length` and `last_error_message` functions
if (!outstanding(0x0)) { if (!outstanding (NULL))
int error_length = last_error_length(); {
char *error = malloc(error_length); int error_length = last_error_length ();
last_error_message(error, error_length); char *error = malloc (error_length);
eprintln("Encountered error: %s", error); last_error_message (error, error_length);
free(error); eprintln ("Encountered error: %s", error);
} free (error);
}
println("Saying hi!"); println ("Saying hi!");
string_t hi; string_t hi;
if (!one.hi(&hi, "Adam")) { if (!one.hi (&hi, "Adam"))
int error_length = last_error_length(); {
char *error = malloc(error_length); int error_length = last_error_length ();
last_error_message(error, error_length); char *error = malloc (error_length);
eprintln("Encountered error: %s", error); last_error_message (error, error_length);
free(error); eprintln ("Encountered error: %s", error);
} free (error);
println("Rust returned: %s", hi); }
string_free(hi); println ("Rust returned: %s", hi);
string_free (hi);
return 0; return 0;
} }

View File

@ -22,7 +22,6 @@
/// Call out an outstanding person /// Call out an outstanding person
fn outstanding(name: String); fn outstanding(name: String);
mod one { mod one {
/// Say hi to a name /// Say hi to a name
fn hi(name: String) -> String; fn hi(name: String) -> String;

View File

@ -49,11 +49,11 @@ fn handle_cmd(cmd: Commands) {
fn main() { fn main() {
let library_path = env::args().nth(1).expect("USAGE: cargo r -- <LIB>"); let library_path = env::args().nth(1).expect("USAGE: cargo r -- <LIB>");
type AddFunc = unsafe fn() -> c_int; type AddFunc = unsafe fn() -> c_int;
println!("Loading p_main() from {}", library_path); println!("Loading plugin_main() from {}", library_path);
unsafe { unsafe {
let lib = Library::new(library_path).unwrap(); let lib = Library::new(library_path).unwrap();
let func: Symbol<AddFunc> = lib.get(b"p_main").unwrap(); let func: Symbol<AddFunc> = lib.get(b"plugin_main").unwrap();
println!("starting plugin"); println!("starting plugin");
let out = func(); let out = func();
println!("plugin finished with: {}", out); println!("plugin finished with: {}", out);

View File

@ -174,7 +174,8 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay", "rust-overlay": "rust-overlay",
"systems": "systems" "systems": "systems",
"treefmt-nix": "treefmt-nix"
} }
}, },
"rust-overlay": { "rust-overlay": {
@ -247,6 +248,26 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1708335038,
"narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# and the Lesser GNU General Public License along with this program. # and the Lesser GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>. # If not, see <https://www.gnu.org/licenses/>.
{ {
description = "A rust crate used to generate multi-language apis for your description = "A rust crate used to generate multi-language apis for your
application"; application";
@ -29,6 +28,13 @@
flake = false; flake = false;
}; };
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
systems = { systems = {
url = "github:nix-systems/default"; url = "github:nix-systems/default";
}; };
@ -64,11 +70,13 @@
}; };
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
crane, crane,
flake-utils, flake-utils,
rust-overlay, rust-overlay,
ebnf2pdf, ebnf2pdf,
treefmt-nix,
... ...
}: }:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
@ -112,18 +120,52 @@
doCheck = true; doCheck = true;
inherit nativeBuildInputs buildInputs; inherit nativeBuildInputs buildInputs;
}; };
treefmtEval = treefmt-nix.lib.evalModule pkgs (
{pkgs, ...}: {
# Used to find the project root
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
rustfmt.enable = true;
clang-format.enable = true;
mdformat.enable = true;
shfmt = {
enable = true;
indent_size = 4;
};
shellcheck.enable = true;
};
settings.formatter = {
clang-format = {
options = ["--style" "GNU"];
};
rustfmt = {
# also add the Trixy files
includes = ["*.tri"];
};
};
}
);
in { in {
checks.default = craneBuild; checks.default = craneBuild;
packages = { packages = {
default = craneBuild; default = craneBuild;
}; };
formatter = treefmtEval.config.build.wrapper;
checks = {
formatting = treefmtEval.config.build.check self;
};
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
alejandra alejandra
cocogitto cocogitto
licensure licensure
treefmt
rust rust
cargo-edit cargo-edit

View File

@ -19,14 +19,12 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
use convert_case::{Case, Casing}; use convert_case::{Case, Casing};
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote, ToTokens}; use quote::{format_ident, quote, ToTokens};
use syn::{punctuated::Punctuated, Ident, Token, Type}; use syn::{punctuated::Punctuated, Ident, Token, Type};
use crate::{DataCommandEnum, command_enum_parsing::Field}; use crate::{command_enum_parsing::Field, DataCommandEnum};
use super::get_input_type_of_bare_fn_field; use super::get_input_type_of_bare_fn_field;

View File

@ -19,14 +19,12 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote}; use quote::{format_ident, quote};
use syn::{punctuated::Punctuated, Token}; use syn::{punctuated::Punctuated, Token};
use crate::{ use crate::{
command_enum_parsing::{Field, NamespacePath, FunctionDeclaration}, command_enum_parsing::{Field, FunctionDeclaration, NamespacePath},
DataCommandEnum, DataCommandEnum,
}; };

View File

@ -19,8 +19,6 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
use quote::quote; use quote::quote;

View File

@ -19,8 +19,6 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
use convert_case::{Case, Casing}; use convert_case::{Case, Casing};
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
use quote::quote; use quote::quote;

View File

@ -19,8 +19,6 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
mod command_enum; mod command_enum;
mod lua_wrapper; mod lua_wrapper;

View File

@ -80,6 +80,7 @@ impl TrixyConfig {
write!(c_header_out, "{}\n{}", c_header, VIM_LINE_C).expect("Write should work"); write!(c_header_out, "{}\n{}", c_header, VIM_LINE_C).expect("Write should work");
Command::new("clang-format") Command::new("clang-format")
.args(["--style", "GNU"])
.args(["-i", &c_header_path.to_str().unwrap()]) .args(["-i", &c_header_path.to_str().unwrap()])
.status() .status()
.unwrap_or_else(|err| { .unwrap_or_else(|err| {

View File

@ -1,10 +1,13 @@
# trixy-lang_parser # trixy-lang_parser
This crate contains a parser (and lexer) for the Trixy language. This crate contains a parser (and lexer) for the Trixy language.
The corresponding grammar is in the grammar file [here](./docs/grammar.ebnf) encoded in [Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form). The corresponding grammar is in the grammar file [here](./docs/grammar.ebnf) encoded in [Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form).
## Testing ## Testing
A binary (`trixy-parser`) exists, which provides easy access to the different library A binary (`trixy-parser`) exists, which provides easy access to the different library
parsing steps parsing steps
## Docs ## Docs
Run `./generate_docs` to turn the grammar file into railroad diagrams. Run `./generate_docs` to turn the grammar file into railroad diagrams.

View File

@ -19,17 +19,14 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
fn print(message: String); fn print(message: String);
/// First doc comment /// First doc comment
// Some more text // Some more text
nasp trinitrix { mod trinitrix {
/// Second doc comment /// Second doc comment
fn hi(name: String) -> String; fn hi(name: String) -> String;
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,12 +19,8 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
// an empty comment: // an empty comment:
// //
// an empty doc comment: // an empty doc comment:
/// ///
nasp test {} mod test {}

View File

@ -1,32 +0,0 @@
/*
* Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
*
* This file is part of the Trixy crate for Trinitrix.
*
* Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
fn print(message: CommandTransferValue);
nasp trinitrix { {}
fn hi honner(name: String) -> String; ;
}
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
*
* This file is part of the Trixy crate for Trinitrix.
*
* Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
fn print(message: CommandTransferValue);
/// Some doc comment
// Some more text
nasp trinitrix {
fn hi(name: String) -> String;
}
/// Trailing doc comment (I will fail)
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust

View File

@ -19,20 +19,17 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
mod trinitrix {
nasp trinitrix {
/// This enum can't be called Trinitrix, as that's already the name of the namespace /// This enum can't be called Trinitrix, as that's already the name of the namespace
/// (if it's in Pascal case) /// (if it's in Pascal case)
enum Trinitrix { enum Trinitrix {
High, High,
Medium, Medium,
Low, Low,
}; }
fn execute_callback(priority: Trinitrix); fn execute_callback(priority: Trinitrix);
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,15 +19,12 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
struct Callback { struct Callback {
func: Function, func: Function,
timeout: Integer, timeout: Integer,
}; }
fn execute_callback(callback: Name); fn execute_callback(callback: Name);
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,14 +19,12 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
struct A {}
struct B {}
struct A {}; enum Error {}
struct B {};
enum Error {};
fn execute_callback(callback: String<A, B>) -> Error<String, Error>; fn execute_callback(callback: String<A, B>) -> Error<String, Error>;
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,34 +19,32 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
/// Prints to the output, with a newline. /// Prints to the output, with a newline.
// HACK(@soispha): The stdlib Lua `print()` function has stdout as output hardcoded, // HACK(@soispha): The stdlib Lua `print()` function has stdout as output hardcoded,
// redirecting stdout seems too much like a hack thus we are just redefining the print function // redirecting stdout seems too much like a hack thus we are just redefining the print function
// to output to a controlled output. <2023-09-09> // to output to a controlled output. <2023-09-09>
//fn print(input: CommandTransferValue); //fn print(input: CommandTransferValue);
nasp trinitrix { mod trinitrix {
/// Language specific functions, which mirror the `trinitrix.api` namespace. /// Language specific functions, which mirror the `trinitrix.api` namespace.
/// That is, if you have to choose between a `std` and a `api` function choose the `std` /// That is, if you have to choose between a `std` and a `api` function choose the `std`
/// one as it will most likely be more high-level and easier to use (as it isn't abstracted /// one as it will most likely be more high-level and easier to use (as it isn't abstracted
/// over multiple languages). Feel free to drop down to the lower level api, if you feel /// over multiple languages). Feel free to drop down to the lower level api, if you feel
/// like that more, it should be as stable and user-oriented as the `std` functions /// like that more, it should be as stable and user-oriented as the `std` functions
nasp std {} mod std {}
/// Debug only functions, these are effectively useless /// Debug only functions, these are effectively useless
nasp debug { mod debug {
enum UserGreet { enum UserGreet {
Friendly, Friendly,
Angrily, Angrily,
Hastly Hastly,
}; }
struct GreetedUser { struct GreetedUser {
names: Vec<String>, names: Vec<String>,
new: GreetedUser, new: GreetedUser,
state: UserGreet state: UserGreet,
}; }
/// Greets the user /// Greets the user
fn greet(input: String) -> String; fn greet(input: String) -> String;
@ -55,7 +53,7 @@ nasp trinitrix {
} }
/// General API to change stuff in Trinitrix /// General API to change stuff in Trinitrix
nasp api { mod api {
/// Closes the application /// Closes the application
fn exit(); fn exit();
@ -73,7 +71,7 @@ nasp trinitrix {
/* fn register_function(function: RawFunction); */ /* fn register_function(function: RawFunction); */
/// Function that change the UI, or UI state /// Function that change the UI, or UI state
nasp ui { mod ui {
/// Shows the command line /// Shows the command line
fn command_line_show(); fn command_line_show();
@ -118,7 +116,7 @@ nasp trinitrix {
/// The callback MUST be registered first by calling /// The callback MUST be registered first by calling
/// `trinitrix.api.register_function()` the returned value can than be used to /// `trinitrix.api.register_function()` the returned value can than be used to
/// set the keymap. /// set the keymap.
nasp keymaps { mod keymaps {
/// Add a new keymapping /// Add a new keymapping
fn add(mode: String, key: String, callback: Function); fn add(mode: String, key: String, callback: Function);
@ -132,7 +130,7 @@ nasp trinitrix {
} }
/// Functions only used internally within Trinitrix /// Functions only used internally within Trinitrix
nasp raw { mod raw {
/// Send an error to the default error output /// Send an error to the default error output
fn raise_error(input: String); fn raise_error(input: String);
@ -150,7 +148,7 @@ nasp trinitrix {
/// ensuring memory locations stay allocated in garbage collected language is hard) /// ensuring memory locations stay allocated in garbage collected language is hard)
/// ///
/// Treat it as an implementation detail /// Treat it as an implementation detail
nasp __private {} mod __private {}
} }
} }
} }

View File

@ -19,18 +19,15 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
fn print(message: CommandTransferValue); fn print(message: CommandTransferValue);
nasp trinitrix { mod trinitrix {
fn hi(name: String) -> String; fn hi(name: String) -> String;
} }
nasp trinitrix { mod trinitrix {
fn ho(name: String, name2: String) -> String; fn ho(name: String, name2: String) -> String;
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,8 +19,6 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
/// other doc comment /// other doc comment
fn hi(name: String) -> String; fn hi(name: String) -> String;
@ -29,13 +27,12 @@ struct ho {
ident: String, ident: String,
/// also a doc comment /// also a doc comment
codebase: Vec<String>, codebase: Vec<String>,
}; }
/// Some doc comment /// Some doc comment
nasp trinitrix { mod trinitrix {
fn hi(name: String) -> String; fn hi(name: String) -> String;
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,14 +19,11 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
fn print(message: CommandTransferValue); fn print(message: CommandTransferValue);
nasp trinitrix { mod trinitrix {
fn hi(name: String) -> String; fn hi(name: String) -> String;
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -19,23 +19,20 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
mod trinitrix {
nasp trinitrix {
struct Callback { struct Callback {
func: Function, func: Function,
timeout: Integer, timeout: Integer,
}; }
enum CallbackPriority { enum CallbackPriority {
High, High,
Medium, Medium,
Low, Low,
}; }
fn execute_callback(callback: Callback, priority: CallbackPriority); fn execute_callback(callback: Callback, priority: CallbackPriority);
} }
// That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing: // That's a flat out lie, but it results in a rather nice syntax highlight compared to nothing:
// vim: syntax=rust // vim: syntax=rust

View File

@ -1,23 +1,23 @@
/* /*
* Copyright (C) 2023 - 2024: * Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org> * The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
* *
* This file is part of the Trixy crate for Trinitrix. * This file is part of the Trixy crate for Trinitrix.
* *
* Trixy is free software: you can redistribute it and/or modify * Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as * it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of * published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program. * and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef TRIXY_ERRNO_H #ifndef TRIXY_ERRNO_H
#define TRIXY_ERRNO_H #define TRIXY_ERRNO_H
@ -26,10 +26,10 @@
/** Calculate the number of bytes in the last error's error message **not** /** Calculate the number of bytes in the last error's error message **not**
* including any trailing `null` characters. * including any trailing `null` characters.
*/ */
extern int last_error_length(); extern int last_error_length ();
/** Write the most recent error message into a caller-provided buffer as a UTF-8 /** Write the most recent error message into a caller-provided buffer as a
* string, returning the number of bytes written. * UTF-8 string, returning the number of bytes written.
* *
* # Note * # Note
* *
@ -40,6 +40,6 @@ extern int last_error_length();
* bytes). `-1` is returned if there are any errors, for example when passed a * bytes). `-1` is returned if there are any errors, for example when passed a
* null pointer or a buffer of insufficient size. * null pointer or a buffer of insufficient size.
*/ */
extern int last_error_message(char *buffer, uint64_t length); extern int last_error_message (char *buffer, uint64_t length);
#endif // TRIXY_ERRNO_H #endif // TRIXY_ERRNO_H

View File

@ -1,30 +1,30 @@
/* /*
* Copyright (C) 2023 - 2024: * Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org> * The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
* *
* This file is part of the Trixy crate for Trinitrix. * This file is part of the Trixy crate for Trinitrix.
* *
* Trixy is free software: you can redistribute it and/or modify * Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as * it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of * published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program. * and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef TRIXY_STRING_H #ifndef TRIXY_STRING_H
#define TRIXY_STRING_H #define TRIXY_STRING_H
/** /**
* @brief This string type is allocated by rust, which means that you can't just * @brief This string type is allocated by rust, which means that you can't
* free it from c, but need to return it to rust to be freed. * just free it from c, but need to return it to rust to be freed.
* @see the `string_free` method * @see the `string_free` method
*/ */
typedef const char *string_t; typedef const char *string_t;
@ -32,6 +32,6 @@ typedef const char *string_t;
/** /**
* @brief The free function for rust stings * @brief The free function for rust stings
*/ */
extern int string_free(string_t string); extern int string_free (string_t string);
#endif // TRIXY_STRING_H #endif // TRIXY_STRING_H

View File

@ -1,23 +1,23 @@
/* /*
* Copyright (C) 2023 - 2024: * Copyright (C) 2023 - 2024:
* The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org> * The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
* *
* This file is part of the Trixy crate for Trinitrix. * This file is part of the Trixy crate for Trinitrix.
* *
* Trixy is free software: you can redistribute it and/or modify * Trixy is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as * it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation, either version 3 of * published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* and the Lesser GNU General Public License along with this program. * and the Lesser GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef TRIXY_VEC_H #ifndef TRIXY_VEC_H
#define TRIXY_VEC_H #define TRIXY_VEC_H
@ -30,11 +30,12 @@
* You are must not free it by calling c's `free`. Use `vec_free` * You are must not free it by calling c's `free`. Use `vec_free`
* instead. * instead.
*/ */
struct vec { struct vec
{
void *data; void *data;
size_t length; size_t length;
}; };
extern int vec_free(struct vec vector); extern int vec_free (struct vec vector);
#endif // TRIXY_VEC_H #endif // TRIXY_VEC_H

View File

@ -1,3 +1,4 @@
#! /usr/bin/env sh
# Copyright (C) 2023 - 2024: # Copyright (C) 2023 - 2024:
# The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org> # The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
# #