2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-05-19 01:43:13 +04:00
|
|
|
#ifndef nscore_h___
|
|
|
|
#define nscore_h___
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Incorporate the core NSPR data types which XPCOM uses.
|
|
|
|
*/
|
|
|
|
#include "prtypes.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Core XPCOM declarations. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Macros defining the target platform...
|
|
|
|
*/
|
1999-05-19 01:43:13 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define NS_WIN32 1
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#elif defined(__unix)
|
1999-05-19 01:43:13 +04:00
|
|
|
#define NS_UNIX 1
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#elif defined(XP_OS2)
|
2000-02-29 18:50:48 +03:00
|
|
|
#define NS_OS2 1
|
|
|
|
#endif
|
1999-05-19 01:43:13 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* Import/export defines */
|
|
|
|
|
|
|
|
#ifdef NS_WIN32
|
2001-09-27 07:43:00 +04:00
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#define NS_IMPORT _declspec(dllimport)
|
|
|
|
#define NS_IMPORT_(type) type _declspec(dllimport) __stdcall
|
|
|
|
#define NS_EXPORT _declspec(dllexport)
|
|
|
|
#define NS_EXPORT_(type) type _declspec(dllexport) __stdcall
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_IMETHOD_(type) virtual type __stdcall
|
|
|
|
#define NS_IMETHODIMP_(type) type __stdcall
|
|
|
|
#define NS_METHOD_(type) type __stdcall
|
|
|
|
#define NS_CALLBACK_(_type, _name) _type (__stdcall * _name)
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#elif defined(XP_MAC)
|
|
|
|
|
|
|
|
#define NS_IMPORT
|
|
|
|
#define NS_IMPORT_(type) type
|
|
|
|
#define NS_EXPORT __declspec(export)
|
|
|
|
#define NS_EXPORT_(type) __declspec(export) type
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_IMETHOD_(type) virtual type
|
|
|
|
#define NS_IMETHODIMP_(type) type
|
|
|
|
#define NS_METHOD_(type) type
|
|
|
|
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
|
|
|
|
|
|
|
#elif defined(XP_OS2)
|
1999-05-19 01:43:13 +04:00
|
|
|
|
|
|
|
#define NS_IMPORT
|
|
|
|
#define NS_IMPORT_(type) type
|
|
|
|
#define NS_EXPORT
|
|
|
|
#define NS_EXPORT_(type) type
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_IMETHOD_(type) virtual type
|
|
|
|
#define NS_IMETHODIMP_(type) type
|
|
|
|
#define NS_METHOD_(type) type
|
2001-09-27 20:04:44 +04:00
|
|
|
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
1999-05-19 01:43:13 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_IMPORT
|
|
|
|
#define NS_IMPORT_(type) type
|
|
|
|
#define NS_EXPORT
|
|
|
|
#define NS_EXPORT_(type) type
|
|
|
|
#define NS_IMETHOD_(type) virtual type
|
|
|
|
#define NS_IMETHODIMP_(type) type
|
|
|
|
#define NS_METHOD_(type) type
|
|
|
|
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Generic API modifiers which return the standard XPCOM nsresult type
|
|
|
|
*/
|
|
|
|
#define NS_IMETHOD NS_IMETHOD_(nsresult)
|
|
|
|
#define NS_IMETHODIMP NS_IMETHODIMP_(nsresult)
|
|
|
|
#define NS_METHOD NS_METHOD_(nsresult)
|
|
|
|
#define NS_CALLBACK(_name) NS_CALLBACK_(nsresult, _name)
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Import/Export macros for XPCOM APIs
|
|
|
|
*/
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#ifdef _IMPL_NS_COM
|
|
|
|
#define NS_COM NS_EXPORT
|
2002-03-22 02:43:21 +03:00
|
|
|
#elif _IMPL_NS_COM_OFF
|
|
|
|
#define NS_COM
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_COM NS_IMPORT
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* NS_NO_VTABLE is emitted by xpidl in interface declarations whenever
|
|
|
|
* xpidl can determine that the interface can't contain a constructor.
|
|
|
|
* This results in some space savings and possible runtime savings -
|
|
|
|
* see bug 49416. We undefine it first, as xpidl-generated headers
|
|
|
|
* define it for IDL uses that don't include this file.
|
|
|
|
*/
|
|
|
|
#ifdef NS_NO_VTABLE
|
|
|
|
#undef NS_NO_VTABLE
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
2001-09-27 07:43:00 +04:00
|
|
|
#if defined(_MSC_VER) && _MSC_VER >= 1100
|
|
|
|
#define NS_NO_VTABLE __declspec(novtable)
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_NO_VTABLE
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Generic XPCOM result data type
|
|
|
|
*/
|
|
|
|
typedef PRUint32 nsresult;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The preferred symbol for null.
|
|
|
|
*/
|
|
|
|
#define nsnull 0
|
1999-05-19 01:43:13 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
1999-06-04 06:00:19 +04:00
|
|
|
/* Casting macros for hiding C++ features from older compilers */
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2000-01-13 08:48:47 +03:00
|
|
|
/*
|
|
|
|
All our compiler support template specialization, but not all support the
|
|
|
|
|template <>| notation. The compiler that don't understand this notation
|
|
|
|
just omit it for specialization.
|
|
|
|
|
|
|
|
Need to add an autoconf test for this.
|
|
|
|
*/
|
|
|
|
|
2000-01-14 02:06:47 +03:00
|
|
|
/* under Metrowerks (Mac), we don't have autoconf yet */
|
2000-01-13 08:48:47 +03:00
|
|
|
#ifdef __MWERKS__
|
|
|
|
#define HAVE_CPP_SPECIALIZATION
|
2000-04-26 04:55:37 +04:00
|
|
|
#define HAVE_CPP_PARTIAL_SPECIALIZATION
|
2000-01-13 08:48:47 +03:00
|
|
|
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
2000-03-18 02:08:29 +03:00
|
|
|
|
2000-06-05 04:46:37 +04:00
|
|
|
#define HAVE_CPP_ACCESS_CHANGING_USING
|
|
|
|
#define HAVE_CPP_AMBIGUITY_RESOLVING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
#define HAVE_CPP_EXPLICIT
|
2000-06-18 09:00:31 +04:00
|
|
|
#define HAVE_CPP_TYPENAME
|
2000-03-18 02:08:29 +03:00
|
|
|
#define HAVE_CPP_BOOL
|
2000-03-28 11:01:37 +04:00
|
|
|
#define HAVE_CPP_NAMESPACE_STD
|
2000-04-04 10:38:12 +04:00
|
|
|
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
2000-06-21 05:31:09 +04:00
|
|
|
#define HAVE_CPP_2BYTE_WCHAR_T
|
2000-03-28 11:01:37 +04:00
|
|
|
#endif
|
|
|
|
|
2000-01-14 02:06:47 +03:00
|
|
|
/* under VC++ (Windows), we don't have autoconf yet */
|
2000-01-13 08:48:47 +03:00
|
|
|
#if defined(_MSC_VER) && (_MSC_VER>=1100)
|
2000-01-14 02:06:47 +03:00
|
|
|
/* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */
|
2000-01-13 08:48:47 +03:00
|
|
|
#define HAVE_CPP_SPECIALIZATION
|
|
|
|
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
2000-03-18 02:08:29 +03:00
|
|
|
|
|
|
|
#define HAVE_CPP_EXPLICIT
|
2000-06-18 09:00:31 +04:00
|
|
|
#define HAVE_CPP_TYPENAME
|
2000-06-05 04:46:37 +04:00
|
|
|
#define HAVE_CPP_ACCESS_CHANGING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
|
|
|
|
#if (_MSC_VER<1100)
|
2000-09-13 16:22:17 +04:00
|
|
|
/* before 5.0, VC++ couldn't handle explicit */
|
2000-03-18 02:08:29 +03:00
|
|
|
#undef HAVE_CPP_EXPLICIT
|
|
|
|
#elif (_MSC_VER==1100)
|
2000-09-13 16:22:17 +04:00
|
|
|
/* VC++5.0 has an internal compiler error (sometimes) without this */
|
2000-06-05 04:46:37 +04:00
|
|
|
#undef HAVE_CPP_ACCESS_CHANGING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
#endif
|
2000-03-24 03:38:52 +03:00
|
|
|
|
2000-03-28 11:44:26 +04:00
|
|
|
#define HAVE_CPP_NAMESPACE_STD
|
2000-04-04 10:38:12 +04:00
|
|
|
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
2000-09-03 06:24:58 +04:00
|
|
|
#define HAVE_CPP_2BYTE_WCHAR_T
|
2000-06-13 04:05:18 +04:00
|
|
|
#endif
|
|
|
|
|
2000-06-19 01:27:27 +04:00
|
|
|
/* until we get an autoconf test for this, we'll assume it's on (since we're using it already) */
|
2000-06-18 09:00:31 +04:00
|
|
|
#define HAVE_CPP_TYPENAME
|
|
|
|
|
|
|
|
/* waiting to find out if OS/2 VisualAge participates in autoconf */
|
2002-01-25 18:07:38 +03:00
|
|
|
#if defined(XP_OS2_VACPP) || defined(AIX_XLC_364) || (defined(IRIX) && !defined(__GNUC__))
|
2000-06-18 09:00:31 +04:00
|
|
|
#undef HAVE_CPP_TYPENAME
|
|
|
|
#endif
|
|
|
|
|
2000-06-13 04:05:18 +04:00
|
|
|
|
|
|
|
#ifndef __PRUNICHAR__
|
|
|
|
#define __PRUNICHAR__
|
2001-05-21 20:34:20 +04:00
|
|
|
/* For now, don't use wchar_t on Unix because it breaks the Netscape
|
|
|
|
* commercial build. When this is fixed there will be no need for the
|
|
|
|
* |NS_REINTERPRET_CAST| in nsLiteralString.h either.
|
|
|
|
*/
|
2001-09-27 07:43:00 +04:00
|
|
|
#if defined(HAVE_CPP_2BYTE_WCHAR_T) && (defined(NS_WIN32) || defined(XP_MAC))
|
2001-05-21 20:34:20 +04:00
|
|
|
typedef wchar_t PRUnichar;
|
|
|
|
#else
|
|
|
|
typedef PRUint16 PRUnichar;
|
|
|
|
#endif
|
2000-01-13 08:48:47 +03:00
|
|
|
#endif
|
|
|
|
|
2000-06-10 13:58:15 +04:00
|
|
|
/*
|
|
|
|
If the compiler doesn't support |explicit|, we'll just make it go away, trusting
|
|
|
|
that the builds under compilers that do have it will keep us on the straight and narrow.
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_CPP_EXPLICIT
|
|
|
|
#define explicit
|
|
|
|
#endif
|
|
|
|
|
2000-06-18 09:00:31 +04:00
|
|
|
#ifndef HAVE_CPP_TYPENAME
|
|
|
|
#define typename
|
|
|
|
#endif
|
|
|
|
|
2000-01-13 08:48:47 +03:00
|
|
|
#ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
|
|
|
#define NS_SPECIALIZE_TEMPLATE template <>
|
|
|
|
#else
|
|
|
|
#define NS_SPECIALIZE_TEMPLATE
|
|
|
|
#endif
|
|
|
|
|
1999-07-28 01:22:56 +04:00
|
|
|
/* unix and beos now determine this automatically */
|
2000-02-29 18:50:48 +03:00
|
|
|
#if ! defined XP_UNIX && ! defined XP_BEOS && !defined(XP_OS2)
|
1999-06-04 06:00:19 +04:00
|
|
|
#define HAVE_CPP_NEW_CASTS /* we'll be optimistic. */
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CPP_NEW_CASTS)
|
2000-03-18 02:08:29 +03:00
|
|
|
#define NS_STATIC_CAST(__type, __ptr) static_cast< __type >(__ptr)
|
|
|
|
#define NS_CONST_CAST(__type, __ptr) const_cast< __type >(__ptr)
|
2000-01-13 08:48:47 +03:00
|
|
|
|
2000-03-18 02:08:29 +03:00
|
|
|
#define NS_REINTERPRET_POINTER_CAST(__type, __ptr) reinterpret_cast< __type >(__ptr)
|
|
|
|
#define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) reinterpret_cast< __type >(__obj)
|
|
|
|
#define NS_REINTERPRET_CAST(__type, __expr) reinterpret_cast< __type >(__expr)
|
2000-01-13 08:48:47 +03:00
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
|
|
|
#define NS_STATIC_CAST(__type, __ptr) ((__type)(__ptr))
|
|
|
|
#define NS_CONST_CAST(__type, __ptr) ((__type)(__ptr))
|
1999-12-08 04:41:28 +03:00
|
|
|
|
2000-01-13 08:48:47 +03:00
|
|
|
#define NS_REINTERPRET_POINTER_CAST(__type, __ptr) ((__type)((void*)(__ptr)))
|
|
|
|
#define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) ((__type)(__obj))
|
|
|
|
|
1999-12-08 04:41:28 +03:00
|
|
|
/* Note: the following is only appropriate for pointers. */
|
2000-01-13 08:48:47 +03:00
|
|
|
#define NS_REINTERPRET_CAST(__type, __expr) NS_REINTERPRET_POINTER_CAST(__type, __expr)
|
1999-12-08 04:41:28 +03:00
|
|
|
/*
|
2000-01-13 08:48:47 +03:00
|
|
|
Why cast to a |void*| first? Well, when old-style casting from
|
|
|
|
a pointer to a base to a pointer to a derived class, the cast will be
|
|
|
|
ambiguous if the source pointer type appears multiple times in the
|
|
|
|
destination, e.g.,
|
|
|
|
|
|
|
|
class Base {};
|
|
|
|
class Derived : public Base, public Base {};
|
|
|
|
|
|
|
|
void foo( Base* b )
|
|
|
|
{
|
2000-09-02 08:17:11 +04:00
|
|
|
((Derived*)b)->some_derived_member ... // Error: Ambiguous, expand from which |Base|?
|
2000-01-13 08:48:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
an old-style cast (like |static_cast|) will change the pointer, but
|
|
|
|
here, doesn't know how. The cast to |void*| prevents it from thinking
|
|
|
|
it needs to expand the original pointer.
|
1999-12-08 04:41:28 +03:00
|
|
|
|
|
|
|
The cost is, |NS_REINTERPRET_CAST| is no longer appropriate for non-pointer
|
|
|
|
conversions. Also, mis-applying |NS_REINTERPRET_CAST| to cast |this| to something
|
|
|
|
will still expand the pointer to the outer object in standards complying compilers.
|
|
|
|
*/
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2000-06-13 04:05:18 +04:00
|
|
|
/*
|
|
|
|
No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate
|
|
|
|
the semantics. So if you want to dynamic_cast, then just use it
|
|
|
|
"straight", no macro.
|
|
|
|
*/
|
|
|
|
#endif
|
2001-09-27 07:43:00 +04:00
|
|
|
|
2001-08-14 08:14:47 +04:00
|
|
|
/*
|
|
|
|
* Use these macros to do 64bit safe pointer conversions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NS_PTR_TO_INT32(x) ((char *)(x) - (char *)0)
|
|
|
|
#define NS_INT32_TO_PTR(x) ((void *)((char *)0 + (x)))
|
|
|
|
|
2001-12-24 02:23:41 +03:00
|
|
|
/* Include deprecated APIs... */
|
2001-09-27 07:43:00 +04:00
|
|
|
|
|
|
|
#ifndef nsComObsolete_h__
|
|
|
|
#include "nsComObsolete.h"
|
|
|
|
#endif
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif /* nscore_h___ */
|
2001-09-27 07:43:00 +04:00
|
|
|
|