Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions mypy/typeshed/stubs/librt/librt/internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class ReadBuffer:
class WriteBuffer:
def getvalue(self) -> bytes: ...

def write_bool(data: WriteBuffer, value: bool) -> None: ...
def read_bool(data: ReadBuffer) -> bool: ...
def write_str(data: WriteBuffer, value: str) -> None: ...
def read_str(data: ReadBuffer) -> str: ...
def write_bytes(data: WriteBuffer, value: bytes) -> None: ...
def read_bytes(data: ReadBuffer) -> bytes: ...
def write_float(data: WriteBuffer, value: float) -> None: ...
def read_float(data: ReadBuffer) -> float: ...
def write_int(data: WriteBuffer, value: int) -> None: ...
def read_int(data: ReadBuffer) -> int: ...
def write_tag(data: WriteBuffer, value: u8) -> None: ...
def read_tag(data: ReadBuffer) -> u8: ...
def write_bool(data: WriteBuffer, value: bool, /) -> None: ...
def read_bool(data: ReadBuffer, /) -> bool: ...
def write_str(data: WriteBuffer, value: str, /) -> None: ...
def read_str(data: ReadBuffer, /) -> str: ...
def write_bytes(data: WriteBuffer, value: bytes, /) -> None: ...
def read_bytes(data: ReadBuffer, /) -> bytes: ...
def write_float(data: WriteBuffer, value: float, /) -> None: ...
def read_float(data: ReadBuffer, /) -> float: ...
def write_int(data: WriteBuffer, value: int, /) -> None: ...
def read_int(data: ReadBuffer, /) -> int: ...
def write_tag(data: WriteBuffer, value: u8, /) -> None: ...
def read_tag(data: ReadBuffer, /) -> u8: ...
def cache_version() -> u8: ...
156 changes: 78 additions & 78 deletions mypyc/lib-rt/librt_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ read_bool_internal(PyObject *data) {
}

