bindgen: snap

This commit is contained in:
nym21
2026-03-16 09:04:10 +01:00
parent c1565c5f42
commit 46d85d397d
7 changed files with 220 additions and 357 deletions

View File

@@ -695,12 +695,27 @@ pub fn generate_structural_patterns(
" \"\"\"Pattern struct for repeated tree structure.\"\"\""
)
.unwrap();
// Skip constructor for non-parameterizable patterns (inlined at tree level)
if !metadata.is_parameterizable(&pattern.name) {
writeln!(output, " pass\n").unwrap();
continue;
}
writeln!(output, " ").unwrap();
writeln!(
output,
" def __init__(self, client: BrkClientBase, acc: str):"
)
.unwrap();
if pattern.is_templated() {
writeln!(
output,
" def __init__(self, client: BrkClientBase, acc: str, disc: str):"
)
.unwrap();
} else {
writeln!(
output,
" def __init__(self, client: BrkClientBase, acc: str):"
)
.unwrap();
}
writeln!(
output,
" \"\"\"Create pattern node with accumulated metric name.\"\"\""

View File

@@ -95,12 +95,27 @@ fn generate_tree_class(
child.name,
GenericSyntax::PYTHON,
);
writeln!(
output,
" self.{}: {} = {}(client, '{}')",
field_name_py, py_type, child.field.rust_type, child.base_result.base
)
.unwrap();
let pattern = metadata.find_pattern(&child.field.rust_type);
if let Some(pat) = pattern
&& pat.is_templated()
{
let disc = pat
.extract_disc_from_instance(&child.base_result.field_parts)
.unwrap_or_default();
writeln!(
output,
" self.{}: {} = {}(client, '{}', '{}')",
field_name_py, py_type, child.field.rust_type, child.base_result.base, disc
)
.unwrap();
} else {
writeln!(
output,
" self.{}: {} = {}(client, '{}')",
field_name_py, py_type, child.field.rust_type, child.base_result.base
)
.unwrap();
}
}
}