Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dtoolbase/dtoolbase_cc.h

Go to the documentation of this file.
00001 // Filename: dtoolbase_cc.h
00002 // Created by:  drose (13Sep00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PANDABASE_CC_H
00020 #define PANDABASE_CC_H
00021 
00022 // This file should never be included directly; it's intended to be
00023 // included only from dtoolbase.h.  Include that file instead.
00024 
00025 
00026 #ifdef CPPPARSER
00027 #include <iostream>
00028 #include <string>
00029 
00030 using namespace std;
00031 
00032 #define INLINE inline
00033 #define TYPENAME typename
00034 
00035 #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname)
00036 
00037 // We define the macro PUBLISHED to mark C++ methods that are to be
00038 // published via interrogate to scripting languages.  However, if
00039 // we're not running the interrogate pass (CPPPARSER isn't defined),
00040 // this maps to public.
00041 #define PUBLISHED __published
00042 
00043 typedef int streamsize;
00044 typedef int ios_openmode;
00045 typedef int ios_fmtflags;
00046 typedef int ios_iostate;
00047 typedef int ios_seekdir;
00048 
00049 #else  // CPPPARSER
00050 
00051 #ifdef HAVE_IOSTREAM
00052 #include <iostream>
00053 #include <fstream>
00054 #include <iomanip>
00055 #else
00056 #include <iostream.h>
00057 #include <fstream.h>
00058 #include <iomanip.h>
00059 #endif
00060 
00061 #ifdef HAVE_SSTREAM
00062 #include <sstream>
00063 #else
00064 #include "fakestringstream.h"
00065 #endif
00066 
00067 #ifdef HAVE_NEW
00068 #include <new>
00069 #endif
00070 
00071 #include <string>
00072 
00073 #ifdef HAVE_NAMESPACE
00074 using namespace std;
00075 #endif
00076 
00077 #ifdef HAVE_TYPENAME
00078 #define TYPENAME typename
00079 #else
00080 #define TYPENAME
00081 #endif
00082 
00083 #ifndef HAVE_WSTRING
00084 // Some C++ libraries (gcc 2.95) don't define this.
00085 typedef basic_string<wchar_t> wstring;
00086 #endif
00087 
00088 #ifndef HAVE_STREAMSIZE
00089 // Some C++ libraries (Irix) don't define this.
00090 typedef int streamsize;
00091 #endif
00092 
00093 #ifndef HAVE_IOS_TYPEDEFS
00094 typedef int ios_openmode;
00095 typedef int ios_fmtflags;
00096 typedef int ios_iostate;
00097 // Old iostream libraries used ios::seek_dir instead of ios::seekdir.
00098 typedef ios::seek_dir ios_seekdir;
00099 #else
00100 typedef ios::openmode ios_openmode;
00101 typedef ios::fmtflags ios_fmtflags;
00102 typedef ios::iostate ios_iostate;
00103 typedef ios::seekdir ios_seekdir;
00104 #endif
00105 
00106 
00107 #if defined(WIN32_VC) && defined(FORCE_INLINING)
00108 // If FORCE_INLINING is defined, we use the keyword __forceinline,
00109 // which tells MS VC++ to override its internal benefit heuristic
00110 // and inline the fn if it is technically possible to do so.
00111 #define INLINE __forceinline
00112 #else
00113 #define INLINE inline
00114 #endif
00115 
00116 #if defined(WIN32_VC) && !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES)
00117 // This macro must be used to export an instantiated template class
00118 // from a DLL.  If the template class name itself contains commas, it
00119 // may be necessary to first define a macro for the class name, to
00120 // allow proper macro parameter passing.
00121 #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) \
00122   exptp template class expcl classname;
00123 #else
00124 #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname)
00125 #endif
00126 
00127 // We define the macro PUBLISHED to mark C++ methods that are to be
00128 // published via interrogate to scripting languages.  However, if
00129 // we're not running the interrogate pass (CPPPARSER isn't defined),
00130 // this maps to public.
00131 #define PUBLISHED public
00132 
00133 #endif  // CPPPARSER
00134 
00135 // Now redefine global operators new and delete so we can optionally
00136 // provide custom handlers for them.  The MemoryUsage class in Panda
00137 // takes advantage of this to track the size of allocated pointers.
00138 #ifndef NDEBUG
00139 EXPCL_DTOOL void *default_operator_new(size_t size);
00140 EXPCL_DTOOL void default_operator_delete(void *ptr);
00141 
00142 extern EXPCL_DTOOL void *(*global_operator_new)(size_t size);
00143 extern EXPCL_DTOOL void (*global_operator_delete)(void *ptr);
00144 
00145 #ifdef GLOBAL_OPERATOR_NEW_EXCEPTIONS
00146 
00147 // Redefinitions of operator new/delete, for O1 - O3 builds (!NDEBUG)
00148 // only.  These flavors are for modern compilers that expect these
00149 // function prototypes to handle exceptions.
00150 INLINE void *operator new(size_t size) throw (std::bad_alloc) {
00151   return (*global_operator_new)(size);
00152 }
00153 INLINE void *operator new[](size_t size) throw (std::bad_alloc) {
00154   return (*global_operator_new)(size);
00155 }
00156 
00157 INLINE void operator delete(void *ptr) throw() {
00158   (*global_operator_delete)(ptr);
00159 }
00160 INLINE void operator delete[](void *ptr) throw() {
00161   (*global_operator_delete)(ptr);
00162 }
00163 #else   // GLOBAL_OPERATOR_NEW_EXCEPTIONS
00164 
00165 // The same definitions as above, for compilers that don't expect
00166 // exception handing in global operator new/delete functions.
00167 INLINE void *operator new(size_t size) {
00168   return (*global_operator_new)(size);
00169 }
00170 INLINE void *operator new[](size_t size) {
00171   return (*global_operator_new)(size);
00172 }
00173 
00174 INLINE void operator delete(void *ptr) {
00175   (*global_operator_delete)(ptr);
00176 }
00177 INLINE void operator delete[](void *ptr) {
00178   (*global_operator_delete)(ptr);
00179 }
00180 
00181 #endif  // GLOBAL_OPERATOR_NEW_EXCEPTIONS
00182 #endif  // NDEBUG
00183 
00184 #endif

Generated on Thu May 1 22:12:58 2003 for DTool by doxygen1.3