mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-02-14 09:40:57 +00:00
instr_id submodule for exposing opcodes
This commit is contained in:
parent
85bf2c887a
commit
a043492df6
@ -2,6 +2,7 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#include "rabbitizer_module.h"
|
||||
#include "instructions/RabbitizerInstrId.h"
|
||||
|
||||
|
||||
static PyModuleDef rabbitizer_module = {
|
||||
@ -15,16 +16,31 @@ PyMODINIT_FUNC
|
||||
PyInit_rabbitizer(void)
|
||||
{
|
||||
PyObject *m;
|
||||
if (PyType_Ready(&rabbitizer_Instr_Type) < 0)
|
||||
if (PyType_Ready(&rabbitizer_type_Instr) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m = PyModule_Create(&rabbitizer_module);
|
||||
if (m == NULL)
|
||||
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_INCREF(&rabbitizer_type_Instr);
|
||||
if (PyModule_AddObject(m, "Instr", (PyObject *) &rabbitizer_type_Instr) < 0) {
|
||||
Py_DECREF(&rabbitizer_type_Instr);
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *submodule = rabbitizer_submodule_instr_id_Init();
|
||||
if (submodule == NULL) {
|
||||
Py_DECREF(&rabbitizer_type_Instr);
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
if (PyModule_AddObject(m, "instr_id", (PyObject *) submodule) < 0) {
|
||||
Py_DECREF(submodule);
|
||||
Py_DECREF(&rabbitizer_type_Instr);
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -5,4 +5,7 @@
|
||||
#include <Python.h>
|
||||
#include "structmember.h"
|
||||
|
||||
extern PyTypeObject rabbitizer_Instr_Type;
|
||||
|
||||
extern PyTypeObject rabbitizer_type_Instr;
|
||||
|
||||
PyObject *rabbitizer_submodule_instr_id_Init(void);
|
||||
|
31
rabbitizer/rabbitizer_submodule_instr_id.c
Normal file
31
rabbitizer/rabbitizer_submodule_instr_id.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
#include "structmember.h"
|
||||
|
||||
#include "instructions/RabbitizerInstrId.h"
|
||||
|
||||
|
||||
static PyModuleDef rabbitizer_instr_id_submodule = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
.m_name = "rabbitizer.instr_id",
|
||||
.m_doc = "",
|
||||
.m_size = -1,
|
||||
};
|
||||
|
||||
PyObject *rabbitizer_submodule_instr_id_Init(void) {
|
||||
PyObject *submodule;
|
||||
submodule = PyModule_Create(&rabbitizer_instr_id_submodule);
|
||||
if (submodule == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PyModule_AddIntConstant(submodule, "RABBITIZER_INSTR_CPU_ID_nop", RABBITIZER_INSTR_CPU_ID_nop) < 0) {
|
||||
Py_DECREF(submodule);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return submodule;
|
||||
}
|
@ -184,7 +184,7 @@ static PyMethodDef Instr_methods[] = {
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
PyTypeObject rabbitizer_Instr_Type = {
|
||||
PyTypeObject rabbitizer_type_Instr = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
.tp_name = "rabbitizer.Instr",
|
||||
.tp_doc = PyDoc_STR("Instruction"),
|
2
setup.py
2
setup.py
@ -13,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/rabbitizer_module.c", "rabbitizer/rabbitizer_Instr.c",
|
||||
["rabbitizer/rabbitizer_module.c", "rabbitizer/rabbitizer_type_Instr.c", "rabbitizer/rabbitizer_submodule_instr_id.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"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user