xref: /freebsd/contrib/llvm-project/lldb/bindings/macros.swig (revision cab6a39d7b343596a5823e65c0f7b426551ec22d)
1%define STRING_EXTENSION_LEVEL(Class, Level)
2%extend {
3  std::string lldb:: ## Class ## ::__str__(){
4    lldb::SBStream stream;
5    $self->GetDescription (stream, Level);
6    const char *desc = stream.GetData();
7    size_t desc_len = stream.GetSize();
8    if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
9      --desc_len;
10    }
11    return std::string(desc, desc_len);
12  }
13}
14%enddef
15
16%define STRING_EXTENSION(Class)
17%extend {
18  std::string lldb:: ## Class ## ::__str__(){
19    lldb::SBStream stream;
20    $self->GetDescription (stream);
21    const char *desc = stream.GetData();
22    size_t desc_len = stream.GetSize();
23    if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
24      --desc_len;
25    }
26    return std::string(desc, desc_len);
27  }
28}
29%enddef
30