xpcom/glue/EnumeratedArrayCycleCollection.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/glue/EnumeratedArrayCycleCollection.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef EnumeratedArrayCycleCollection_h_
    1.11 +#define EnumeratedArrayCycleCollection_h_
    1.12 +
    1.13 +#include "mozilla/EnumeratedArray.h"
    1.14 +#include "nsCycleCollectionTraversalCallback.h"
    1.15 +
    1.16 +template <typename IndexType,
    1.17 +          MOZ_TEMPLATE_ENUM_CLASS_ENUM_TYPE(IndexType) SizeAsEnumValue,
    1.18 +          typename ValueType>
    1.19 +inline void
    1.20 +ImplCycleCollectionUnlink(mozilla::EnumeratedArray<IndexType,
    1.21 +                                                   SizeAsEnumValue,
    1.22 +                                                   ValueType>& aField)
    1.23 +{
    1.24 +  for (size_t i = 0; i < size_t(SizeAsEnumValue); i++) {
    1.25 +    aField[IndexType(i)] = nullptr;
    1.26 +  }
    1.27 +}
    1.28 +
    1.29 +template <typename IndexType,
    1.30 +          MOZ_TEMPLATE_ENUM_CLASS_ENUM_TYPE(IndexType) SizeAsEnumValue,
    1.31 +          typename ValueType>
    1.32 +inline void
    1.33 +ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
    1.34 +                            mozilla::EnumeratedArray<IndexType,
    1.35 +                                                     SizeAsEnumValue,
    1.36 +                                                     ValueType>& aField,
    1.37 +                            const char* aName,
    1.38 +                            uint32_t aFlags = 0)
    1.39 +{
    1.40 +  aFlags |= CycleCollectionEdgeNameArrayFlag;
    1.41 +  for (size_t i = 0; i < size_t(SizeAsEnumValue); ++i) {
    1.42 +    ImplCycleCollectionTraverse(aCallback, aField[IndexType(i)], aName, aFlags);
    1.43 +  }
    1.44 +}
    1.45 +
    1.46 +#endif // EnumeratedArrayCycleCollection_h_

mercurial