Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs
nscore.h File Reference
#include "xpcom-config.h"
#include "prtypes.h"
#include "nsError.h"

Go to the source code of this file.

Defines

#define NS_VISIBILITY_HIDDEN
 Make sure that we have the proper platform specific c++ definitions needed by nscore.h.
#define NS_VISIBILITY_DEFAULT
#define NS_HIDDEN_(type)   NS_VISIBILITY_HIDDEN type
#define NS_EXTERNAL_VIS_(type)   NS_VISIBILITY_DEFAULT type
#define NS_HIDDEN   NS_VISIBILITY_HIDDEN
#define NS_EXTERNAL_VIS   NS_VISIBILITY_DEFAULT
#define IMETHOD_VISIBILITY   NS_VISIBILITY_HIDDEN
#define NS_FASTCALL
 Mark a function as using a potentially non-standard function calling convention.
#define NS_DEFCALL
#define NS_IMPORT   NS_EXTERNAL_VIS
#define NS_IMPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_EXPORT   NS_EXTERNAL_VIS
#define NS_EXPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMETHOD_(type)   virtual IMETHOD_VISIBILITY type NS_DEFCALL
#define NS_IMETHODIMP_(type)   type
#define NS_METHOD_(type)   type
#define NS_CALLBACK_(_type, _name)   _type (* _name)
#define NS_STDCALL
#define NS_EXPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args)   ret (NS_STDCALL class::*name) args
 Macro for creating typedefs for pointer-to-member types which are declared with stdcall.
#define NS_IMETHOD   NS_IMETHOD_(nsresult)
 Generic API modifiers which return the standard XPCOM nsresult type.
#define NS_IMETHODIMP   NS_IMETHODIMP_(nsresult)
#define NS_METHOD   NS_METHOD_(nsresult)
#define NS_CALLBACK(_name)   NS_CALLBACK_(nsresult, _name)
#define NS_COM   NS_IMPORT
 Import/Export macros for XPCOM APIs.
#define NS_COM_GLUE
#define NS_NO_VTABLE
 NS_NO_VTABLE is emitted by xpidl in interface declarations whenever xpidl can determine that the interface can't contain a constructor.
#define nsnull   0
 The preferred symbol for null.
