mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-15 12:15:02 +01:00
restructuring
This commit is contained in:
parent
ed4a107c44
commit
9b48dec533
12 changed files with 1988 additions and 1586 deletions
|
|
@ -123,7 +123,7 @@ pub fn main() {
|
|||
|
||||
fn codegen(amqp: &Amqp) {
|
||||
println!("#![allow(dead_code)]");
|
||||
println!("// This file has been generated by `amqp_codegen`. Do not edit it manually.\n");
|
||||
println!("// This file has been generated by `xtask/src/codegen`. Do not edit it manually.\n");
|
||||
codegen_domain_defs(amqp);
|
||||
codegen_class_defs(amqp);
|
||||
codegen_parser(amqp);
|
||||
|
|
@ -159,22 +159,15 @@ fn codegen_domain_defs(amqp: &Amqp) {
|
|||
|
||||
fn codegen_class_defs(amqp: &Amqp) {
|
||||
println!("#[derive(Debug, Clone, PartialEq)]");
|
||||
println!("pub enum Class {{");
|
||||
for class in &amqp.classes {
|
||||
let class_name = class.name.to_upper_camel_case();
|
||||
println!(" {class_name}({class_name}),");
|
||||
}
|
||||
println!("}}\n");
|
||||
println!("pub enum Method {{");
|
||||
|
||||
for class in &amqp.classes {
|
||||
let enum_name = class.name.to_upper_camel_case();
|
||||
doc_comment(&class.doc, 0);
|
||||
println!("#[derive(Debug, Clone, PartialEq)]");
|
||||
println!("pub enum {enum_name} {{");
|
||||
for method in &class.methods {
|
||||
let method_name = method.name.to_upper_camel_case();
|
||||
doc_comment(&class.doc, 4);
|
||||
doc_comment(&method.doc, 4);
|
||||
print!(" {method_name}");
|
||||
print!(" {enum_name}{method_name}");
|
||||
if !method.fields.is_empty() {
|
||||
println!(" {{");
|
||||
for field in &method.fields {
|
||||
|
|
@ -197,8 +190,9 @@ fn codegen_class_defs(amqp: &Amqp) {
|
|||
println!(",");
|
||||
}
|
||||
}
|
||||
println!("}}");
|
||||
}
|
||||
|
||||
println!("}}\n");
|
||||
}
|
||||
|
||||
fn amqp_type_to_rust_type(amqp_type: &str) -> &'static str {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue