File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
bindgen/src/bindings/cpp/templates Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
- Scaffolding: Decorate public functions with ` __declspec(dllexport) ` under Windows and ` __attribute__((visibility("default"))) ` on other platforms
6
6
- Core: Make complex function arguments be passed by ` const& ` for non-callback functions
7
+ - Core: Write enums based on variant instead of casting to uint during conversion
7
8
8
9
#### v0.4.0+v0.25.0
9
10
Original file line number Diff line number Diff line change @@ -32,7 +32,15 @@ RustBuffer {{ ffi_converter_name }}::lower(const {{ type_name }} &val) {
32
32
}
33
33
34
34
void {{ ffi_converter_name }}::write(RustStream &stream, const {{ type_name }} &val) {
35
- stream << static_cast <int32_t >(val);
35
+ switch (val) {
36
+ {% for variant in e.variants () %}
37
+ case {{ type_name }}::{{ variant|variant_name }}:
38
+ stream << static_cast <int32_t >({{ loop.index }});
39
+ break ;
40
+ {% endfor %}
41
+ default :
42
+ throw std::runtime_error (" No matching {{ type_name }} variant" );
43
+ }
36
44
}
37
45
38
46
int32_t {{ ffi_converter_name }}::allocation_size(const {{ type_name|class_name }} &) {
@@ -122,4 +130,4 @@ int32_t {{ ffi_converter_name }}::allocation_size(const {{ type_name|class_name
122
130
123
131
return size;
124
132
}
125
- {%- endif %}
133
+ {%- endif %}
You can’t perform that action at this time.
0 commit comments