On Sat, Sep 18, 2010 at 3:32 AM, Thilo Planz <thilopl...@googlemail.com> wrote:
> Hi, I have updated to the new CamelBones, but I am still having the problem
> of NSObject->isEqual not working properly.
> To recap the thread below, I am calling -isEqual on cocoa components
> (I think NSButtons), and it returns values, which do not work as
> booleans in Perl (maybe a memory address).

Found it! What's happening is that, for one- and two-byte return types
(i.e., char and short), *four* bytes are being stored in a Perl
variable. Since only one or two bytes were actually returned from the
method, the other two or three bytes of the value being returned to
Perl are essentially random.

> This used to work back in the old days...

It's probably a holdover from the old FFCall library. Comments in the
code indicated that it "promoted" such return types to 32 bits.
Apparently libffi doesn't do that. I've fixed the bug and checked the
change into Subversion, and I'll roll a new release as soon as I've
verified that it applies to both PPC & Intel, and for all of the
supported Mac OS X versions.

> Any idea on how I can fix or workaround this issue?

One workaround is to assign a tag to the relevant controls in
Interface Builder, and compare it like this:

  if ($sender->tag() == $self->{'thisButton'}->tag()) {

Tags are 32-bit values, so this bug doesn't bite them.


Cocoa programming in Perl:

Reply via email to