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
326: Fix UB related to engine enum layout r=Bromeon a=lilizoey
`EngineEnum`s should be represented as 32-bit values, but also should be passed as i64 to/from godot in function parameters/return values.
This fixes that by having engine enums not implement `GodotFfi` but instead only implements `GodotFuncMarshal`.
To support this change, `GodotFuncMarshal` has been refactored:
- `Via` now represents only the intermediate type, and must implement `GodotFfi`
- Add error-types for when conversion fails
- Add explicit conversion methods to/from `Via`, we can't just use `TryFrom` here since not all types we wanna use have the proper `TryFrom` conversions. like f32 and f64
With this change, a minor change was made to the class generator, such that all arguments are first converted to their `Via` type, before a pointer to them is made. And return pointers are now dereferenced to the `Via` type before they're converted to the proper type.
This means that `GodotFuncMarshal` is now the type that represents whether something can be passed as an argument/return value to a ptrcall.
`AsArg` was also removed and its method moved into `GodotFfi` as that simplifies codegen. (we can just always call `GodotFfi::as_arg_ptr` to create the pointer, rather than treating classes and other types differently). In the future we can try splitting up `GodotFfi` more, but i do think that `AsArg` belonged more in `godot_ffi` anyway.
Co-authored-by: Lili Zoey <[email protected]>
0 commit comments