2011-07-20 06:41:47 +08:00
|
|
|
//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-07-20 06:41:47 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace lldb {
|
|
|
|
|
2011-07-21 08:32:12 +08:00
|
|
|
%feature("docstring",
|
|
|
|
"Represents a container which holds the result from command execution.
|
2021-01-15 21:43:26 +08:00
|
|
|
It works with :py:class:`SBCommandInterpreter.HandleCommand()` to encapsulate the result
|
2011-07-21 08:32:12 +08:00
|
|
|
of command execution.
|
|
|
|
|
2021-01-15 21:43:26 +08:00
|
|
|
See :py:class:`SBCommandInterpreter` for example usage of SBCommandReturnObject."
|
2011-07-21 08:32:12 +08:00
|
|
|
) SBCommandReturnObject;
|
2011-07-20 06:41:47 +08:00
|
|
|
class SBCommandReturnObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SBCommandReturnObject ();
|
|
|
|
|
|
|
|
SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
|
|
|
|
|
|
|
|
~SBCommandReturnObject ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsValid() const;
|
|
|
|
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
explicit operator bool() const;
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
const char *
|
|
|
|
GetOutput ();
|
|
|
|
|
|
|
|
const char *
|
|
|
|
GetError ();
|
|
|
|
|
|
|
|
size_t
|
|
|
|
GetOutputSize ();
|
|
|
|
|
|
|
|
size_t
|
|
|
|
GetErrorSize ();
|
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
const char *
|
|
|
|
GetOutput (bool only_if_no_immediate);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
const char *
|
|
|
|
GetError (bool if_no_immediate);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
size_t
|
2019-10-10 05:50:49 +08:00
|
|
|
PutOutput (lldb::SBFile file);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
size_t
|
2019-10-10 05:50:49 +08:00
|
|
|
PutError (lldb::SBFile file);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
PutOutput (lldb::FileSP BORROWED);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
PutError (lldb::FileSP BORROWED);
|
2011-07-20 06:41:47 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
Clear();
|
|
|
|
|
2012-06-28 01:25:36 +08:00
|
|
|
void
|
|
|
|
SetStatus (lldb::ReturnStatus status);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2013-07-10 04:14:26 +08:00
|
|
|
void
|
|
|
|
SetError (lldb::SBError &error,
|
|
|
|
const char *fallback_error_cstr = NULL);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2013-07-10 04:14:26 +08:00
|
|
|
void
|
|
|
|
SetError (const char *error_cstr);
|
2012-06-28 01:25:36 +08:00
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
lldb::ReturnStatus
|
|
|
|
GetStatus();
|
|
|
|
|
|
|
|
bool
|
|
|
|
Succeeded ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
HasResult ();
|
|
|
|
|
|
|
|
void
|
|
|
|
AppendMessage (const char *message);
|
|
|
|
|
2012-09-29 07:57:51 +08:00
|
|
|
void
|
|
|
|
AppendWarning (const char *message);
|
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
bool
|
|
|
|
GetDescription (lldb::SBStream &description);
|
2016-03-26 07:40:32 +08:00
|
|
|
|
2019-10-10 05:50:49 +08:00
|
|
|
void SetImmediateOutputFile(lldb::SBFile file);
|
|
|
|
void SetImmediateErrorFile(lldb::SBFile file);
|
|
|
|
void SetImmediateOutputFile(lldb::FileSP BORROWED);
|
|
|
|
void SetImmediateErrorFile(lldb::FileSP BORROWED);
|
2019-04-19 00:23:33 +08:00
|
|
|
|
2020-01-09 08:13:03 +08:00
|
|
|
STRING_EXTENSION(SBCommandReturnObject)
|
|
|
|
|
2016-03-26 07:40:32 +08:00
|
|
|
%extend {
|
2019-10-10 05:50:49 +08:00
|
|
|
// transfer_ownership does nothing, and is here for compatibility with
|
|
|
|
// old scripts. Ownership is tracked by reference count in the ordinary way.
|
|
|
|
|
|
|
|
void SetImmediateOutputFile(lldb::FileSP BORROWED, bool transfer_ownership) {
|
|
|
|
self->SetImmediateOutputFile(BORROWED);
|
2016-03-26 07:40:32 +08:00
|
|
|
}
|
2019-10-10 05:50:49 +08:00
|
|
|
void SetImmediateErrorFile(lldb::FileSP BORROWED, bool transfer_ownership) {
|
|
|
|
self->SetImmediateErrorFile(BORROWED);
|
2016-03-26 07:40:32 +08:00
|
|
|
}
|
|
|
|
}
|
2011-08-17 07:24:13 +08:00
|
|
|
|
|
|
|
void
|
2013-05-03 01:29:04 +08:00
|
|
|
PutCString(const char* string, int len);
|
2011-08-17 07:24:13 +08:00
|
|
|
|
2013-03-26 01:37:39 +08:00
|
|
|
// wrapping the variadic Printf() with a plain Print()
|
|
|
|
// because it is hard to support varargs in SWIG bridgings
|
|
|
|
%extend {
|
|
|
|
void Print (const char* str)
|
|
|
|
{
|
|
|
|
self->Printf("%s", str);
|
|
|
|
}
|
|
|
|
}
|
2011-08-17 07:24:13 +08:00
|
|
|
|
2011-07-20 06:41:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace lldb
|