Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / generate / templates / cpp2 / module_layouts_cpp / frozen_freeze_union.mustache
blob6d91ac6038aaf4db185a41c7eafa8e434c05afb4
1 <%!
3   Copyright (c) Facebook, Inc. and its affiliates.
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
9       http://www.apache.org/licenses/LICENSE-2.0
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
18   void Layout<<%struct:cpp_fullname%>>::freeze(
19       FreezeRoot& root, const T& x, FreezePosition self) const {
20     auto type = x.getType();
21     root.freezeField(self, this->type_Field, type);
22     switch (type) {
23 <%#struct:fields%>
24       case <%struct:cpp_fullname%>::Type::<%field:cpp_name%>: {
25         root.freezeField(self, this-><%field:cpp_name%>Field, x.get_<%field:cpp_name%>());
26         break;
27       }
28 <%/struct:fields%>
29       default: {
30         assert(false);
31         break;
32       }
33     }
34   }