[Openmcl-devel] same foreign object?

Ben Hyde bhyde at pobox.com
Sat Jan 30 22:50:12 UTC 2010


Thanks.  And since eql works on ccl::foreign-standard-objects as well;  
it can be usefule on the cocoa bridge objects.

ccl> (defmacro application-native-menubar () `(slot-value (slot-value  
*application* 'ccl::ui-object) 'ns:_main-menu))
APPLICATION-NATIVE-MENUBAR
ccl> (type-of (application-native-menubar))
NS:NS-MENU
ccl> (typep (application-native-menubar) 'foreign-standard-object)
T
ccl> (eq (application-native-menubar) (application-native-menubar))
NIL
ccl> (eql (application-native-menubar) (application-native-menubar))
T
ccl>


On Jan 30, 2010, at 11:13 AM, Gail Zacharias wrote:
> EQL compares unboxed macptr's.
>
> ? (eql (%int-to-ptr 123) (%int-to-ptr 123))
> T
>
> On Sat, Jan 30, 2010 at 10:19 AM, Ben Hyde <bhyde at pobox.com> wrote:
>> I could use a bit of critique here.  No doubt I am confused on many
>> many different levels, but I think I need something like this.
>>
>> (in-package :ccl)
>>
>> (defmethod same-foreign-object ((a foreign-standard-object) (b  
>> foreign-
>> standard-object))
>>   (flet ((raw-addr (x)
>>            (let* ((p (%null-ptr)))
>>              (%set-macptr-domain p 1)
>>              (%setf-macptr p x)
>>              (ccl:%ptr-to-int p))))
>>     (eq (raw-addr a) (raw-addr b))))
>>
>> This came up because I wanted to toggle the IDE's menubar back and
>> forth between my App's menubar and the IDE's one.  That lead to a
>> desire to squirrel away the current menubar.   See that (slot-value
>> (slot-value *application* 'ccl::ui-object) 'ns:_main-menu)) boxes; so
>> eq tests don't work out.   Diving into the objective c bridge leads  
>> to
>> finding that ns-object is based on foreign-standard-object.   That  
>> raw-
>> addr code is entirely adhoc -- based on something I saw in the  
>> bridge.
>>
>> Thoughts?
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20100130/a7b0cad4/attachment.html>


More information about the Openmcl-devel mailing list