1 # The MIT License (MIT)
3 # Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 if not isinstance(o
, bool):
28 raise TypeError("'{}' is not a 'bool' object".format(o
.__class
__.__name
__))
32 if not isinstance(o
, int):
33 raise TypeError("'{}' is not an 'int' object".format(o
.__class
__.__name
__))
37 if not isinstance(o
, float):
38 raise TypeError("'{}' is not a 'float' object".format(o
.__class
__.__name
__))
42 if not isinstance(o
, str):
43 raise TypeError("'{}' is not a 'str' object".format(o
.__class
__.__name
__))
46 def _check_type(o
, expected_type
):
47 if not isinstance(o
, expected_type
):
48 raise TypeError("'{}' is not a '{}' object".format(o
.__class
__.__name
__,
54 return v
>= -(2**63) and v
<= (2**63 - 1)
59 return v
>= 0 and v
<= (2**64 - 1)
62 def _check_int64(v
, msg
=None):
65 msg
= 'expecting a signed 64-bit integral value'
67 msg
+= ' (got {})'.format(v
)
71 def _check_uint64(v
, msg
=None):
74 msg
= 'expecting an unsigned 64-bit integral value'
76 msg
+= ' (got {})'.format(v
)
81 return v
== 18446744073709551615
85 return v
!= 0 and ((v
& (v
- 1)) == 0)
88 def _check_alignment(a
):
93 raise ValueError('{} is not a power of two'.format(a
))
96 def _handle_ret(ret
, msg
=None):
101 error
= bt2
.Error(msg
)
106 def _handle_ptr(ptr
, msg
=None):
111 error
= bt2
.Error(msg
)
This page took 0.033917 seconds and 5 git commands to generate.