You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This were the result of me implementing the Python bindings using the
new pipeline system. There were a handful of things I realized I
needed/wanted there that didn't come up when I was implementing the JS
bindings.
Add `FfiTypeNode`. I didn't originally have this as part of the general
pipeline, since it wasn't needed there. However, virtually all language
pipelines are going to want to add it so we may as well do it in shared
code.
Determine enum discriminants for the bindings. This uses basically the
same algorithm as from `ComponentInterface`. The one difference is that
for enums without a specified `repr`, this calculates the smallest
integer width needed to store the variants.
I used a new pipeline technique for the enum discriminents: the
old/optional `discr` field gets renamed to `meta_discr` so that we can
create a new/non-optional `discr` field.
Adding the `Node::has_descendant` method. I've noticed I'm implementing
this code again and again, so it feels a good time to generalize.
Several other smaller changes/fixes.
Copy file name to clipboardExpand all lines: docs/manual/src/internals/bindings_ir_pipeline.md
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,33 @@ pub struct Node {
65
65
}
66
66
```
67
67
68
+
### Field Conversion order
69
+
70
+
Fields are converted in declaration order.
71
+
This matters when a field is listed twice with one of them using `#[node(from(<name_of_the_other_field>)]`.
72
+
In this case the first field declared will be initialized with the data from the previous pass and the second field will be initialized to the default value.
73
+
74
+
You can take advantage of this to convert an optional value into a non-optional value.
75
+
For example:
76
+
77
+
```rust
78
+
#[derive(Node)]
79
+
pubstructSourceNode {
80
+
name:Option<String>
81
+
}
82
+
83
+
#[derive(Node)]
84
+
pubstructDestNode {
85
+
/// This field will be set to `SourceNode::name`
86
+
#[node(from(name))]
87
+
name_from_previous_pass:Option<String>
88
+
/// This field will be a non-optional version of `SourceNode::name`.
89
+
/// It will be initialized to an empty string, then a pipeline pass will populate it using
90
+
/// `maybe_foo` combined with logic to handle the `None` case.
91
+
name:String,
92
+
}
93
+
```
94
+
68
95
## Module structure
69
96
70
97
Each IRs will typically have a module dedicated to them with the following structure:
0 commit comments