llmcc_python/descriptor/
class.rs

1#[derive(Debug, Clone)]
2pub struct PythonClassDescriptor {
3    pub name: String,
4    pub base_classes: Vec<String>,
5    pub methods: Vec<String>,
6    pub fields: Vec<ClassField>,
7}
8
9#[derive(Debug, Clone)]
10pub struct ClassField {
11    pub name: String,
12    pub type_hint: Option<String>,
13}
14
15impl PythonClassDescriptor {
16    pub fn new(name: String) -> Self {
17        Self {
18            name,
19            base_classes: Vec::new(),
20            methods: Vec::new(),
21            fields: Vec::new(),
22        }
23    }
24
25    pub fn add_base_class(&mut self, base: String) {
26        self.base_classes.push(base);
27    }
28
29    pub fn add_method(&mut self, method: String) {
30        self.methods.push(method);
31    }
32
33    pub fn add_field(&mut self, field: ClassField) {
34        self.fields.push(field);
35    }
36}
37
38impl ClassField {
39    pub fn new(name: String) -> Self {
40        Self {
41            name,
42            type_hint: None,
43        }
44    }
45
46    pub fn with_type_hint(mut self, type_hint: String) -> Self {
47        self.type_hint = Some(type_hint);
48        self
49    }
50}