123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- /*
- * Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
- */
- #ifndef _PYTHON_RPNTOKEN_H__
- #define _PYTHON_RPNTOKEN_H__
-
- #include "config.h"
- #include "rpn_parse.h"
-
- #define PY_SSIZE_T_CLEAN
- #include <Python.h>
- #include "structmember.h"
-
- /**@file python_rpntoken.h
- * @brief Python RPNToken type headers
- * @ingroup python_ext
- * @ingroup pymod_pyrpn_token
- *
- * This file is the header of the RPNToken classes and subclasses
- *
- */
-
- /**@defgroup pymod_pyrpn_token module pyrpn.token
- * @brief Python module representing RPNExpr tokens
- * @ingroup pymod_pyrpn
- */
- /**@brief pyrpn.token module */
- extern PyModuleDef rpntokens_module;
-
- /**@defgroup pymod_pyrpn_token_Token pyrpn.token.Token
- * @brief Abstract class representing an @ref pymod_pyrpn_RPNExpr token
- * @ingroup pymod_pyrpn_token */
- /**@brief pyrpn.token.Token generic type
- * @ingroup pymod_pyrpn_token_Token */
- extern PyTypeObject RPNTokenType;
-
- /**@defgroup pymod_pyrpn_token_TokenOp pyrpn.token.TokenOp
- * @brief Python class representing an @ref pymod_pyrpn_RPNExpr operation token
- *
- * Extends @ref pymod_pyrpn_token_Token
- * @ingroup pymod_pyrpn_token */
- /**@brief pyrpn.token.TokenOp type
- * @ingroup pymod_pyrpn_token_TokenOp */
- extern PyTypeObject RPNTokenOpType;
-
- /**@defgroup pymod_pyrpn_token_TokenVal pyrpn.token.TokenVal
- * @brief Python class representing an @ref pymod_pyrpn_RPNExpr value token
- *
- * Extends @ref pymod_pyrpn_token_Token
- * @ingroup pymod_pyrpn_token */
- /**@brief pyrpn.token.TokenVal type
- * @ingroup pymod_pyrpn_token_TokenVal */
- extern PyTypeObject RPNTokenValType;
-
- /**@defgroup pymod_pyrpn_token_TokenArg pyrpn.token.TokenArg
- * @brief Python class representing an @ref pymod_pyrpn_RPNExpr argument token
- *
- * Extends @ref pymod_pyrpn_token_Token
- * @ingroup pymod_pyrpn_token */
- /**@brief pyrpn.token.TokenArg type
- * @ingroup pymod_pyrpn_token_TokenArg */
- extern PyTypeObject RPNTokenArgType;
-
-
- /**@brief C representation of @ref RPNTokenType generic class
- * @ingroup pymod_pyrpn_token_Token */
- typedef struct
- {
- /** Python's type definition */
- PyObject_HEAD;
- /** @brief The token value (will be set by subtypes) */
- rpn_token_t value;
- } RPNToken_t;
-
- /**@brief C representation of all @ref RPNTokenType subclasses
- * @ingroup pymod_pyrpn_token_tokenOp
- * @ingroup pymod_pyrpn_token_tokenVal
- * @ingroup pymod_pyrpn_token_tokenArg
- */
- typedef struct {
- /** @brief Pointer on super type */
- RPNToken_t super;
- } RPNTokenSubClass_t;
-
- /**@brief C representation of @ref RPNTokenOpType
- * @ingroup pymod_pyrpn_token_TokenOp */
- typedef RPNTokenSubClass_t RPNTokenOp_t;
- /**@brief C representation of @ref RPNTokenValType
- * @ingroup pymod_pyrpn_token_TokenVal */
- typedef RPNTokenSubClass_t RPNTokenVal_t;
- /**@brief C representation of @ref RPNTokenArgType
- * @ingroup pymod_pyrpn_token_TokenArg */
- typedef RPNTokenSubClass_t RPNTokenArg_t;
-
-
- /**@brief Module initialisation function
- * @return initialized module
- * @ingroup pymod_pyrpn_token */
- PyObject* rpntokens_module_init(void);
-
- /**@brief Class method returning a token instance from a string representation
- * @param cls @ref RPNTokenType class or any subclass
- * @param arg A str representing a token
- * @return A new @ref RPNTokenType subclass instance or NULL on error
- * @ingroup pymod_pyrpn_token_Token
- */
- PyObject* rpntoken_from_str(PyObject *cls, PyObject *arg);
-
- /**@brief Instanciate a new RPNToken subclass given a C token
- * @param token An expression token
- * @return A new @ref RPNTokenType subclass instance
- * @ingroup pymod_pyrpn_token_Token
- */
- PyObject* rpntoken_from_token(const rpn_token_t *token);
-
-
- /**@brief @ref RPNTokenType __init__ method
- * @param _self @ref RPNTokenType subclass instance
- * @param args Positional arguments
- * @param kwds Keyword arguments
- * @return 0 or -1 on error
- * @ingroup pymod_pyrpn_token_Token
- */
- int rpntoken_init(PyObject *_self, PyObject *args, PyObject *kwds);
-
- /**@brief PEP-207 comparison method
- * @param _self An @ref RPNTokenType subclass instance
- * @param other The @ref RPNTokenType subclass instance to compare to
- * @param op The comparison
- * @return Py_True or Py_False
- * @ingroup pymod_pyrpn_token_Token
- */
- PyObject* rpntoken_richcompare(PyObject *_self, PyObject *other, int op);
-
- /**@brief __str__ method
- * @param _self An @ref RPNTokenType subclass instance
- * @return A str representing the token
- * @ingroup pymod_pyrpn_token_Token */
- PyObject* rpntoken_str(PyObject *_self);
-
- /**@brief __repr__ method
- * @param _self An @ref RPNTokenType subclass instance
- * @return A str representing the token
- * @ingroup pymod_pyrpn_token_Token */
- PyObject* rpntoken_repr(PyObject *_self);
-
-
-
-
-
- /**@brief @ref RPNTokenOpType __init__ method
- * @param _self RPNTokenOpType being initialized
- * @param args Positional arguments
- * @param kwds Keyword arguments
- * @return 0 or -1 on error
- * @ingroup pymod_pyrpn_token_TokenOp */
- int rpntokenop_init(PyObject *_self, PyObject *args, PyObject *kwds);
-
- /**@brief @ref RPNTokenOpType opcode_max method
- * @param Py_UNUSED unused argument for static method
- * @return The maximum valid opcode
- * @ingroup pymod_pyrpn_token_TokenOp */
- PyObject *rpntokenop_opcode_max(PyObject *Py_UNUSED(_static));
-
- /**@brief @ref RPNTokenOpType chr method
- * @param _self @ref RPNTokenOpType instance
- * @param Py_UNUSED unused argument
- * @return A string with a single chr representing the operation
- * @ingroup pymod_pyrpn_token_TokenOp */
- PyObject *rpntokenop_opchr(PyObject *_self, PyObject* Py_UNUSED(_null));
-
- /**@brief @ref RPNTokenOpType str method
- * @param _self @ref RPNTokenOpType instance
- * @param Py_UNUSED unused argument
- * @return A string representing the operation on multiple chr
- * @ingroup pymod_pyrpn_token_TokenOp */
- PyObject *rpntokenop_opstr(PyObject *_self, PyObject* Py_UNUSED(_null));
-
-
- /**@brief @ref RPNTokenValType __init__ method
- * @param _self RPNTokenValType being initialized
- * @param args Positional arguments
- * @param kwds Keyword arguments
- * @return 0 or -1 on error
- * @ingroup pymod_pyrpn_token_TokenVal */
- int rpntokenval_init(PyObject *_self, PyObject *args, PyObject *kwds);
-
- /**@brief @ref RPNTokenArgType __init__ method
- * @param _self RPNTokenArgType being initialized
- * @param args Positional arguments
- * @param kwds Keyword arguments
- * @return 0 or -1 on error
- * @ingroup pymod_pyrpn_token_TokenArg */
- int rpntokenarg_init(PyObject *_self, PyObject *args, PyObject *kwds);
-
- #endif
|