<commit_before># -*- coding: utf-8 -*-
# GUI Application automation and testing library
# Copyright (C) 2006-2019 <NAME> and Contributors
# https://github.com/pywinauto/pywinauto/graphs/contributors
# http://pywinauto.readthedocs.io/en/latest/credits.html
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# * Neither the name of pywinauto nor the names of its
#   contributors may be used to endorse or promote products derived from
#   this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Low-level interface to Linux ATSPI"""

import subprocess
import six

from ctypes import Structure, c_int, c_bool, c_char_p, c_char, POINTER, c_uint, c_uint32, c_uint64, c_double, c_short, \
    create_string_buffer, cdll, pointer, c_void_p, CFUNCTYPE
from functools import wraps

from ..backend import Singleton


class CtypesEnum(object):

    """Base class for Enums"""

    @classmethod
    def from_param(cls, obj):
        return int(obj)


class RECT(Structure):

    """Wrap the RECT structure and add extra functionality"""

    _fields_ = [
        ('left', c_int),
        ('top', c_int),
        ('right', c_int),
        ('bottom', c_int),
    ]

    # ----------------------------------------------------------------
    def __init__(self, otherRect_or_left=0, top=0, right=0, bottom=0):
        """
        Provide a constructor for RECT structures

        A RECT can be constructed by:
        - Another RECT (each value will be copied)
        - Values for left, top, right and bottom

        e.g. my_rect = RECT(otherRect)
        or   my_rect = RECT(10, 20, 34, 100)
        """
        if isinstance(otherRect_or_left, RECT):
            self.left = otherRect_or_left.left
            self.right = otherRect_or_left.right
            self.top = otherRect_or_left.top
            self.bottom = otherRect_or_left.bottom
        elif isinstance(otherRect_or_left, AtspiRect):
            self.left = otherRect_or_left.x
            self.right = otherRect_or_left.x + otherRect_or_left.width
            self.top = otherRect_or_left.y
            self.bottom = otherRect_or_left.y + otherRect_or_left.height
        else:
            # if not isinstance(otherRect_or_left, (int, long)):
            #    print type(self), type(otherRect_or_left), otherRect_or_left
            self.left = otherRect_or_left
            self.right = right
            self.top = top
            self.bottom = bottom

    def __eq__(self, other):
        "return true if the two rectangles have the same coordinates"
        try:
            return \
                self.left == other.left and \
                self.top == other.top and \
                self.right == other.right and \
                self.bottom == other.bottom
        except AttributeError:
            return False

    # ----------------------------------------------------------------
    def __str__(self):
        """Return a string representation of the RECT"""
        return "(L%d, T%d, R%d, B%d)" % (
            self.left, self.top, self.right, self.bottom)

    # ----------------------------------------------------------------
    def __repr__(self):
        """Return some representation of the RECT"""
        return "<RECT L%d, T%d, R%d, B%d>" % (
            self.left, self.top, self.right, self.bottom)

    # ----------------------------------------------------------------
    def __sub__(self, other):
        """Return a new rectangle which is offset from the one passed in"""
        newRect = RECT()

        newRect.left = self.left - other.left
        newRect.right = self.right - other.left

        newRect.top = self.top - other.top
        newRect.bottom = self.bottom - other.top

        return newRect

    # ----------------------------------------------------------------
    def __add__(self, other):
        """Allow two rects to be added using +"""
        newRect = RECT()

        newRect.left = self.left + other.left
        newRect.right = self.right + other.left

        newRect.top = self.top + other.top
        newRect.bottom = self.bottom + other.top

        return newRect

    # ----------------------------------------------------------------
    def width(self):
        """Return the width of the  rect"""
        return self.right - self.left

    # ----------------------------------------------------------------
    def height(self):
        """Return the height of the rect"""
        return self.bottom - self.top

    # ----------------------------------------------------------------
    def mid_point(self):
        """Return a POINT structure representing the mid point"""
        pt = AtspiPoint()
        pt.x = self.left + int(float(self.width()) / 2.)
        pt.y = self.top + int(float(self.height()) / 2.)
        return pt


class _AtspiCoordType(CtypesEnum):
    ATSPI_COORD_TYPE_SCREEN = 0
    ATSPI_COORD_TYPE_WINDOW = 1


