xref: /freebsd/contrib/llvm-project/lldb/bindings/macros.swig (revision 3e8eb5c7f4909209c042403ddee340b2ee7003a5)
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