no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / xpcom / ds / nsArray.h
blobadff3b2980577dab88c812ef65ac55e105836783
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsArray_h__
8 #define nsArray_h__
10 #include "nsIMutableArray.h"
11 #include "nsCOMArray.h"
12 #include "nsCOMPtr.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "mozilla/Attributes.h"
16 // {35C66FD1-95E9-4e0a-80C5-C3BD2B375481}
17 #define NS_ARRAY_CID \
18 { \
19 0x35c66fd1, 0x95e9, 0x4e0a, { \
20 0x80, 0xc5, 0xc3, 0xbd, 0x2b, 0x37, 0x54, 0x81 \
21 } \
24 // nsArray without any refcounting declarations
25 class nsArrayBase : public nsIMutableArray {
26 public:
27 NS_DECL_NSIARRAY
28 NS_DECL_NSIARRAYEXTENSIONS
29 NS_DECL_NSIMUTABLEARRAY
31 /* Both of these factory functions create a cycle-collectable array
32 on the main thread and a non-cycle-collectable array on other
33 threads. */
34 static already_AddRefed<nsIMutableArray> Create();
35 /* Only for the benefit of the XPCOM module system, use Create()
36 instead. */
37 static nsresult XPCOMConstructor(const nsIID& aIID, void** aResult);
39 protected:
40 nsArrayBase() = default;
41 nsArrayBase(const nsArrayBase& aOther);
42 explicit nsArrayBase(const nsCOMArray_base& aBaseArray)
43 : mArray(aBaseArray) {}
44 virtual ~nsArrayBase();
46 nsCOMArray_base mArray;
49 class nsArray final : public nsArrayBase {
50 friend class nsArrayBase;
52 public:
53 NS_DECL_ISUPPORTS
55 private:
56 nsArray() {}
57 nsArray(const nsArray& aOther);
58 explicit nsArray(const nsCOMArray_base& aBaseArray)
59 : nsArrayBase(aBaseArray) {}
60 ~nsArray() = default;
63 class nsArrayCC final : public nsArrayBase {
64 friend class nsArrayBase;
66 public:
67 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
68 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsArrayCC, nsIMutableArray)
70 private:
71 nsArrayCC() {}
72 nsArrayCC(const nsArrayCC& aOther);
73 explicit nsArrayCC(const nsCOMArray_base& aBaseArray)
74 : nsArrayBase(aBaseArray) {}
75 ~nsArrayCC() = default;
78 #endif