class _AtspiComponentLayer(CtypesEnum):
    ATSPI_LAYER_INVALID = 0
    ATSPI_LAYER_BACKGROUND = 1
    ATSPI_LAYER_CANVAS = 2
    ATSPI_LAYER_WIDGET = 3
    ATSPI_LAYER_MDI = 4
    ATSPI_LAYER_POPUP = 5
    ATSPI_LAYER_OVERLAY = 6
    ATSPI_LAYER_WINDOW = 7
    ATSPI_LAYER_LAST_DEFINED = 8


class _AtspiScrollType(CtypesEnum):
    ATSPI_SCROLL_TOP_LEFT = 0
    ATSPI_SCROLL_BOTTOM_RIGHT = 1
    ATSPI_SCROLL_TOP_EDGE = 2
    ATSPI_SCROLL_BOTTOM_EDGE = 3
    ATSPI_SCROLL_LEFT_EDGE = 4
    ATSPI_SCROLL_RIGHT_EDGE = 5
    ATSPI_SCROLL_ANYWHERE = 6


_AtspiTextGranularity = ["char", "word", "sentence", "line", "paragraph"]


class _AtspiStateType(CtypesEnum):
    ATSPI_STATE_INVALID = 0
    ATSPI_STATE_ACTIVE = 1
    ATSPI_STATE_ARMED = 2
    ATSPI_STATE_BUSY = 3
    ATSPI_STATE_CHECKED = 4
    ATSPI_STATE_COLLAPSED = 5
    ATSPI_STATE_DEFUNCT = 6
    ATSPI_STATE_EDITABLE = 7
    ATSPI_STATE_ENABLED = 8
    ATSPI_STATE_EXPANDABLE = 9
    ATSPI_STATE_EXPANDED = 10
    ATSPI_STATE_FOCUSABLE = 11
    ATSPI_STATE_FOCUSED = 12
    ATSPI_STATE_HAS_TOOLTIP = 13
    ATSPI_STATE_HORIZONTAL = 14
    ATSPI_STATE_ICONIFIED = 15
    ATSPI_STATE_MODAL = 16
    ATSPI_STATE_MULTI_LINE = 17
    ATSPI_STATE_MULTISELECTABLE = 18
    ATSPI_STATE_OPAQUE = 19
    ATSPI_STATE_PRESSED = 20
    ATSPI_STATE_RESIZABLE = 21
    ATSPI_STATE_SELECTABLE = 22
    ATSPI_STATE_SELECTED = 23
    ATSPI_STATE_SENSITIVE = 24
    ATSPI_STATE_SHOWING = 25
    ATSPI_STATE_SINGLE_LINE = 26
    ATSPI_STATE_STALE = 27
    ATSPI_STATE_TRANSIENT = 28
    ATSPI_STATE_VERTICAL = 29
    ATSPI_STATE_VISIBLE = 30
    ATSPI_STATE_MANAGES_DESCENDANTS = 31
    ATSPI_STATE_INDETERMINATE = 32
    ATSPI_STATE_REQUIRED = 33
    ATSPI_STATE_TRUNCATED = 34
    ATSPI_STATE_ANIMATED = 35
    ATSPI_STATE_INVALID_ENTRY = 36
    ATSPI_STATE_SUPPORTS_AUTOCOMPLETION = 37
    ATSPI_STATE_SELECTABLE_TEXT = 38
    ATSPI_STATE_IS_DEFAULT = 39
    ATSPI_STATE_VISITED = 40
    ATSPI_STATE_CHECKABLE = 41
    ATSPI_STATE_HAS_POPUP = 42
    ATSPI_STATE_READ_ONLY = 43
    ATSPI_STATE_LAST_DEFINED = 44


