| |
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/. */ |
| |
5 |
| |
6 #include "nsIBinaryInputStream.idl" |
| |
7 |
| |
8 /** |
| |
9 * @see nsIObjectOutputStream |
| |
10 * @see nsIBinaryInputStream |
| |
11 */ |
| |
12 |
| |
13 [scriptable, uuid(6c248606-4eae-46fa-9df0-ba58502368eb)] |
| |
14 interface nsIObjectInputStream : nsIBinaryInputStream |
| |
15 { |
| |
16 /** |
| |
17 * Read an object from this stream to satisfy a strong or weak reference |
| |
18 * to one of its interfaces. If the interface was not along the primary |
| |
19 * inheritance chain ending in the "root" or XPCOM-identity nsISupports, |
| |
20 * readObject will QueryInterface from the deserialized object root to the |
| |
21 * correct interface, which was specified when the object was serialized. |
| |
22 * |
| |
23 * @see nsIObjectOutputStream |
| |
24 */ |
| |
25 nsISupports readObject(in boolean aIsStrongRef); |
| |
26 |
| |
27 [notxpcom] nsresult readID(out nsID aID); |
| |
28 |
| |
29 /** |
| |
30 * Optimized deserialization support -- see nsIStreamBufferAccess.idl. |
| |
31 */ |
| |
32 [notxpcom] charPtr getBuffer(in uint32_t aLength, in uint32_t aAlignMask); |
| |
33 [notxpcom] void putBuffer(in charPtr aBuffer, in uint32_t aLength); |
| |
34 }; |
| |
35 |
| |
36 %{C++ |
| |
37 |
| |
38 inline nsresult |
| |
39 NS_ReadOptionalObject(nsIObjectInputStream* aStream, bool aIsStrongRef, |
| |
40 nsISupports* *aResult) |
| |
41 { |
| |
42 bool nonnull; |
| |
43 nsresult rv = aStream->ReadBoolean(&nonnull); |
| |
44 if (NS_SUCCEEDED(rv)) { |
| |
45 if (nonnull) |
| |
46 rv = aStream->ReadObject(aIsStrongRef, aResult); |
| |
47 else |
| |
48 *aResult = nullptr; |
| |
49 } |
| |
50 return rv; |
| |
51 } |
| |
52 |
| |
53 %} |