Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f0ff8da
feat: add Transpil for type
reneca Mar 6, 2026
0d96508
fix: replace try from for types by from
reneca Mar 6, 2026
b40ebd0
feat: add serde::Deserialize for TypeMapper
reneca Mar 6, 2026
2eafef1
feat: make TypeMapper Debug and Clone
reneca Mar 6, 2026
b128637
feat: introduce transpil trait and implement trait for automatic C++ …
reneca Mar 13, 2026
f15ff64
feat: add transpilation for C++ const and static expression
reneca Mar 20, 2026
1afeef1
fix: fmt
reneca Mar 20, 2026
dd4cd22
feat: improve transpiler errors
reneca Mar 20, 2026
3522edc
feat: improve transpiler errors with their value
reneca Mar 20, 2026
c3d14be
fix: revert transpiler error debug
reneca Mar 20, 2026
468c81a
fix: handle C++ dynamic arrays
reneca Mar 20, 2026
c69123f
feat: implement transpilation for C++ enums
reneca Mar 20, 2026
7a17539
feat: add helper for auto types
reneca Mar 20, 2026
8915150
fix: types with cast if needed
reneca Mar 25, 2026
7d03445
feat: improve type assignment
reneca Mar 26, 2026
d2069f4
fix: remove from for const expr
reneca Mar 26, 2026
21749ea
feat: add helper for ast::Ident and ast::Visibility
reneca Mar 26, 2026
faa0ad1
feat: add config to skip types from transpilation
reneca Mar 26, 2026
4a83248
fix: remove unwanted println
reneca Apr 3, 2026
abf4f76
fix: ast parsing for Verbatim
reneca Apr 3, 2026
cb24f8c
feat: change Verbatim token type for LinkedList
reneca Apr 3, 2026
707445e
fix: clippy
reneca Apr 4, 2026
d756d70
feat: improve ast doc for specific items
reneca Apr 8, 2026
3ffe86e
feat: Type and Field transpilation
reneca Apr 8, 2026
cca63d5
feat: handle static for ast::Field
reneca Apr 10, 2026
5d846b7
feat: add regular ast::Var to fix static
reneca Apr 10, 2026
5b01206
feat: add utils for ast::Ident
reneca Apr 10, 2026
f79abd8
fix: ast::Ident PartialEq
reneca Apr 10, 2026
9052c88
feat: impl helper for default contructor
reneca Apr 10, 2026
0395d95
feat: handle class_name for ast function
reneca Apr 10, 2026
6d5835f
feat: add more helper on ast function
reneca Apr 10, 2026
25305b1
feat: handle member init in constructor definition
reneca Apr 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
[package]
name = "cppshift"
version = "0.1.0"
version = "0.1.1"
authors = ["Jérémy HERGAULT", "Enzo PASQUALINI"]
description = "CPP parser and transpiler"
repository = "https://github.com/worldline/cppshift"
edition = "2024"
license = "Apache-2.0"

[features]
default = ["transpiler"]
ast = []
transpiler = ["ast", "dep:serde", "dep:syn", "dep:quote", "dep:proc-macro2"]

[dependencies]
miette = { version = "7", features = ["fancy"] }
thiserror = "2"
serde = { version = "1", features = ["derive"], optional = true }
syn = { version = "2", features = ["full", "extra-traits", "printing"], optional = true }
quote = { version = "1", optional = true }
proc-macro2 = { version = "1", optional = true }

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
Expand Down
44 changes: 44 additions & 0 deletions src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! Analogous to `syn::Expr`.

use crate::SourceSpan;
use crate::ast::ty::{FundamentalKind, Type};

use super::item::{Ident, Path};
use super::punct::Punctuated;
Expand All @@ -16,6 +17,49 @@ pub enum LitKind {
Char,
}

impl LitKind {
/// Check if the fundamental kind matches the literal kind
pub fn match_fundamental(&self, kind: FundamentalKind) -> bool {
match self {
LitKind::Integer => matches!(
kind,
FundamentalKind::Short
| FundamentalKind::Int
| FundamentalKind::Long
| FundamentalKind::LongLong
| FundamentalKind::SignedChar
| FundamentalKind::UnsignedChar
| FundamentalKind::UnsignedShort
| FundamentalKind::UnsignedInt
| FundamentalKind::UnsignedLong
| FundamentalKind::UnsignedLongLong
),
LitKind::Float => matches!(
kind,
FundamentalKind::Float | FundamentalKind::Double | FundamentalKind::LongDouble
),
LitKind::Char => matches!(
kind,
FundamentalKind::Char
| FundamentalKind::Wchar
| FundamentalKind::Char8
| FundamentalKind::Char16
| FundamentalKind::Char32
),
_ => false,
}
}

/// Check if the literal kind matches the type
pub fn match_type(&self, ty: &Type) -> bool {
match ty {
Type::Fundamental(fund) => self.match_fundamental(fund.kind),
Type::Qualified(qualified) => self.match_type(&qualified.ty),
_ => false,
}
}
}

/// Unary operator.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum UnaryOp {
Expand Down
Loading
Loading