Author vstinner
Recipients gvanrossum, loewis, pitrou, sbt, vstinner
Date 2014-01-28.08:31:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390897917.96.0.44504756303.issue20414@psf.upfronthosting.co.za>
In-reply-to
Content
> One sub issue then is naming: _overlapped renamed Overlapped.GetOverlappedResult to Overlapped.getresult. I think the _winapi name is better, since all other methods also use Windows API function names.

I also prefer Overlapped.GetOverlappedResult name.

There are other differences. Using _overlapped, the overlapped object is created before calling an operation like WriteFile() or AcceptEx() (ex: ov.WriteFile(...)). Using _winapi, the operation may create an overlapped object if asked (ex: WriteFile(..., overlapped=True)).

The structure is different.

_winapi.c:
---
typedef struct {
    PyObject_HEAD
    OVERLAPPED overlapped;
    /* For convenience, we store the file handle too */
    HANDLE handle;
    /* Whether there's I/O in flight */
    int pending;
    /* Whether I/O completed successfully */
    int completed;
    /* Buffer used for reading (optional) */
    PyObject *read_buffer;
    /* Buffer used for writing (optional) */
    Py_buffer write_buffer;
} OverlappedObject;
---

overlapped.c:
---
enum {TYPE_NONE, TYPE_NOT_STARTED, TYPE_READ, TYPE_WRITE, TYPE_ACCEPT,
      TYPE_CONNECT, TYPE_DISCONNECT, TYPE_CONNECT_NAMED_PIPE,
      TYPE_WAIT_NAMED_PIPE_AND_CONNECT};

typedef struct {
    PyObject_HEAD
    OVERLAPPED overlapped;
    /* For convenience, we store the file handle too */
    HANDLE handle;
    /* Error returned by last method call */
    DWORD error;
    /* Type of operation */
    DWORD type;
    union {
        /* Buffer used for reading (optional) */
        PyObject *read_buffer;
        /* Buffer used for writing (optional) */
        Py_buffer write_buffer;
    };
} OverlappedObject;
---

And the object in overlapped.c has much more methods.

_winapi.c:
---
static PyMethodDef overlapped_methods[] = {
    {"GetOverlappedResult", (PyCFunction) overlapped_GetOverlappedResult,
                            METH_O, NULL},
    {"getbuffer", (PyCFunction) overlapped_getbuffer, METH_NOARGS, NULL},
    {"cancel", (PyCFunction) overlapped_cancel, METH_NOARGS, NULL},
    {NULL}
};
---

overlapped.c:
---
static PyMethodDef Overlapped_methods[] = {
    {"getresult", (PyCFunction) Overlapped_getresult,
     METH_VARARGS, Overlapped_getresult_doc},
    {"cancel", (PyCFunction) Overlapped_cancel,
     METH_NOARGS, Overlapped_cancel_doc},
    {"ReadFile", (PyCFunction) Overlapped_ReadFile,
     METH_VARARGS, Overlapped_ReadFile_doc},
    {"WSARecv", (PyCFunction) Overlapped_WSARecv,
     METH_VARARGS, Overlapped_WSARecv_doc},
    {"WriteFile", (PyCFunction) Overlapped_WriteFile,
     METH_VARARGS, Overlapped_WriteFile_doc},
    {"WSASend", (PyCFunction) Overlapped_WSASend,
     METH_VARARGS, Overlapped_WSASend_doc},
    {"AcceptEx", (PyCFunction) Overlapped_AcceptEx,
     METH_VARARGS, Overlapped_AcceptEx_doc},
    {"ConnectEx", (PyCFunction) Overlapped_ConnectEx,
     METH_VARARGS, Overlapped_ConnectEx_doc},
    {"DisconnectEx", (PyCFunction) Overlapped_DisconnectEx,
     METH_VARARGS, Overlapped_DisconnectEx_doc},
    {"ConnectNamedPipe", (PyCFunction) Overlapped_ConnectNamedPipe,
     METH_VARARGS, Overlapped_ConnectNamedPipe_doc},
    {"WaitNamedPipeAndConnect",
     (PyCFunction) Overlapped_WaitNamedPipeAndConnect,
     METH_VARARGS, Overlapped_WaitNamedPipeAndConnect_doc},
    {NULL}
};
---

_winapi.c doesn't provide AcceptEx() nor Accept().
History
Date User Action Args
2014-01-28 08:31:58vstinnersetrecipients: + vstinner, gvanrossum, loewis, pitrou, sbt
2014-01-28 08:31:57vstinnersetmessageid: <1390897917.96.0.44504756303.issue20414@psf.upfronthosting.co.za>
2014-01-28 08:31:57vstinnerlinkissue20414 messages
2014-01-28 08:31:57vstinnercreate