<reponame>ubook-editora/finn
# AUTOGENERATED FILE - DO NOT MODIFY!
# This file generated by Djinni from example.djinni

from djinni.support import MultiSet # default imported in all files
from djinni.exception import CPyException # default imported in all files
from djinni.pycffi_marshal import CPyObject, CPyRecord

from rc import Rc
from PyCFFIlib_cffi import ffi, lib

from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception

class ListRecordRcHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ListRecordRcHelper.c_data_set) == 0
        Rc.check_c_data_set_empty()

    @ffi.callback("struct DjinniRecordHandle *(struct DjinniObjectHandle *, size_t)")
    def __get_elem(cself, index):
        try:
            _ret = CPyRecord.fromPy(Rc.c_data_set, CPyObject.toPy(None, cself)[index])
            assert _ret != ffi.NULL
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObject.toPy(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(list())
        ListRecordRcHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniRecordHandle *)")
    def __python_add(cself, el):
        CPyObject.toPy(None, cself).append(CPyRecord.toPy(Rc.c_data_set, el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in ListRecordRcHelper.c_data_set
        ListRecordRcHelper.c_data_set.remove(c_ptr)

    @staticmethod
    def _add_callbacks():
        lib.list_record_rc_add_callback__get_elem(ListRecordRcHelper.__get_elem)
        lib.list_record_rc_add_callback___delete(ListRecordRcHelper.__delete)
        lib.list_record_rc_add_callback__get_size(ListRecordRcHelper.__get_size)
        lib.list_record_rc_add_callback__python_create(ListRecordRcHelper.__python_create)
        lib.list_record_rc_add_callback__python_add(ListRecordRcHelper.__python_add)

ListRecordRcHelper._add_callbacks()


# AUTOGENERATED FILE - DO NOT MODIFY!
# This file generated by Djinni from example.djinni

from djinni.support import MultiSet # default imported in all files
from djinni.exception import CPyException # default imported in all files
from djinni.pycffi_marshal import CPyObject, CPyRecord

from rc import Rc
from PyCFFIlib_cffi import ffi, lib

from djinni import exception # this forces run of __init__.py which gives cpp option to call back into py to create exception

class ListRecordRcHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ListRecordRcHelper.c_data_set) == 0
        Rc.check_c_data_set_empty()

    @ffi.callback("struct DjinniRecordHandle *(struct DjinniObjectHandle *, size_t)")
    def __get_elem(cself, index):
        try:
            _ret = CPyRecord.fromPy(Rc.c_data_set, CPyObject.toPy(None, cself)[index])
            assert _ret != ffi.NULL
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObject.toPy(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(list())
        ListRecordRcHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniRecordHandle *)")
    def __python_add(cself, el):
        CPyObject.toPy(None, cself).append(CPyRecord.toPy(Rc.c_data_set, el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in ListRecordRcHelper.c_data_set
        ListRecordRcHelper.c_data_set.remove(c_ptr)

    @staticmethod
    def _add_callbacks():
        lib.list_record_rc_add_callback__get_elem(ListRecordRcHelper.__get_elem)
        lib.list_record_rc_add_callback___delete(ListRecordRcHelper.__delete)
        lib.list_record_rc_add_callback__get_size(ListRecordRcHelper.__get_size)
        lib.list_record_rc_add_callback__python_create(ListRecordRcHelper.__python_create)
        lib.list_record_rc_add_callback__python_add(ListRecordRcHelper.__python_add)

ListRecordRcHelper._add_callbacks()
# AUTOGENERATED FILE - DO NOT MODIFY! # This file generated by Djinni from example.djinni # default imported in all files # default imported in all files # this forces run of __init__.py which gives cpp option to call back into py to create exception