xpcom/io/nsIObjectOutputStream.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial