llvm-project/lldb/bindings/interface/SBInstructionExtensions.i
Med Ismail Bennani 6813ef3737 Re-land "[lldb/docs] Silence warnings when generating website"
This patch re-lands f0731d5b61ba with more fixes and improvements.

First, this patch removes `__eq__` implementations from classes that
didn't implemented `operator!=` on the C++ implementation.

This patch removes sphinx document generation for special members such
as `__len__`, since there is no straightforward way to skip class that
don't implement them. We also don't want to introduce a change in
behavior by implementing artifical special members for classes that are
missing them.

Finally, this patch improve the ergonomics of some classes by
implementing special members where it makes sense, i.e. `hex(SBFrame)`
is equivalent to `SBFrame.GetPC()`.

Differential Revision: https://reviews.llvm.org/D159017

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-31 20:35:10 +01:00

34 lines
1.7 KiB
OpenEdge ABL

STRING_EXTENSION_OUTSIDE(SBInstruction)
%extend lldb::SBInstruction {
#ifdef SWIGPYTHON
%pythoncode %{
def __hex__(self):
""" Returns the address of the instruction. """
return self.GetAddress()
def __len__(self):
""" Returns the size of the instruction. """
return self.GetByteSize()
def __mnemonic_property__ (self):
return self.GetMnemonic (target)
def __operands_property__ (self):
return self.GetOperands (target)
def __comment_property__ (self):
return self.GetComment (target)
def __file_addr_property__ (self):
return self.GetAddress ().GetFileAddress()
def __load_adrr_property__ (self):
return self.GetComment (target)
mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''')
operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''')
comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''')
addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''')
size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''')
is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
%}
#endif
}