xpcom/ds/nsStaticAtom.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsStaticAtom_h__
     7 #define nsStaticAtom_h__
     9 #include "nsIAtom.h"
    10 #include "nsStringBuffer.h"
    11 #include "prlog.h"
    13 typedef char16_t nsStaticAtomStringType;
    15 #define NS_STATIC_ATOM(buffer_name, atom_ptr)  { (nsStringBuffer*) &buffer_name, atom_ptr }
    16 #define NS_STATIC_ATOM_BUFFER(buffer_name, str_data) static nsFakeStringBuffer< sizeof(str_data) > buffer_name = { 1, sizeof(str_data) * sizeof(nsStaticAtomStringType), MOZ_UTF16(str_data) };
    18 /**
    19  * Holds data used to initialize large number of atoms during startup. Use
    20  * the above macros to initialize these structs. They should never be accessed
    21  * directly other than from AtomTable.cpp
    22  */
    23 struct nsStaticAtom {
    24     nsStringBuffer* mStringBuffer;
    25     nsIAtom ** mAtom;
    26 };
    28 /**
    29  * This is a struct with the same binary layout as a nsStringBuffer.
    30  */
    31 template <uint32_t size>
    32 struct nsFakeStringBuffer {
    33     int32_t mRefCnt;
    34     uint32_t mSize;
    35     nsStaticAtomStringType mStringData[size];
    36 };
    38 // Register an array of static atoms with the atom table
    39 template<uint32_t N>
    40 nsresult
    41 NS_RegisterStaticAtoms(const nsStaticAtom (&atoms)[N])
    42 {
    43     extern nsresult RegisterStaticAtoms(const nsStaticAtom*, uint32_t aAtomCount);
    44     return RegisterStaticAtoms(atoms, N);
    45 }
    47 #endif

mercurial