Skip to content

Commit

Permalink
Add remaining PyFloat APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher committed Jun 19, 2019
1 parent 5838dca commit f40ecd3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,12 @@
("PyFloat_AsDouble", "O", "d"),
("PyFloat_Check", "O", "i"),
("PyFloat_CheckExact", "O", "i"),
("PyFloat_ClearFreeList", "", "i"),
("PyFloat_FromDouble", "d", "N"),
("PyFloat_FromString", "O", "N"),
("PyFloat_GetInfo", "", "N"),
("PyFloat_GetMax", "", "d"),
("PyFloat_GetMin", "", "d"),
("PyFrozenSet_Check", "O", "i"),
("PyFrozenSet_CheckExact", "O", "i"),
("PyFrozenSet_New", "O", "N"),
Expand Down
42 changes: 42 additions & 0 deletions pycapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4019,6 +4019,19 @@ static PyObject* capi_PyFloat_CheckExact(PyObject* Py_UNUSED(self), PyObject* ar
return PyLong_FromLong(result);
}

static PyObject* capi_PyFloat_ClearFreeList(PyObject* Py_UNUSED(self), PyObject* Py_UNUSED(null)) {

int result;

result = PyFloat_ClearFreeList();

if (PyErr_Occurred()) {
return NULL;
}

return PyLong_FromLong(result);
}

static PyObject* capi_PyFloat_FromDouble(PyObject* Py_UNUSED(self), PyObject* args) {

double arg0;
Expand Down Expand Up @@ -4079,6 +4092,32 @@ static PyObject* capi_PyFloat_GetInfo(PyObject* Py_UNUSED(self), PyObject* Py_UN
return result;
}

static PyObject* capi_PyFloat_GetMax(PyObject* Py_UNUSED(self), PyObject* Py_UNUSED(null)) {

double result;

result = PyFloat_GetMax();

if (PyErr_Occurred()) {
return NULL;
}

return PyFloat_FromDouble(result);
}

static PyObject* capi_PyFloat_GetMin(PyObject* Py_UNUSED(self), PyObject* Py_UNUSED(null)) {

double result;

result = PyFloat_GetMin();

if (PyErr_Occurred()) {
return NULL;
}

return PyFloat_FromDouble(result);
}

/* PyFrozenSet */

static PyObject* capi_PyFrozenSet_Check(PyObject* Py_UNUSED(self), PyObject* arg) {
Expand Down Expand Up @@ -11653,9 +11692,12 @@ static PyMethodDef CAPIMethods[] = {
{"PyFloat_AsDouble", capi_PyFloat_AsDouble, METH_O, NULL},
{"PyFloat_Check", capi_PyFloat_Check, METH_O, NULL},
{"PyFloat_CheckExact", capi_PyFloat_CheckExact, METH_O, NULL},
{"PyFloat_ClearFreeList", capi_PyFloat_ClearFreeList, METH_NOARGS, NULL},
{"PyFloat_FromDouble", capi_PyFloat_FromDouble, METH_VARARGS, NULL},
{"PyFloat_FromString", capi_PyFloat_FromString, METH_O, NULL},
{"PyFloat_GetInfo", capi_PyFloat_GetInfo, METH_NOARGS, NULL},
{"PyFloat_GetMax", capi_PyFloat_GetMax, METH_NOARGS, NULL},
{"PyFloat_GetMin", capi_PyFloat_GetMin, METH_NOARGS, NULL},

/* PyFrozenSet */

Expand Down
3 changes: 3 additions & 0 deletions pycapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,12 @@ def PyFloat_AS_DOUBLE(__0: object) -> float: ...
def PyFloat_AsDouble(__0: object) -> float: ...
def PyFloat_Check(__0: object) -> int: ...
def PyFloat_CheckExact(__0: object) -> int: ...
def PyFloat_ClearFreeList() -> int: ...
def PyFloat_FromDouble(__0: float) -> typing.Any: ...
def PyFloat_FromString(__0: object) -> typing.Any: ...
def PyFloat_GetInfo() -> typing.Any: ...
def PyFloat_GetMax() -> float: ...
def PyFloat_GetMin() -> float: ...

# PyFrozenSet

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
long_description_content_type="text/markdown",
name="pycapi",
url="https://github.com/brandtbucher/pycapi",
version="0.59.0",
version="0.60.0",
)

0 comments on commit f40ecd3

Please sign in to comment.