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_pyrpn.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #include "python_rpnexpr.h"
  28. #include "python_if.h"
  29. #include "python_const.h"
  30. #include "python_rpntoken.h"
  31. /**@file python_pyrpn.h
  32. * @brief Python module & type headers
  33. * @ingroup python_ext
  34. * @ingroup pymod_pyrpn
  35. *
  36. * This file is the header of the pyrpn Python module definition
  37. */
  38. /**@defgroup python_ext Python extension
  39. * @brief RPNIFS python extension
  40. *
  41. * RPNIFS comes with a python extension module allowing to use the RPN
  42. * expressions in python.
  43. *
  44. * @ref python_pyrpn.c and @ref python_rpnexpr.c should be compiled in a .so file
  45. * in order to expose a pyrpn Python module.
  46. *
  47. * This module contains functions :
  48. * - pyrpn.get_ops() returning a dict with long & short operations
  49. * - pyrpn.random_expr(args_count, token_count=10) generating a random expression
  50. *
  51. * And it contains the pyrpn.RPNExpr class with following methods :
  52. * - pyrpn.RPNExpr.__init__(self, expression, args_count, stack_size=16)
  53. * - pyrpn.RPNExpr.eval(self, ...) expression evaluation
  54. * - pyrpn.RPNExpr.reset_stack(self) to set all stack items to 0
  55. */
  56. /**@defgroup pymod_pyrpn pyrpn Python module
  57. * @brief Python extension main entry-point
  58. * @ingroup python_ext
  59. */
  60. /**@brief RPNExpr Python class type definition */
  61. extern PyTypeObject RPNExprType;
  62. /**@brief Python module initialization function
  63. * @return The initialized module
  64. * @ingroup pymod_pyrpn */
  65. PyMODINIT_FUNC PyInit_pyrpn(void);
  66. /**@brief Python module specs
  67. * @ingroup pymod_pyrpn */
  68. extern PyModuleDef rpnmodule;
  69. /**@brief Return a dict with valid operations (short keys and long values)
  70. * @param mod pyrpn module object
  71. * @param noargs Dummy argument for METH_NOARG
  72. * @return The a new dict
  73. * @ingroup pymod_pyrpn
  74. */
  75. PyObject* pyrpn_ops(PyObject* mod, PyObject* noargs);
  76. /**@brief Return a new Python str with a random RPN expression
  77. * @param mod pyrpn module object
  78. * @param args Position arguments in Python list
  79. * @param kwds Keywords arguments in Python dict
  80. * @return A str instance
  81. * @ingroup pymod_pyrpn
  82. */
  83. PyObject* pyrpn_random(PyObject *mod, PyObject *args, PyObject *kwds);
  84. /**@mainpage
  85. * Documentation entrypoints :
  86. * - @ref python_ext
  87. * - @ref rpn_lang
  88. * - @ref rpn
  89. */
  90. #endif