-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhelpers.py
135 lines (118 loc) · 4.29 KB
/
helpers.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/python
# Debugging helpers for custom types
# Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
# 2016-2017
from dumper import *
import math
import sys
def qdump____m128(d, value):
d.putEmptyValue()
d.putNumChild(1)
if d.isExpanded():
d.putArrayData(value.address(), 4, d.lookupType("float"))
def qdump____m128d(d, value):
d.putEmptyValue()
d.putNumChild(1)
if d.isExpanded():
d.putArrayData(value.address(), 2, d.lookupType("double"))
def qdump__Sph__AutoPtr(d, value):
ptr = value["ptr"]
if ptr.integer() == 0:
d.putValue("nullptr")
else:
d.putItem(ptr.dereference())
def qdump__Sph__RawPtr(d, value):
ptr = value["ptr"]
if ptr.integer() == 0:
d.putValue("nullptr")
else:
d.putItem(ptr.dereference())
def qdump__Sph__SharedPtr(d, value):
ptr = value["ptr"]
if ptr.integer() == 0:
d.putValue("nullptr")
else:
d.putItem(ptr.dereference())
def qdump__Sph__Optional(d, value):
used = value["used"]
if used.integer() == 0:
d.putValue("NOTHING")
else:
templateType = d.templateArgument(value.type, 0)
x = d.createValue(value.address(), templateType)
d.putItem(x)
def qdump__Sph__Array(d, value):
actsize = value["actSize"].integer()
# maxsize = value["maxSize"].integer()
d.putNumChild(actsize)
p = value["data"]
d.putValue("(%s values)" % (actsize))
innerType = p.type
templateType = d.templateArgument(value.type, 0)
if d.isExpanded():
with Children(d, actsize, childType=innerType):
for i in range(0, actsize):
d.putSubItem(i, p.dereference().cast(templateType))
p = p + 1
def qdump__Sph__ArrayView(d, value):
actsize = value["actSize"].integer()
d.putNumChild(actsize)
p = value["data"]
d.putValue("(%s values)" % (actsize))
innerType = p.type
templateType = d.templateArgument(value.type, 0)
if d.isExpanded():
with Children(d, actsize, childType=innerType):
for i in range(0, actsize):
d.putSubItem(i, p.dereference().cast(templateType))
p = p + 1
def qdump__Sph__BasicVector(d, value):
d.putNumChild(4)
templateType = d.templateArgument(value.type, 0)
siz = 8 # have to be changed to 4 for floats!
x = d.createValue(value.address(), templateType)
y = d.createValue(value.address() + siz, templateType)
z = d.createValue(value.address() + 2*siz, templateType)
h = d.createValue(value.address() + 3*siz, templateType)
if d.isExpanded():
with Children(d, 4, childType=templateType):
d.putSubItem("x", x)
d.putSubItem("y", y)
d.putSubItem("z", z)
d.putSubItem("h", h)
def qdump__Sph__TracelessTensor(d, value):
d.putNumChild(5)
templateType = d.lookupType("double")
siz = 8 # have to be changed to 4 for floats!
sxx = d.createValue(value.address(), templateType)
syy = d.createValue(value.address() + siz, templateType)
sxy = d.createValue(value.address() + 2*siz, templateType)
sxz = d.createValue(value.address() + 3*siz, templateType)
syz = d.createValue(value.address() + 4*siz, templateType)
if d.isExpanded():
with Children(d, 5, childType=templateType):
d.putSubItem("sxx", sxx)
d.putSubItem("syy", syy)
d.putSubItem("sxy", sxy)
d.putSubItem("sxz", sxz)
d.putSubItem("syz", syz)
def qdump__Sph__SymmetricTensor(d, value):
d.putNumChild(6)
templateType = d.lookupType("double")
diag = value["diag"]
off = value["off"]
siz = 8 # have to be changed to 4 for floats!
sxx = d.createValue(diag.address(), templateType)
syy = d.createValue(diag.address() + siz, templateType)
szz = d.createValue(diag.address() + 2*siz, templateType)
sxy = d.createValue(off.address(), templateType)
sxz = d.createValue(off.address() + siz, templateType)
syz = d.createValue(off.address() + 2*siz, templateType)
if d.isExpanded():
with Children(d, 6, childType=templateType):
d.putSubItem("sxx", sxx)
d.putSubItem("syy", syy)
d.putSubItem("szz", szz)
d.putSubItem("sxy", sxy)
d.putSubItem("sxz", sxz)
d.putSubItem("syz", syz)