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

Generated on Tue May 27 18:40:51 2003 for Simkin C++ for Symbian by doxygen1.3