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 2.8KB

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