#define explicit
#define typename
#define NS_SPECIALIZE_TEMPLATE
#define NS_STATIC_CAST(__type, __ptr)   static_cast< __type >(__ptr)
#define NS_CONST_CAST(__type, __ptr)   const_cast< __type >(__ptr)
#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)
#define NS_PTR_TO_INT32(x)   ((PRInt32) (PRWord) (x))
#define NS_PTR_TO_UINT32(x)   ((PRUint32) (PRWord) (x))
#define NS_INT32_TO_PTR(x)   ((void *) (PRWord) (x))
#define NS_STRINGIFY_HELPER(x_)   #x_
#define NS_STRINGIFY(x_)   NS_STRINGIFY_HELPER(x_)
#define NS_LIKELY(x)   (x)
#define NS_UNLIKELY(x)   (x)
#define NS_VISIBILITY_HIDDEN
#define NS_VISIBILITY_DEFAULT
#define NS_HIDDEN_(type)   NS_VISIBILITY_HIDDEN type
#define NS_EXTERNAL_VIS_(type)   NS_VISIBILITY_DEFAULT type
#define NS_HIDDEN   NS_VISIBILITY_HIDDEN
#define NS_EXTERNAL_VIS   NS_VISIBILITY_DEFAULT
#define IMETHOD_VISIBILITY   NS_VISIBILITY_HIDDEN
#define NS_FASTCALL
#define NS_DEFCALL
#define NS_IMPORT   NS_EXTERNAL_VIS
#define NS_IMPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_EXPORT   NS_EXTERNAL_VIS
#define NS_EXPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMETHOD_(type)   virtual IMETHOD_VISIBILITY type NS_DEFCALL
#define NS_IMETHODIMP_(type)   type
#define NS_METHOD_(type)   type
#define NS_CALLBACK_(_type, _name)   _type (* _name)
#define NS_STDCALL
#define NS_EXPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args)   ret (NS_STDCALL class::*name) args
#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)
#define NS_COM   NS_IMPORT
#define NS_COM_GLUE
#define NS_NO_VTABLE
#define nsnull   0
#define explicit
#define typename
#define NS_SPECIALIZE_TEMPLATE
#define NS_STATIC_CAST(__type, __ptr)   static_cast< __type >(__ptr)
#define NS_CONST_CAST(__type, __ptr)   const_cast< __type >(__ptr)
#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)
#define NS_PTR_TO_INT32(x)   ((PRInt32) (PRWord) (x))
#define NS_PTR_TO_UINT32(x)   ((PRUint32) (PRWord) (x))
#define NS_INT32_TO_PTR(x)   ((void *) (PRWord) (x))
#define NS_STRINGIFY_HELPER(x_)   #x_
#define NS_STRINGIFY(x_)   NS_STRINGIFY_HELPER(x_)
#define NS_LIKELY(x)   (x)
#define NS_UNLIKELY(x)   (x)
#define NS_VISIBILITY_HIDDEN
#define NS_VISIBILITY_DEFAULT
#define NS_HIDDEN_(type)   NS_VISIBILITY_HIDDEN type
#define NS_EXTERNAL_VIS_(type)   NS_VISIBILITY_DEFAULT type
#define NS_HIDDEN   NS_VISIBILITY_HIDDEN
#define NS_EXTERNAL_VIS   NS_VISIBILITY_DEFAULT
#define IMETHOD_VISIBILITY   NS_VISIBILITY_HIDDEN
#define NS_FASTCALL
#define NS_DEFCALL
#define NS_IMPORT   NS_EXTERNAL_VIS
#define NS_IMPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_EXPORT   NS_EXTERNAL_VIS
#define NS_EXPORT_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMETHOD_(type)   virtual IMETHOD_VISIBILITY type NS_DEFCALL
#define NS_IMETHODIMP_(type)   type
#define NS_METHOD_(type)   type
#define NS_CALLBACK_(_type, _name)   _type (* _name)
#define NS_STDCALL
#define NS_EXPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_IMPORT_STATIC_MEMBER_(type)   NS_EXTERNAL_VIS_(type)
#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args)   ret (NS_STDCALL class::*name) args
#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)
#define NS_COM   NS_IMPORT
#define NS_COM_GLUE
#define NS_NO_VTABLE
#define nsnull   0
#define explicit
#define typename
#define NS_SPECIALIZE_TEMPLATE
#define NS_STATIC_CAST(__type, __ptr)   static_cast< __type >(__ptr)
#define NS_CONST_CAST(__type, __ptr)   const_cast< __type >(__ptr)
#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)
#define NS_PTR_TO_INT32(x)   ((PRInt32) (PRWord) (x))
#define NS_PTR_TO_UINT32(x)   ((PRUint32) (PRWord) (x))
#define NS_INT32_TO_PTR(x)   ((void *) (PRWord) (x))
#define NS_STRINGIFY_HELPER(x_)   #x_
#define NS_STRINGIFY(x_)   NS_STRINGIFY_HELPER(x_)
#define NS_LIKELY(x)   (x)
#define NS_UNLIKELY(x)   (x)

Typedefs

typedef PRUint32 nsresult
 Generic XPCOM result data type.

Define Documentation

Definition at line 352 of file nsrootidl.idl.

Definition at line 122 of file nsrootidl.idl.

#define NS_CALLBACK (   _name)    NS_CALLBACK_(nsresult, _name)
#define NS_CALLBACK (   _name)    NS_CALLBACK_(nsresult, _name)

Definition at line 229 of file nsrootidl.idl.

#define NS_CALLBACK (   _name)    NS_CALLBACK_(nsresult, _name)
#define NS_CALLBACK_ (   _type,
  _name 
)    _type (* _name)

Definition at line 189 of file nsrootidl.idl.

#define NS_CALLBACK_ (   _type,
  _name 
)    _type (* _name)
#define NS_CALLBACK_ (   _type,
  _name 
)    _type (* _name)

Import/Export macros for XPCOM APIs.

Definition at line 242 of file nsrootidl.idl.

Definition at line 257 of file nsrootidl.idl.

#define NS_CONST_CAST (   __type,
  __ptr 
)    const_cast< __type >(__ptr)

Definition at line 374 of file nsrootidl.idl.

#define NS_CONST_CAST (   __type,
  __ptr 
)    const_cast< __type >(__ptr)
#define NS_CONST_CAST (   __type,
  __ptr 
)    const_cast< __type >(__ptr)

Definition at line 157 of file nsrootidl.idl.

Definition at line 184 of file nsrootidl.idl.

