/* * 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 #include #include namespace { using namespace apache::thrift::compiler; } template class func_signature_helper; template class func_signature_helper { public: static std::unique_ptr get_type() { return get_type(dummy::type>()); } private: template struct dummy {}; static std::unique_ptr get_type(dummy) { return std::make_unique(t_primitive_type::t_void()); } static std::unique_ptr get_type(dummy) { return std::make_unique(t_primitive_type::t_i32()); } static std::unique_ptr get_type(dummy) { return std::make_unique(t_primitive_type::t_double()); } }; template class func_signature; template <> class func_signature<> { public: static void get_arg_type(std::vector>&) {} }; template class func_signature { public: static void get_arg_type(std::vector>& vec) { vec.push_back(func_signature_helper::get_type()); func_signature::get_arg_type(vec); } }; template class func_signature { public: static std::unique_ptr return_type() { return func_signature_helper::get_type(); } static std::vector> args_types() { std::vector> result; func_signature::get_arg_type(result); return result; } };