static PyObject*
read_bool(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_bool", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_bool(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_bool() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
char res = read_bool_internal(data);
if (unlikely(res == CPY_BOOL_ERROR))
Expand All @@ -365,14 +365,14 @@ write_bool_internal(PyObject *data, char value) {
}

static PyObject*
write_bool(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_bool", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_bool(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_bool() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
if (unlikely(!PyBool_Check(value))) {
PyErr_SetString(PyExc_TypeError, "value must be a bool");
Expand Down Expand Up @@ -445,13 +445,13 @@ read_str_internal(PyObject *data) {
}

static PyObject*
read_str(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_str", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_str(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_str() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
return read_str_internal(data);
}
Expand Down Expand Up @@ -506,14 +506,14 @@ write_str_internal(PyObject *data, PyObject *value) {
}

static PyObject*
write_str(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_str", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_str(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_str() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
if (unlikely(!PyUnicode_Check(value))) {
PyErr_SetString(PyExc_TypeError, "value must be a str");
Expand Down Expand Up @@ -561,13 +561,13 @@ read_bytes_internal(PyObject *data) {
}

static PyObject*
read_bytes(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_bytes", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_bytes(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_bytes() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
return read_bytes_internal(data);
}
Expand Down Expand Up @@ -596,14 +596,14 @@ write_bytes_internal(PyObject *data, PyObject *value) {
}

static PyObject*
write_bytes(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_bytes", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_bytes(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_bytes() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
if (unlikely(!PyBytes_Check(value))) {
PyErr_SetString(PyExc_TypeError, "value must be a bytes object");
Expand Down Expand Up @@ -633,13 +633,13 @@ read_float_internal(PyObject *data) {
}

static PyObject*
read_float(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_float", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_float(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_float() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
double retval = read_float_internal(data);
if (unlikely(retval == CPY_FLOAT_ERROR && PyErr_Occurred())) {
Expand All @@ -660,14 +660,14 @@ write_float_internal(PyObject *data, double value) {
}

static PyObject*
write_float(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_float", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_float(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_float() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
if (unlikely(!PyFloat_Check(value))) {
PyErr_SetString(PyExc_TypeError, "value must be a float");
Expand Down Expand Up @@ -735,13 +735,13 @@ read_int_internal(PyObject *data) {
}

static PyObject*
read_int(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_int", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_int(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_int() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
CPyTagged retval = read_int_internal(data);
if (unlikely(retval == CPY_INT_TAG)) {
Expand Down Expand Up @@ -841,14 +841,14 @@ write_int_internal(PyObject *data, CPyTagged value) {
}

static PyObject*
write_int(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_int", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_int(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_int() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
if (unlikely(!PyLong_Check(value))) {
PyErr_SetString(PyExc_TypeError, "value must be an int");
Expand Down Expand Up @@ -876,13 +876,13 @@ read_tag_internal(PyObject *data) {
}

static PyObject*
read_tag(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", 0};
static CPyArg_Parser parser = {"O:read_tag", kwlist, 0};
PyObject *data;
if (unlikely(!CPyArg_ParseStackAndKeywordsOneArg(args, nargs, kwnames, &parser, &data))) {
read_tag(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 1)) {
PyErr_Format(PyExc_TypeError,
"read_tag() takes exactly 1 argument (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
_CHECK_READ_BUFFER(data, NULL)
uint8_t retval = read_tag_internal(data);
if (unlikely(retval == CPY_LL_UINT_ERROR && PyErr_Occurred())) {
Expand All @@ -899,14 +899,14 @@ write_tag_internal(PyObject *data, uint8_t value) {
}

static PyObject*
write_tag(PyObject *self, PyObject *const *args, size_t nargs, PyObject *kwnames) {
static const char * const kwlist[] = {"data", "value", 0};
static CPyArg_Parser parser = {"OO:write_tag", kwlist, 0};
PyObject *data;
PyObject *value;
if (unlikely(!CPyArg_ParseStackAndKeywordsSimple(args, nargs, kwnames, &parser, &data, &value))) {
write_tag(PyObject *self, PyObject *const *args, size_t nargs) {
if (unlikely(nargs != 2)) {
PyErr_Format(PyExc_TypeError,
"write_tag() takes exactly 2 arguments (%zu given)", nargs);
return NULL;
}
PyObject *data = args[0];
PyObject *value = args[1];
_CHECK_WRITE_BUFFER(data, NULL)
uint8_t unboxed = CPyLong_AsUInt8(value);
if (unlikely(unboxed == CPY_LL_UINT_ERROR && PyErr_Occurred())) {
Expand Down Expand Up @@ -941,18 +941,18 @@ WriteBuffer_type_internal(void) {
};

static PyMethodDef librt_internal_module_methods[] = {
{"write_bool", (PyCFunction)write_bool, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write a bool")},
{"read_bool", (PyCFunction)read_bool, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read a bool")},
{"write_str", (PyCFunction)write_str, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write a string")},
{"read_str", (PyCFunction)read_str, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read a string")},
{"write_bytes", (PyCFunction)write_bytes, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write bytes")},
{"read_bytes", (PyCFunction)read_bytes, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read bytes")},
{"write_float", (PyCFunction)write_float, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write a float")},
{"read_float", (PyCFunction)read_float, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read a float")},
{"write_int", (PyCFunction)write_int, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write an int")},
{"read_int", (PyCFunction)read_int, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read an int")},
{"write_tag", (PyCFunction)write_tag, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("write a short int")},
{"read_tag", (PyCFunction)read_tag, METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("read a short int")},
{"write_bool", (PyCFunction)write_bool, METH_FASTCALL, PyDoc_STR("write a bool")},
{"read_bool", (PyCFunction)read_bool, METH_FASTCALL, PyDoc_STR("read a bool")},
{"write_str", (PyCFunction)write_str, METH_FASTCALL, PyDoc_STR("write a string")},
{"read_str", (PyCFunction)read_str, METH_FASTCALL, PyDoc_STR("read a string")},
{"write_bytes", (PyCFunction)write_bytes, METH_FASTCALL, PyDoc_STR("write bytes")},
{"read_bytes", (PyCFunction)read_bytes, METH_FASTCALL, PyDoc_STR("read bytes")},
{"write_float", (PyCFunction)write_float, METH_FASTCALL, PyDoc_STR("write a float")},
{"read_float", (PyCFunction)read_float, METH_FASTCALL, PyDoc_STR("read a float")},
{"write_int", (PyCFunction)write_int, METH_FASTCALL, PyDoc_STR("write an int")},
{"read_int", (PyCFunction)read_int, METH_FASTCALL, PyDoc_STR("read an int")},
{"write_tag", (PyCFunction)write_tag, METH_FASTCALL, PyDoc_STR("write a short int")},
{"read_tag", (PyCFunction)read_tag, METH_FASTCALL, PyDoc_STR("read a short int")},
{"cache_version", (PyCFunction)cache_version, METH_NOARGS, PyDoc_STR("cache format version")},
{NULL, NULL, 0, NULL}
};
Expand Down