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

skGeneral.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019   $Id: skGeneral_8h-source.html,v 1.7 2004/12/17 21:31:15 sdw Exp $
00020 */
00021 #ifndef skGENERAL_H
00022 #define skGENERAL_H
00023 
00024 #if defined(_MSC_VER)
00025 #if (_MSC_VER<=1300)
00026 #ifndef STL_STREAMS
00027 // STL streams introduce STL versions of new and delete
00028 #define USE_DEBUG_NEW
00029 #endif
00030 #endif
00031 #endif
00032 
00033 #ifndef __SYMBIAN32__
00034 #if defined(USE_DEBUG_NEW)
00035    #ifdef _DEBUG
00036       #define MYDEBUG_NEW   new( _NORMAL_BLOCK, __FILE__, __LINE__)
00037        // Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
00038        //allocations to be of _CLIENT_BLOCK type
00039    #else
00040       #define MYDEBUG_NEW
00041    #endif // _DEBUG
00042 #endif
00043 #endif
00044 
00045 
00046 #ifdef __SYMBIAN32__
00047 #include <E32BASE.H>
00048 #include <stdlib.h>
00049 #include <string.h>
00050 #include <stdio.h>
00051 #include "skSymbian.h"
00052 #include <eikenv.h>
00053 #else
00054 #include <stdlib.h>
00055 #endif
00056 
00057 typedef unsigned int USize;
00058 
00059 #ifndef max
00060 #define max(a,b) (((a)>(b))?(a):(b))
00061 #endif
00062 #ifndef min
00063 #define min(a,b) (((a)<(b))?(a):(b))
00064 #endif
00065 
00066 // Windows Specific Thread Control...
00067 // We use this for skInterpreter::getInterpreter()
00068 // What we should do is have a method whereby the curent interpreter is set into each executable
00069 // object, so that it can be reused when that object spawns a new one.
00070 // At present, this only occurs in skTreeNodeObject and skXMLElementObject
00071 // TODO: Define thread control for other platforms!!!
00072 #ifdef ENABLE_WINDOWS_THREAD_SUPPORT
00073 #if defined(_MSC_VER) && (_MSC_VER >= 1200 )
00074 #define THREAD __declspec(thread)
00075 #else
00076 #define THREAD
00077 #endif
00078 #else
00079 #define THREAD
00080 #endif
00081 
00082 // define ENABLE_WINDOWS_DLL_SUPPORT when using a Windows DLL version of Simkin. 
00083 // then define BUILDING_DLL when building the Simkin DLL
00084 
00085 #ifdef ENABLE_WINDOWS_DLL_SUPPORT
00086  #if defined(_MSC_VER)
00087   #define LIBIMPORT       __declspec( dllimport )
00088   #define LIBEXPORT       __declspec( dllexport )
00089   #endif
00090  #if defined(BUILDING_DLL)
00091   #define CLASSEXPORT     LIBEXPORT
00092   #define EXTERN_TEMPLATE
00093  #else
00094   #define CLASSEXPORT     LIBIMPORT
00095   #define EXTERN_TEMPLATE extern
00096  #endif 
00097 #else
00098 #ifdef __SYMBIAN32__
00099 #define CLASSEXPORT     
00100 #else
00101 // TODO: Dynamic linking declarations for other platforms?
00102  #define LIBIMPORT       
00103  #define LIBEXPORT       
00104  #define CLASSEXPORT
00105  #define EXTERN_TEMPLATE 
00106 #endif
00107 #endif
00108 
00109 #ifndef __SYMBIAN32__
00110 // adds code to instantiate various templates- not necessary on MetroWerks CodeWarrior?
00111 #define INSTANTIATE_TEMPLATES
00112 #define IMPORT_C
00113 #define EXPORT_C
00114 #endif
00115 
00116 // define this to enable floating point support
00117 #define USE_FLOATING_POINT 1
00118 
00119 // define this to enable execution scripts via the parse tree, rather than the new smaller representation
00120 #define EXECUTE_PARSENODES 1
00121 
00122 
00123 #if defined(USE_DEBUG_NEW)
00124 #ifndef __SYMBIAN32__
00125 #ifdef _DEBUG
00126 #define _CRTDBG_MAP_ALLOC
00127 #define _INC_MALLOC
00128 #include <crtdbg.h>
00129 #endif
00130 #endif
00131 #endif
00132 
00133 
00134 #ifndef __SYMBIAN32__
00135 #if defined(USE_DEBUG_NEW)
00136    #ifdef _DEBUG
00137    #undef new
00138    #define new MYDEBUG_NEW
00139    #endif
00140 #endif
00141 #endif
00142 
00143 #ifdef __SYMBIAN32__
00144 // Symbian does not support exceptions or streams, but does use unicode
00145 #include <assert.h>
00146 #if defined(_UNICODE)
00147 #define UNICODE_STRINGS
00148 #endif
00149 
00150 inline void ExitSystem()
00151 {
00152   User::Leave(KErrGeneral);
00153 }
00155 #define skNEW(a) new (ELeave) a
00156 #define skARRAY_NEW(type,size) new (ELeave) type[size]
00157 // puts a pointer into the cleanup stack
00158 #define SAVE_POINTER(p) CleanupDeletePushL((p))
00159 #define SAVE_VARIABLE(p) CleanupStack::PushL((p))
00160 // removes the pointer, but doesn't delete it - it is assumed the method does this if it exits normally
00161 #define RELEASE_POINTER(p) CleanupStack::Pop(p)
00162 // removes the variable - don't call destroy as the destructor is called if the method exits normally
00163 #define RELEASE_VARIABLE(p) CleanupStack::Pop(&p)
00164 #else
00165 
00166 #define skNEW(a) new a
00167 #define skARRAY_NEW(type,size) new type[size]
00168 #define SAVE_POINTER(p) 
00169 #define RELEASE_POINTER(p) 
00170 #define SAVE_VARIABLE(p)
00171 #define RELEASE_VARIABLE(p) 
00172 // Look out for Windows CE - which doesn't support streams or exceptions or assert!
00173 #ifdef _WIN32_WCE
00174 #include <windows.h>
00175 #include <dbgapi.h>
00176 #define assert ASSERT
00177 #define UNICODE_STRINGS
00178 
00179 inline void ExitSystem()
00180 {
00181   exit(EXIT_FAILURE);
00182 }
00183 #else
00184 #define STREAMS_ENABLED
00185 #if (_MSC_VER>1300)
00186 #define STL_STREAMS 1
00187 #endif
00188 #define EXCEPTIONS_DEFINED
00189 #include <assert.h>
00190 #endif
00191 #endif
00192 #endif

Generated on Fri Dec 17 20:28:26 2004 for Simkin C++ for Symbian by doxygen1.3