split the extension files a bit

This commit is contained in:
angie 2022-06-04 12:28:51 -04:00
parent 1db58ddfcc
commit 47fe456d97
4 changed files with 51 additions and 33 deletions

View File

@ -1,9 +1,11 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#include "rabbitizer_module.h"
#include "instructions/RabbitizerInstr.h"
typedef struct PyRabbitizerInstr {
PyObject_HEAD
//PyObject *first; /* first name */
@ -184,7 +186,7 @@ static PyMethodDef Instr_methods[] = {
{NULL} /* Sentinel */
};
static PyTypeObject InstrType = {
PyTypeObject rabbitizer_Instr_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "rabbitizer.Instr",
.tp_doc = PyDoc_STR("Instruction"),
@ -198,31 +200,3 @@ static PyTypeObject InstrType = {
.tp_methods = Instr_methods,
.tp_getset = Instr_getsetters,
};
static PyModuleDef rabbitizer_module = {
PyModuleDef_HEAD_INIT,
.m_name = "rabbitizer",
.m_doc = "",
.m_size = -1,
};
PyMODINIT_FUNC
PyInit_rabbitizer(void)
{
PyObject *m;
if (PyType_Ready(&InstrType) < 0)
return NULL;
m = PyModule_Create(&rabbitizer_module);
if (m == NULL)
return NULL;
Py_INCREF(&InstrType);
if (PyModule_AddObject(m, "Instr", (PyObject *) &InstrType) < 0) {
Py_DECREF(&InstrType);
Py_DECREF(m);
return NULL;
}
return m;
}

View File

@ -0,0 +1,33 @@
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#include "rabbitizer_module.h"
static PyModuleDef rabbitizer_module = {
PyModuleDef_HEAD_INIT,
.m_name = "rabbitizer",
.m_doc = "",
.m_size = -1,
};
PyMODINIT_FUNC
PyInit_rabbitizer(void)
{
PyObject *m;
if (PyType_Ready(&rabbitizer_Instr_Type) < 0)
return NULL;
m = PyModule_Create(&rabbitizer_module);
if (m == NULL)
return NULL;
Py_INCREF(&rabbitizer_Instr_Type);
if (PyModule_AddObject(m, "Instr", (PyObject *) &rabbitizer_Instr_Type) < 0) {
Py_DECREF(&rabbitizer_Instr_Type);
Py_DECREF(m);
return NULL;
}
return m;
}

View File

@ -0,0 +1,8 @@
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
extern PyTypeObject rabbitizer_Instr_Type;

View File

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: © 2022 Decompollaborate
# SPDX-License-Identifier: MIT
from setuptools import setup, find_packages, Extension
@ -10,7 +13,7 @@ setup(
# the qualified name of the extension module to build
'rabbitizer',
# the files to compile into our module relative to ``setup.py``
['rabbitizer/module.c',
["rabbitizer/rabbitizer_module.c", "rabbitizer/rabbitizer_Instr.c",
"src/instructions/RabbitizerInstr_Disassemble.c", "src/instructions/RabbitizerInstr_ProcessUniqueId.c", "src/instructions/RabbitizerInstr.c",
"src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c",
"src/common/Utils.c"],