mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-27 15:14:31 +00:00
Introduce a PythonBytes class into PythonDataObjects.
This class behaves the same as PythonString on Python2, but differently on Python3. Unittests are added as well. llvm-svn: 257397
This commit is contained in:
1 parent
472cc78ccb
commit
5a72c02be9
3 files changed
+166
No files matched your search
@@ -23,8 +23,11 @@
|
||||
#include "lldb/Host/File.h"
|
||||
#include "lldb/Interpreter/OptionValue.h"
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
class PythonBytes;
|
||||
class PythonString;
|
||||
class PythonList;
|
||||
class PythonDictionary;
|
||||
@@ -71,6 +74,11 @@ enum class PyObjectType
|
||||
Dictionary,
|
||||
List,
|
||||
String,
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Bytes,
|
||||
#else
|
||||
Bytes = String,
|
||||
#endif
|
||||
Module,
|
||||
Callable,
|
||||
Tuple,
|
||||
@@ -256,6 +264,39 @@ protected:
|
||||
PyObject* m_py_obj;
|
||||
};
|
||||
|
||||
class PythonBytes : public PythonObject
|
||||
{
|
||||
public:
|
||||
PythonBytes();
|
||||
explicit PythonBytes(llvm::ArrayRef<uint8_t> bytes);
|
||||
PythonBytes(const uint8_t *bytes, size_t length);
|
||||
PythonBytes(PyRefType type, PyObject *o);
|
||||
PythonBytes(const PythonBytes &object);
|
||||
|
||||
~PythonBytes() override;
|
||||
|
||||
static bool
|
||||
Check(PyObject *py_obj);
|
||||
|
||||
// Bring in the no-argument base class version
|
||||
using PythonObject::Reset;
|
||||
|
||||
void
|
||||
Reset(PyRefType type, PyObject *py_obj) override;
|
||||
|
||||
llvm::ArrayRef<uint8_t>
|
||||
GetBytes() const;
|
||||
|
||||
size_t
|
||||
GetSize() const;
|
||||
|
||||
void
|
||||
SetBytes(llvm::ArrayRef<uint8_t> stringbytes);
|
||||
|
||||
StructuredData::StringSP
|
||||
CreateStructuredString() const;
|
||||
};
|
||||
|
||||
class PythonString : public PythonObject
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in new issue
Block a user