1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsIBinaryOutputStream.idl"
9 * @See nsIObjectInputStream
10 * @See nsIBinaryOutputStream
13 [scriptable
, uuid(92c898ac
-5fde
-4b99
-87b3
-5d486422094b
)]
14 interface nsIObjectOutputStream
: nsIBinaryOutputStream
17 * Write the object whose "root" or XPCOM-identity nsISupports is aObject.
18 * The cause for writing this object is a strong or weak reference, so the
19 * aIsStrongRef argument must tell which kind of pointer is being followed
20 * here during serialization.
22 * If the object has only one strong reference in the serialization and no
23 * weak refs, use writeSingleRefObject. This is a valuable optimization:
24 * it saves space in the stream, and cycles on both ends of the process.
26 * If the reference being serialized is a pointer to an interface not on
27 * the primary inheritance chain ending in the root nsISupports, you must
28 * call writeCompoundObject instead of this method.
30 void writeObject
(in nsISupports aObject
, in boolean aIsStrongRef
);
33 * Write an object referenced singly and strongly via its root nsISupports
34 * or a subclass of its root nsISupports. There must not be other refs to
35 * aObject in memory, or in the serialization.
37 void writeSingleRefObject
(in nsISupports aObject
);
40 * Write the object referenced by an interface pointer at aObject that
41 * inherits from a non-primary nsISupports, i.e., a reference to one of
42 * the multiply inherited interfaces derived from an nsISupports other
43 * than the root or XPCOM-identity nsISupports; or a reference to an
44 * inner object in the case of true XPCOM aggregation. aIID identifies
47 void writeCompoundObject
(in nsISupports aObject
,
49 in boolean aIsStrongRef
);
51 void writeID
(in nsIDRef aID
);
54 * Optimized serialization support -- see nsIStreamBufferAccess.idl.
56 [notxpcom
] charPtr getBuffer
(in uint32_t aLength
, in uint32_t aAlignMask
);
57 [notxpcom
] void putBuffer
(in charPtr aBuffer
, in uint32_t aLength
);
63 NS_WriteOptionalObject
(nsIObjectOutputStream
* aStream
, nsISupports
* aObject
,
66 bool nonnull
= (aObject
!= nullptr
);
67 nsresult rv
= aStream
->WriteBoolean
(nonnull
);
68 if
(NS_SUCCEEDED
(rv
) && nonnull
)
69 rv
= aStream
->WriteObject
(aObject
, aIsStrongRef
);
74 NS_WriteOptionalSingleRefObject
(nsIObjectOutputStream
* aStream
,
77 bool nonnull
= (aObject
!= nullptr
);
78 nsresult rv
= aStream
->WriteBoolean
(nonnull
);
79 if
(NS_SUCCEEDED
(rv
) && nonnull
)
80 rv
= aStream
->WriteSingleRefObject
(aObject
);
85 NS_WriteOptionalCompoundObject
(nsIObjectOutputStream
* aStream
,
90 bool nonnull
= (aObject
!= nullptr
);
91 nsresult rv
= aStream
->WriteBoolean
(nonnull
);
92 if
(NS_SUCCEEDED
(rv
) && nonnull
)
93 rv
= aStream
->WriteCompoundObject
(aObject
, aIID
, aIsStrongRef
);