{{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Cpp2 <-> thrift-python converters for Thrift structs }} {{> common/auto_generated_cython}} from thrift.python.capi.cpp_converter cimport cpp_to_python, python_to_cpp from libcpp.utility cimport move as cmove cdef extern from "{{program:includePrefix}}gen-python-capi/{{program:name}}/thrift_types_capi.h": pass {{#program:structs}} {{! thrift-python replacement for py3_struct._cpp_obj, but no heap allocation }} cdef c{{struct:py_name}} {{struct:py_name}}_convert_to_cpp(object inst) except *: return cmove(python_to_cpp[c{{struct:py_name}}](inst)) {{! thrift-python replacement for Py3Struct._fbthrift_create }} cdef object {{struct:py_name}}_from_cpp(const c{{struct:py_name}}& c_struct): return cpp_to_python[c{{struct:py_name}}](c_struct) {{/program:structs}}