#
# Autogenerated by Thrift for shared.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 test.fixtures.another_interactions.shared.types as _test_fixtures_another_interactions_shared_types


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

    @staticmethod
    cdef __DoSomethingResult_FieldsSetter _fbthrift_create(_test_fixtures_another_interactions_shared_cbindings.cDoSomethingResult* struct_cpp_obj):
        cdef __DoSomethingResult_FieldsSetter __fbthrift_inst = __DoSomethingResult_FieldsSetter.__new__(__DoSomethingResult_FieldsSetter)
        __fbthrift_inst._struct_cpp_obj = struct_cpp_obj
        __fbthrift_inst._setters[__cstring_view(<const char*>"s_res")] = __DoSomethingResult_FieldsSetter._set_field_0
        __fbthrift_inst._setters[__cstring_view(<const char*>"i_res")] = __DoSomethingResult_FieldsSetter._set_field_1
        return __fbthrift_inst

    cdef void set_field(__DoSomethingResult_FieldsSetter self, const char* name, object value) except *:
        cdef __cstring_view cname = __cstring_view(name)
        cdef cumap[__cstring_view, __DoSomethingResult_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 s_res
        if _fbthrift_value is None:
            __reset_field[_test_fixtures_another_interactions_shared_cbindings.cDoSomethingResult](deref(self._struct_cpp_obj), 0)
            return
        if not isinstance(_fbthrift_value, str):
            raise TypeError(f's_res is not a { str !r}.')
        deref(self._struct_cpp_obj).s_res_ref().assign(cmove(bytes_to_string(_fbthrift_value.encode('utf-8'))))

    cdef void _set_field_1(self, _fbthrift_value) except *:
        # for field i_res
        if _fbthrift_value is None:
            __reset_field[_test_fixtures_another_interactions_shared_cbindings.cDoSomethingResult](deref(self._struct_cpp_obj), 1)
            return
        if not isinstance(_fbthrift_value, int):
            raise TypeError(f'i_res is not a { int !r}.')
        _fbthrift_value = <cint32_t> _fbthrift_value
        deref(self._struct_cpp_obj).i_res_ref().assign(_fbthrift_value)

