Re: BOOL returned from Objective-C does not getted mapped properly (always true)
[email protected] (Thilo Planz)
| Newsgroups | perl.macosx |
|---|---|
| Message-ID | <[email protected]> |
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).
real code is here:
http://bitbucket.org/thiloplanz/perlpad/src/tip/MyWindowController.pm#cl-229
$sender->isEqual($self->{PerlInputButton}) returns something like "44858369"
This used to work back in the old days...
Any idea on how I can fix or workaround this issue?
Thanks,
Thilo
>> Have you tried -isEqual: for other classes? NSApplication is a
>> singleton, and Apple may not have anticipated anyone comparing it with
>> itself, or with random strings of text. :-)
>
> My real code does not call -isEqual: on NSApplication.
> This was just test code for the sake of the bug report.
>
> I real life, I am calling it on UI components, I think NSButtons:
>
> http://bitbucket.org/thiloplanz/perlpad/src/tip/MyWindowController.pm#cl-229
>
>
> Thilo
>
>>
>> I'll add some -isEqual: cases to the test suite, in any event. One
>> can't have too many test cases.
>>
>> sherm--
>>
>> On Sat, Dec 5, 2009 at 9:59 PM, Thilo Planz <[email protected]> wrote:
>>> Hi there,
>>>
>>> For a long time, PerlPad has been segfaulting on recent Camelbones
>>> versions, and it seems that is caused BOOL return values no longer being
>>> mapped properly into Perl.
>>>
>>> It seems that functions such as NSObject->isEqual that return a BOOL
>>> return some kind of memory index to Perl.
>>>
>>>
>>>> my $x = NSApplication->sharedApplication;
>>>> print $x->isEqual($x);
>>>> print "\n";
>>> should return YES, prints 44858369
>>>
>>>> print $x->isEqual("random string");
>>>> print "\n";
>>> should return NO, prints 42636800
>>>
>>>> print "true\n" if $x->isEqual("random string");
>>> should evaluate to false in boolean context, but evaluates as true.
>>>
>>>
>>> I think in previous versions (of CB) this worked better.
>>>
>>> Is there any way I can rewrite my code to make at least
>>> "isEqual" work for now?
>>>
>>> Thanks,
>>>
>>> Thilo
>>>
>>
>>
>>
>