1 # Copyright (c) 2022 Intel and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 import ExpressionConverter
15 from InputFormat import *
20 self.DefaultValue = None
21 self.IsReserved = None
22 self.IsReadonly = None
23 self.IsAutoIncrease = None
24 self.IsIncreaseLength = None
26 self.VariableSize = None
34 if token["name"] == None:
36 if token["size"] == None:
40 field.Name = token["name"]
42 if field.Name == "reserved":
43 field.IsReserved = True
45 inputFormat = InputFormat.bytearray
46 res, u16 = ExpressionConverter.ToNum(token["size"])
52 inputFormat = InputFormat.u8
54 inputFormat = InputFormat.u16
56 inputFormat = InputFormat.u32
58 inputFormat = InputFormat.u64
60 inputFormat = InputFormat.bytearray
63 field.VariableSize = token["size"]
65 if "format" in token and token["format"] != None:
66 inputFormat = InputFormat[token["format"]]
68 field.Format = inputFormat
70 if "default" in token and token["default"] != None:
71 field.DefaultValue = token["default"]
72 ret, _ = ExpressionConverter.Verify(field.Format, field.DefaultValue)
76 if "readonly" in token and token["readonly"] == "true" or field.IsReserved:
77 field.IsReadonly = True
78 if "autoincrease" in token and token["autoincrease"] == "true":
79 field.IsAutoIncrease = True
80 field.IsReadonly = True
81 if "increaselength" in token and token["increaselength"] == "true":
82 field.IsIncreaseLength = True
83 if "optional" in token:
84 field.Optional = token["optional"]