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

Generated on Sat Apr 19 18:54:38 2003 for Simkin by doxygen1.3