{{! 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. }}{{! Used in cases where we have a C++ object defined in Cython code and we need to create or return a Python object. For complex objects, a Python wrapper is initialized; for simple objects it can be returned directly. Strings need to be converted from unicode to binary representation. }}{{#type:iobuf?}}_fbthrift_iobuf.from_unique_ptr(move_iobuf({{field:py_name}})){{/type:iobuf?}}{{! }}{{#type:iobufRef?}}_fbthrift_iobuf.from_unique_ptr(move_iobuf(deref({{field:py_name}}))){{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}(deref({{field:py_name}}).data())[:deref({{field:py_name}}).size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}{{field:py_name}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:py_name}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:py_name}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:py_name}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:py_name}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:py_name}}{{/type:double?}}{{! }}{{#type:float?}}{{field:py_name}}{{/type:float?}}{{! }}{{#type:string?}}(deref({{field:py_name}})).data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}(deref({{field:py_name}})){{/type:binary?}}{{! }}{{#type:struct?}}{{> types/cython_python_type}}._fbthrift_create({{! }}shared_ptr[{{> types/cython_cpp_type}}]({{field:py_name}}.release())){{/type:struct?}}{{! }}{{#type:container?}}{{> types/cython_python_type}}._fbthrift_create({{! }}__to_shared_ptr(cmove({{field:py_name}}))){{/type:container?}}{{! }}{{#type:enum?}}{{> types/cython_python_type}}( {{field:py_name}}){{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}}