Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 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 | #pragma once |
| 18 | |
| 19 | #include <map> |
| 20 | #include <variant> |
| 21 | |
| 22 | #include "enum_def.h" |
| 23 | #include "field_list.h" |
| 24 | #include "fields/packet_field.h" |
Myles Watson | ea6331b | 2019-07-09 14:09:42 -0700 | [diff] [blame] | 25 | #include "parent_def.h" |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 26 | |
Myles Watson | ea6331b | 2019-07-09 14:09:42 -0700 | [diff] [blame] | 27 | class PacketDef : public ParentDef { |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 28 | public: |
| 29 | PacketDef(std::string name, FieldList fields); |
| 30 | PacketDef(std::string name, FieldList fields, PacketDef* parent); |
| 31 | |
Myles Watson | ea6331b | 2019-07-09 14:09:42 -0700 | [diff] [blame] | 32 | PacketField* GetNewField(const std::string& name, ParseLocation loc) const; |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 33 | |
| 34 | void GenParserDefinition(std::ostream& s) const; |
| 35 | |
Jack He | 9be1dcd | 2019-11-18 19:20:41 -0800 | [diff] [blame] | 36 | void GenParserDefinitionPybind11(std::ostream& s) const; |
| 37 | |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 38 | void GenParserFieldGetter(std::ostream& s, const PacketField* field) const; |
| 39 | |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 40 | void GenValidator(std::ostream& s) const; |
| 41 | |
Myles Watson | ea6331b | 2019-07-09 14:09:42 -0700 | [diff] [blame] | 42 | TypeDef::Type GetDefinitionType() const; |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 43 | |
Myles Watson | ea6331b | 2019-07-09 14:09:42 -0700 | [diff] [blame] | 44 | void GenBuilderDefinition(std::ostream& s) const; |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 45 | |
Jack He | 9be1dcd | 2019-11-18 19:20:41 -0800 | [diff] [blame] | 46 | void GenBuilderDefinitionPybind11(std::ostream& s) const; |
| 47 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 48 | void GenTestDefine(std::ostream& s) const; |
| 49 | |
Jack He | 8af1b62 | 2019-10-18 16:11:17 -0700 | [diff] [blame] | 50 | void GenFuzzTestDefine(std::ostream& s) const; |
| 51 | |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 52 | FieldList GetParametersToValidate() const; |
| 53 | |
| 54 | void GenBuilderCreate(std::ostream& s) const; |
| 55 | |
Jack He | 9be1dcd | 2019-11-18 19:20:41 -0800 | [diff] [blame] | 56 | void GenBuilderCreatePybind11(std::ostream& s) const; |
| 57 | |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 58 | void GenBuilderParameterChecker(std::ostream& s) const; |
| 59 | |
| 60 | void GenBuilderConstructor(std::ostream& s) const; |
Ajay Panicker | 4d6b760 | 2019-02-06 14:02:36 -0800 | [diff] [blame] | 61 | }; |