# Path: src/rustypy/rswrapper/rswrapper.py
# FIND_TYPE = re.compile("type\((.*)\)")
# class TupleMeta(type):
# class Tuple(metaclass=TupleMeta):
# class OpaquePtr(object):
# class KrateData(object):
# class RustBinds(object):
#     class FnCall(object):
#     def __new__(mcs, name, bases, namespace, parameters=None):
#         def check_type(arg_t, **checkers):
#     def __init__(cls, *args, **kwds):
#     def __len__(self):
#     def __getitem__(self, parameters):
#     def __repr__(self):
#     def element_type(self, pos):
#     def __subclasscheck__(self, cls):
#     def __iter__(self):
#     def __next__(self):
#     def __new__(cls, *args, **kwds):
# def _get_signature_types(params):
#     def inner_types(t):
#     def non_empty(param):
# def _get_ptr_to_C_obj(obj, sig=None):
# def _extract_pytypes(ref, sig=False, call_fn=None, depth=0):
# def get_crate_entry(mod):
# def bind_rs_crate_funcs(mod, lib, prefixes=None):
#     def __init__(self, prefixes):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, entry_point, compiled_lib, prefixes=None):
#         def __init__(self, name, argtypes, lib):
#         def __call__(self, *args, **kwargs):
#         def real_restype(self):
#         def restype(self):
#         def restype(self, annotation):
#         def argtypes(self):
#         def argtypes(self):
#         def add_argtype(self, position, hint):
#         def get_argtype(self, position):
#     def decl_C_args(FFI, params):


import abc
from collections import deque
from enum import Enum, unique
from collections import abc as abc_coll
from rustypy.type_checkers import prev_to_37
from .ffi_defs import *
from .rswrapper import Float, Double, UnsignedLongLong, Tuple

    def free(self):
        if hasattr(self, "_ptr"):
            c_backend.pytuple_free(self._ptr)
            delattr(self, '_ptr')
            setattr(self, 'to_tuple', _dangling_pointer)

    def to_tuple(self, depth=0):
        arity = c_backend.pytuple_len(self._ptr)
        if arity != len(self.signature) and self.call_fn:
            raise TypeError("rustypy: the type hint for returning tuple of fn `{}` "
                            "and the return tuple value are not of "
                            "the same length".format(self.call_fn._fn_name))
        elif arity != len(self.signature):
            raise TypeError(
                "rustypy: type hint for PyTuple is of wrong length")
        tuple_elems = []
        for pos, arg_t in enumerate(self.signature):
            pyarg = c_backend.pytuple_get_element(self._ptr, pos)
            pytype = _extract_value(pyarg, arg_t, depth=depth + 1)
            if pytype is None:
                raise TypeError("rustypy: subtype `{t}` of Tuple type is "
                                "not supported".format(t=arg_t))
            tuple_elems.append(pytype)
        self.free()
        return tuple(tuple_elems)

    @staticmethod
    def from_tuple(source: tuple, signature):
        try:

# Path: src/rustypy/rswrapper/rswrapper.py
# FIND_TYPE = re.compile("type\((.*)\)")
# class TupleMeta(type):
# class Tuple(metaclass=TupleMeta):
# class OpaquePtr(object):
# class KrateData(object):
# class RustBinds(object):
#     class FnCall(object):
#     def __new__(mcs, name, bases, namespace, parameters=None):
#         def check_type(arg_t, **checkers):
#     def __init__(cls, *args, **kwds):
#     def __len__(self):
#     def __getitem__(self, parameters):
#     def __repr__(self):
#     def element_type(self, pos):
#     def __subclasscheck__(self, cls):
#     def __iter__(self):
#     def __next__(self):
#     def __new__(cls, *args, **kwds):
# def _get_signature_types(params):
#     def inner_types(t):
#     def non_empty(param):
# def _get_ptr_to_C_obj(obj, sig=None):
# def _extract_pytypes(ref, sig=False, call_fn=None, depth=0):
# def get_crate_entry(mod):
# def bind_rs_crate_funcs(mod, lib, prefixes=None):
#     def __init__(self, prefixes):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, entry_point, compiled_lib, prefixes=None):
#         def __init__(self, name, argtypes, lib):
#         def __call__(self, *args, **kwargs):
#         def real_restype(self):
#         def restype(self):
#         def restype(self, annotation):
#         def argtypes(self):
#         def argtypes(self):
#         def add_argtype(self, position, hint):
#         def get_argtype(self, position):
#     def decl_C_args(FFI, params):


# Path: src/rustypy/rswrapper/pytypes.py
import abc
from collections import deque
from enum import Enum, unique
from collections import abc as abc_coll
from rustypy.type_checkers import prev_to_37
from .ffi_defs import *
from .rswrapper import Float, Double, UnsignedLongLong, Tuple


    def free(self):
        if hasattr(self, "_ptr"):
            c_backend.pytuple_free(self._ptr)
            delattr(self, '_ptr')
            setattr(self, 'to_tuple', _dangling_pointer)

    def to_tuple(self, depth=0):
        arity = c_backend.pytuple_len(self._ptr)
        if arity != len(self.signature) and self.call_fn:
            raise TypeError("rustypy: the type hint for returning tuple of fn `{}` "
                            "and the return tuple value are not of "
                            "the same length".format(self.call_fn._fn_name))
        elif arity != len(self.signature):
            raise TypeError(
                "rustypy: type hint for PyTuple is of wrong length")
        tuple_elems = []
        for pos, arg_t in enumerate(self.signature):
            pyarg = c_backend.pytuple_get_element(self._ptr, pos)
            pytype = _extract_value(pyarg, arg_t, depth=depth + 1)
            if pytype is None:
                raise TypeError("rustypy: subtype `{t}` of Tuple type is "
                                "not supported".format(t=arg_t))
            tuple_elems.append(pytype)
        self.free()
        return tuple(tuple_elems)

    @staticmethod
    def from_tuple(source: tuple, signature):
        try:

            if not issubclass(signature, Tuple):