| 1 |
# Copyright (C) 2012 Martin Pitt <[email protected]> |
| 2 |
# |
| 3 |
# This library is free software; you can redistribute it and/or |
| 4 |
# modify it under the terms of the GNU Lesser General Public |
| 5 |
# License as published by the Free Software Foundation; either |
| 6 |
# version 2.1 of the License, or (at your option) any later version. |
| 7 |
# |
| 8 |
# This library is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
# Lesser General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU Lesser General Public |
| 14 |
# License along with this library; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 |
| 16 |
# USA |
| 17 |
|
| 18 |
from ..importer import get_introspection_module |
| 19 |
from ..overrides import override |
| 20 |
|
| 21 |
Regress = get_introspection_module("Regress") |
| 22 |
|
| 23 |
REGRESS_OVERRIDE = 42 |
| 24 |
|
| 25 |
|
| 26 |
class Bitmask(Regress.Bitmask): |
| 27 |
"""Replicate override of Bitmask (uint64), similar to GStreamer.""" |
| 28 |
|
| 29 |
def __init__(self, v): |
| 30 |
if not isinstance(v, int): |
| 31 |
raise TypeError(f"{type(v)} is not an int.") |
| 32 |
|
| 33 |
self.v = int(v) |
| 34 |
|
| 35 |
def __str__(self): |
| 36 |
return hex(self.v) |
| 37 |
|
| 38 |
def __eq__(self, other): |
| 39 |
return self.v == other |
| 40 |
|
| 41 |
|
| 42 |
Bitmask = override(Bitmask) |
| 43 |
|
| 44 |
__all__ = ["REGRESS_OVERRIDE", "Bitmask"] |