Skip to content

Commit 42b0253

Browse files
committed
Reorganize godot-macros file structure
Organize by semantics, grouping class-related macros together. Also move helper types into their own data_models directory.
1 parent bb2be22 commit 42b0253

20 files changed

+584
-577
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
*/
6+
7+
use crate::class::{FieldExport, FieldVar};
8+
use proc_macro2::{Ident, TokenStream};
9+
10+
pub struct Field {
11+
pub name: Ident,
12+
pub ty: venial::TyExpr,
13+
pub default: Option<TokenStream>,
14+
pub var: Option<FieldVar>,
15+
pub export: Option<FieldExport>,
16+
}
17+
18+
impl Field {
19+
pub fn new(field: &venial::NamedField) -> Self {
20+
Self {
21+
name: field.name.clone(),
22+
ty: field.ty.clone(),
23+
default: None,
24+
var: None,
25+
export: None,
26+
}
27+
}
28+
}
29+
30+
pub struct Fields {
31+
/// All fields except `base_field`.
32+
pub all_fields: Vec<Field>,
33+
34+
/// The field annotated with `#[base]`.
35+
pub base_field: Option<Field>,
36+
}

godot-macros/src/derive_godot_class/property/field_export.rs renamed to godot-macros/src/class/data_models/field_export.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7+
use proc_macro2::{Ident, TokenStream};
8+
use quote::quote;
79
use std::collections::HashSet;
810

11+
use crate::class::FieldHint;
912
use crate::util::{KvParser, ListParser};
1013
use crate::ParseResult;
11-
use proc_macro2::{Ident, TokenStream};
12-
use quote::quote;
13-
14-
use super::FieldHint;
1514

1615
/// Store info from `#[export]` attribute.
1716
pub enum FieldExport {

godot-macros/src/derive_godot_class/property/field_var.rs renamed to godot-macros/src/class/data_models/field_var.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7-
use crate::derive_godot_class::{make_existence_check, Field, FieldHint};
8-
use crate::method_registration::make_method_registration;
9-
use crate::method_registration::FuncDefinition;
10-
use crate::util::KvParser;
11-
use crate::{util, ParseResult};
127
use proc_macro2::{Ident, TokenStream};
138
use quote::{format_ident, quote};
149

10+
use crate::class::{
11+
make_existence_check, make_method_registration, Field, FieldHint, FuncDefinition,
12+
};
13+
use crate::util::KvParser;
14+
use crate::{util, ParseResult};
15+
1516
/// Store info from `#[var]` attribute.
1617
#[derive(Default, Clone, Debug)]
1718
pub struct FieldVar {
@@ -144,7 +145,7 @@ impl GetSet {
144145
}
145146

146147
#[derive(Clone, Debug)]
147-
pub(super) struct GetterSetterImpl {
148+
pub struct GetterSetterImpl {
148149
pub function_name: Ident,
149150
pub function_impl: TokenStream,
150151
pub export_token: TokenStream,

0 commit comments

Comments
 (0)