2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsArray_h__
|
|
|
|
#define nsArray_h__
|
|
|
|
|
|
|
|
#include "nsIMutableArray.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2008-02-07 03:37:18 -08:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-05 16:51:58 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// {35C66FD1-95E9-4e0a-80C5-C3BD2B375481}
|
|
|
|
#define NS_ARRAY_CID \
|
|
|
|
{ 0x35c66fd1, 0x95e9, 0x4e0a, \
|
|
|
|
{ 0x80, 0xc5, 0xc3, 0xbd, 0x2b, 0x37, 0x54, 0x81 } }
|
|
|
|
|
2014-05-15 09:52:58 -07:00
|
|
|
// nsArray without any refcounting declarations
|
|
|
|
class nsArrayBase : public nsIMutableArray
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-07-09 08:15:21 -07:00
|
|
|
NS_DECL_NSIARRAY
|
|
|
|
NS_DECL_NSIMUTABLEARRAY
|
|
|
|
|
|
|
|
/* Both of these factory functions create a cycle-collectable array
|
|
|
|
on the main thread and a non-cycle-collectable array on other
|
|
|
|
threads. */
|
|
|
|
static already_AddRefed<nsIMutableArray> Create();
|
|
|
|
/* Only for the benefit of the XPCOM module system, use Create()
|
|
|
|
instead. */
|
|
|
|
static nsresult XPCOMConstructor(nsISupports* aOuter, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2009-01-15 20:02:22 -08:00
|
|
|
protected:
|
2014-07-09 08:15:21 -07:00
|
|
|
nsArrayBase() {}
|
|
|
|
nsArrayBase(const nsArrayBase& aOther);
|
2014-07-28 10:19:06 -07:00
|
|
|
explicit nsArrayBase(const nsCOMArray_base& aBaseArray) : mArray(aBaseArray) {}
|
2014-07-09 08:15:21 -07:00
|
|
|
virtual ~nsArrayBase();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-07-09 08:15:21 -07:00
|
|
|
nsCOMArray_base mArray;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-05-15 09:52:58 -07:00
|
|
|
class nsArray MOZ_FINAL : public nsArrayBase
|
|
|
|
{
|
2014-07-09 08:15:21 -07:00
|
|
|
friend class nsArrayBase;
|
2014-05-15 09:52:58 -07:00
|
|
|
|
|
|
|
public:
|
2014-07-09 08:15:21 -07:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-05-15 09:52:58 -07:00
|
|
|
|
|
|
|
private:
|
2014-07-09 08:15:21 -07:00
|
|
|
nsArray() : nsArrayBase() {}
|
|
|
|
nsArray(const nsArray& aOther);
|
2014-07-28 10:19:06 -07:00
|
|
|
explicit nsArray(const nsCOMArray_base& aBaseArray) : nsArrayBase(aBaseArray) {}
|
2014-07-09 08:15:21 -07:00
|
|
|
~nsArray() {}
|
2014-05-15 09:52:58 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsArrayCC MOZ_FINAL : public nsArrayBase
|
2009-01-15 20:02:22 -08:00
|
|
|
{
|
2014-07-09 08:15:21 -07:00
|
|
|
friend class nsArrayBase;
|
2012-09-21 09:12:32 -07:00
|
|
|
|
2009-01-15 20:02:22 -08:00
|
|
|
public:
|
2014-07-09 08:15:21 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsArrayCC)
|
2012-09-21 09:12:32 -07:00
|
|
|
|
|
|
|
private:
|
2014-07-09 08:15:21 -07:00
|
|
|
nsArrayCC() : nsArrayBase() {}
|
|
|
|
nsArrayCC(const nsArrayCC& aOther);
|
2014-07-28 10:19:06 -07:00
|
|
|
explicit nsArrayCC(const nsCOMArray_base& aBaseArray) : nsArrayBase(aBaseArray) {}
|
2014-07-09 08:15:21 -07:00
|
|
|
~nsArrayCC() {}
|
2009-01-15 20:02:22 -08:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|