rpnifs/python_rpntoken.h

80 lines
2.2 KiB
C

/*
* 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_rpnexpr.h
* @brief Python RPNToken type headers
* @ingroup python_type
*
* This file is the header of the RPNToken classes and subclasses
*
*/
extern PyTypeObject RPNTokenType;
extern PyTypeObject RPNTokenOpType;
extern PyTypeObject RPNTokenValType;
extern PyTypeObject RPNTokenArgType;
extern PyModuleDef rpntokens_module;
typedef struct
{
PyObject_HEAD;
rpn_token_t value;
} RPNToken_t;
typedef struct {
RPNToken_t super;
} RPNTokenOp_t;
typedef struct {
RPNToken_t super;
} RPNTokenVal_t;
typedef struct {
RPNToken_t super;
} RPNTokenArg_t;
PyObject* rpntokens_module_init(void);
PyObject* rpntoken_from_str(PyObject *_self, PyObject *arg);
/** Instanciate a new RPNToken subclass given a token */
PyObject* rpntoken_from_token(const rpn_token_t *token);
int rpntoken_init(PyObject *_self, PyObject *args, PyObject *kwds);
PyObject* rpntoken_str(PyObject *_self);
PyObject* rpntoken_repr(PyObject *_self);
int rpntokenop_init(PyObject *_self, PyObject *args, PyObject *kwds);
PyObject *rpntokenop_opcode_max(PyObject *Py_UNUSED(_static));
PyObject *rpntokenop_opchr(PyObject *_self, PyObject* Py_UNUSED(_null));
PyObject *rpntokenop_opstr(PyObject *_self, PyObject* Py_UNUSED(_null));
int rpntokenval_init(PyObject *_self, PyObject *args, PyObject *kwds);
int rpntokenarg_init(PyObject *_self, PyObject *args, PyObject *kwds);
#endif