nscore.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef nscore_h___
00038 #define nscore_h___
00039
00040
00041
00042
00043 #include "prtypes.h"
00044
00045
00046
00047
00048
00049
00050 #ifdef _WIN32
00051 #define NS_WIN32 1
00052
00053 #elif defined(__unix)
00054 #define NS_UNIX 1
00055
00056 #elif defined(XP_OS2)
00057 #define NS_OS2 1
00058 #endif
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 #ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
00095 #define NS_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden")))
00096 #else
00097 #define NS_VISIBILITY_HIDDEN
00098 #endif
00099
00100 #if defined(HAVE_VISIBILITY_ATTRIBUTE)
00101 #define NS_VISIBILITY_DEFAULT __attribute__ ((visibility ("default")))
00102 #else
00103 #define NS_VISIBILITY_DEFAULT
00104 #endif
00105
00106 #define NS_HIDDEN_(type) NS_VISIBILITY_HIDDEN type
00107 #define NS_EXTERNAL_VIS_(type) NS_VISIBILITY_DEFAULT type
00108
00109 #define NS_HIDDEN NS_VISIBILITY_HIDDEN
00110 #define NS_EXTERNAL_VIS NS_VISIBILITY_DEFAULT
00111
00112 #undef IMETHOD_VISIBILITY
00113 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 #if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
00136 #define NS_FASTCALL __attribute__ ((regparm (3), stdcall))
00137 #else
00138 #define NS_FASTCALL
00139 #endif
00140
00141
00142
00143
00144
00145 #if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
00146 #define NS_DEFCALL __attribute__ ((regparm (0), cdecl))
00147 #else
00148 #define NS_DEFCALL
00149 #endif
00150
00151 #ifdef NS_WIN32
00152
00153 #define NS_IMPORT __declspec(dllimport)
00154 #define NS_IMPORT_(type) type __declspec(dllimport) __stdcall
00155 #define NS_EXPORT __declspec(dllexport)
00156 #define NS_EXPORT_(type) type __declspec(dllexport) __stdcall
00157 #define NS_IMETHOD_(type) virtual type __stdcall
00158 #define NS_IMETHODIMP_(type) type __stdcall
00159 #define NS_METHOD_(type) type __stdcall
00160 #define NS_CALLBACK_(_type, _name) _type (__stdcall * _name)
00161 #define NS_STDCALL __stdcall
00162
00163
00164
00165
00166
00167
00168 #define NS_EXPORT_STATIC_MEMBER_(type) type
00169 #define NS_IMPORT_STATIC_MEMBER_(type) type
00170
00171 #else
00172
00173 #define NS_IMPORT NS_EXTERNAL_VIS
00174 #define NS_IMPORT_(type) NS_EXTERNAL_VIS_(type)
00175 #define NS_EXPORT NS_EXTERNAL_VIS
00176 #define NS_EXPORT_(type) NS_EXTERNAL_VIS_(type)
00177 #define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL
00178 #define NS_IMETHODIMP_(type) type
00179 #define NS_METHOD_(type) type
00180 #define NS_CALLBACK_(_type, _name) _type (* _name)
00181 #define NS_STDCALL
00182 #define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
00183 #define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
00184
00185 #endif
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 #ifdef __GNUC__
00207 #define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
00208 typeof(&class::func) name
00209 #else
00210 #define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
00211 ret (NS_STDCALL class::*name) args
00212 #endif
00213
00214
00215
00216
00217 #define NS_IMETHOD NS_IMETHOD_(nsresult)
00218 #define NS_IMETHODIMP NS_IMETHODIMP_(nsresult)
00219 #define NS_METHOD NS_METHOD_(nsresult)
00220 #define NS_CALLBACK(_name) NS_CALLBACK_(nsresult, _name)
00221
00222
00223
00224
00225
00226 #ifdef _IMPL_NS_COM
00227 #define NS_COM NS_EXPORT
00228 #elif defined(_IMPL_NS_COM_OFF)
00229 #define NS_COM
00230 #elif defined(XPCOM_GLUE)
00231 #define NS_COM
00232 #else
00233 #define NS_COM NS_IMPORT
00234 #endif
00235
00236 #ifdef MOZILLA_INTERNAL_API
00237 # define NS_COM_GLUE NS_COM
00238
00239
00240
00241
00242
00243
00244
00245 # define nsAString nsAString_internal
00246 # define nsACString nsACString_internal
00247 #else
00248 # define NS_COM_GLUE
00249 #endif
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 #ifdef NS_NO_VTABLE
00260 #undef NS_NO_VTABLE
00261 #endif
00262 #if defined(_MSC_VER) && _MSC_VER >= 1100
00263 #define NS_NO_VTABLE __declspec(novtable)
00264 #else
00265 #define NS_NO_VTABLE
00266 #endif
00267
00268
00269
00270
00271
00272 typedef PRUint32 nsresult;
00273
00274
00275
00276
00277 #define nsnull 0
00278
00279 #include "nsError.h"
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 #ifdef __MWERKS__
00294 #define HAVE_CPP_PARTIAL_SPECIALIZATION
00295 #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
00296
00297 #define HAVE_CPP_ACCESS_CHANGING_USING
00298 #define HAVE_CPP_AMBIGUITY_RESOLVING_USING
00299 #define HAVE_CPP_EXPLICIT
00300 #define HAVE_CPP_TYPENAME
00301 #define HAVE_CPP_BOOL
00302 #define HAVE_CPP_NAMESPACE_STD
00303 #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
00304 #define HAVE_CPP_2BYTE_WCHAR_T
00305 #endif
00306
00307
00308 #if defined(_MSC_VER) && (_MSC_VER>=1100)
00309
00310 #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
00311
00312 #define HAVE_CPP_EXPLICIT
00313 #define HAVE_CPP_TYPENAME
00314 #define HAVE_CPP_ACCESS_CHANGING_USING
00315
00316 #if (_MSC_VER==1100)
00317
00318 #undef HAVE_CPP_ACCESS_CHANGING_USING
00319 #endif
00320
00321 #define HAVE_CPP_NAMESPACE_STD
00322 #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
00323 #define HAVE_CPP_2BYTE_WCHAR_T
00324 #endif
00325
00326 #ifndef __PRUNICHAR__
00327 #define __PRUNICHAR__
00328
00329
00330
00331
00332 #if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32)
00333 typedef wchar_t PRUnichar;
00334 #else
00335 typedef PRUint16 PRUnichar;
00336 #endif
00337 #endif
00338
00339
00340
00341
00342
00343 #ifndef HAVE_CPP_EXPLICIT
00344 #define explicit
00345 #endif
00346
00347 #ifndef HAVE_CPP_TYPENAME
00348 #define typename
00349 #endif
00350
00351 #ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
00352 #define NS_SPECIALIZE_TEMPLATE template <>
00353 #else
00354 #define NS_SPECIALIZE_TEMPLATE
00355 #endif
00356
00357
00358 #if ! defined XP_UNIX && ! defined XP_BEOS && !defined(XP_OS2)
00359 #ifndef HAVE_CPP_NEW_CASTS
00360 #define HAVE_CPP_NEW_CASTS 1
00361 #endif
00362 #endif
00363
00364 #if defined(HAVE_CPP_NEW_CASTS)
00365 #define NS_STATIC_CAST(__type, __ptr) static_cast< __type >(__ptr)
00366 #define NS_CONST_CAST(__type, __ptr) const_cast< __type >(__ptr)
00367
00368 #define NS_REINTERPRET_POINTER_CAST(__type, __ptr) reinterpret_cast< __type >(__ptr)
00369 #define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) reinterpret_cast< __type >(__obj)
00370 #define NS_REINTERPRET_CAST(__type, __expr) reinterpret_cast< __type >(__expr)
00371
00372 #else
00373 #define NS_STATIC_CAST(__type, __ptr) ((__type)(__ptr))
00374 #define NS_CONST_CAST(__type, __ptr) ((__type)(__ptr))
00375
00376 #define NS_REINTERPRET_POINTER_CAST(__type, __ptr) ((__type)((void*)(__ptr)))
00377 #define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) ((__type)(__obj))
00378
00379
00380 #define NS_REINTERPRET_CAST(__type, __expr) NS_REINTERPRET_POINTER_CAST(__type, __expr)
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 #endif
00410
00411
00412
00413
00414
00415 #define NS_PTR_TO_INT32(x) ((PRInt32) (PRWord) (x))
00416 #define NS_PTR_TO_UINT32(x) ((PRUint32) (PRWord) (x))
00417 #define NS_INT32_TO_PTR(x) ((void *) (PRWord) (x))
00418
00419
00420
00421
00422 #define NS_STRINGIFY_HELPER(x_) #x_
00423 #define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_)
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 #if defined(__GNUC__) && (__GNUC__ > 2)
00440 #define NS_LIKELY(x) (__builtin_expect((x), 1))
00441 #define NS_UNLIKELY(x) (__builtin_expect((x), 0))
00442 #else
00443 #define NS_LIKELY(x) (x)
00444 #define NS_UNLIKELY(x) (x)
00445 #endif
00446
00447 #endif