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_ifs.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2020,2023 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_IFS_H__
  20. #define _PYTHON_IFS_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 "rpn_ifs.h"
  29. #include "python_rpnexpr.h"
  30. #include "python_if.h"
  31. #include "python_const.h"
  32. /**@file python_ifs.h */
  33. /** @brief RPNIFS Python class type definition */
  34. extern PyTypeObject RPNIFSType;
  35. /**@brief Points on Python's std mmap module */
  36. extern PyObject *mmap_module;
  37. /**@brief Python's mmap.mmap class */
  38. extern PyObject *mmap_cls;
  39. /** @brief Structure holding RPNIFS attributes */
  40. typedef struct
  41. {
  42. PyObject_VAR_HEAD;
  43. /** @brief Tuple with RPNIterExpr instances */
  44. PyObject *rpn_if;
  45. /** @brief Tuple with RPNExpr instances */
  46. PyObject *rpn_expr;
  47. /** @brief IFS pointer */
  48. rpn_ifs_t *ifs;
  49. /** @brief Pointer on IF expressions in the system */
  50. rpn_if_t **rifs;
  51. /**@brief Python mmap.mmap instance representing rif memory map
  52. * @note NULL if unpickled instance */
  53. PyObject *mmap;
  54. /**@brief Memory map buffer allowing acces to underlying pointer
  55. * @note unrelevant if unpickled instance */
  56. Py_buffer mm_buff;
  57. /**@brief Memory map buffer pointer */
  58. void *_mmap;
  59. } PyRPNIFS_t;
  60. PyObject *rpnifs_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);
  61. int rpnifs_init(PyObject *self, PyObject *args, PyObject *kwds);
  62. void rpnifs_del(PyObject *self);
  63. PyObject *rpnifs_to_pos(PyObject *self, PyObject** argv, Py_ssize_t argc);
  64. PyObject *rpnifs_from_pos(PyObject *self, PyObject* _pos);
  65. PyObject *rpnifs_weights(PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  66. PyObject *rpnifs_weight(PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  67. PyObject *rpnifs_position(PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  68. PyObject *rpnifs_run(PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  69. PyObject *rpnifs_str(PyObject *self);
  70. PyObject *rpnifs_repr(PyObject *self);
  71. Py_ssize_t rpnifs_len(PyObject *self);
  72. PyObject *rpnifs_expr_item(PyObject *self, Py_ssize_t idx);
  73. int rpnifs_expr_ass_item(PyObject *self, Py_ssize_t idx, PyObject *value);
  74. int rpnifs_getbuffer(PyObject *self, Py_buffer *view, int flags);
  75. void rpnifs_releasebuffer(PyObject *self, Py_buffer *view);
  76. int _rpnifs_update_if_tuple(PyRPNIFS_t *ifs_self);
  77. #endif