1//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9namespace lldb { 10 11%feature("docstring", 12"Represents a container which holds the result from command execution. 13It works with SBCommandInterpreter.HandleCommand() to encapsulate the result 14of command execution. 15 16See SBCommandInterpreter for example usage of SBCommandReturnObject." 17) SBCommandReturnObject; 18class SBCommandReturnObject 19{ 20public: 21 22 SBCommandReturnObject (); 23 24 SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); 25 26 ~SBCommandReturnObject (); 27 28 bool 29 IsValid() const; 30 31 explicit operator bool() const; 32 33 const char * 34 GetOutput (); 35 36 const char * 37 GetError (); 38 39 size_t 40 GetOutputSize (); 41 42 size_t 43 GetErrorSize (); 44 45 const char * 46 GetOutput (bool only_if_no_immediate); 47 48 const char * 49 GetError (bool if_no_immediate); 50 51 size_t 52 PutOutput (lldb::SBFile file); 53 54 size_t 55 PutError (lldb::SBFile file); 56 57 size_t 58 PutOutput (lldb::FileSP BORROWED); 59 60 size_t 61 PutError (lldb::FileSP BORROWED); 62 63 void 64 Clear(); 65 66 void 67 SetStatus (lldb::ReturnStatus status); 68 69 void 70 SetError (lldb::SBError &error, 71 const char *fallback_error_cstr = NULL); 72 73 void 74 SetError (const char *error_cstr); 75 76 lldb::ReturnStatus 77 GetStatus(); 78 79 bool 80 Succeeded (); 81 82 bool 83 HasResult (); 84 85 void 86 AppendMessage (const char *message); 87 88 void 89 AppendWarning (const char *message); 90 91 bool 92 GetDescription (lldb::SBStream &description); 93 94 void SetImmediateOutputFile(lldb::SBFile file); 95 void SetImmediateErrorFile(lldb::SBFile file); 96 void SetImmediateOutputFile(lldb::FileSP BORROWED); 97 void SetImmediateErrorFile(lldb::FileSP BORROWED); 98 99 STRING_EXTENSION(SBCommandReturnObject) 100 101 %extend { 102 // transfer_ownership does nothing, and is here for compatibility with 103 // old scripts. Ownership is tracked by reference count in the ordinary way. 104 105 void SetImmediateOutputFile(lldb::FileSP BORROWED, bool transfer_ownership) { 106 self->SetImmediateOutputFile(BORROWED); 107 } 108 void SetImmediateErrorFile(lldb::FileSP BORROWED, bool transfer_ownership) { 109 self->SetImmediateErrorFile(BORROWED); 110 } 111 } 112 113 void 114 PutCString(const char* string, int len); 115 116 // wrapping the variadic Printf() with a plain Print() 117 // because it is hard to support varargs in SWIG bridgings 118 %extend { 119 void Print (const char* str) 120 { 121 self->Printf("%s", str); 122 } 123 } 124 125}; 126 127} // namespace lldb 128