mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-02-22 15:40:10 +00:00
Expose hasOperand and hasOperandAlias to python
This commit is contained in:
parent
1e4dd7ea48
commit
61e2581428
@ -65,6 +65,9 @@ class Instruction:
|
|||||||
def sameOpcode(self, other: Instruction) -> bool: ...
|
def sameOpcode(self, other: Instruction) -> bool: ...
|
||||||
def sameOpcodeButDifferentArguments(self, other: Instruction) -> bool: ...
|
def sameOpcodeButDifferentArguments(self, other: Instruction) -> bool: ...
|
||||||
|
|
||||||
|
def hasOperand(self, operand: Enum) -> bool: ...
|
||||||
|
def hasOperandAlias(self, operand: Enum) -> bool: ...
|
||||||
|
|
||||||
def isValid(self) -> bool: ...
|
def isValid(self) -> bool: ...
|
||||||
|
|
||||||
def isUnknownType(self) -> bool: ...
|
def isUnknownType(self) -> bool: ...
|
||||||
|
@ -227,6 +227,68 @@ static PyObject *rabbitizer_type_Instruction_sameOpcodeButDifferentArguments(PyR
|
|||||||
Py_RETURN_FALSE;
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *rabbitizer_type_Instruction_hasOperand(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) {
|
||||||
|
static char *kwlist[] = { "operand", NULL };
|
||||||
|
PyObject *pyOperand = NULL;
|
||||||
|
int enumCheck;
|
||||||
|
RabbitizerOperandType operandType = RAB_OPERAND_ALL_INVALID;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Enum_TypeObject, &pyOperand)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pyOperand == NULL) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Invalid value for 'operand' parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
enumCheck = rabbitizer_enum_OperandType_Check(pyOperand);
|
||||||
|
|
||||||
|
if (enumCheck <= 0) {
|
||||||
|
if (enumCheck == 0) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Invalid value for 'operand' parameter");
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
operandType = ((PyRabbitizerEnum*)pyOperand)->value;
|
||||||
|
|
||||||
|
if (RabbitizerInstruction_hasOperand(&self->instr, operandType)) {
|
||||||
|
Py_RETURN_TRUE;
|
||||||
|
}
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *rabbitizer_type_Instruction_hasOperandAlias(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) {
|
||||||
|
static char *kwlist[] = { "operand", NULL };
|
||||||
|
PyObject *pyOperand = NULL;
|
||||||
|
int enumCheck;
|
||||||
|
RabbitizerOperandType operandType = RAB_OPERAND_ALL_INVALID;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Enum_TypeObject, &pyOperand)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pyOperand == NULL) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Invalid value for 'operand' parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
enumCheck = rabbitizer_enum_OperandType_Check(pyOperand);
|
||||||
|
|
||||||
|
if (enumCheck <= 0) {
|
||||||
|
if (enumCheck == 0) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Invalid value for 'operand' parameter");
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
operandType = ((PyRabbitizerEnum*)pyOperand)->value;
|
||||||
|
|
||||||
|
if (RabbitizerInstruction_hasOperandAlias(&self->instr, operandType)) {
|
||||||
|
Py_RETURN_TRUE;
|
||||||
|
}
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
DEF_METHOD_BOOL(isValid)
|
DEF_METHOD_BOOL(isValid)
|
||||||
|
|
||||||
#define DEF_DESCRIPTOR_METHOD_BOOL(name) \
|
#define DEF_DESCRIPTOR_METHOD_BOOL(name) \
|
||||||
@ -342,6 +404,9 @@ static PyMethodDef rabbitizer_type_Instruction_methods[] = {
|
|||||||
METHOD_ARGS(sameOpcode, "description"),
|
METHOD_ARGS(sameOpcode, "description"),
|
||||||
METHOD_ARGS(sameOpcodeButDifferentArguments, "description"),
|
METHOD_ARGS(sameOpcodeButDifferentArguments, "description"),
|
||||||
|
|
||||||
|
METHOD_ARGS(hasOperand, ""),
|
||||||
|
METHOD_ARGS(hasOperandAlias, ""),
|
||||||
|
|
||||||
METHOD_NO_ARGS(isValid, ""),
|
METHOD_NO_ARGS(isValid, ""),
|
||||||
|
|
||||||
METHOD_NO_ARGS(isUnknownType, ""),
|
METHOD_NO_ARGS(isUnknownType, ""),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user