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.15 2003/11/20 17:20:22 sdw Exp $
00020 */
00021 #ifndef skGENERAL_H
00022 #define skGENERAL_H
00023 
00024 #if defined(_MSC_VER)
00025 #if (_MSC_VER<=1300)
00026 #define USE_DEBUG_NEW
00027 #endif
00028 #endif
00029 
00030 #ifndef __SYMBIAN32__
00031 #if defined(USE_DEBUG_NEW)
00032    #ifdef _DEBUG
00033       #define MYDEBUG_NEW   new( _NORMAL_BLOCK, __FILE__, __LINE__)
00034        // Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
00035        //allocations to be of _CLIENT_BLOCK type
00036    #else
00037       #define MYDEBUG_NEW
00038    #endif // _DEBUG
00039 #endif
00040 #endif
00041 
00042 
00043 #ifdef __SYMBIAN32__
00044 #include <E32BASE.H>
00045 #include <stdlib.h>
00046 #include <string.h>
00047 #include <stdio.h>
00048 #include "skSymbian.h"
00049 #include <eikenv.h>
00050 #else
00051 #include <stdlib.h>
00052 #endif
00053 
00054 typedef unsigned int USize;
00055 
00056 #ifndef max
00057 #define max(a,b) (((a)>(b))?(a):(b))
00058 #endif
00059 #ifndef min
00060 #define min(a,b) (((a)<(b))?(a):(b))
00061 #endif
00062 
00063 // Windows Specific Thread Control...
00064 // We use this for skInterpreter::getInterpreter()
00065 // What we should do is have a method whereby the curent interpreter is set into each executable
00066 // object, so that it can be reused when that object spawns a new one.
00067 // At present, this only occurs in skTreeNodeObject and skXMLElementObject
00068 // TODO: Define thread control for other platforms!!!
00069 #ifdef ENABLE_WINDOWS_THREAD_SUPPORT
00070 #if defined(_MSC_VER) && (_MSC_VER >= 1200 )
00071 #define THREAD __declspec(thread)
00072 #else
00073 #define THREAD
00074 #endif
00075 #else
00076 #define THREAD
00077 #endif
00078 
00079 // define ENABLE_WINDOWS_DLL_SUPPORT when using a Windows DLL version of Simkin. 
00080 // then define BUILDING_DLL when building the Simkin DLL
00081 
00082 #ifdef ENABLE_WINDOWS_DLL_SUPPORT
00083  #if defined(_MSC_VER)
00084   #define LIBIMPORT       __declspec( dllimport )
00085   #define LIBEXPORT       __declspec( dllexport )
00086   #endif
00087  #if defined(BUILDING_DLL)
00088   #define CLASSEXPORT     LIBEXPORT
00089   #define EXTERN_TEMPLATE
00090  #else
00091   #define CLASSEXPORT     LIBIMPORT
00092   #define EXTERN_TEMPLATE extern
00093  #endif 
00094 #else
00095 #ifdef __SYMBIAN32__
00096 #define CLASSEXPORT     
00097 #else
00098 // TODO: Dynamic linking declarations for other platforms?
00099  #define LIBIMPORT       
00100  #define LIBEXPORT       
00101  #define CLASSEXPORT
00102  #define EXTERN_TEMPLATE 
00103 #endif
00104 #endif
00105 
00106 #ifndef __SYMBIAN32__
00107 // adds code to instantiate various templates- not necessary on MetroWerks CodeWarrior?
00108 #define INSTANTIATE_TEMPLATES
00109 #define IMPORT_C
00110 #define EXPORT_C
00111 #endif
00112 
00113 // define this to enable floating point support
00114 #define USE_FLOATING_POINT 1
00115 
00116 // define this to enable execution scripts via the parse tree, rather than the new smaller representation
00117 #define EXECUTE_PARSENODES 1
00118 
00119 
00120 #if defined(USE_DEBUG_NEW)
00121 #ifndef __SYMBIAN32__
00122 #ifdef _DEBUG
00123 #define _CRTDBG_MAP_ALLOC
00124 #define _INC_MALLOC
00125 #include <crtdbg.h>
00126 #endif
00127 #endif
00128 #endif
00129 
00130 
00131 #ifndef __SYMBIAN32__
00132 #if defined(USE_DEBUG_NEW)
00133    #ifdef _DEBUG
00134    #undef new
00135    #define new MYDEBUG_NEW
00136    #endif
00137 #endif
00138 #endif
00139 
00140 #ifdef __SYMBIAN32__
00141 // Symbian does not support exceptions or streams, but does use unicode
00142 #include <assert.h>
00143 #if defined(_UNICODE)
00144 #define UNICODE_STRINGS
00145 #endif
00146 
00147 inline void ExitSystem()
00148 {
00149   User::Leave(KErrGeneral);
00150 }
00152 #define skNEW(a) new (ELeave) a
00153 #define skARRAY_NEW(type,size) new (ELeave) type[size]
00154 // puts a pointer into the cleanup stack
00155 #define SAVE_POINTER(p) CleanupDeletePushL((p))
00156 #define SAVE_VARIABLE(p) CleanupStack::PushL((p))
00157 // removes the pointer, but doesn't delete it - it is assumed the method does this if it exits normally
00158 #define RELEASE_POINTER(p) CleanupStack::Pop(p)
00159 // removes the variable - don't call destroy as the destructor is called if the method exits normally
00160 #define RELEASE_VARIABLE(p) CleanupStack::Pop(&p)
00161 #else
00162 
00163 #define skNEW(a) new a
00164 #define skARRAY_NEW(type,size) new type[size]
00165 #define SAVE_POINTER(p) 
00166 #define RELEASE_POINTER(p) 
00167 #define SAVE_VARIABLE(p)
00168 #define RELEASE_VARIABLE(p) 
00169 // Look out for Windows CE - which doesn't support streams or exceptions or assert!
00170 #ifdef _WIN32_WCE
00171 #include <windows.h>
00172 #include <dbgapi.h>
00173 #define assert ASSERT
00174 #define UNICODE_STRINGS
00175 
00176 inline void ExitSystem()
00177 {
00178   exit(EXIT_FAILURE);
00179 }
00180 #else
00181 #define STREAMS_ENABLED
00182 #if (_MSC_VER>1300)
00183 #define STL_STREAMS 1
00184 #endif
00185 #define EXCEPTIONS_DEFINED
00186 #include <assert.h>
00187 #endif
00188 #endif
00189 #endif

Generated on Thu Nov 20 15:48:33 2003 for Simkin by doxygen1.3