Definition at line 185 of file nsrootidl.idl.

Definition at line 191 of file nsrootidl.idl.

Definition at line 119 of file nsrootidl.idl.

Definition at line 116 of file nsrootidl.idl.

Mark a function as using a potentially non-standard function calling convention.

This can be used on functions that are called very frequently, to reduce the overhead of the function call. It is still worth using the macro for C++ functions which take no parameters since it allows passing |this| in a register.

  • Do not use this on any scriptable interface method since xptcall won't be aware of the different calling convention.
    • This must appear on the declaration, not the definition.
    • Adding this to a public function will break binary compatibility.
    • This may be used on virtual functions but you must ensure it is applied to all implementations - the compiler will not warn but it will crash.
    • This has no effect for inline functions or functions which take a variable number of arguments.

Examples: int NS_FASTCALL func1(char *foo); NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);

Definition at line 147 of file nsrootidl.idl.

Definition at line 118 of file nsrootidl.idl.

Definition at line 115 of file nsrootidl.idl.

Generic API modifiers which return the standard XPCOM nsresult type.

Definition at line 226 of file nsrootidl.idl.

Definition at line 186 of file nsrootidl.idl.

Definition at line 227 of file nsrootidl.idl.

Definition at line 187 of file nsrootidl.idl.

Definition at line 182 of file nsrootidl.idl.

Definition at line 183 of file nsrootidl.idl.

Definition at line 192 of file nsrootidl.idl.

#define NS_INT32_TO_PTR (   x)    ((void *) (PRWord) (x))
#define NS_INT32_TO_PTR (   x)    ((void *) (PRWord) (x))

Definition at line 425 of file nsrootidl.idl.

#define NS_INT32_TO_PTR (   x)    ((void *) (PRWord) (x))
#define NS_LIKELY (   x)    (x)
#define NS_LIKELY (   x)    (x)

Definition at line 451 of file nsrootidl.idl.

#define NS_LIKELY (   x)    (x)

Definition at line 228 of file nsrootidl.idl.

#define NS_METHOD_ (   type)    type

Definition at line 188 of file nsrootidl.idl.

#define NS_METHOD_ (   type)    type
#define NS_METHOD_ (   type)    type

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.

Definition at line 274 of file nsrootidl.idl.

#define NS_PTR_TO_INT32 (   x)    ((PRInt32) (PRWord) (x))

Definition at line 423 of file nsrootidl.idl.

#define NS_PTR_TO_INT32 (   x)    ((PRInt32) (PRWord) (x))
#define NS_PTR_TO_INT32 (   x)    ((PRInt32) (PRWord) (x))
#define NS_PTR_TO_UINT32 (   x)    ((PRUint32) (PRWord) (x))
#define NS_PTR_TO_UINT32 (   x)    ((PRUint32) (PRWord) (x))

Definition at line 424 of file nsrootidl.idl.

#define NS_PTR_TO_UINT32 (   x)    ((PRUint32) (PRWord) (x))
#define NS_REINTERPRET_CAST (   __type,
  __expr 
)    reinterpret_cast< __type >(__expr)
#define NS_REINTERPRET_CAST (   __type,
  __expr 
)    reinterpret_cast< __type >(__expr)

Definition at line 378 of file nsrootidl.idl.

#define NS_REINTERPRET_CAST (   __type,
  __expr 
)    reinterpret_cast< __type >(__expr)
#define NS_REINTERPRET_NONPOINTER_CAST (   __type,
  __obj 
)    reinterpret_cast< __type >(__obj)

Definition at line 377 of file nsrootidl.idl.

#define NS_REINTERPRET_NONPOINTER_CAST (   __type,
  __obj 
)    reinterpret_cast< __type >(__obj)
#define NS_REINTERPRET_NONPOINTER_CAST (   __type,
  __obj 
)    reinterpret_cast< __type >(__obj)
#define NS_REINTERPRET_POINTER_CAST (   __type,
  __ptr 
)    reinterpret_cast< __type >(__ptr)
#define NS_REINTERPRET_POINTER_CAST (   __type,
  __ptr 
)    reinterpret_cast< __type >(__ptr)

Definition at line 376 of file nsrootidl.idl.

#define NS_REINTERPRET_POINTER_CAST (   __type,
  __ptr 
)    reinterpret_cast< __type >(__ptr)

Definition at line 362 of file nsrootidl.idl.

