[Openmcl-devel] ObjC Inheritance
Brent Fulgham
bfulg at pacbell.net
Sun Dec 3 23:29:51 PST 2006
I've probably made a poor design decision, but I'm curious if there
is a way to work around it.
I've created a simple cocoa window class, based on the example code
in the OpenMCL sources. The test is so simple that it immediately
displays the "Tiny Cocoa" example output when you invoke:
? (make-instance 'ccl::window)
So far, so good.
The "Open Agent Architecture" uses views and windows to display
information, much like Cocoa. I thought I might be able to use
'ns:ns-view as the root class of the OAA "simple-view" class, and
likewise use my window class for the OAA "window" class. This would
make connecting event handlers and so forth easier for me later on.
Unfortunately, the actual window used in the OAA architecture is
multiply inherited from simple-view and window. OpenMCL does not
like this, complaining that :
;Loading #P"Texture-and-Image-Import.lisp"...
;Loading #P"Camera.lisp"...
;Loading #P"OpenGL for MCL.lisp"...
;Compiler warnings :
; Undeclared free variable *WATCH-CURSOR*, in (USE-TEXTURE (OPENGL-
SIMPLE-VIEW T)) inside an anonymous lambda form.
;Compiler warnings :
; Undeclared free variable $GENEVA, in (MAKE-OPENGL-FONT (OPENGL-
SIMPLE-VIEW)) inside an anonymous lambda form.
> Error: Exactly one OBJC:OBJC-CLASS must appear in (#<OBJC:OBJC-
CLASS WINDOW (#x364050)> #<OBJC:OBJC-CLASS OPENGL-SIMPLE-VIEW
(#x3995F0)>), found 2
> While executing: #<STANDARD-METHOD ALLOCATE-INSTANCE (OBJC:OBJC-
METACLASS)>, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available
restarts.
> If continued: Skip loading "Load OpenGL for MCL.lisp"
> Type :? for other options.
1 > (quit)
Since I wasn't really doing much ObjC stuff in the view class, I made
a root view class to inherit from (with no Cocoa/Objc binding) and
was able to get a little further. Still, I now find that the
initargs tests are failing, since the class hierachy is bifurcated,
and the ObjC-tainted class is attempting to be handled by a
"standard" CLOS class:
? (make-instance 'ccl::opengl-window)
> Error: value #<OBJC:OBJC-CLASS CCL::OPENGL-WINDOW (#x329560)> is
not of the expected type (SATISFIES CCL::STD-CLASS-P).
> While executing: CCL::CHECK-INITARGS, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :B
(F0135AB0) : 0 (CHECK-INITARGS #<OPENGL-WINDOW <OpenGLWindow:
0x189ca00> (#x189CA00)> #<OBJC:OBJC-CLASS CCL::OPENGL-WINDOW
(#x329560)> NIL NIL [...]) 96
(F0135AD0) : 2 (%%CNM-WITH-ARGS-CHECK-INITARGS '(#<STANDARD-GENERIC-
FUNCTION INITIALIZE-INSTANCE #x808F20E> #) '(#<# # (#x189CA00)>)) 596
(F0135AE0) : 3 (%%CNM-WITH-ARGS-COMBINED-METHOD-DCODE #(#<STANDARD-
GENERIC-FUNCTION INITIALIZE-INSTANCE #x808F20E> (#<#> #<#> #<#> #<#>
#<#>) (#<STANDARD-GENERIC-FUNCTION INITIALIZE-INSTANCE #x808F20E> #)
#<Compiled-function CCL::%%CNM-WITH-ARGS-CHECK-INITARGS #x8082226>
(NIL # #<#> #<#>)) '(#<# # (#x189CA00)>) [...]) 108
(F0135B00) : 5 (%CALL-NEXT-METHOD-WITH-ARGS '(# # . 1613691) [...]) 208
(F0135B10) : 6 (FUNCALL #'#<#<STANDARD-METHOD INITIALIZE-INSTANCE
(CCL::OPENGL-WINDOW)>> '(# # . 1613691) [...]) 68
(F0135B30) : 8 (%%BEFORE-AND-AFTER-COMBINED-METHOD-DCODE '(# # .
1613691)) 624
(F0135B50) : 10 (%%CNM-WITH-ARGS-COMBINED-METHOD-DCODE #(#<STANDARD-
GENERIC-FUNCTION INITIALIZE-INSTANCE #x808F20E> (#<#> #<#> #<#> #<#>
#<#>) (#<STANDARD-GENERIC-FUNCTION INITIALIZE-INSTANCE #x808F20E> #)
#<Compiled-function CCL::%%CNM-WITH-ARGS-CHECK-INITARGS #x8082226>
(NIL # #<#> #<#>)) 1613691 [...]) 416
(F0135B90) : 14 (FUNCALL #'#<#<CCL::STANDARD-KERNEL-METHOD MAKE-
INSTANCE (SYMBOL)>> 'CCL::OPENGL-WINDOW [...]) 64
(F0135BB0) : 16 (CALL-CHECK-REGS 'MAKE-INSTANCE [...]) 72
(F0135BD0) : 18 (TOPLEVEL-EVAL '(MAKE-INSTANCE #) [...]) 152
(F0135BE0) : 19 (READ-LOOP [...]) 864
(F0135C20) : 20 (TOPLEVEL-LOOP) 124
(F0135C40) : 21 (FUNCALL #'#<Anonymous Function #x816A8C6>) 68
(F0135C60) : 23 (FUNCALL #'#<Anonymous Function #x820C4AE>) 356
(F0135C80) : 24 (RUN-PROCESS-INITIAL-FORM #<PROCESS listener(1)
[Active] #x8508126> '(#)) 400
(F0135CC0) : 26 (FUNCALL #'#<Anonymous Function #x81716FE> #<PROCESS
listener(1) [Active] #x8508126> '(#)) 152
(F0135CE0) : 27 (FUNCALL #'#<Anonymous Function #x815BC3E>) 172
1 >
What to do?
1. Should I just encapsulate the ObjC stuff as a member of a set of
STD classes to avoid this?
2. Did I misunderstand the first error, and multiple inheritance is
actually permitted?
3. Other ideas?
Thanks,
-Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20061203/c1ff092e/attachment.htm>
More information about the Openmcl-devel
mailing list