[vtk-developers] Proposed change to vtkCocoaGLView.h (regarding C++ usage)
Berk Geveci
berk.geveci at kitware.com
Tue Mar 11 07:43:18 EDT 2008
Sounds good. Can you tell us a bit about the refactoring support in XCode?
-berk
On 3/11/08, David Cole <david.cole at kitware.com> wrote:
> Go for it...
>
>
>
> On 3/10/08, Sean McBride <sean at rogue-research.com> wrote:
> > Hi all,
> >
> > VTK provides the public class vtkCocoaGLView. It is a subclass of
> > Apple's NSView. NSView is an Objective-C class. vtkCocoaGLView is a so-
> > called Objective-C++ class, meaning that it is an Objective-C class but
> > it has some C++ syntax (needed because it has methods and instance
> > variables with C++ types). This is absolutely fine, working, common,
> > and well-supported. However...
> >
> > Apple's Xcode 3 IDE provides some code refactoring features which are
> > extremely useful, however they only support Objective-C, not C++ and not
> > even Objective-C++.
> >
> > Every time I #include vtkCocoaGLView.h I am forced to make my files .mm
> > instead of .m (Obj-C++ vs Obj-C). Then I loose refactoring for those
> > files. :(
> >
> > I have a fix, and want to see if anyone objects... Basically,
> > vtkCocoaGLView.h can be summarised as:
> >
> > --------
> > class vtkCocoaRenderWindow; // fwd declare
> >
> > @interface vtkCocoaGLView : NSView
> > {
> > vtkCocoaRenderWindow* ivar;
> > }
> >
> > - (vtkCocoaRenderWindow*)method;
> > @end
> > --------
> >
> > Where vtkCocoaRenderWindow is a C++ type. I'd like to change it to:
> >
> > --------
> > #ifdef __cplusplus
> > class vtkCocoaRenderWindow; // fwd declare
> > typedef vtkCocoaRenderWindow* vtkCocoaRenderWindowRef;
> > #else
> > typedef void* vtkCocoaRenderWindowRef;
> > #endif
> >
> > @interface vtkCocoaGLView : NSView
> > {
> > vtkCocoaRenderWindowRef ivar;
> > }
> >
> > - (vtkCocoaRenderWindowRef)method;
> > @end
> > --------
> >
> > Now, if vtkCocoaGLView.h is included by a .m file it sees pure Obj-C, if
> > it is included by a .mm files it sees Obj-C++.
> >
> > It's not too ugly... :) Any objections?
> >
> > Thanks,
> >
> > --
> >
> ____________________________________________________________
> > Sean McBride, B. Eng sean at rogue-research.com
> > Rogue Research
> www.rogue-research.com
> > Mac Software Developer Montréal, Québec,
> Canada
> >
> > _______________________________________________
> > vtk-developers mailing list
> > vtk-developers at vtk.org
> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
More information about the vtk-developers
mailing list