aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qtcreatorcdbext/pyvalue.h
blob: c124abf425f2241dcfb912e356c925bd811f4fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "pytype.h"

#include "common.h"
#include "pyfield.h"
#include "pycdbextmodule.h"

class PyValue
{
public:
    PyValue() = default;
    PyValue(unsigned long index, CIDebugSymbolGroup *symbolGroup);
    PyValue(const PyValue &other);
    ~PyValue();

    std::string name() const;
    PyType type();
    ULONG64 bitsize();
    Bytes asBytes(); // return value transfers ownership to caller
    ULONG64 address();
    int childCount();
    bool hasChildren();
    bool expand();
    std::string nativeDebuggerValue();

    int isValid();
    int tag();

    PyValue childFromName(const std::string &name);
    PyValue childFromField(const PyField &field);
    PyValue childFromIndex(int index);
    ULONG currentNumberOfDescendants();

    static PyValue createValue(ULONG64 address, const PyType &type);
    static int tag(const std::string &typeName);

private:
    static void indicesMoved(CIDebugSymbolGroup *symbolGroup, ULONG start, ULONG delta);

    unsigned long m_index = 0;
    CIDebugSymbolGroup *m_symbolGroup = nullptr;  // not owned
};

struct ValuePythonObject
{
    PyObject_HEAD
    PyValue *impl;
};

PyTypeObject *value_pytype();
PyObject *createPythonObject(PyValue typeClass);