home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / ODUtils / TempObj.th < prev    next >
Encoding:
Text File  |  1996-09-17  |  1.9 KB  |  91 lines  |  [TEXT/MPS ]

  1. /*
  2. #    File:        TempObj.th
  3. #
  4. #    Contains:    Internal header for use by TempObj.h
  5. #
  6. #    Owned by:    Jens Alfke
  7. #
  8. #    Copyright:    © 1995 - 1996 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #    Change History (most recent first):
  11. #
  12. #         <2>     5/24/96    jpa        1322106: Add operator "&" so taking address
  13. #                                    works as expected. 1246074:
  14. #                                    Native-exception optimizations.
  15. #
  16. #    In Progress:
  17. */
  18.  
  19. // This header is a utility used by TempObj.h. Do not include it directly unless you
  20. // really know what you're doing -- see the Tech Note "Temporary Objects/References".
  21.  
  22. #ifndef SOM_ODStorageUnitView_xh
  23. #include <SUView.xh>
  24. #endif
  25.  
  26. #ifndef SOM_ODTypeList_xh
  27. #include <TypeList.xh>
  28. #endif
  29.  
  30. #ifndef _T_
  31. #error _T_ must be defined before including a .th file
  32. #endif
  33. #ifndef _C_
  34. #error _C_ must be defined before including a .th file
  35. #endif
  36.  
  37. //===========================================================================
  38. //    TempObj <T>
  39. //===========================================================================
  40.  
  41. #ifdef __SC__
  42. // Some of the typecasts below offend certain compilers.
  43. #pragma options(!warn_cast_incomplete_type)
  44. #endif
  45.  
  46. #ifdef _TMPL_IMPL_
  47.  
  48.     // Implementation of the TempRef constructor/destructor.
  49.     // Used only if we don't use native exceptions.
  50.     _C_::_C_( _T_ *obj )
  51.     {
  52.         fObj = (ODObject*) obj;
  53.     }
  54.     
  55.     _C_::~_C_( )
  56.     {
  57.         // Prevent compiler from inlining synthesized destructor
  58.         // which causes code bloat.
  59.     }
  60.  
  61. #else
  62.  
  63.     // Declaration of the TempObj class
  64.     class _C_ :public BaseTempObj
  65.     {
  66.         public:
  67. #ifdef _NATIVE_EXCEPTIONS_
  68.         _C_( _T_* t )                {fObj = (ODObject*)t;}
  69.         ~_C_( )                        { }
  70. #else
  71.         _C_( _T_* );
  72.         ~_C_( );
  73. #endif
  74.         _T_* operator-> ()            {return (_T_*)fObj;}
  75.         _T_** operator& ()            {return (_T_**)&fObj;}
  76.         operator _T_* ()            {return (_T_*)fObj;}
  77.     
  78.         _T_* operator= (_T_* t)        {fObj=(ODObject*)t; return t;}
  79.         
  80.         _T_* DontDelete()            {_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
  81.     };
  82.  
  83. #endif
  84.  
  85. #ifdef __SC__
  86. #pragma options(warn_cast_incomplete_type)
  87. #endif
  88.  
  89. #undef _T_
  90. #undef _C_
  91.