Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
PyG_nsIInputStream Class Reference
Inheritance diagram for PyG_nsIInputStream:
Inheritance graph
[legend]
Collaboration diagram for PyG_nsIInputStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PyG_nsIInputStream (PyObject *instance)
 PYGATEWAY_BASE_SUPPORT (nsIInputStream, PyG_Base)
NS_IMETHOD Close (void)
NS_IMETHOD Available (PRUint32 *_retval)
NS_IMETHOD Read (char *buf, PRUint32 count, PRUint32 *_retval)
NS_IMETHOD ReadSegments (nsWriteSegmentFun writer, void *closure, PRUint32 count, PRUint32 *_retval)
NS_IMETHOD IsNonBlocking (PRBool *aNonBlocking)
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Detailed Description

Definition at line 52 of file PyGInputStream.cpp.


Constructor & Destructor Documentation

PyG_nsIInputStream::PyG_nsIInputStream ( PyObject *  instance) [inline]

Definition at line 55 of file PyGInputStream.cpp.

: PyG_Base(instance, NS_GET_IID(nsIInputStream)) {;}

Member Function Documentation

Definition at line 80 of file PyGInputStream.cpp.

{
       NS_PRECONDITION(_retval, "null pointer");
       CEnterLeavePython _celp;
       PyObject *ret;
       const char *methodName = "available";
       nsresult nr = InvokeNativeViaPolicy(methodName, &ret);
       if (NS_SUCCEEDED(nr)) {
              *_retval = PyInt_AsLong(ret);
              if (PyErr_Occurred())
                     nr = HandleNativeGatewayError(methodName);
              Py_XDECREF(ret);
       }
       return nr;
}
unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream

Definition at line 72 of file PyGInputStream.cpp.

{
       CEnterLeavePython _celp;
       const char *methodName = "close";
       return InvokeNativeViaPolicy(methodName, NULL);
}
void nsIInputStream::close ( ) [inherited]

Close the stream.

Definition at line 132 of file PyGInputStream.cpp.

{
       NS_PRECONDITION(aNonBlocking, "null pointer");
       CEnterLeavePython _celp;
       PyObject *ret;
       const char *methodName = "isNonBlocking";
       nsresult nr = InvokeNativeViaPolicy(methodName, &ret);
       if (NS_SUCCEEDED(nr)) {
              *aNonBlocking = PyInt_AsLong(ret);
              if (PyErr_Occurred())
                     nr = HandleNativeGatewayError(methodName);
              Py_XDECREF(ret);
       }
       return nr;
}
Returns:
true if stream is non-blocking
NS_IMETHODIMP PyG_nsIInputStream::Read ( char *  buf,
PRUint32  count,
PRUint32 _retval 
)

Definition at line 97 of file PyGInputStream.cpp.

{
       NS_PRECONDITION(_retval, "null pointer");
       NS_PRECONDITION(buf, "null pointer");
       CEnterLeavePython _celp;
       PyObject *ret;
       const char *methodName = "read";
       nsresult nr = InvokeNativeViaPolicy(methodName, &ret, "i", count);
       if (NS_SUCCEEDED(nr)) {
              PRUint32 py_size;
              const void *py_buf;
              if (PyObject_AsReadBuffer(ret, &py_buf, (int *)&py_size)!=0) {
                     PyErr_Format(PyExc_TypeError, "nsIInputStream::read() method must return a buffer object - not a '%s' object", ret->ob_type->tp_name);
                     nr = HandleNativeGatewayError(methodName);
              } else {
                     if (py_size > count) {
                            PyXPCOM_LogWarning("nsIInputStream::read() was asked for %d bytes, but the string returned is %d bytes - truncating!\n", count, py_size);
                            py_size = count;
                     }
                     memcpy(buf, py_buf, py_size);
                     *_retval = py_size;
              }
       }
       return nr;
}

Here is the call graph for this function:

unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
NS_IMETHODIMP PyG_nsIInputStream::ReadSegments ( nsWriteSegmentFun  writer,
void closure,
PRUint32  count,
PRUint32 _retval 
)

Definition at line 125 of file PyGInputStream.cpp.

{
       NS_WARNING("ReadSegments() not implemented!!!");
       return NS_ERROR_NOT_IMPLEMENTED;
}
unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).


The documentation for this class was generated from the following file: