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/. */
10 #include "nsIMutableArray.h"
11 #include "nsCOMArray.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "mozilla/Attributes.h"
16 // {35C66FD1-95E9-4e0a-80C5-C3BD2B375481}
17 #define NS_ARRAY_CID \
19 0x35c66fd1, 0x95e9, 0x4e0a, { \
20 0x80, 0xc5, 0xc3, 0xbd, 0x2b, 0x37, 0x54, 0x81 \
24 // nsArray without any refcounting declarations
25 class nsArrayBase
: public nsIMutableArray
{
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
34 static already_AddRefed
<nsIMutableArray
> Create();
35 /* Only for the benefit of the XPCOM module system, use Create()
37 static nsresult
XPCOMConstructor(const nsIID
& aIID
, void** aResult
);
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
;
57 nsArray(const nsArray
& aOther
);
58 explicit nsArray(const nsCOMArray_base
& aBaseArray
)
59 : nsArrayBase(aBaseArray
) {}
63 class nsArrayCC final
: public nsArrayBase
{
64 friend class nsArrayBase
;
67 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
68 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsArrayCC
, nsIMutableArray
)
72 nsArrayCC(const nsArrayCC
& aOther
);
73 explicit nsArrayCC(const nsCOMArray_base
& aBaseArray
)
74 : nsArrayBase(aBaseArray
) {}
75 ~nsArrayCC() = default;