#
# Autogenerated by Thrift for thrift/compiler/test/fixtures/refs/src/module.thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#  @generated
#
cimport cython as __cython
from cython.operator cimport dereference as deref
from libcpp.utility cimport move as cmove
from thrift.py3.types cimport (
    assign_unique_ptr,
    assign_shared_ptr,
    assign_shared_const_ptr,
    bytes_to_string,
    make_unique,
    make_shared,
    make_const_shared,
)
cimport thrift.py3.types
from thrift.py3.types cimport (
    reset_field as __reset_field,
    StructFieldsSetter as __StructFieldsSetter
)

from thrift.py3.types cimport const_pointer_cast
from thrift.python.types cimport BadEnum as _fbthrift_BadEnum


import module.types as _module_types


@__cython.auto_pickle(False)
cdef class __MyField_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __MyField_FieldsSetter _fbthrift_create(_module_cbindings.cMyField* struct_cpp_obj):
        cdef __MyField_FieldsSetter __fbthrift_inst = __MyField_FieldsSetter.__new__(__MyField_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_value")] = __MyField_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"value")] = __MyField_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_value")] = __MyField_FieldsSetter._set_field_2
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_enum_value")] = __MyField_FieldsSetter._set_field_3
        __fbthrift_inst._setters[__cstring_view(<const char*>"enum_value")] = __MyField_FieldsSetter._set_field_4
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_enum_value")] = __MyField_FieldsSetter._set_field_5
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_str_value")] = __MyField_FieldsSetter._set_field_6
        __fbthrift_inst._setters[__cstring_view(<const char*>"str_value")] = __MyField_FieldsSetter._set_field_7
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_str_value")] = __MyField_FieldsSetter._set_field_8
        return __fbthrift_inst

    cdef void set_field(__MyField_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __MyField_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field opt_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, int):
            raise TypeError(f'opt_value is not a { int !r}.')
        _fbthrift_value = <cint64_t> _fbthrift_value
        assign_unique_ptr[cint64_t](deref(self._struct_cpp_obj).opt_value_ref(), make_unique[cint64_t](deref((<cint64_t?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, int):
            raise TypeError(f'value is not a { int !r}.')
        _fbthrift_value = <cint64_t> _fbthrift_value
        assign_unique_ptr[cint64_t](deref(self._struct_cpp_obj).value_ref(), make_unique[cint64_t](deref((<cint64_t?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, int):
            raise TypeError(f'req_value is not a { int !r}.')
        _fbthrift_value = <cint64_t> _fbthrift_value
        assign_unique_ptr[cint64_t](deref(self._struct_cpp_obj).req_value_ref(), make_unique[cint64_t](deref((<cint64_t?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_3(self, _fbthrift_value) except *:
        # for field opt_enum_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 3)
            return
        if not isinstance(_fbthrift_value, _fbthrift_BadEnum) and not isinstance(_fbthrift_value, _module_types.MyEnum):
            raise TypeError(f'field opt_enum_value value: {repr(_fbthrift_value)} is not of the enum type { _module_types.MyEnum }.')
        assign_unique_ptr[_module_cbindings.cMyEnum](deref(self._struct_cpp_obj).opt_enum_value_ref(), make_unique[_module_cbindings.cMyEnum](deref((<object?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_4(self, _fbthrift_value) except *:
        # for field enum_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 4)
            return
        if not isinstance(_fbthrift_value, _fbthrift_BadEnum) and not isinstance(_fbthrift_value, _module_types.MyEnum):
            raise TypeError(f'field enum_value value: {repr(_fbthrift_value)} is not of the enum type { _module_types.MyEnum }.')
        assign_unique_ptr[_module_cbindings.cMyEnum](deref(self._struct_cpp_obj).enum_value_ref(), make_unique[_module_cbindings.cMyEnum](deref((<object?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_5(self, _fbthrift_value) except *:
        # for field req_enum_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 5)
            return
        if not isinstance(_fbthrift_value, _fbthrift_BadEnum) and not isinstance(_fbthrift_value, _module_types.MyEnum):
            raise TypeError(f'field req_enum_value value: {repr(_fbthrift_value)} is not of the enum type { _module_types.MyEnum }.')
        assign_unique_ptr[_module_cbindings.cMyEnum](deref(self._struct_cpp_obj).req_enum_value_ref(), make_unique[_module_cbindings.cMyEnum](deref((<object?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_6(self, _fbthrift_value) except *:
        # for field opt_str_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 6)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'opt_str_value is not a { str !r}.')
        assign_unique_ptr[string](deref(self._struct_cpp_obj).opt_str_value_ref(), make_unique[string](deref((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_7(self, _fbthrift_value) except *:
        # for field str_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 7)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'str_value is not a { str !r}.')
        assign_unique_ptr[string](deref(self._struct_cpp_obj).str_value_ref(), make_unique[string](deref((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_8(self, _fbthrift_value) except *:
        # for field req_str_value
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyField](deref(self._struct_cpp_obj), 8)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'req_str_value is not a { str !r}.')
        assign_unique_ptr[string](deref(self._struct_cpp_obj).req_str_value_ref(), make_unique[string](deref((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))


@__cython.auto_pickle(False)
cdef class __MyStruct_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __MyStruct_FieldsSetter _fbthrift_create(_module_cbindings.cMyStruct* struct_cpp_obj):
        cdef __MyStruct_FieldsSetter __fbthrift_inst = __MyStruct_FieldsSetter.__new__(__MyStruct_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_ref")] = __MyStruct_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"ref")] = __MyStruct_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_ref")] = __MyStruct_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__MyStruct_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __MyStruct_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field opt_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyStruct](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'opt_ref is not a { _module_types.MyField !r}.')
        assign_unique_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).opt_ref_ref(), make_unique[_module_cbindings.cMyField](deref((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyStruct](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'ref is not a { _module_types.MyField !r}.')
        assign_unique_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).ref_ref(), make_unique[_module_cbindings.cMyField](deref((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cMyStruct](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'req_ref is not a { _module_types.MyField !r}.')
        assign_unique_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).req_ref_ref(), make_unique[_module_cbindings.cMyField](deref((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))


@__cython.auto_pickle(False)
cdef class __StructWithUnion_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithUnion_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithUnion* struct_cpp_obj):
        cdef __StructWithUnion_FieldsSetter __fbthrift_inst = __StructWithUnion_FieldsSetter.__new__(__StructWithUnion_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"u")] = __StructWithUnion_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"aDouble")] = __StructWithUnion_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"f")] = __StructWithUnion_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithUnion_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithUnion_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field u
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithUnion](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.MyUnion):
            raise TypeError(f'u is not a { _module_types.MyUnion !r}.')
        assign_unique_ptr[_module_cbindings.cMyUnion](deref(self._struct_cpp_obj).u_ref(), make_unique[_module_cbindings.cMyUnion](deref((<_module_types.MyUnion?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field aDouble
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithUnion](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, (float, int)):
            raise TypeError(f'aDouble is not a { float !r}.')
        assign_unique_ptr[double](deref(self._struct_cpp_obj).aDouble_ref(), make_unique[double](deref((<double?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field f
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithUnion](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'f is not a { _module_types.MyField !r}.')
        deref(self._struct_cpp_obj).f_ref().assign(deref((<_module_types.MyField?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __RecursiveStruct_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __RecursiveStruct_FieldsSetter _fbthrift_create(_module_cbindings.cRecursiveStruct* struct_cpp_obj):
        cdef __RecursiveStruct_FieldsSetter __fbthrift_inst = __RecursiveStruct_FieldsSetter.__new__(__RecursiveStruct_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"mes")] = __RecursiveStruct_FieldsSetter._set_field_0
        return __fbthrift_inst

    cdef void set_field(__RecursiveStruct_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __RecursiveStruct_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field mes
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cRecursiveStruct](deref(self._struct_cpp_obj), 0)
            return
        deref(self._struct_cpp_obj).mes_ref().assign(_module_types.List__RecursiveStruct__make_instance(_fbthrift_value))


@__cython.auto_pickle(False)
cdef class __StructWithContainers_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithContainers_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithContainers* struct_cpp_obj):
        cdef __StructWithContainers_FieldsSetter __fbthrift_inst = __StructWithContainers_FieldsSetter.__new__(__StructWithContainers_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"list_ref")] = __StructWithContainers_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"set_ref")] = __StructWithContainers_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"map_ref")] = __StructWithContainers_FieldsSetter._set_field_2
        __fbthrift_inst._setters[__cstring_view(<const char*>"list_ref_unique")] = __StructWithContainers_FieldsSetter._set_field_3
        __fbthrift_inst._setters[__cstring_view(<const char*>"set_ref_shared")] = __StructWithContainers_FieldsSetter._set_field_4
        __fbthrift_inst._setters[__cstring_view(<const char*>"list_ref_shared_const")] = __StructWithContainers_FieldsSetter._set_field_5
        return __fbthrift_inst

    cdef void set_field(__StructWithContainers_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithContainers_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field list_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 0)
            return
        assign_unique_ptr[vector[cint32_t]](deref(self._struct_cpp_obj).list_ref_ref(), make_unique[vector[cint32_t]](_module_types.List__i32__make_instance(_fbthrift_value)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field set_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 1)
            return
        assign_unique_ptr[cset[cint32_t]](deref(self._struct_cpp_obj).set_ref_ref(), make_unique[cset[cint32_t]](deref(_module_types.Set__i32(_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field map_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 2)
            return
        assign_unique_ptr[cmap[cint32_t,cint32_t]](deref(self._struct_cpp_obj).map_ref_ref(), make_unique[cmap[cint32_t,cint32_t]](deref(_module_types.Map__i32_i32(_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_3(self, _fbthrift_value) except *:
        # for field list_ref_unique
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 3)
            return
        assign_unique_ptr[vector[cint32_t]](deref(self._struct_cpp_obj).list_ref_unique_ref(), make_unique[vector[cint32_t]](_module_types.List__i32__make_instance(_fbthrift_value)))

    cdef void _set_field_4(self, _fbthrift_value) except *:
        # for field set_ref_shared
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 4)
            return
        assign_shared_ptr[cset[cint32_t]](deref(self._struct_cpp_obj).set_ref_shared_ref(), _module_types.Set__i32(_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)

    cdef void _set_field_5(self, _fbthrift_value) except *:
        # for field list_ref_shared_const
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithContainers](deref(self._struct_cpp_obj), 5)
            return
        assign_shared_const_ptr[vector[cint32_t]](deref(self._struct_cpp_obj).list_ref_shared_const_ref(), make_const_shared[vector[cint32_t]](_module_types.List__i32__make_instance(_fbthrift_value)))


@__cython.auto_pickle(False)
cdef class __StructWithSharedConst_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithSharedConst_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithSharedConst* struct_cpp_obj):
        cdef __StructWithSharedConst_FieldsSetter __fbthrift_inst = __StructWithSharedConst_FieldsSetter.__new__(__StructWithSharedConst_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_shared_const")] = __StructWithSharedConst_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"shared_const")] = __StructWithSharedConst_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_shared_const")] = __StructWithSharedConst_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithSharedConst_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithSharedConst_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field opt_shared_const
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithSharedConst](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'opt_shared_const is not a { _module_types.MyField !r}.')
        assign_shared_const_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).opt_shared_const_ref(), const_pointer_cast((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field shared_const
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithSharedConst](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'shared_const is not a { _module_types.MyField !r}.')
        assign_shared_const_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).shared_const_ref(), const_pointer_cast((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_shared_const
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithSharedConst](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'req_shared_const is not a { _module_types.MyField !r}.')
        assign_shared_const_ptr[_module_cbindings.cMyField](deref(self._struct_cpp_obj).req_shared_const_ref(), const_pointer_cast((<_module_types.MyField?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __Empty_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __Empty_FieldsSetter _fbthrift_create(_module_cbindings.cEmpty* struct_cpp_obj):
        cdef __Empty_FieldsSetter __fbthrift_inst = __Empty_FieldsSetter.__new__(__Empty_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        return __fbthrift_inst

    cdef void set_field(__Empty_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __Empty_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)


@__cython.auto_pickle(False)
cdef class __StructWithRef_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithRef_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithRef* struct_cpp_obj):
        cdef __StructWithRef_FieldsSetter __fbthrift_inst = __StructWithRef_FieldsSetter.__new__(__StructWithRef_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_field")] = __StructWithRef_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_field")] = __StructWithRef_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_field")] = __StructWithRef_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithRef_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithRef_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRef](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'def_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).def_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field opt_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRef](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'opt_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).opt_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRef](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'req_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).req_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))


@__cython.auto_pickle(False)
cdef class __StructWithBox_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithBox_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithBox* struct_cpp_obj):
        cdef __StructWithBox_FieldsSetter __fbthrift_inst = __StructWithBox_FieldsSetter.__new__(__StructWithBox_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"a")] = __StructWithBox_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"b")] = __StructWithBox_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"c")] = __StructWithBox_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithBox_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithBox_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field a
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithBox](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'a is not a { str !r}.')
        deref(self._struct_cpp_obj).a_ref().assign(cmove(bytes_to_string(_fbthrift_value.encode('utf-8'))))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field b
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithBox](deref(self._struct_cpp_obj), 1)
            return
        deref(self._struct_cpp_obj).b_ref().assign(_module_types.List__i64__make_instance(_fbthrift_value))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field c
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithBox](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.StructWithRef):
            raise TypeError(f'c is not a { _module_types.StructWithRef !r}.')
        deref(self._struct_cpp_obj).c_ref().assign(deref((<_module_types.StructWithRef?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __StructWithInternBox_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithInternBox_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithInternBox* struct_cpp_obj):
        cdef __StructWithInternBox_FieldsSetter __fbthrift_inst = __StructWithInternBox_FieldsSetter.__new__(__StructWithInternBox_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"field1")] = __StructWithInternBox_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"field2")] = __StructWithInternBox_FieldsSetter._set_field_1
        return __fbthrift_inst

    cdef void set_field(__StructWithInternBox_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithInternBox_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field field1
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithInternBox](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'field1 is not a { _module_types.Empty !r}.')
        deref(self._struct_cpp_obj).field1_ref().assign(deref((<_module_types.Empty?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field field2
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithInternBox](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'field2 is not a { _module_types.MyField !r}.')
        deref(self._struct_cpp_obj).field2_ref().assign(deref((<_module_types.MyField?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __StructWithTerseInternBox_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithTerseInternBox_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithTerseInternBox* struct_cpp_obj):
        cdef __StructWithTerseInternBox_FieldsSetter __fbthrift_inst = __StructWithTerseInternBox_FieldsSetter.__new__(__StructWithTerseInternBox_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"field1")] = __StructWithTerseInternBox_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"field2")] = __StructWithTerseInternBox_FieldsSetter._set_field_1
        return __fbthrift_inst

    cdef void set_field(__StructWithTerseInternBox_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithTerseInternBox_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field field1
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithTerseInternBox](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'field1 is not a { _module_types.Empty !r}.')
        deref(self._struct_cpp_obj).field1_ref().assign(deref((<_module_types.Empty?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field field2
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithTerseInternBox](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'field2 is not a { _module_types.MyField !r}.')
        deref(self._struct_cpp_obj).field2_ref().assign(deref((<_module_types.MyField?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __AdaptedStructWithInternBox_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __AdaptedStructWithInternBox_FieldsSetter _fbthrift_create(_module_cbindings.cAdaptedStructWithInternBox* struct_cpp_obj):
        cdef __AdaptedStructWithInternBox_FieldsSetter __fbthrift_inst = __AdaptedStructWithInternBox_FieldsSetter.__new__(__AdaptedStructWithInternBox_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"field1")] = __AdaptedStructWithInternBox_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"field2")] = __AdaptedStructWithInternBox_FieldsSetter._set_field_1
        return __fbthrift_inst

    cdef void set_field(__AdaptedStructWithInternBox_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __AdaptedStructWithInternBox_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field field1
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cAdaptedStructWithInternBox](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'field1 is not a { _module_types.Empty !r}.')
        deref(self._struct_cpp_obj).field1_ref().assign(deref((<_module_types.Empty?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field field2
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cAdaptedStructWithInternBox](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'field2 is not a { _module_types.MyField !r}.')
        deref(self._struct_cpp_obj).field2_ref().assign(deref((<_module_types.MyField?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __AdaptedStructWithTerseInternBox_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __AdaptedStructWithTerseInternBox_FieldsSetter _fbthrift_create(_module_cbindings.cAdaptedStructWithTerseInternBox* struct_cpp_obj):
        cdef __AdaptedStructWithTerseInternBox_FieldsSetter __fbthrift_inst = __AdaptedStructWithTerseInternBox_FieldsSetter.__new__(__AdaptedStructWithTerseInternBox_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"field1")] = __AdaptedStructWithTerseInternBox_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"field2")] = __AdaptedStructWithTerseInternBox_FieldsSetter._set_field_1
        return __fbthrift_inst

    cdef void set_field(__AdaptedStructWithTerseInternBox_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __AdaptedStructWithTerseInternBox_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field field1
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cAdaptedStructWithTerseInternBox](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'field1 is not a { _module_types.Empty !r}.')
        deref(self._struct_cpp_obj).field1_ref().assign(deref((<_module_types.Empty?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field field2
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cAdaptedStructWithTerseInternBox](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.MyField):
            raise TypeError(f'field2 is not a { _module_types.MyField !r}.')
        deref(self._struct_cpp_obj).field2_ref().assign(deref((<_module_types.MyField?> _fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __StructWithRefTypeUnique_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithRefTypeUnique_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithRefTypeUnique* struct_cpp_obj):
        cdef __StructWithRefTypeUnique_FieldsSetter __fbthrift_inst = __StructWithRefTypeUnique_FieldsSetter.__new__(__StructWithRefTypeUnique_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_field")] = __StructWithRefTypeUnique_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_field")] = __StructWithRefTypeUnique_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_field")] = __StructWithRefTypeUnique_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithRefTypeUnique_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithRefTypeUnique_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeUnique](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'def_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).def_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field opt_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeUnique](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'opt_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).opt_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeUnique](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'req_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).req_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))


@__cython.auto_pickle(False)
cdef class __StructWithRefTypeShared_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithRefTypeShared_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithRefTypeShared* struct_cpp_obj):
        cdef __StructWithRefTypeShared_FieldsSetter __fbthrift_inst = __StructWithRefTypeShared_FieldsSetter.__new__(__StructWithRefTypeShared_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_field")] = __StructWithRefTypeShared_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_field")] = __StructWithRefTypeShared_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_field")] = __StructWithRefTypeShared_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithRefTypeShared_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithRefTypeShared_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeShared](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'def_field is not a { _module_types.Empty !r}.')
        assign_shared_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).def_field_ref(), (<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field opt_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeShared](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'opt_field is not a { _module_types.Empty !r}.')
        assign_shared_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).opt_field_ref(), (<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeShared](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'req_field is not a { _module_types.Empty !r}.')
        assign_shared_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).req_field_ref(), (<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)


@__cython.auto_pickle(False)
cdef class __StructWithRefTypeSharedConst_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithRefTypeSharedConst_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithRefTypeSharedConst* struct_cpp_obj):
        cdef __StructWithRefTypeSharedConst_FieldsSetter __fbthrift_inst = __StructWithRefTypeSharedConst_FieldsSetter.__new__(__StructWithRefTypeSharedConst_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_field")] = __StructWithRefTypeSharedConst_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"opt_field")] = __StructWithRefTypeSharedConst_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"req_field")] = __StructWithRefTypeSharedConst_FieldsSetter._set_field_2
        return __fbthrift_inst

    cdef void set_field(__StructWithRefTypeSharedConst_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithRefTypeSharedConst_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeSharedConst](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'def_field is not a { _module_types.Empty !r}.')
        assign_shared_const_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).def_field_ref(), const_pointer_cast((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field opt_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeSharedConst](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'opt_field is not a { _module_types.Empty !r}.')
        assign_shared_const_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).opt_field_ref(), const_pointer_cast((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field req_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefTypeSharedConst](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'req_field is not a { _module_types.Empty !r}.')
        assign_shared_const_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).req_field_ref(), const_pointer_cast((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))


@__cython.auto_pickle(False)
cdef class __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithRefAndAnnotCppNoexceptMoveCtor* struct_cpp_obj):
        cdef __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter __fbthrift_inst = __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter.__new__(__StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_field")] = __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter._set_field_0
        return __fbthrift_inst

    cdef void set_field(__StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithRefAndAnnotCppNoexceptMoveCtor_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_field
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithRefAndAnnotCppNoexceptMoveCtor](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, _module_types.Empty):
            raise TypeError(f'def_field is not a { _module_types.Empty !r}.')
        assign_unique_ptr[_module_cbindings.cEmpty](deref(self._struct_cpp_obj).def_field_ref(), make_unique[_module_cbindings.cEmpty](deref((<_module_types.Empty?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))


@__cython.auto_pickle(False)
cdef class __StructWithString_FieldsSetter(__StructFieldsSetter):

    @staticmethod
    cdef __StructWithString_FieldsSetter _fbthrift_create(_module_cbindings.cStructWithString* struct_cpp_obj):
        cdef __StructWithString_FieldsSetter __fbthrift_inst = __StructWithString_FieldsSetter.__new__(__StructWithString_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_unique_string_ref")] = __StructWithString_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_shared_string_ref")] = __StructWithString_FieldsSetter._set_field_1
        __fbthrift_inst._setters[__cstring_view(<const char*>"def_shared_string_const_ref")] = __StructWithString_FieldsSetter._set_field_2
        __fbthrift_inst._setters[__cstring_view(<const char*>"unique_string_ref")] = __StructWithString_FieldsSetter._set_field_3
        __fbthrift_inst._setters[__cstring_view(<const char*>"shared_string_ref")] = __StructWithString_FieldsSetter._set_field_4
        return __fbthrift_inst

    cdef void set_field(__StructWithString_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __StructWithString_FieldsSetterFunc].iterator found = self._setters.find(cname)
        if found == self._setters.end():
            raise TypeError(f"invalid field name {name.decode('utf-8')}")
        deref(found).second(self, value)

    cdef void _set_field_0(self, _fbthrift_value) except *:
        # for field def_unique_string_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithString](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'def_unique_string_ref is not a { str !r}.')
        assign_unique_ptr[string](deref(self._struct_cpp_obj).def_unique_string_ref_ref(), make_unique[string](deref((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field def_shared_string_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithString](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'def_shared_string_ref is not a { str !r}.')
        assign_shared_ptr[string](deref(self._struct_cpp_obj).def_shared_string_ref_ref(), (<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)

    cdef void _set_field_2(self, _fbthrift_value) except *:
        # for field def_shared_string_const_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithString](deref(self._struct_cpp_obj), 2)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'def_shared_string_const_ref is not a { str !r}.')
        assign_shared_const_ptr[string](deref(self._struct_cpp_obj).def_shared_string_const_ref_ref(), const_pointer_cast((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE))

    cdef void _set_field_3(self, _fbthrift_value) except *:
        # for field unique_string_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithString](deref(self._struct_cpp_obj), 3)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'unique_string_ref is not a { str !r}.')
        assign_unique_ptr[string](deref(self._struct_cpp_obj).unique_string_ref_ref(), make_unique[string](deref((<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)))

    cdef void _set_field_4(self, _fbthrift_value) except *:
        # for field shared_string_ref
        if _fbthrift_value is None:
            __reset_field[_module_cbindings.cStructWithString](deref(self._struct_cpp_obj), 4)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f'shared_string_ref is not a { str !r}.')
        assign_shared_ptr[string](deref(self._struct_cpp_obj).shared_string_ref_ref(), (<str?>_fbthrift_value)._cpp_obj_FBTHRIFT_ONLY_DO_NOT_USE)

