/*
 * DO NOT EDIT.  THIS FILE IS GENERATED FROM $SRCDIR/xpcom/io/nsIObjectOutputStream.idl
 */

#ifndef __gen_nsIObjectOutputStream_h__
#define __gen_nsIObjectOutputStream_h__


#include "nsIBinaryOutputStream.h"

/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif

/* starting interface:    nsIObjectOutputStream */
#define NS_IOBJECTOUTPUTSTREAM_IID_STR "92c898ac-5fde-4b99-87b3-5d486422094b"

#define NS_IOBJECTOUTPUTSTREAM_IID \
  {0x92c898ac, 0x5fde, 0x4b99, \
    { 0x87, 0xb3, 0x5d, 0x48, 0x64, 0x22, 0x09, 0x4b }}

class NS_NO_VTABLE MOZ_BINDING(binding_to, idl, class, XPIDL_nsIObjectOutputStream) nsIObjectOutputStream : public nsIBinaryOutputStream {
 public:

  NS_INLINE_DECL_STATIC_IID(NS_IOBJECTOUTPUTSTREAM_IID)

  /* Used by ToJSValue to check which scriptable interface is implemented. */
  using ScriptableInterfaceType = nsIObjectOutputStream;

  /* [must_use] void writeObject (in nsISupports aObject, in boolean aIsStrongRef); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeObject)
  [[nodiscard]] NS_IMETHOD WriteObject(nsISupports *aObject, bool aIsStrongRef) = 0;

  /* [must_use] void writeSingleRefObject (in nsISupports aObject); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeSingleRefObject)
  [[nodiscard]] NS_IMETHOD WriteSingleRefObject(nsISupports *aObject) = 0;

  /* [must_use] void writeCompoundObject (in nsISupports aObject, in nsIIDRef aIID, in boolean aIsStrongRef); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeCompoundObject)
  [[nodiscard]] NS_IMETHOD WriteCompoundObject(nsISupports *aObject, const nsIID & aIID, bool aIsStrongRef) = 0;

  /* [must_use] void writeID (in nsIDRef aID); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeID)
  [[nodiscard]] NS_IMETHOD WriteID(const nsID & aID) = 0;

  /* [must_use,notxpcom] charPtr getBuffer (in uint32_t aLength, in uint32_t aAlignMask); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_getBuffer)
  [[nodiscard]] NS_IMETHOD_(char *) GetBuffer(uint32_t aLength, uint32_t aAlignMask) = 0;

  /* [notxpcom] void putBuffer (in charPtr aBuffer, in uint32_t aLength); */
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_putBuffer)
  NS_IMETHOD_(void) PutBuffer(char * aBuffer, uint32_t aLength) = 0;

};


/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIOBJECTOUTPUTSTREAM \
  [[nodiscard]] NS_IMETHOD WriteObject(nsISupports *aObject, bool aIsStrongRef) override; \
  [[nodiscard]] NS_IMETHOD WriteSingleRefObject(nsISupports *aObject) override; \
  [[nodiscard]] NS_IMETHOD WriteCompoundObject(nsISupports *aObject, const nsIID & aIID, bool aIsStrongRef) override; \
  [[nodiscard]] NS_IMETHOD WriteID(const nsID & aID) override; \
  [[nodiscard]] NS_IMETHOD_(char *) GetBuffer(uint32_t aLength, uint32_t aAlignMask) override; \
  NS_IMETHOD_(void) PutBuffer(char * aBuffer, uint32_t aLength) override; 

/* Use this macro when declaring the members of this interface when the
   class doesn't implement the interface. This is useful for forwarding. */
#define NS_DECL_NON_VIRTUAL_NSIOBJECTOUTPUTSTREAM \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeObject)\
  [[nodiscard]] nsresult WriteObject(nsISupports *aObject, bool aIsStrongRef); \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeSingleRefObject)\
  [[nodiscard]] nsresult WriteSingleRefObject(nsISupports *aObject); \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeCompoundObject)\
  [[nodiscard]] nsresult WriteCompoundObject(nsISupports *aObject, const nsIID & aIID, bool aIsStrongRef); \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_writeID)\
  [[nodiscard]] nsresult WriteID(const nsID & aID); \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_getBuffer)\
  [[nodiscard]] nsresult_(char *) GetBuffer(uint32_t aLength, uint32_t aAlignMask); \
  MOZ_BINDING(binding_to, idl, method, XPIDL_nsIObjectOutputStream_putBuffer)\
  nsresult_(void) PutBuffer(char * aBuffer, uint32_t aLength); 

