-
Notifications
You must be signed in to change notification settings - Fork 467
/
Copy pathUIBreakpoint.cpp
65 lines (56 loc) · 1.69 KB
/
UIBreakpoint.cpp
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
56
57
58
59
60
61
62
63
64
65
#include "UIBreakpoint.hpp"
UIBreakpoint::UIBreakpoint() {}
UIBreakpoint::~UIBreakpoint() {}
bool UIBreakpoint::SameAs(const UIBreakpoint& other) const
{
// check the type first
if(GetType() != other.GetType()) {
return false;
}
switch(GetType()) {
case UIBreakpointType::INVALID:
return true;
case UIBreakpointType::SOURCE:
return m_file == other.m_file && m_line == other.m_line;
case UIBreakpointType::FUNCTION:
return m_function == other.m_function;
}
return false; // should not get here
}
JSONItem UIBreakpoint::To() const
{
JSON root(cJSON_Object);
auto json = root.toElement();
json.addProperty("type", (int)m_type);
json.addProperty("file", m_file);
json.addProperty("line", m_line);
json.addProperty("function", m_function);
json.addProperty("condition", m_condition);
return json;
}
void UIBreakpoint::From(const JSONItem& json)
{
m_type = (UIBreakpointType)json["type"].toInt(wxNOT_FOUND);
m_file = json["file"].toString();
m_line = json["line"].toInt(wxNOT_FOUND);
m_function = json["function"].toString();
m_condition = json["condition"].toString();
}
bool UIBreakpoint::From(const clDebuggerBreakpoint& bp)
{
if(bp.bp_type != BreakpointType::BP_type_break)
return false;
if(!bp.function_name.empty()) {
SetType(UIBreakpointType::FUNCTION);
SetFunction(bp.function_name);
SetCondition(bp.conditions);
} else if(bp.lineno < 0 || bp.file.empty()) {
return false;
} else {
SetType(UIBreakpointType::SOURCE);
SetFile(bp.file);
SetLine(bp.lineno);
SetCondition(bp.conditions);
}
return true;
}