-
Notifications
You must be signed in to change notification settings - Fork 157
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
C int to java Boolean convertion for >1 values #123
Comments
So you are proposing that specifying boolean as the type should do conversion based on the C standard: nonzero is true? It seems reasonable to me, though in similar cases in the other jnr libraries, we've eventually had to add the int version. Note that we haven't added these to jnr-posix because there are Java equivalents that behave mostly the same, but do produce boolean values. |
So poking around to see where this conversion happens I found two locations: This looks like the default boolean invoker logic, but it uses This has the logic you're seeing ( I'm going to step debug and figure out what's up. |
Hmmm...I wrote a test to see if I could find this behavior, but my test passes as written: @Test public void testBooleanFromInt() throws Exception {
assertEquals(false, testboolean.ret_int32_t(0));
assertEquals(true, testboolean.ret_int32_t(-1));
assertEquals(true, testboolean.ret_int32_t(1));
assertEquals(true, testboolean.ret_int32_t(2));
} I will push this test to master and see if there's some behavioral difference on Linux versus OS X. |
@goto1134 Can you provide an example, perhaps via a small git repo, that demonstrates your issue? I expected my test case to fail but it appears to have passed on both OS X and Linux. |
@headius look at https://github.com/goto1134/jnr-std-c-test . There are |
@headius |
@headius Do you have any idea about what could go wrong? |
UPD: test works with |
Here is compile dump for loading testBoolean library:
|
As I see, the problem is here
Constant 1 is pushed on the stack and then bitwise AND operation is performed with |
Its happen on the linux arm platform.
+// return new X86_64StubCompiler(runtime); //currently supporting only A64
` |
I tried to use predicate
It checks whether
c
is either a decimal digit or an uppercase or lowercase letter. It returns different values for different types,1
for uppercase,2
for lowercase,3
for digit.As soon as it as a predicate, I would like to declare boolean result for it, but if I do so, the predicate returns true only for uppercase letters.
I think, the boolean convertion from native should be changed.
The text was updated successfully, but these errors were encountered: