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_rpnexpr.h 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_PYRPN_H__
  20. #define _PYTHON_PYRPN_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_jit.h"
  27. /**@defgroup python_type RPNExpr Python class
  28. * @brief Exposed Python class : RPNExpr
  29. * @ingroup python_ext
  30. */
  31. /**@file python_rpnexpr.h
  32. * @brief Python RPNExpr type headers
  33. * @ingroup python_type
  34. *
  35. * This file is the header of the RPNExpr Python class
  36. */
  37. /**@brief RPNExpr Python class methods list
  38. * @ingroup python_type */
  39. extern PyMethodDef RPNExpr_methods[];
  40. /**@brief RPNExpr Python class members list
  41. * @ingroup python_type */
  42. extern PyMemberDef RPNExpr_members[];
  43. /**@brief RPNExpr Python class type definition
  44. * @ingroup python_type */
  45. extern PyTypeObject RPNExprType;
  46. /**@brief Structure holding RPNExpr objects
  47. * @ingroup python_type */
  48. typedef struct
  49. {
  50. PyObject_VAR_HEAD;
  51. /**@brief Pointer on @ref rpn_expr_s */
  52. rpn_expr_t *rpn;
  53. /**@brief Array storing expression argument
  54. * @note As attribute of rpn_expr allowing malloc & free only once */
  55. unsigned long *args;
  56. } PyRPNExpr_t;
  57. /**@brief RpnExpr __new__ method
  58. * @param subtype Type of object being created (pyrpn.RPNExpr)
  59. * @param args positional arguments for subtype
  60. * @param kwargs keyword argumenrs for subtype
  61. * @return The new Python RPNExpr object
  62. */
  63. PyObject* rpnexpr_new(PyTypeObject *subtype, PyObject *args, PyObject* kwds);
  64. /**@brief RpnExpr constructor
  65. * @param self New RPNExpr instance
  66. * @param args Positional arguments list
  67. * @param kwds Keywords arguments dict
  68. * @return 0 if no error else -1
  69. * @ingroup python_type
  70. */
  71. int rpnexpr_init(PyObject *self, PyObject *args, PyObject *kwds);
  72. /**@brief RPNExpr __del__ method
  73. * @param self RPNExpr instance
  74. * @ingroup python_type
  75. */
  76. void rpnexpr_del(PyObject *self);
  77. /**@brief Eval an RPN expression given arguments and return the
  78. * value
  79. * @param self RPNExpr instance
  80. * @param argv Array of PyObject* arguments
  81. * @param argc Number of arguments
  82. * @return The value resulting of evaluation
  83. * @ingroup python_type
  84. */
  85. PyObject* rpnexpr_eval(PyObject* self, PyObject** argv, Py_ssize_t argc);
  86. /**@brief Set all stack item to zero
  87. * @param self RPNExpr instance
  88. * @param noargs Dummy argument for METH_NOARG
  89. * @return None
  90. * @ingroup python_type
  91. */
  92. PyObject* rpnexpr_reset_stack(PyObject *self, PyObject *noargs);
  93. /**@brief RPNExpr.__repr__()
  94. * @param self RPNExpr instance
  95. * @ingroup python_type
  96. */
  97. PyObject* rpnexpr_repr(PyObject *self);
  98. /**@brief RPNExpr.__str__()
  99. * @param self RPNExpr instance
  100. * @ingroup python_type
  101. */
  102. PyObject* rpnexpr_str(PyObject *self);
  103. #endif