AtspiStateEnum = {
    0: 'STATE_INVALID',
    1: 'STATE_ACTIVE',
    2: 'STATE_ARMED',
    3: 'STATE_BUSY',
    4: 'STATE_CHECKED',
    5: 'STATE_COLLAPSED',
    6: 'STATE_DEFUNCT',
    7: 'STATE_EDITABLE',
    8: 'STATE_ENABLED',
    9: 'STATE_EXPANDABLE',
    10: 'STATE_EXPANDED',
    11: 'STATE_FOCUSABLE',
    12: 'STATE_FOCUSED',
    13: 'STATE_HAS_TOOLTIP',
    14: 'STATE_HORIZONTAL',
    15: 'STATE_ICONIFIED',
    16: 'STATE_MODAL',
    17: 'STATE_MULTI_LINE',
    18: 'STATE_MULTISELECTABLE',
    19: 'STATE_OPAQUE',
    20: 'STATE_PRESSED',
    21: 'STATE_RESIZABLE',
    22: 'STATE_SELECTABLE',
    23: 'STATE_SELECTED',
    24: 'STATE_SENSITIVE',
    25: 'STATE_SHOWING',
    26: 'STATE_SINGLE_LINE',
    27: 'STATE_STALE',
    28: 'STATE_TRANSIENT',
    29: 'STATE_VERTICAL',
    30: 'STATE_VISIBLE',
    31: 'STATE_MANAGES_DESCENDANTS',
    32: 'STATE_INDETERMINATE',
    33: 'STATE_REQUIRED',
    34: 'STATE_TRUNCATED',
    35: 'STATE_ANIMATED',
    36: 'STATE_INVALID_ENTRY',
    37: 'STATE_SUPPORTS_AUTOCOMPLETION',
    38: 'STATE_SELECTABLE_TEXT',
    39: 'STATE_IS_DEFAULT',
    40: 'STATE_VISITED',
    41: 'STATE_CHECKABLE',
    42: 'STATE_HAS_POPUP',
    43: 'STATE_READ_ONLY',
    44: 'STATE_LAST_DEFINED',
}


class AtspiRect(Structure):
    _fields_ = [
        ('x', c_int),
        ('y', c_int),
        ('width', c_int),
        ('height', c_int),
    ]


class AtspiPoint(Structure):
    _fields_ = [
        ('x', c_int),
        ('y', c_int),
    ]


class _GTypeInstance(Structure):
    pass


class _GData(Structure):
    pass


class _GObject(Structure):
    _fields_ = [
        ('g_type_instance', _GTypeInstance),
        ('ref_count', c_uint),
        ('qdata', POINTER(_GData)),
    ]


class _GError(Structure):
    _fields_ = [
        ('domain', c_uint32),
        ('code', c_int),
        ('message', c_char_p),
    ]


class _GArray(Structure):
    _fields_ = [
        ('data', POINTER(c_char)),
        ('len', c_uint32),
    ]


class _GHashTable(Structure):
    pass


class _GPtrArray(Structure):
    pass


class _GTypeInterface(Structure):
    pass


class _AtspiRole(Structure):
    pass


class _AtspiApplication(Structure):
    pass


class _AtspiComponent(Structure):
    pass


class _AtspiDocument(Structure):
    pass


class _AtspiStateSet(Structure):
    pass


class _AtspiAccessiblePrivate(Structure):
    pass


class _AtspiObject(Structure):
    _fields_ = [
        ('parent', _GObject),
        ('accessible_parent', POINTER(_AtspiApplication)),
        ('path', c_char_p),
    ]


