xpcom/io/nsIObjectInputStream.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/io/nsIObjectInputStream.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     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 +#include "nsIBinaryInputStream.idl"
    1.10 +
    1.11 +/**
    1.12 + * @see nsIObjectOutputStream
    1.13 + * @see nsIBinaryInputStream
    1.14 + */
    1.15 +
    1.16 +[scriptable, uuid(6c248606-4eae-46fa-9df0-ba58502368eb)]
    1.17 +interface nsIObjectInputStream : nsIBinaryInputStream
    1.18 +{
    1.19 +    /**
    1.20 +     * Read an object from this stream to satisfy a strong or weak reference
    1.21 +     * to one of its interfaces.  If the interface was not along the primary
    1.22 +     * inheritance chain ending in the "root" or XPCOM-identity nsISupports,
    1.23 +     * readObject will QueryInterface from the deserialized object root to the
    1.24 +     * correct interface, which was specified when the object was serialized.
    1.25 +     *
    1.26 +     * @see nsIObjectOutputStream
    1.27 +     */
    1.28 +    nsISupports readObject(in boolean aIsStrongRef);
    1.29 +
    1.30 +    [notxpcom] nsresult readID(out nsID aID);
    1.31 +
    1.32 +    /**
    1.33 +     * Optimized deserialization support -- see nsIStreamBufferAccess.idl.
    1.34 +     */
    1.35 +    [notxpcom] charPtr getBuffer(in uint32_t aLength, in uint32_t aAlignMask);
    1.36 +    [notxpcom] void    putBuffer(in charPtr aBuffer, in uint32_t aLength);
    1.37 +};
    1.38 +
    1.39 +%{C++
    1.40 +
    1.41 +inline nsresult
    1.42 +NS_ReadOptionalObject(nsIObjectInputStream* aStream, bool aIsStrongRef,
    1.43 +                      nsISupports* *aResult)
    1.44 +{
    1.45 +    bool nonnull;
    1.46 +    nsresult rv = aStream->ReadBoolean(&nonnull);
    1.47 +    if (NS_SUCCEEDED(rv)) {
    1.48 +        if (nonnull)
    1.49 +            rv = aStream->ReadObject(aIsStrongRef, aResult);
    1.50 +        else
    1.51 +            *aResult = nullptr;
    1.52 +    }
    1.53 +    return rv;
    1.54 +}
    1.55 +
    1.56 +%}

mercurial