1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is Mozilla FastLoad code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 2001
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | * Brendan Eich <[email protected]> (original author)
|
---|
24 | *
|
---|
25 | * Alternatively, the contents of this file may be used under the terms of
|
---|
26 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
27 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
29 | * of those above. If you wish to allow use of your version of this file only
|
---|
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
31 | * use your version of this file under the terms of the MPL, indicate your
|
---|
32 | * decision by deleting the provisions above and replace them with the notice
|
---|
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
34 | * the provisions above, a recipient may use your version of this file under
|
---|
35 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
36 | *
|
---|
37 | * ***** END LICENSE BLOCK ***** */
|
---|
38 |
|
---|
39 | #include "nsIBinaryOutputStream.idl"
|
---|
40 | #include "nsrootidl.idl"
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * @See nsIObjectInputStream
|
---|
44 | * @See nsIBinaryOutputStream
|
---|
45 | */
|
---|
46 |
|
---|
47 | [scriptable, uuid(92c898ac-5fde-4b99-87b3-5d486422094b)]
|
---|
48 | interface nsIObjectOutputStream : nsIBinaryOutputStream
|
---|
49 | {
|
---|
50 | /**
|
---|
51 | * Write the object whose "root" or XPCOM-identity nsISupports is aObject.
|
---|
52 | * The cause for writing this object is a strong or weak reference, so the
|
---|
53 | * aIsStrongRef argument must tell which kind of pointer is being followed
|
---|
54 | * here during serialization.
|
---|
55 | *
|
---|
56 | * If the object has only one strong reference in the serialization and no
|
---|
57 | * weak refs, use writeSingleRefObject. This is a valuable optimization:
|
---|
58 | * it saves space in the stream, and cycles on both ends of the process.
|
---|
59 | *
|
---|
60 | * If the reference being serialized is a pointer to an interface not on
|
---|
61 | * the primary inheritance chain ending in the root nsISupports, you must
|
---|
62 | * call writeCompoundObject instead of this method.
|
---|
63 | */
|
---|
64 | void writeObject(in nsISupports aObject, in PRBool aIsStrongRef);
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Write an object referenced singly and strongly via its root nsISupports
|
---|
68 | * or a subclass of its root nsISupports. There must not be other refs to
|
---|
69 | * aObject in memory, or in the serialization.
|
---|
70 | */
|
---|
71 | void writeSingleRefObject(in nsISupports aObject);
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Write the object referenced by an interface pointer at aObject that
|
---|
75 | * inherits from a non-primary nsISupports, i.e., a reference to one of
|
---|
76 | * the multiply inherited interfaces derived from an nsISupports other
|
---|
77 | * than the root or XPCOM-identity nsISupports; or a reference to an
|
---|
78 | * inner object in the case of true XPCOM aggregation. aIID identifies
|
---|
79 | * this interface.
|
---|
80 | */
|
---|
81 | void writeCompoundObject(in nsISupports aObject,
|
---|
82 | in nsIIDRef aIID,
|
---|
83 | in PRBool aIsStrongRef);
|
---|
84 |
|
---|
85 | void writeID(in nsIDRef aID);
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Optimized serialization support -- see nsIStreamBufferAccess.idl.
|
---|
89 | */
|
---|
90 | [notxpcom] charPtr getBuffer(in PRUint32 aLength, in PRUint32 aAlignMask);
|
---|
91 | [notxpcom] void putBuffer(in charPtr aBuffer, in PRUint32 aLength);
|
---|
92 | };
|
---|
93 |
|
---|
94 | %{C++
|
---|
95 |
|
---|
96 | inline nsresult
|
---|
97 | NS_WriteOptionalObject(nsIObjectOutputStream* aStream, nsISupports* aObject,
|
---|
98 | PRBool aIsStrongRef)
|
---|
99 | {
|
---|
100 | PRBool nonnull = (aObject != nsnull);
|
---|
101 | nsresult rv = aStream->WriteBoolean(nonnull);
|
---|
102 | if (NS_SUCCEEDED(rv) && nonnull)
|
---|
103 | rv = aStream->WriteObject(aObject, aIsStrongRef);
|
---|
104 | return rv;
|
---|
105 | }
|
---|
106 |
|
---|
107 | inline nsresult
|
---|
108 | NS_WriteOptionalSingleRefObject(nsIObjectOutputStream* aStream,
|
---|
109 | nsISupports* aObject)
|
---|
110 | {
|
---|
111 | PRBool nonnull = (aObject != nsnull);
|
---|
112 | nsresult rv = aStream->WriteBoolean(nonnull);
|
---|
113 | if (NS_SUCCEEDED(rv) && nonnull)
|
---|
114 | rv = aStream->WriteSingleRefObject(aObject);
|
---|
115 | return rv;
|
---|
116 | }
|
---|
117 |
|
---|
118 | inline nsresult
|
---|
119 | NS_WriteOptionalCompoundObject(nsIObjectOutputStream* aStream,
|
---|
120 | nsISupports* aObject,
|
---|
121 | const nsIID& aIID,
|
---|
122 | PRBool aIsStrongRef)
|
---|
123 | {
|
---|
124 | PRBool nonnull = (aObject != nsnull);
|
---|
125 | nsresult rv = aStream->WriteBoolean(nonnull);
|
---|
126 | if (NS_SUCCEEDED(rv) && nonnull)
|
---|
127 | rv = aStream->WriteCompoundObject(aObject, aIID, aIsStrongRef);
|
---|
128 | return rv;
|
---|
129 | }
|
---|
130 |
|
---|
131 | %}
|
---|