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 from InputFormat import *
15 import ExpressionConverter
20 self.DefaultValue = None
26 attr = NodeAttribute()
28 if token["name"] == None:
30 if token["size"] == None:
34 attr.Name = token["name"]
36 inputFormat = InputFormat.bytearray
37 res, u16 = ExpressionConverter.ToNum(token["size"])
43 inputFormat = InputFormat.u8
45 inputFormat = InputFormat.u16
47 inputFormat = InputFormat.u32
49 inputFormat = InputFormat.u64
51 inputFormat = InputFormat.bytearray
55 if "format" in token and token["format"] != None:
56 inputFormat = InputFormat[token["format"]]
58 attr.Format = inputFormat
59 if "default" in token and token["default"] != None:
60 attr.DefaultValue = token["default"]
61 ret, _ = ExpressionConverter.Verify(attr.Format, attr.DefaultValue)