Fast IFS using RPN notation
python
c
x86-64
nasm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

python_if.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (C) 2020 Weber Yann
  3. *
  4. * This file is part of pyrpn.
  5. *
  6. * pyrpn is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * pyrpn is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _PYTHON_IF_H__
  20. #define _PYTHON_IF_H__
  21. #include "config.h"
  22. #include <errno.h>
  23. #define PY_SSIZE_T_CLEAN
  24. #include <Python.h>
  25. #include "structmember.h"
  26. #include "rpn_if.h"
  27. #include "rpn_if_default.h"
  28. #include "python_rpnexpr.h"
  29. /**@defgroup python_if RPN Iterated Function Python class
  30. * @ingroup python_module
  31. * @brief Exposed Python class : RPNIterExpr
  32. *
  33. * Iterated expression are composed of RPN expressions, they are able to
  34. * iterate taking their parameters from a memory array and setting back values
  35. * in it on each iteration.
  36. *
  37. * @see ifs_if
  38. */
  39. /**@file python_if.h
  40. * @brief Python RPNIterExpr type headers
  41. * @ingroup python_if
  42. *
  43. * This file is the header of the RPNIterExpr Python class
  44. */
  45. /**@brief RPNIterExpr Python class methods list
  46. * @ingroup python_if */
  47. extern PyMethodDef RPNIterExpr_methods[];
  48. /**@brief RPNIterExpr Python class members list
  49. * @ingroup python_if */
  50. extern PyMemberDef RPNIterExpr_members[];
  51. /**@brief RPNIterExpr Python class type definition
  52. * @ingroup python_if */
  53. extern PyTypeObject RPNIterExprType;
  54. /**@brief Structure holding RPNIterExpr objects
  55. * @ingroup python_if */
  56. typedef struct
  57. {
  58. PyObject_VAR_HEAD;
  59. /**@brief Pointer on @ref rpn_if_s */
  60. rpn_if_t *rif;
  61. } PyRPNIterExpr_t;
  62. /**@brief RpnIterExpr __new__ method
  63. * @param subtype Type of object being created (pyrpn.RPNIterExpr)
  64. * @param args positional arguments for subtype
  65. * @param kwargs keyword argumenrs for subtype
  66. * @return The new Python RPNIterExpr object
  67. */
  68. PyObject* rpnif_new(PyTypeObject *subtype, PyObject* args, PyObject* kwds);
  69. /**@brief RpnIterExpr constructor
  70. * @param self New RPNIterExpr instance
  71. * @param args Positional arguments list
  72. * @param kwds Keywords arguments dict
  73. * @return 0 if no error else -1
  74. * @ingroup python_if
  75. */
  76. int rpnif_init(PyObject *self, PyObject *args, PyObject *kwds);
  77. /**@brief RPNIterExpr __del__ method
  78. * @param self RPNExpr instance
  79. * @ingroup python_type
  80. */
  81. void rpnif_del(PyObject *self);
  82. /**@brief RPNIterExpr __getstate__ method for pickling
  83. * @param cls RPNIterExpr type object
  84. * @param noargs Not an argument...
  85. * @return A bytes Python instance suitable as argument for
  86. * @ref rpnexpr_setstate
  87. */
  88. PyObject* rpnif_getstate(PyObject *cls, PyObject *noargs);
  89. /**@brief RPNIterExpr __setstate__ method for pickling
  90. * @param cls RPNIterExpr type object
  91. * @param state Should by a bytes Python instance returned by @ref
  92. * rpnexpr_getstate
  93. * @return A bytes Python instance suitable as argument for
  94. * @ref rpnexpr_setstate
  95. */
  96. PyObject* rpnif_setstate(PyObject *cls, PyObject *state);
  97. /**@brief RPNIterExpr.__repr__()
  98. * @param self RPNIterExpr instance
  99. * @ingroup python_type
  100. */
  101. PyObject* rpnif_repr(PyObject *self);
  102. /**@brief RPNIterExpr.__str__()
  103. * @param self RPNIterExpr instance
  104. * @ingroup python_type
  105. */
  106. PyObject* rpnif_str(PyObject *self);
  107. #endif