1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "assemblyFieldProto.h" 17 18namespace panda::proto { 19void Field::Serialize(const panda::pandasm::Field &field, protoPanda::Field &protoField) 20{ 21 auto *protoType = protoField.mutable_type(); 22 Type::Serialize(field.type, *protoType); 23 protoField.set_name(field.name); 24 auto *protoFieldmeta = protoField.mutable_metadata(); 25 FieldMetadata::Serialize(*field.metadata, *protoFieldmeta); 26 protoField.set_lineofdef(field.line_of_def); 27 protoField.set_wholeline(field.whole_line); 28 protoField.set_boundleft(field.bound_left); 29 protoField.set_boundright(field.bound_right); 30 protoField.set_isdefined(field.is_defined); 31} 32 33void Field::Deserialize(const protoPanda::Field &protoField, panda::pandasm::Field &field, 34 panda::ArenaAllocator *allocator) 35{ 36 field.type = Type::Deserialize(protoField.type(), allocator); 37 field.name = protoField.name(); 38 FieldMetadata::Deserialize(protoField.metadata(), field.metadata, allocator); 39 field.line_of_def = protoField.lineofdef(); 40 field.whole_line = protoField.wholeline(); 41 field.bound_left = protoField.boundleft(); 42 field.bound_right = protoField.boundright(); 43 field.is_defined = protoField.isdefined(); 44} 45} // panda::proto 46