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(nsISupports
* aOuter
, const nsIID
& aIID
,
42 nsArrayBase(const nsArrayBase
& aOther
);
43 explicit nsArrayBase(const nsCOMArray_base
& aBaseArray
)
44 : mArray(aBaseArray
) {}
45 virtual ~nsArrayBase();
47 nsCOMArray_base mArray
;
50 class nsArray final
: public nsArrayBase
{
51 friend class nsArrayBase
;
57 nsArray() : nsArrayBase() {}
58 nsArray(const nsArray
& aOther
);
59 explicit nsArray(const nsCOMArray_base
& aBaseArray
)
60 : nsArrayBase(aBaseArray
) {}
64 class nsArrayCC final
: public nsArrayBase
{
65 friend class nsArrayBase
;
68 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
69 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsArrayCC
, nsIMutableArray
)
72 nsArrayCC() : nsArrayBase() {}
73 nsArrayCC(const nsArrayCC
& aOther
);
74 explicit nsArrayCC(const nsCOMArray_base
& aBaseArray
)
75 : nsArrayBase(aBaseArray
) {}