class _AtspiAction(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiText(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiEditableText(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiValue(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiTextRange(Structure):
    _fields_ = [
        ('start_offset', c_int),
        ('end_offset', c_int),
        ('content', c_char_p),
    ]


class _AtspiRange(Structure):
    _fields_ = [
        ('start_offset', c_int),
        ('end_offset', c_int),
    ]


class _AtspiAccessible(Structure):
    pass


_AtspiAccessible._fields_ = [
    ('parent', _AtspiObject),
    ('accessible_parent', POINTER(_AtspiAccessible)),
    ('children', POINTER(_GPtrArray)),
    ('role', _AtspiRole),
    ('gint', c_int),
    ('name', c_char_p),
    ('description', c_char_p),
    ('states', POINTER(_AtspiStateSet)),
    ('attributes', POINTER(_GHashTable)),
    ('cached_properties', c_uint),
    ('cached_properties', _AtspiAccessiblePrivate),
]

_AtspiStateSet._fields_ = [
    ('fake', c_uint64 * 4),
    ('states', c_uint64),
]


class GErrorException(RuntimeError):

    """Raised when an exception occurred during libatspi method call"""<commit_msg>ATSPI: fix _AtspiAccessible._fields<commit_after># -*- coding: utf-8 -*-
# GUI Application automation and testing library
# Copyright (C) 2006-2019 <NAME> and Contributors
# https://github.com/pywinauto/pywinauto/graphs/contributors
# http://pywinauto.readthedocs.io/en/latest/credits.html
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# * Neither the name of pywinauto nor the names of its
#   contributors may be used to endorse or promote products derived from
#   this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Low-level interface to Linux ATSPI"""

import subprocess
import six

from ctypes import Structure, c_int, c_bool, c_char_p, c_char, POINTER, c_uint, c_uint32, c_uint64, c_double, c_short, \
    create_string_buffer, cdll, pointer, c_void_p, CFUNCTYPE
from functools import wraps

from ..backend import Singleton


class CtypesEnum(object):

    """Base class for Enums"""

    @classmethod
    def from_param(cls, obj):
        return int(obj)


class RECT(Structure):

    """Wrap the RECT structure and add extra functionality"""

    _fields_ = [
        ('left', c_int),
        ('top', c_int),
        ('right', c_int),
        ('bottom', c_int),
    ]

    # ----------------------------------------------------------------
    def __init__(self, otherRect_or_left=0, top=0, right=0, bottom=0):
        """
        Provide a constructor for RECT structures

        A RECT can be constructed by:
        - Another RECT (each value will be copied)
        - Values for left, top, right and bottom

        e.g. my_rect = RECT(otherRect)
        or   my_rect = RECT(10, 20, 34, 100)
        """
        if isinstance(otherRect_or_left, RECT):
            self.left = otherRect_or_left.left
            self.right = otherRect_or_left.right
            self.top = otherRect_or_left.top
            self.bottom = otherRect_or_left.bottom
        elif isinstance(otherRect_or_left, AtspiRect):
            self.left = otherRect_or_left.x
            self.right = otherRect_or_left.x + otherRect_or_left.width
            self.top = otherRect_or_left.y
            self.bottom = otherRect_or_left.y + otherRect_or_left.height
        else:
            # if not isinstance(otherRect_or_left, (int, long)):
            #    print type(self), type(otherRect_or_left), otherRect_or_left
            self.left = otherRect_or_left
            self.right = right
            self.top = top
            self.bottom = bottom

    def __eq__(self, other):
        "return true if the two rectangles have the same coordinates"
        try:
            return \
                self.left == other.left and \
                self.top == other.top and \
                self.right == other.right and \
                self.bottom == other.bottom
        except AttributeError:
            return False

    # ----------------------------------------------------------------
    def __str__(self):
        """Return a string representation of the RECT"""
        return "(L%d, T%d, R%d, B%d)" % (
            self.left, self.top, self.right, self.bottom)

    # ----------------------------------------------------------------
    def __repr__(self):
        """Return some representation of the RECT"""
        return "<RECT L%d, T%d, R%d, B%d>" % (
            self.left, self.top, self.right, self.bottom)

    # ----------------------------------------------------------------
    def __sub__(self, other):
        """Return a new rectangle which is offset from the one passed in"""
        newRect = RECT()

        newRect.left = self.left - other.left
        newRect.right = self.right - other.left

        newRect.top = self.top - other.top
        newRect.bottom = self.bottom - other.top

        return newRect

    # ----------------------------------------------------------------
    def __add__(self, other):
        """Allow two rects to be added using +"""
        newRect = RECT()

        newRect.left = self.left + other.left
        newRect.right = self.right + other.left

        newRect.top = self.top + other.top
        newRect.bottom = self.bottom + other.top

        return newRect

    # ----------------------------------------------------------------
    def width(self):
        """Return the width of the  rect"""
        return self.right - self.left

    # ----------------------------------------------------------------
    def height(self):
        """Return the height of the rect"""
        return self.bottom - self.top

    # ----------------------------------------------------------------
    def mid_point(self):
        """Return a POINT structure representing the mid point"""
        pt = AtspiPoint()
        pt.x = self.left + int(float(self.width()) / 2.)
        pt.y = self.top + int(float(self.height()) / 2.)
        return pt


class _AtspiCoordType(CtypesEnum):
    ATSPI_COORD_TYPE_SCREEN = 0
    ATSPI_COORD_TYPE_WINDOW = 1


class _AtspiComponentLayer(CtypesEnum):
    ATSPI_LAYER_INVALID = 0
    ATSPI_LAYER_BACKGROUND = 1
    ATSPI_LAYER_CANVAS = 2
    ATSPI_LAYER_WIDGET = 3
    ATSPI_LAYER_MDI = 4
    ATSPI_LAYER_POPUP = 5
    ATSPI_LAYER_OVERLAY = 6
    ATSPI_LAYER_WINDOW = 7
    ATSPI_LAYER_LAST_DEFINED = 8


class _AtspiScrollType(CtypesEnum):
    ATSPI_SCROLL_TOP_LEFT = 0
    ATSPI_SCROLL_BOTTOM_RIGHT = 1
    ATSPI_SCROLL_TOP_EDGE = 2
    ATSPI_SCROLL_BOTTOM_EDGE = 3
    ATSPI_SCROLL_LEFT_EDGE = 4
    ATSPI_SCROLL_RIGHT_EDGE = 5
    ATSPI_SCROLL_ANYWHERE = 6


_AtspiTextGranularity = ["char", "word", "sentence", "line", "paragraph"]


class _AtspiStateType(CtypesEnum):
    ATSPI_STATE_INVALID = 0
    ATSPI_STATE_ACTIVE = 1
    ATSPI_STATE_ARMED = 2
    ATSPI_STATE_BUSY = 3
    ATSPI_STATE_CHECKED = 4
    ATSPI_STATE_COLLAPSED = 5
    ATSPI_STATE_DEFUNCT = 6
    ATSPI_STATE_EDITABLE = 7
    ATSPI_STATE_ENABLED = 8
    ATSPI_STATE_EXPANDABLE = 9
    ATSPI_STATE_EXPANDED = 10
    ATSPI_STATE_FOCUSABLE = 11
    ATSPI_STATE_FOCUSED = 12
    ATSPI_STATE_HAS_TOOLTIP = 13
    ATSPI_STATE_HORIZONTAL = 14
    ATSPI_STATE_ICONIFIED = 15
    ATSPI_STATE_MODAL = 16
    ATSPI_STATE_MULTI_LINE = 17
    ATSPI_STATE_MULTISELECTABLE = 18
    ATSPI_STATE_OPAQUE = 19
    ATSPI_STATE_PRESSED = 20
    ATSPI_STATE_RESIZABLE = 21
    ATSPI_STATE_SELECTABLE = 22
    ATSPI_STATE_SELECTED = 23
    ATSPI_STATE_SENSITIVE = 24
    ATSPI_STATE_SHOWING = 25
    ATSPI_STATE_SINGLE_LINE = 26
    ATSPI_STATE_STALE = 27
    ATSPI_STATE_TRANSIENT = 28
    ATSPI_STATE_VERTICAL = 29
    ATSPI_STATE_VISIBLE = 30
    ATSPI_STATE_MANAGES_DESCENDANTS = 31
    ATSPI_STATE_INDETERMINATE = 32
    ATSPI_STATE_REQUIRED = 33
    ATSPI_STATE_TRUNCATED = 34
    ATSPI_STATE_ANIMATED = 35
    ATSPI_STATE_INVALID_ENTRY = 36
    ATSPI_STATE_SUPPORTS_AUTOCOMPLETION = 37
    ATSPI_STATE_SELECTABLE_TEXT = 38
    ATSPI_STATE_IS_DEFAULT = 39
    ATSPI_STATE_VISITED = 40
    ATSPI_STATE_CHECKABLE = 41
    ATSPI_STATE_HAS_POPUP = 42
    ATSPI_STATE_READ_ONLY = 43
    ATSPI_STATE_LAST_DEFINED = 44


AtspiStateEnum = {
    0: 'STATE_INVALID',
    1: 'STATE_ACTIVE',
    2: 'STATE_ARMED',
    3: 'STATE_BUSY',
    4: 'STATE_CHECKED',
    5: 'STATE_COLLAPSED',
    6: 'STATE_DEFUNCT',
    7: 'STATE_EDITABLE',
    8: 'STATE_ENABLED',
    9: 'STATE_EXPANDABLE',
    10: 'STATE_EXPANDED',
    11: 'STATE_FOCUSABLE',
    12: 'STATE_FOCUSED',
    13: 'STATE_HAS_TOOLTIP',
    14: 'STATE_HORIZONTAL',
    15: 'STATE_ICONIFIED',
    16: 'STATE_MODAL',
    17: 'STATE_MULTI_LINE',
    18: 'STATE_MULTISELECTABLE',
    19: 'STATE_OPAQUE',
    20: 'STATE_PRESSED',
    21: 'STATE_RESIZABLE',
    22: 'STATE_SELECTABLE',
    23: 'STATE_SELECTED',
    24: 'STATE_SENSITIVE',
    25: 'STATE_SHOWING',
    26: 'STATE_SINGLE_LINE',
    27: 'STATE_STALE',
    28: 'STATE_TRANSIENT',
    29: 'STATE_VERTICAL',
    30: 'STATE_VISIBLE',
    31: 'STATE_MANAGES_DESCENDANTS',
    32: 'STATE_INDETERMINATE',
    33: 'STATE_REQUIRED',
    34: 'STATE_TRUNCATED',
    35: 'STATE_ANIMATED',
    36: 'STATE_INVALID_ENTRY',
    37: 'STATE_SUPPORTS_AUTOCOMPLETION',
    38: 'STATE_SELECTABLE_TEXT',
    39: 'STATE_IS_DEFAULT',
    40: 'STATE_VISITED',
    41: 'STATE_CHECKABLE',
    42: 'STATE_HAS_POPUP',
    43: 'STATE_READ_ONLY',
    44: 'STATE_LAST_DEFINED',
}


class AtspiRect(Structure):
    _fields_ = [
        ('x', c_int),
        ('y', c_int),
        ('width', c_int),
        ('height', c_int),
    ]


class AtspiPoint(Structure):
    _fields_ = [
        ('x', c_int),
        ('y', c_int),
    ]


class _GTypeInstance(Structure):
    pass


class _GData(Structure):
    pass


class _GObject(Structure):
    _fields_ = [
        ('g_type_instance', _GTypeInstance),
        ('ref_count', c_uint),
        ('qdata', POINTER(_GData)),
    ]


class _GError(Structure):
    _fields_ = [
        ('domain', c_uint32),
        ('code', c_int),
        ('message', c_char_p),
    ]


class _GArray(Structure):
    _fields_ = [
        ('data', POINTER(c_char)),
        ('len', c_uint32),
    ]


class _GHashTable(Structure):
    pass


class _GPtrArray(Structure):
    pass


class _GTypeInterface(Structure):
    pass


class _AtspiRole(Structure):
    pass


class _AtspiApplication(Structure):
    pass


class _AtspiComponent(Structure):
    pass


class _AtspiDocument(Structure):
    pass


class _AtspiStateSet(Structure):
    pass


class _AtspiAccessiblePrivate(Structure):
    pass


class _AtspiObject(Structure):
    _fields_ = [
        ('parent', _GObject),
        ('accessible_parent', POINTER(_AtspiApplication)),
        ('path', c_char_p),
    ]


class _AtspiAction(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiText(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiEditableText(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiValue(Structure):
    _fields_ = [
        ('parent', _GTypeInterface),
    ]


class _AtspiTextRange(Structure):
    _fields_ = [
        ('start_offset', c_int),
        ('end_offset', c_int),
        ('content', c_char_p),
    ]


class _AtspiRange(Structure):
    _fields_ = [
        ('start_offset', c_int),
        ('end_offset', c_int),
    ]


class _AtspiAccessible(Structure):
    pass


_AtspiAccessible._fields_ = [
    ('parent', _AtspiObject),
    ('accessible_parent', POINTER(_AtspiAccessible)),
    ('children', POINTER(_GPtrArray)),
    ('role', _AtspiRole),
    ('gint', c_int),
    ('name', c_char_p),
    ('description', c_char_p),
    ('states', POINTER(_AtspiStateSet)),
    ('attributes', POINTER(_GHashTable)),
    ('cached_properties', c_uint),
    ('priv', POINTER(_AtspiAccessiblePrivate)),
]

_AtspiStateSet._fields_ = [
    ('fake', c_uint64 * 4),
    ('states', c_uint64),
]


class GErrorException(RuntimeError):

    """Raised when an exception occurred during libatspi method call"""
{'fraction_non_alphanumeric': 0.13775679257786613, 'fraction_numerical': 0.017809807819748176, 'mean_word_length': 2.447315819531696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2247909', 'n_tokens_mistral': 8311, 'n_tokens_neox': 7644, 'n_words': 1887}