# Path: src/pegl/ext/khr_sync.py
# class FenceSync(Sync):
#     '''Represents the "fence" type of sync object.
# 
#     Class attributes:
#         extension -- The name string of the fence sync extension.
#         sync_type -- SyncTypes.FENCE.
# 
#     Instance attributes:
#         synchandle, display, status, signaled, sync_type -- As per the
#             superclass, Sync.
#         attribs -- Always an empty AttribList.
#         sync_condition -- The condition under which this sync object
#             will be automatically set to signaled. A value from the
#             SyncConditions tuple.
# 
#     '''
#     extension = 'EGL_KHR_fence_sync'
#     sync_type = SyncTypes.FENCE
# 
#     def __init__(self, display):
#         '''Create the fence sync object.
# 
#         Keyword arguments:
#             display -- As the instance attribute.
# 
#         '''
#         # Fence sync objects have empty attribute lists.
#         super().__init__(display, {})
# 
#     @property
#     def sync_condition(self):
#         '''Get the condition under which this sync object gets signaled.'''
#         return self._attr(SyncAttribs.SYNC_CONDITION)
# 
# class SyncAttribs(Attribs):
#     '''The set of attributes relevant to sync objects.
# 
#     Class attributes:
#         details -- As per the superclass, Attribs.
#         Additionally, symbolic constants for all the known attributes
#         are available as class attributes. Their names are the same as
#         in the extension specification, except without the EGL_ prefix
#         and _KHR suffix.
# 
#     '''
#     # Only for querying; this is not set at creation, but can be toggled later.
#     SYNC_STATUS = 0x30F1
#     # Only for querying; at creation, this is passed as its own parameter.
#     SYNC_TYPE = 0x30F7
#     # As above, plus only valid for fence sync objects.
#     SYNC_CONDITION = 0x30F8
# 
#     details = {SYNC_TYPE: Details('The type of this sync object', c_int, 0),
#                SYNC_STATUS: Details('Which state this sync object is in',
#                                     c_int, SyncStatus.UNSIGNALED),
#                SYNC_CONDITION: Details('Under what condition this sync object '
#                                        'will be automatically signaled', c_int,
#                                        SyncConditions.PRIOR_COMMANDS_COMPLETE)}


from ctypes import c_int, c_int64, POINTER
from .khr_sync import FenceSync, SyncAttribs

# Subclass SyncAttribs to generate wider native values, and add the new sync
# attribute.
class WideSyncAttribs(SyncAttribs):
    '''The set of attributes relevant to sync objects.

    Unlike the superclass, SyncAttribs, this class uses a native type
    that can fit any pointer, avoiding size issues on systems wider than
    32 bits that fail to define their EGLint types as an appropriate
    width.

    Class attributes:
        details -- As per the superclass, Attribs.
        Additionally, symbolic constants for all the known attributes
        are available as class attributes. Their names are the same as
        in the extension specification, except without the EGL_ prefix
        and _KHR suffix.

    '''
    _native_item = c_wideattr
    _native_list = c_wideattr_list

WideSyncAttribs.extend('CL_EVENT_HANDLE', 0x309C, c_wideattr, None)

# New values for SyncTypes and SyncConditions.
# TODO: Replace the namedtuple instances with extensible enumerations.
SYNC_CL_EVENT = 0x30FE
SYNC_CL_EVENT_COMPLETE = 0x30FF

# New Sync subclass.

# Path: src/pegl/ext/khr_sync.py
# class FenceSync(Sync):
#     '''Represents the "fence" type of sync object.
# 
#     Class attributes:
#         extension -- The name string of the fence sync extension.
#         sync_type -- SyncTypes.FENCE.
# 
#     Instance attributes:
#         synchandle, display, status, signaled, sync_type -- As per the
#             superclass, Sync.
#         attribs -- Always an empty AttribList.
#         sync_condition -- The condition under which this sync object
#             will be automatically set to signaled. A value from the
#             SyncConditions tuple.
# 
#     '''
#     extension = 'EGL_KHR_fence_sync'
#     sync_type = SyncTypes.FENCE
# 
#     def __init__(self, display):
#         '''Create the fence sync object.
# 
#         Keyword arguments:
#             display -- As the instance attribute.
# 
#         '''
#         # Fence sync objects have empty attribute lists.
#         super().__init__(display, {})
# 
#     @property
#     def sync_condition(self):
#         '''Get the condition under which this sync object gets signaled.'''
#         return self._attr(SyncAttribs.SYNC_CONDITION)
# 
# class SyncAttribs(Attribs):
#     '''The set of attributes relevant to sync objects.
# 
#     Class attributes:
#         details -- As per the superclass, Attribs.
#         Additionally, symbolic constants for all the known attributes
#         are available as class attributes. Their names are the same as
#         in the extension specification, except without the EGL_ prefix
#         and _KHR suffix.
# 
#     '''
#     # Only for querying; this is not set at creation, but can be toggled later.
#     SYNC_STATUS = 0x30F1
#     # Only for querying; at creation, this is passed as its own parameter.
#     SYNC_TYPE = 0x30F7
#     # As above, plus only valid for fence sync objects.
#     SYNC_CONDITION = 0x30F8
# 
#     details = {SYNC_TYPE: Details('The type of this sync object', c_int, 0),
#                SYNC_STATUS: Details('Which state this sync object is in',
#                                     c_int, SyncStatus.UNSIGNALED),
#                SYNC_CONDITION: Details('Under what condition this sync object '
#                                        'will be automatically signaled', c_int,
#                                        SyncConditions.PRIOR_COMMANDS_COMPLETE)}


# Path: src/pegl/ext/khr_clevent2.py
from ctypes import c_int, c_int64, POINTER
from .khr_sync import FenceSync, SyncAttribs


# Subclass SyncAttribs to generate wider native values, and add the new sync
# attribute.
class WideSyncAttribs(SyncAttribs):
    '''The set of attributes relevant to sync objects.

    Unlike the superclass, SyncAttribs, this class uses a native type
    that can fit any pointer, avoiding size issues on systems wider than
    32 bits that fail to define their EGLint types as an appropriate
    width.

    Class attributes:
        details -- As per the superclass, Attribs.
        Additionally, symbolic constants for all the known attributes
        are available as class attributes. Their names are the same as
        in the extension specification, except without the EGL_ prefix
        and _KHR suffix.

    '''
    _native_item = c_wideattr
    _native_list = c_wideattr_list

WideSyncAttribs.extend('CL_EVENT_HANDLE', 0x309C, c_wideattr, None)

# New values for SyncTypes and SyncConditions.
# TODO: Replace the namedtuple instances with extensible enumerations.
SYNC_CL_EVENT = 0x30FE
SYNC_CL_EVENT_COMPLETE = 0x30FF

# New Sync subclass.

class OpenCLSync(FenceSync):