-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert _Bool to boolean #6
Comments
Well, I suppose there is one major problem: converting a _Bool declared in the .h/.bi to an integer or other numeric type in FB. Using byte results in 0/1 while using boolean results in 0/-1. (When this conversion happens in code that fbfrog itself translates, it can convert to 0/1; the issue is in non-translated code.) |
Here are the results of regenerating fbbindings with my branch: There were no changes due to the addition of (_Bool) cast support or _Bool->long casting in expressions to fbfrog; all changes were in the types of args, return values, struct members or extern variables. This is the wrong repo to discuss this, but I suggest that if compatibility is a concern allegro5 and ncurses and maybe gif_lib5 bindings continue to use byte instead of boolean, and all the other headers switch to boolean. llvm-c bindings are way out of date anyway, and raylib bindings are not yet in fbc so can be changed. Ideally there would be opt in or deprecation process for these headers. |
Agreed, since FB has a C-compatible boolean type now, it can be used in translations too. fbfrog even already has some support for turning |
I think that changing a header to use boolean instead of byte is very unlikely to break any individual program using it, Changes to the default behaviour of fbfrog can be made pretty freely, though. I've force-pushed my branch with tests and better handling of _Bools in expressions. It's now part of the 0|1 -> 0|-1 handling. |
To my surprise, on examing the assembly/C, I realise that a
boolean
is stored as a value of either 0 or 1 in a byte, and is converted to/from 0/-1 when converting to/from a numerical type. This appears to mean it is exactly the same as C's_Bool
(orbool
with stdbool.h).Therefore, why doesn't fbfrog convert
_Bool
toboolean
? The fact that it instead translates to 'byte' breaks code such aswhile not WindowShouldClose()
(function returning a bool) from the raylib examples and all previous translations of those examples and headers into FB, so I feel I have no choice but to edit my new translation of raylib.bi to use boolean.Boolean was only added in 2015, so I guess it was just never implemented.
I'm currently working on this, and have come across no problems so far.
The only concern is whether there's any case where this would break code using existing headers, if the headers are regenerated.
The text was updated successfully, but these errors were encountered: