1 /*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "fields/reserved_field.h"
18
19 #include "util.h"
20
21 int ReservedField::unique_id_ = 0;
22
23 const std::string ReservedField::kFieldType = "ReservedField";
24
ReservedField(int size,ParseLocation loc)25 ReservedField::ReservedField(int size, ParseLocation loc)
26 : PacketField("ReservedScalar" + std::to_string(unique_id_++), loc), size_(size) {}
27
GetFieldType() const28 const std::string& ReservedField::GetFieldType() const { return ReservedField::kFieldType; }
29
GetSize() const30 Size ReservedField::GetSize() const { return size_; }
31
GetDataType() const32 std::string ReservedField::GetDataType() const { return util::GetTypeForSize(size_); }
33
GenExtractor(std::ostream &,int,bool) const34 void ReservedField::GenExtractor(std::ostream&, int, bool) const {}
35
GetGetterFunctionName() const36 std::string ReservedField::GetGetterFunctionName() const { return ""; }
37
GenGetter(std::ostream &,Size,Size) const38 void ReservedField::GenGetter(std::ostream&, Size, Size) const {
39 // There is no Getter for a reserved field
40 }
41
GetBuilderParameterType() const42 std::string ReservedField::GetBuilderParameterType() const {
43 // There is no builder parameter for a reserved field
44 return "";
45 }
46
HasParameterValidator() const47 bool ReservedField::HasParameterValidator() const { return false; }
48
GenParameterValidator(std::ostream &) const49 void ReservedField::GenParameterValidator(std::ostream&) const {
50 // There is no builder parameter for a reserved field
51 }
52
GenInserter(std::ostream & s) const53 void ReservedField::GenInserter(std::ostream& s) const {
54 s << "insert(static_cast<" << util::GetTypeForSize(GetSize().bits()) << ">(0) /* Reserved */, i, "
55 << GetSize().bits() << " );\n";
56 }
57
GenValidator(std::ostream &) const58 void ReservedField::GenValidator(std::ostream&) const {
59 // There is no need to validate the value of a reserved field
60 }
61