Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
seqre committed Jul 12, 2024
1 parent 15694a1 commit e5a35ac
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"flareon-orm",
# Examples
"examples/hello-world",
"examples/simple-orm",
]
resolver = "2"

Expand Down
8 changes: 8 additions & 0 deletions examples/simple-orm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "example-simple-orm"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
flareon-orm = { path = "../../flareon-orm" }
12 changes: 12 additions & 0 deletions examples/simple-orm/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use flareon_orm as orm;
use orm::{model, Model};

#[model(test, test_val = 3)]
struct User {
pub id: u128,
pub email: String,
}

fn main() {
println!("Hello, world!");
}
2 changes: 2 additions & 0 deletions flareon-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ description = "Modern web framework focused on speed and ease of use - macros."
proc-macro = true

[dependencies]
syn = "2.0"
quote = "1.0"
28 changes: 25 additions & 3 deletions flareon-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
use proc_macro::TokenStream;
use syn::token::Token;
use syn::Token;

#[proc_macro]
pub fn flareon(_input: TokenStream) -> TokenStream {
unimplemented!()
#[proc_macro_attribute]
pub fn model(attr: TokenStream, item: TokenStream) -> TokenStream {
println!("ATTRIBUTE");
println!("Attr: {attr}");
println!("Item: {item}");

let ast: syn::DeriveInput = syn::parse(item).unwrap();
println!("Ident: {:?}", &ast.ident);

let syn::Data::Struct(datastruct) = ast.data else {
unimplemented!()
};

let syn::Fields::Named(namedfields) = datastruct.fields else {
unimplemented!()
};

println!("Fields:");
for field in namedfields.named.iter() {
println!("\tid: {:?}", field.ident);
}

TokenStream::new()
}
1 change: 1 addition & 0 deletions flareon-orm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ license.workspace = true
description = "Modern web framework focused on speed and ease of use - ORM."

[dependencies]
flareon-macros = { path = "../flareon-macros" }
4 changes: 4 additions & 0 deletions flareon-orm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ pub fn add(left: u64, right: u64) -> u64 {
left + right
}

pub use flareon_macros::model;

pub trait Model {}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit e5a35ac

Please sign in to comment.