-
Notifications
You must be signed in to change notification settings - Fork 18
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
bool values are not read back into Lua from Obj-c method calls #2
Comments
It would appear that the signature of the method being called affects the ability to read the return type. A bool returning objective-c method seems to correctly get its return value assigned in the lua interpreter, as well as a method with the signature: However, if I change signature to be: then the value returned is always 1. Here is how I am calling the method from Obj-c: |
Hmm... A Boolean value is converted to NSNumber with numberWithBool:. Type Encodings shows how method signature is encoded. |
My line numbers don't match so I should probably pull again (and should have before opening this, so apologies). Assuming this isn't a recently fixed bug, it would appear to be a pointer error. For some reason, with the NSString as a method parameter, the x value is actually the pointer address. When printing out I get which is correct however: With the method signature changed back to not include the NSString, I get: (lldb) print *((bool *)buffer) |
Ok, I realize now that it should be noted that I am running this on iOS. I believe this could have a fairly big impact and I believe is the cause of the problem (at least possibly). The following seemed to clear it up for me: If we look at the definition of a bool So sometimes is a char and sometimes an int. |
Oh... |
Ok, so here is what I think may be happening after digesting this:
|
When calling an Objective-c's class method which returns a bool, regardless of what I return, the value read within lua always appears to be 1.
UPDATE:
Doing additional tests are showing that the failure condition does not occur with a simple method. I will continue to refine and give exact failure conditions shortly
The text was updated successfully, but these errors were encountered: