style(treewide): Reformat
This commit is contained in:
parent
5a7bb00548
commit
03f8eda241
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module is responsible for the config passed to trixy.
|
//! This module is responsible for the config passed to trixy.
|
||||||
//! It works using the popular builder syntax:
|
//! It works using the popular builder syntax:
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module generates the c header
|
//! This module generates the c header
|
||||||
//! It works by firstly listing the functions and then by grouping them into structures, effectively
|
//! It works by firstly listing the functions and then by grouping them into structures, effectively
|
||||||
//! simulating namespaces in c.
|
//! simulating namespaces in c.
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::format_ident;
|
use quote::format_ident;
|
||||||
use trixy_parser::command_spec::{CommandSpec, Namespace, Identifier, Function};
|
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
use trixy_parser::command_spec::{CommandSpec, Function, Identifier, Namespace};
|
||||||
|
|
||||||
use crate::generate::{identifier_to_rust, c_api::mangle_c_function_ident};
|
use crate::generate::{c_api::mangle_c_function_ident, identifier_to_rust};
|
||||||
|
|
||||||
pub fn generate(trixy: &CommandSpec) -> String {
|
pub fn generate(trixy: &CommandSpec) -> String {
|
||||||
let struct_initializer: TokenStream2 = trixy
|
let struct_initializer: TokenStream2 = trixy
|
||||||
|
@ -83,4 +83,3 @@ fn namespace_to_struct_init(namespace: &Namespace) -> TokenStream2 {
|
||||||
. #ident = #ident ,
|
. #ident = #ident ,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +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::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
|
@ -19,7 +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::{Ident, TokenStream as TokenStream2};
|
use proc_macro2::{Ident, TokenStream as TokenStream2};
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module is responsible for generating the rust code used to interface with the api.
|
//! This module is responsible for generating the rust code used to interface with the api.
|
||||||
//! That includes the structs and enums declared in the trixy file and the enum used to describe the
|
//! That includes the structs and enums declared in the trixy file and the enum used to describe the
|
||||||
//! command being executed.
|
//! command being executed.
|
||||||
|
|
|
@ -19,7 +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::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use trixy_parser::command_spec::{CommandSpec, Function, Identifier, NamedType, Type};
|
use trixy_parser::command_spec::{CommandSpec, Function, Identifier, NamedType, Type};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::{fs, path::PathBuf, process::exit};
|
use std::{fs, path::PathBuf, process::exit};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module contains the already type checked types.
|
//! This module contains the already type checked types.
|
||||||
|
|
||||||
use std::fmt::{Display, Write};
|
use std::fmt::{Display, Write};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module provides the type definitions for the parser.
|
//! This module provides the type definitions for the parser.
|
||||||
//! These types are split into type-checked ones [`checked`] and the raw types [`unchecked`]
|
//! These types are split into type-checked ones [`checked`] and the raw types [`unchecked`]
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! This module contains the not type checked types.
|
//! This module contains the not type checked types.
|
||||||
//! These are generated on the first pass of the parser, to be later converted into the checked
|
//! These are generated on the first pass of the parser, to be later converted into the checked
|
||||||
//! ones.
|
//! ones.
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::{error::Error, fmt::Display};
|
use std::{error::Error, fmt::Display};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use self::{error::SpannedLexingError, tokenizer::Tokenizer};
|
use self::{error::SpannedLexingError, tokenizer::Tokenizer};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use crate::lexing::{Keyword, Token, TokenKind, TokenSpan};
|
use crate::lexing::{Keyword, Token, TokenKind, TokenSpan};
|
||||||
|
|
||||||
use super::TokenStream;
|
use super::TokenStream;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// This code is heavily inspired by: https://michael-f-bryan.github.io/static-analyser-in-rust/book/lex.html
|
// This code is heavily inspired by: https://michael-f-bryan.github.io/static-analyser-in-rust/book/lex.html
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use error::TrixyError;
|
use error::TrixyError;
|
||||||
|
|
||||||
use crate::lexing::TokenStream;
|
use crate::lexing::TokenStream;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use std::{error::Error, fmt::Display};
|
use std::{error::Error, fmt::Display};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use crate::command_spec::checked::{
|
use crate::command_spec::checked::{
|
||||||
Attribute, CommandSpec, DocIdentifier, DocNamedType, Enumeration, Function, Identifier,
|
Attribute, CommandSpec, DocIdentifier, DocNamedType, Enumeration, Function, Identifier,
|
||||||
NamedType, Namespace, Structure, Type,
|
NamedType, Namespace, Structure, Type,
|
||||||
|
|
|
@ -19,6 +19,5 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
pub mod checked;
|
pub mod checked;
|
||||||
pub mod unchecked;
|
pub mod unchecked;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::{error::Error, fmt::Display};
|
use std::{error::Error, fmt::Display};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use std::ffi::c_char;
|
use std::ffi::c_char;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Trixy contains the types used by the [`trixy-macros`] crate to provide ffi safe types
|
//! Trixy contains the types used by the [`trixy-macros`] crate to provide ffi safe types
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use core::slice;
|
use core::slice;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
pub mod convert_trait;
|
pub mod convert_trait;
|
||||||
pub mod errno;
|
pub mod errno;
|
||||||
mod try_from_impl;
|
mod try_from_impl;
|
||||||
|
|
Reference in New Issue