nscore.h File Reference

#include "prtypes.h"
#include "nsError.h"
Include dependency graph for nscore.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#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

Define Documentation

#define explicit

Definition at line 344 of file nscore.h.

#define IMETHOD_VISIBILITY   NS_VISIBILITY_HIDDEN

Definition at line 113 of file nscore.h.

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

Definition at line 220 of file nscore.h.

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

Definition at line 180 of file nscore.h.

#define NS_COM   NS_IMPORT

Import/Export macros for XPCOM APIs

Definition at line 233 of file nscore.h.

#define NS_COM_GLUE

Definition at line 248 of file nscore.h.

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

Definition at line 366 of file nscore.h.

#define NS_DEFCALL

Definition at line 148 of file nscore.h.

#define NS_EXPORT   NS_EXTERNAL_VIS

Definition at line 175 of file nscore.h.

#define NS_EXPORT_ ( type   )     NS_EXTERNAL_VIS_(type)

Definition at line 176 of file nscore.h.

#define NS_EXPORT_STATIC_MEMBER_ ( type   )     NS_EXTERNAL_VIS_(type)

Definition at line 182 of file nscore.h.

#define NS_EXTERNAL_VIS   NS_VISIBILITY_DEFAULT

Definition at line 110 of file nscore.h.

#define NS_EXTERNAL_VIS_ ( type   )     NS_VISIBILITY_DEFAULT type

Definition at line 107 of file nscore.h.

#define NS_FASTCALL

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 138 of file nscore.h.

#define NS_HIDDEN   NS_VISIBILITY_HIDDEN

Definition at line 109 of file nscore.h.

#define NS_HIDDEN_ ( type   )     NS_VISIBILITY_HIDDEN type

Definition at line 106 of file nscore.h.

#define NS_IMETHOD   NS_IMETHOD_(nsresult)

Generic API modifiers which return the standard XPCOM nsresult type

Definition at line 217 of file nscore.h.

#define NS_IMETHOD_ ( type   )     virtual IMETHOD_VISIBILITY type NS_DEFCALL

Definition at line 177 of file nscore.h.

#define NS_IMETHODIMP   NS_IMETHODIMP_(nsresult)

Definition at line 218 of file nscore.h.

#define NS_IMETHODIMP_ ( type   )     type

Definition at line 178 of file nscore.h.

#define NS_IMPORT   NS_EXTERNAL_VIS

Definition at line 173 of file nscore.h.

#define NS_IMPORT_ ( type   )     NS_EXTERNAL_VIS_(type)

Definition at line 174 of file nscore.h.

#define NS_IMPORT_STATIC_MEMBER_ ( type   )     NS_EXTERNAL_VIS_(type)

Definition at line 183 of file nscore.h.

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

Definition at line 417 of file nscore.h.

#define NS_LIKELY (  )     (x)

Definition at line 443 of file nscore.h.

#define NS_METHOD   NS_METHOD_(nsresult)

Definition at line 219 of file nscore.h.

#define NS_METHOD_ ( type   )     type

Definition at line 179 of file nscore.h.

#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. 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 265 of file nscore.h.

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

Definition at line 415 of file nscore.h.

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

Definition at line 416 of file nscore.h.

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

Definition at line 370 of file nscore.h.

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

Definition at line 369 of file nscore.h.

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

Definition at line 368 of file nscore.h.

#define NS_SPECIALIZE_TEMPLATE

Definition at line 354 of file nscore.h.

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

Definition at line 365 of file nscore.h.

#define NS_STDCALL

Definition at line 181 of file nscore.h.

#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 210 of file nscore.h.

#define NS_STRINGIFY ( x_   )     NS_STRINGIFY_HELPER(x_)

Definition at line 423 of file nscore.h.

#define NS_STRINGIFY_HELPER ( x_   )     #x_

Definition at line 422 of file nscore.h.

#define NS_UNLIKELY (  )     (x)

Definition at line 444 of file nscore.h.

#define NS_VISIBILITY_DEFAULT

Definition at line 103 of file nscore.h.

#define NS_VISIBILITY_HIDDEN

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 97 of file nscore.h.

#define nsnull   0
#define typename

Definition at line 348 of file nscore.h.


Typedef Documentation

typedef PRUint32 nsresult

Generic XPCOM result data type

Definition at line 272 of file nscore.h.

Generated by  doxygen 1.6.2-20100208