Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions
AtomImpl Class Reference

A threadsafely-refcounted implementation of nsIAtom. More...

#include <nsAtomTable.h>

Inheritance diagram for AtomImpl:
Inheritance graph
[legend]
Collaboration diagram for AtomImpl:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { REFCNT_PERMANENT_SENTINEL = PR_UINT32_MAX }

Public Member Functions

 AtomImpl ()
virtual PRBool IsPermanent ()
PRBool IsPermanentInDestructor ()
voidoperator new (size_t size, const nsACString &aString) CPP_THROW_NEW
void operator delete (void *ptr)
nsrefcnt GetRefCount ()
AString toString ()
 Get the Unicode or UTF8 value for the string.
AUTF8String toUTF8String ()
void getUTF8String ([shared, retval] out string aResult)
 Return a pointer to a zero terminated UTF8 string.
boolean equals (in AString aString)
 Compare the atom to a specific string value Note that this will NEVER return/throw an error condition.
boolean equalsUTF8 (in AUTF8String aString)
PRBool Equals (const nsAString &s)
PRBool EqualsUTF8 (const nsACString &s)

Public Attributes

char mString [1]

Protected Member Functions

 ~AtomImpl ()

Detailed Description

A threadsafely-refcounted implementation of nsIAtom.

Note that AtomImpl objects are sometimes converted into PermanentAtomImpl objects using placement new and just overwriting the vtable pointer.

Definition at line 49 of file nsAtomTable.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
REFCNT_PERMANENT_SENTINEL 

Definition at line 62 of file nsAtomTable.h.


Constructor & Destructor Documentation

Definition at line 287 of file nsAtomTable.cpp.

{
}
AtomImpl::~AtomImpl ( ) [protected]

Definition at line 291 of file nsAtomTable.cpp.

{
  NS_PRECONDITION(gAtomTable.ops, "uninitialized atom hashtable");
  // Permanent atoms are removed from the hashtable at shutdown, and we
  // don't want to remove them twice.  See comment above in
  // |AtomTableClearEntry|.
  if (!IsPermanentInDestructor()) {
    PL_DHashTableOperate(&gAtomTable, mString, PL_DHASH_REMOVE);
    if (gAtomTable.entryCount == 0) {
      PL_DHashTableFinish(&gAtomTable);
      NS_ASSERTION(gAtomTable.entryCount == 0,
                   "PL_DHashTableFinish changed the entry count");
    }
  }
}

Here is the call graph for this function:


Member Function Documentation

boolean nsIAtom::equals ( in AString  aString) [inherited]

Compare the atom to a specific string value Note that this will NEVER return/throw an error condition.

PRBool nsIAtom::Equals ( const nsAString &  s) [inline, inherited]

Definition at line 75 of file nsIAtom.idl.

                                           {
    PRBool result;
    Equals(s, &result);
    return result;
  }

Here is the caller graph for this function:

boolean nsIAtom::equalsUTF8 ( in AUTF8String  aString) [inherited]
PRBool nsIAtom::EqualsUTF8 ( const nsACString &  s) [inline, inherited]

Definition at line 81 of file nsIAtom.idl.

                                                {
    PRBool result;
    EqualsUTF8(s, &result);
    return result;
  }

Here is the caller graph for this function:

Definition at line 78 of file nsAtomTable.h.

{ return mRefCnt; }

Here is the caller graph for this function:

void nsIAtom::getUTF8String ( [shared, retval] out string  aResult) [inherited]

Return a pointer to a zero terminated UTF8 string.

Reimplemented in PermanentAtomImpl.

Definition at line 331 of file nsAtomTable.cpp.

{
  return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 67 of file nsAtomTable.h.

                                   {
    return mRefCnt == REFCNT_PERMANENT_SENTINEL;
  }

Here is the caller graph for this function:

void AtomImpl::operator delete ( void ptr) [inline]

Definition at line 73 of file nsAtomTable.h.

                                  {
    ::operator delete(ptr);
  }
void * AtomImpl::operator new ( size_t  size,
const nsACString &  aString 
)

Reimplemented in PermanentAtomImpl.

Definition at line 342 of file nsAtomTable.cpp.

{
    /*
      Note: since the |size| will initially also include the |PRUnichar| member
        |mString|, our size calculation will give us one character too many.
        We use that extra character for a zero-terminator.

      Note: this construction is not guaranteed to be possible by the C++
        compiler.  A more reliable scheme is used by |nsShared[C]String|s, see
        http://lxr.mozilla.org/seamonkey/source/xpcom/ds/nsSharedString.h#174
     */
  size += aString.Length() * sizeof(char);
  AtomImpl* ii = NS_STATIC_CAST(AtomImpl*, ::operator new(size));

  char* toBegin = &ii->mString[0];
  nsACString::const_iterator fromBegin, fromEnd;
  *copy_string(aString.BeginReading(fromBegin), aString.EndReading(fromEnd), toBegin) = '\0';
  return ii;
}

Here is the call graph for this function:

AString nsIAtom::toString ( ) [inherited]

Get the Unicode or UTF8 value for the string.

AUTF8String nsIAtom::toUTF8String ( ) [inherited]

Member Data Documentation

Definition at line 82 of file nsAtomTable.h.


The documentation for this class was generated from the following files: