Class DataTypeMapper

java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.DataTypeMapper
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
GoRttiMapper

public class DataTypeMapper extends Object implements AutoCloseable
Information about StructureMapping classes and their metadata, as well as accumulated information about structure instances that have been deserialized.

To use the full might and majesty of StructureMapping(tm), a DataTypeMapper must be created. It must be able to find (more find) the Ghidra structure data types being used, and it must know about all classes that are going to participate during deserialization and markup.

Structure mapped classes can receive a reference to the specific DataTypeMapper type that created them by declaring a DataTypeMapper field, and tagging it with the @ContextField annotation:

 class MyDataTypeMapper extends DataTypeMapper {
  public MyDataTypeMapper() {
    ...
   registerStructure(MyDataType.class);
  }
  public void foo() { ... }
 }
 
 @StructureMapping(structureName = "mydatatype")
 class MyDataType {
 
  @ContextField
  private MyDataTypeMapper myDataTypeMapper;
  
  @ContextField
  private StructureContext<MyDataType> context;
 
  @FieldMapping
  private long someField;
 
 void bar() {
  context.getDataTypeMapper().getProgram(); // can only access methods defined on base DataTypeMapper type
  myDataTypeMapper.foo(); // same context as previous line, but typed correctly
 ...