/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIOBJECTOUTPUTSTREAM(_to) \
  [[nodiscard]] NS_IMETHOD WriteObject(nsISupports *aObject, bool aIsStrongRef) override { return _to WriteObject(aObject, aIsStrongRef); } \
  [[nodiscard]] NS_IMETHOD WriteSingleRefObject(nsISupports *aObject) override { return _to WriteSingleRefObject(aObject); } \
  [[nodiscard]] NS_IMETHOD WriteCompoundObject(nsISupports *aObject, const nsIID & aIID, bool aIsStrongRef) override { return _to WriteCompoundObject(aObject, aIID, aIsStrongRef); } \
  [[nodiscard]] NS_IMETHOD WriteID(const nsID & aID) override { return _to WriteID(aID); } \
  [[nodiscard]] NS_IMETHOD_(char *) GetBuffer(uint32_t aLength, uint32_t aAlignMask) override { return _to GetBuffer(aLength, aAlignMask); } \
  NS_IMETHOD_(void) PutBuffer(char * aBuffer, uint32_t aLength) override { return _to PutBuffer(aBuffer, aLength); } 

/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIOBJECTOUTPUTSTREAM(_to) \
  [[nodiscard]] NS_IMETHOD WriteObject(nsISupports *aObject, bool aIsStrongRef) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteObject(aObject, aIsStrongRef); } \
  [[nodiscard]] NS_IMETHOD WriteSingleRefObject(nsISupports *aObject) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteSingleRefObject(aObject); } \
  [[nodiscard]] NS_IMETHOD WriteCompoundObject(nsISupports *aObject, const nsIID & aIID, bool aIsStrongRef) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteCompoundObject(aObject, aIID, aIsStrongRef); } \
  [[nodiscard]] NS_IMETHOD WriteID(const nsID & aID) override { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteID(aID); } \
  [[nodiscard]] NS_IMETHOD_(char *) GetBuffer(uint32_t aLength, uint32_t aAlignMask) override; \
  NS_IMETHOD_(void) PutBuffer(char * aBuffer, uint32_t aLength) override; 

// %{C++:67-106
already_AddRefed<nsIObjectOutputStream>
NS_NewObjectOutputStream(nsIOutputStream* aOutputStream);

[[nodiscard]] inline nsresult
NS_WriteOptionalObject(nsIObjectOutputStream* aStream, nsISupports* aObject,
                       bool aIsStrongRef)
{
    bool nonnull = (aObject != nullptr);
    MOZ_TRY(aStream->WriteBoolean(nonnull));
    if (nonnull) {
        MOZ_TRY(aStream->WriteObject(aObject, aIsStrongRef));
    }
    return NS_OK;
}

[[nodiscard]] inline nsresult
NS_WriteOptionalSingleRefObject(nsIObjectOutputStream* aStream,
                                nsISupports* aObject)
{
    bool nonnull = (aObject != nullptr);
    MOZ_TRY(aStream->WriteBoolean(nonnull));
    if (nonnull) {
        MOZ_TRY(aStream->WriteSingleRefObject(aObject));
    }
    return NS_OK;
}

[[nodiscard]] inline nsresult
NS_WriteOptionalCompoundObject(nsIObjectOutputStream* aStream,
                               nsISupports* aObject,
                               const nsIID& aIID,
                               bool aIsStrongRef)
{
    bool nonnull = (aObject != nullptr);
    MOZ_TRY(aStream->WriteBoolean(nonnull));
    if (nonnull) {
        MOZ_TRY(aStream->WriteCompoundObject(aObject, aIID, aIsStrongRef));
    }
    return NS_OK;
}
// %}

#endif /* __gen_nsIObjectOutputStream_h__ */
