/*
* Copyright (C) 2020 Weber Yann
*
* This file is part of pyrpn.
*
* pyrpn is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* pyrpn is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with pyrpn. If not, see .
*/
#ifndef _PYTHON_PYRPN_H__
#define _PYTHON_PYRPN_H__
#include "config.h"
#include
#define PY_SSIZE_T_CLEAN
#include
#include "structmember.h"
#include "rpn_jit.h"
/**@defgroup python_type RPNExpr Python class
* @brief Exposed Python class : RPNExpr
* @ingroup python_ext
*/
/**@file python_rpnexpr.h
* @brief Python RPNExpr type headers
* @ingroup python_type
*
* This file is the header of the RPNExpr Python class
*/
/**@brief RPNExpr Python class methods list
* @ingroup python_type */
extern PyMethodDef RPNExpr_methods[];
/**@brief RPNExpr Python class members list
* @ingroup python_type */
extern PyMemberDef RPNExpr_members[];
/**@brief RPNExpr Python class type definition
* @ingroup python_type */
extern PyTypeObject RPNExprType;
/**@brief Structure holding RPNExpr objects
* @ingroup python_type */
typedef struct
{
PyObject_VAR_HEAD;
/**@brief Pointer on @ref rpn_expr_s */
rpn_expr_t *rpn;
/**@brief Array storing expression argument
* @note As attribute of rpn_expr allowing malloc & free only once */
unsigned long *args;
} PyRPNExpr_t;
/**@brief RpnExpr __new__ method
* @param subtype Type of object being created (pyrpn.RPNExpr)
* @param args positional arguments for subtype
* @param kwargs keyword argumenrs for subtype
* @return The new Python RPNExpr object
*/
PyObject* rpnexpr_new(PyTypeObject *subtype, PyObject *args, PyObject* kwds);
/**@brief RpnExpr constructor
* @param self New RPNExpr instance
* @param args Positional arguments list
* @param kwds Keywords arguments dict
* @return 0 if no error else -1
* @ingroup python_type
*/
int rpnexpr_init(PyObject *self, PyObject *args, PyObject *kwds);
/**@brief RPNExpr __del__ method
* @param self RPNExpr instance
* @ingroup python_type
*/
void rpnexpr_del(PyObject *self);
/**@brief Eval an RPN expression given arguments and return the
* value
* @param self RPNExpr instance
* @param argv Array of PyObject* arguments
* @param argc Number of arguments
* @return The value resulting of evaluation
* @ingroup python_type
*/
PyObject* rpnexpr_eval(PyObject* self, PyObject** argv, Py_ssize_t argc);
/**@brief Set all stack item to zero
* @param self RPNExpr instance
* @param noargs Dummy argument for METH_NOARG
* @return None
* @ingroup python_type
*/
PyObject* rpnexpr_reset_stack(PyObject *self, PyObject *noargs);
/**@brief RPNExpr.__repr__()
* @param self RPNExpr instance
* @ingroup python_type
*/
PyObject* rpnexpr_repr(PyObject *self);
/**@brief RPNExpr.__str__()
* @param self RPNExpr instance
* @ingroup python_type
*/
PyObject* rpnexpr_str(PyObject *self);
#endif