xpcom/ds/nsArray.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/ds/nsArray.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsArray_h__
    1.10 +#define nsArray_h__
    1.11 +
    1.12 +#include "nsIMutableArray.h"
    1.13 +#include "nsCOMArray.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsCycleCollectionParticipant.h"
    1.16 +#include "mozilla/Attributes.h"
    1.17 +
    1.18 +// {35C66FD1-95E9-4e0a-80C5-C3BD2B375481}
    1.19 +#define NS_ARRAY_CID \
    1.20 +{ 0x35c66fd1, 0x95e9, 0x4e0a, \
    1.21 +  { 0x80, 0xc5, 0xc3, 0xbd, 0x2b, 0x37, 0x54, 0x81 } }
    1.22 +
    1.23 +class nsArray : public nsIMutableArray
    1.24 +{
    1.25 +public:
    1.26 +    NS_DECL_ISUPPORTS
    1.27 +    NS_DECL_NSIARRAY
    1.28 +    NS_DECL_NSIMUTABLEARRAY
    1.29 +
    1.30 +    /* Both of these factory functions create a cycle-collectable array
    1.31 +       on the main thread and a non-cycle-collectable array on other
    1.32 +       threads.  */
    1.33 +    static already_AddRefed<nsIMutableArray> Create();
    1.34 +    /* Only for the benefit of the XPCOM module system, use Create()
    1.35 +       instead.  */
    1.36 +    static nsresult XPCOMConstructor(nsISupports* aOuter, const nsIID& aIID,
    1.37 +                                     void** aResult);
    1.38 +protected:
    1.39 +    nsArray() { }
    1.40 +    nsArray(const nsArray& other);
    1.41 +    nsArray(const nsCOMArray_base& aBaseArray) : mArray(aBaseArray)
    1.42 +    { }
    1.43 +    
    1.44 +    virtual ~nsArray(); // nsArrayCC inherits from this
    1.45 +
    1.46 +    nsCOMArray_base mArray;
    1.47 +};
    1.48 +
    1.49 +class nsArrayCC MOZ_FINAL : public nsArray
    1.50 +{
    1.51 +    friend class nsArray;
    1.52 +
    1.53 +public:
    1.54 +    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.55 +    NS_DECL_CYCLE_COLLECTION_CLASS(nsArrayCC)
    1.56 +
    1.57 +private:
    1.58 +    nsArrayCC() : nsArray() { }
    1.59 +    nsArrayCC(const nsArrayCC& other);
    1.60 +    nsArrayCC(const nsCOMArray_base& aBaseArray) : nsArray(aBaseArray)
    1.61 +    { }
    1.62 +};
    1.63 +
    1.64 +#endif

mercurial