mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-30 17:40:00 -07:00
bindgen: snap
This commit is contained in:
@@ -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.\"\"\""
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user