#define NS_STATIC_CAST (   __type,
  __ptr 
)    static_cast< __type >(__ptr)

Definition at line 373 of file nsrootidl.idl.

#define NS_STATIC_CAST (   __type,
  __ptr 
)    static_cast< __type >(__ptr)
#define NS_STATIC_CAST (   __type,
  __ptr 
)    static_cast< __type >(__ptr)

Definition at line 190 of file nsrootidl.idl.

#define NS_STDCALL_FUNCPROTO (   ret,
  name,
  class,
  func,
  args 
)    ret (NS_STDCALL class::*name) args
#define NS_STDCALL_FUNCPROTO (   ret,
  name,
  class,
  func,
  args 
)    ret (NS_STDCALL class::*name) args

Macro for creating typedefs for pointer-to-member types which are declared with stdcall.

It is important to use this for any type which is declared as stdcall (i.e. NS_IMETHOD). For example, instead of writing:

typedef nsresult (nsIFoo::someType)(nsISupports arg);

you should write:

typedef NS_STDCALL_FUNCPROTO(nsresult, someType, nsIFoo, typeFunc, (nsISupports*));

where nsIFoo::typeFunc is any method declared as NS_IMETHOD typeFunc(nsISupports*);

XXX this can be simplified to always use the non-typeof implementation when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed.

Definition at line 219 of file nsrootidl.idl.

#define NS_STDCALL_FUNCPROTO (   ret,
  name,
  class,
  func,
  args 
)    ret (NS_STDCALL class::*name) args

Definition at line 431 of file nsrootidl.idl.

#define NS_STRINGIFY_HELPER (   x_)    #x_
#define NS_STRINGIFY_HELPER (   x_)    #x_
#define NS_STRINGIFY_HELPER (   x_)    #x_

Definition at line 430 of file nsrootidl.idl.

#define NS_UNLIKELY (   x)    (x)
#define NS_UNLIKELY (   x)    (x)

Definition at line 452 of file nsrootidl.idl.

#define NS_UNLIKELY (   x)    (x)

Definition at line 112 of file nsrootidl.idl.

Make sure that we have the proper platform specific c++ definitions needed by nscore.h.

Root idl declarations to be used by all.

The mother of all xpcom interfaces.

Incorporate the core NSPR data types which XPCOM uses. Macros defining the target platform... Using the visibility("hidden") attribute allows the compiler to use PC-relative addressing to call this function. If a function does not access any global data, and does not call any methods which are not either file-local or hidden, then on ELF systems we avoid loading the address of the PLT into a register at the start of the function, which reduces code size and frees up a register for general use.

As a general rule, this should be used for any non-exported symbol (including virtual method implementations). NS_IMETHOD uses this by default; if you need to have your NS_IMETHOD functions exported, you can wrap your class as follows:

undef IMETHOD_VISIBILITY

define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT

class Foo { ... };

undef IMETHOD_VISIBILITY

define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN

Don't forget to change the visibility back to hidden before the end of a header!

Other examples:

NS_HIDDEN_(int) someMethod(); SomeCtor() NS_HIDDEN;

FROZEN Make sure that we have the proper platform specific c++ definitions needed by nscore.h Incorporate the core NSPR data types which XPCOM uses. Macros defining the target platform... Using the visibility("hidden") attribute allows the compiler to use PC-relative addressing to call this function. If a function does not access any global data, and does not call any methods which are not either file-local or hidden, then on ELF systems we avoid loading the address of the PLT into a register at the start of the function, which reduces code size and frees up a register for general use.

As a general rule, this should be used for any non-exported symbol (including virtual method implementations). NS_IMETHOD uses this by default; if you need to have your NS_IMETHOD functions exported, you can wrap your class as follows:

undef IMETHOD_VISIBILITY

define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT

class Foo { ... };

undef IMETHOD_VISIBILITY

define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN

Don't forget to change the visibility back to hidden before the end of a header!

Other examples:

NS_HIDDEN_(int) someMethod(); SomeCtor() NS_HIDDEN;

Definition at line 106 of file nsrootidl.idl.

#define nsnull   0

The preferred symbol for null.

Definition at line 286 of file nsrootidl.idl.

#define nsnull   0
#define nsnull   0

Definition at line 356 of file nsrootidl.idl.


Typedef Documentation

typedef PRUint32 nsresult

Generic XPCOM result data type.

Definition at line 280 of file nscore.h.