mirror of git://gcc.gnu.org/git/gcc.git
Replace casts with floordiv operator in Python xmethods
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__) (DequeWorkerBase.index, VectorWorkerBase.get): Use // for division. From-SVN: r240260
This commit is contained in:
parent
0148a041ba
commit
375acfebca
|
|
@ -1,3 +1,8 @@
|
||||||
|
2016-09-20 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__)
|
||||||
|
(DequeWorkerBase.index, VectorWorkerBase.get): Use // for division.
|
||||||
|
|
||||||
2016-09-19 Jonathan Wakely <jwakely@redhat.com>
|
2016-09-19 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
PR libstdc++/77645
|
PR libstdc++/77645
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher):
|
||||||
class DequeWorkerBase(gdb.xmethod.XMethodWorker):
|
class DequeWorkerBase(gdb.xmethod.XMethodWorker):
|
||||||
def __init__(self, val_type):
|
def __init__(self, val_type):
|
||||||
self._val_type = val_type
|
self._val_type = val_type
|
||||||
self._bufsize = int(512 / val_type.sizeof) or 1
|
self._bufsize = 512 // val_type.sizeof or 1
|
||||||
|
|
||||||
def size(self, obj):
|
def size(self, obj):
|
||||||
first_node = obj['_M_impl']['_M_start']['_M_node']
|
first_node = obj['_M_impl']['_M_start']['_M_node']
|
||||||
|
|
@ -174,10 +174,10 @@ class DequeWorkerBase(gdb.xmethod.XMethodWorker):
|
||||||
first = obj['_M_impl']['_M_finish']['_M_first']
|
first = obj['_M_impl']['_M_finish']['_M_first']
|
||||||
return (last_node - first_node) * self._bufsize + (cur - first)
|
return (last_node - first_node) * self._bufsize + (cur - first)
|
||||||
|
|
||||||
def index(self, obj, index):
|
def index(self, obj, idx):
|
||||||
first_node = obj['_M_impl']['_M_start']['_M_node']
|
first_node = obj['_M_impl']['_M_start']['_M_node']
|
||||||
index_node = first_node + int(index / self._bufsize)
|
index_node = first_node + int(idx) // self._bufsize
|
||||||
return index_node[0][index % self._bufsize]
|
return index_node[0][idx % self._bufsize]
|
||||||
|
|
||||||
class DequeEmptyWorker(DequeWorkerBase):
|
class DequeEmptyWorker(DequeWorkerBase):
|
||||||
def get_arg_types(self):
|
def get_arg_types(self):
|
||||||
|
|
@ -410,7 +410,7 @@ class VectorWorkerBase(gdb.xmethod.XMethodWorker):
|
||||||
if self._val_type.code == gdb.TYPE_CODE_BOOL:
|
if self._val_type.code == gdb.TYPE_CODE_BOOL:
|
||||||
start = obj['_M_impl']['_M_start']['_M_p']
|
start = obj['_M_impl']['_M_start']['_M_p']
|
||||||
bit_size = start.dereference().type.sizeof * 8
|
bit_size = start.dereference().type.sizeof * 8
|
||||||
valp = start + int(index / bit_size)
|
valp = start + index // bit_size
|
||||||
offset = index % bit_size
|
offset = index % bit_size
|
||||||
return (valp.dereference() & (1 << offset)) > 0
|
return (valp.dereference() & (1 << offset)) > 0
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue