/* * 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. */ include "thrift/annotation/cpp.thrift" cpp_include "" cpp_include "" cpp_include "" cpp_include "" cpp_include "" cpp_include "" cpp_include "" cpp_include "" package "test.dev/fixtures/python_capi" @cpp.Type{name = "folly::IOBuf"} typedef binary IOBuf @cpp.Type{template = "folly::small_vector"} typedef list small_vector_iobuf @cpp.Type{template = "folly::fbvector"} typedef list fbvector_string @cpp.Type{template = "folly::fbvector"} typedef list fbvector_fbvector_string /** * Vector-like container types that don't work in thrift-cpp2: * - std::array -> requires fixed size, fails cpp2 compilation * - std::stack -> no push_back * - std::forward_list -> no size() * Containers we can support but don't currently work: * - std::list (need to switch constructor to forward iterator) */ struct TemplateLists { // @cpp.Type{template = "std::forward_list"} // 2: optional list intz; @cpp.Type{template = "std::vector"} 1: optional list std_string; @cpp.Type{template = "std::deque"} 2: list deque_string; 3: small_vector_iobuf small_vector_iobuf; @cpp.Type{template = "folly::small_vector"} 4: list nested_small_vector; @cpp.Type{template = "folly::fbvector"} 5: list small_vector_tensor; // @cpp.Type{template = "std::list"} // 6: list list_string; } (cpp.noncomparable) struct TemplateSets { @cpp.Type{template = "std::set"} 1: set std_set; @cpp.Type{template = "std::unordered_set"} 2: set std_unordered; @cpp.Type{template = "folly::F14FastSet"} 3: set folly_fast; @cpp.Type{template = "folly::F14NodeSet"} 4: set folly_node; @cpp.Type{template = "folly::F14ValueSet"} 5: set folly_value; @cpp.Type{template = "folly::F14VectorSet"} 6: set folly_vector; @cpp.Type{template = "folly::sorted_vector_set"} 7: set folly_sorted_vector; } struct TemplateMaps { @cpp.Type{template = "std::map"} 1: map std_map; @cpp.Type{template = "std::unordered_map"} 2: map std_unordered; @cpp.Type{template = "folly::F14FastMap"} 3: map folly_fast; @cpp.Type{template = "folly::F14NodeMap"} 4: map folly_node; @cpp.Type{template = "folly::F14ValueMap"} 5: map folly_value; @cpp.Type{template = "folly::F14VectorMap"} 6: map folly_vector; @cpp.Type{template = "folly::sorted_vector_map"} 7: map folly_sorted_vector; } struct TWrapped { 1: string fieldA; 2: binary fieldB; } @cpp.Type{name = "::thrift::test::python_capi::CppWrapperT"} typedef TWrapped (cpp.indirection) CppWrapper typedef list ListOfWrapped // Should not be marshaled struct IndirectionA { 1: ListOfWrapped lst; } @cpp.Type{template = "std::vector"} typedef list VecOfWrapped // Should also not be marshaled struct IndirectionB { 1: VecOfWrapped lst; } typedef ListOfWrapped ListOfWrappedAlias // Should also not be marshaled struct IndirectionC { 1: ListOfWrappedAlias lst; }