The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
defs.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * defs.h - Global defines, mostly platform-specific stuff
4  *
5  * $Id: defs.h 3823 2020-11-03 23:20:40Z scribe $
6  *
7  * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 // ----------------------------------------------------------------------------
23 //
24 // ----------------------------------------------------------------------------
25 #ifndef SWORDDEFS_H
26 #define SWORDDEFS_H
27 
28 // support for compilers with no namespace support
29 // TODO: What is this? jansorg, why does NO_SWORD_NAMESPACE still define
30 // a C++ namespace, and then force using it? This makes no sense to me.
31 // see commit 1195
32 #ifdef NO_SWORD_NAMESPACE
33  #define SWORD_NAMESPACE_START namespace sword {
34  #define SWORD_NAMESPACE_END }; using namespace sword;
35 #elif defined(__cplusplus)
36  #define SWORD_NAMESPACE_START namespace sword {
37  #define SWORD_NAMESPACE_END }
38 #else
39  #define SWORD_NAMESPACE_START
40  #define SWORD_NAMESPACE_END
41 #endif
42 
44 
45 
46 // support for compilers with no RTTI
47 #define SWDYNAMIC_CAST(className, object) dynamic_cast<className *>(object)
48 
49 #ifdef NODYNCAST
50 // avoid redefined warnings
51 #undef SWDYNAMIC_CAST
52 #define SWDYNAMIC_CAST(className, object) (className *)((object)?((object->getClass()->isAssignableFrom(#className))?object:0):0)
53 #endif
54 
55 
56 // support for compilers with no exception support
57 #define SWTRY try
58 #define SWCATCH(x) catch (x)
59 
60 #ifdef _WIN32_WCE
61 #define SWTRY
62 #define SWCATCH(x) if (0)
63 #define GLOBCONFPATH "/Program Files/sword/sword.conf"
64 #endif
65 
66 #ifdef ANDROID
67 #define _NO_IOSTREAM_
68 #undef SWTRY
69 #undef SWCATCH
70 #define SWTRY
71 #define SWCATCH(x) if (0)
72 #endif
73 
74 // support for export / import of symbols from shared objects
75 // _declspec works in BC++ 5 and later, as well as VC++
76 #if defined(_MSC_VER)
77 
78 # ifdef SWMAKINGDLL
79 # define SWDLLEXPORT _declspec( dllexport )
80 # define SWDLLEXPORT_DATA(type) _declspec( dllexport ) type
81 # define SWDLLEXPORT_CTORFN
82 # elif defined(SWUSINGDLL)
83 # define SWDLLEXPORT _declspec( dllimport )
84 # define SWDLLEXPORT_DATA(type) _declspec( dllimport ) type
85 # define SWDLLEXPORT_CTORFN
86 # else
87 # define SWDLLEXPORT
88 # define SWDLLEXPORT_DATA(type) type
89 # define SWDLLEXPORT_CTORFN
90 # endif
91 
92 // support for deprecated annotation
93 # define SWDEPRECATED __declspec(deprecated("** WARNING: deprecated method **"))
94 
95 
96 #elif defined(__SWPM__)
97 
98 # ifdef SWMAKINGDLL
99 # define SWDLLEXPORT _Export
100 # define SWDLLEXPORT_DATA(type) _Export type
101 # define SWDLLEXPORT_CTORFN
102 # elif defined(SWUSINGDLL)
103 # define SWDLLEXPORT _Export
104 # define SWDLLEXPORT_DATA(type) _Export type
105 # define SWDLLEXPORT_CTORFN
106 # else
107 # define SWDLLEXPORT
108 # define SWDLLEXPORT_DATA(type) type
109 # define SWDLLEXPORT_CTORFN
110 # endif
111 
112 # define SWDEPRECATED
113 
114 
115 #elif defined(__GNUWIN32__)
116 
117 # ifdef SWMAKINGDLL
118 # define SWDLLEXPORT __declspec( dllexport )
119 # define SWDLLEXPORT_DATA(type) __declspec( dllexport ) type
120 # define SWDLLEXPORT_CTORFN
121 # elif defined(SWUSINGDLL)
122 # define SWDLLEXPORT __declspec( dllimport )
123 # define SWDLLEXPORT_DATA(type) __declspec( dllimport ) type
124 # define SWDLLEXPORT_CTORFN
125 # else
126 # define SWDLLEXPORT
127 # define SWDLLEXPORT_DATA(type) type
128 # define SWDLLEXPORT_CTORFN
129 # endif
130 
131 # define SWDEPRECATED __attribute__((__deprecated__))
132 
133 
134 #elif defined(__BORLANDC__)
135 #define NOVARMACS
136 # ifdef SWMAKINGDLL
137 # define SWDLLEXPORT _export
138 # define SWDLLEXPORT_DATA(type) __declspec( dllexport ) type
139 # define SWDLLEXPORT_CTORFN
140 # elif defined(SWUSINGDLL)
141 # define SWDLLEXPORT __declspec( dllimport )
142 # define SWDLLEXPORT_DATA(type) __declspec( dllimport ) type
143 # define SWDLLEXPORT_CTORFN
144 # else
145 # define SWDLLEXPORT
146 # define SWDLLEXPORT_DATA(type) type
147 # define SWDLLEXPORT_CTORFN
148 # endif
149 
150 
151 #define COMMENT SLASH(/)
152 #define SLASH(s) /##s
153 /* Use the following line to comment out all deprecation declarations so you
154  * get "no such method" errors in your code when you want to find them.
155  * Use the next line to put them back in.
156  */
157 //# define SWDEPRECATED COMMENT
158 # define SWDEPRECATED
159 #define va_copy(dest, src) (dest = src)
160 #define unorm2_getNFKDInstance(x) unorm2_getInstance(NULL, "nfkc", UNORM2_DECOMPOSE, x)
161 
162 
163 #elif defined(__GNUC__)
164 # define SWDLLEXPORT
165 # define SWDLLEXPORT_DATA(type) type
166 # define SWDLLEXPORT_CTORFN
167 # define SWDEPRECATED __attribute__((__deprecated__))
168 
169 
170 #else
171 # define SWDLLEXPORT
172 # define SWDLLEXPORT_DATA(type) type
173 # define SWDLLEXPORT_CTORFN
174 # define SWDEPRECATED
175 #endif
176 
177 
178 // For ostream, istream ofstream
179 #if defined(__BORLANDC__) && defined( _RTLDLL )
180 # define SWDLLIMPORT __import
181 #else
182 # define SWDLLIMPORT
183 #endif
184 
185 #ifndef NOVARMACS
186 #ifndef STRIPLOGD
187 #define SWLOGD(...) SWLog::getSystemLog()->logDebug(__VA_ARGS__)
188 #else
189 #define SWLOGD(...) (void)0
190 #endif
191 
192 #ifndef STRIPLOGI
193 #define SWLOGI(...) SWLog::getSystemLog()->logInformation(__VA_ARGS__)
194 #define SWLOGTI(...) SWLog::getSystemLog()->logTimedInformation(__VA_ARGS__)
195 #else
196 #define SWLOGI(...) (void)0
197 #define SWLOGTI(...) (void)0
198 #endif
199 #else
200 #ifndef STRIPLOGD
201 #define SWLOGD SWLog::getSystemLog()->logDebug
202 #else
203 #define SWLOGD COMMENT
204 #endif
205 
206 #ifndef STRIPLOGI
207 #define SWLOGI SWLog::getSystemLog()->logInformation
208 #define SWLOGTI SWLog::getSystemLog()->logTimedInformation
209 #else
210 #define SWLOGI COMMENT
211 #define SWLOGTI COMMENT
212 #endif
213 #endif
214 
215 
217 #endif //SWORDDEFS_H
#define SWORD_NAMESPACE_START
Definition: defs.h:39
#define SWORD_NAMESPACE_END
Definition: defs.h:40