Porytiles
Loading...
Searching...
No Matches
metatile_attribute_inference.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <optional>
6#include <string>
7#include <unordered_set>
8#include <vector>
9
10#include "gsl/pointers"
11
13
14namespace porytiles {
15
16class TextFormatter;
17
19inline constexpr auto metatile_attr_inference_tag = "metatile-attribute-inference";
20
27 std::string name;
28 std::optional<std::int64_t> value;
29};
30
33 std::string name;
34 std::uint32_t value;
35};
36
43 std::string index_name;
44 std::optional<std::uint32_t> value;
45};
46
55 absent,
58 declared,
59};
60
64 std::string path;
65};
66
78 declared,
79};
80
90 std::string element_type;
91 std::size_t pointer_depth{0};
92 bool is_const{false};
93};
94
104[[nodiscard]] std::string to_declaration_string(const AttributeDeclarationScan &scan);
105
113 std::vector<InferenceEnumMember> enum_members;
114 std::vector<InferenceDefine> defines;
115 std::unordered_set<std::string>
117 std::vector<InferenceArrayEntry> masks_array;
118 std::vector<InferenceArrayEntry>
122 std::string header_source;
123 std::string masks_table_source;
124 std::vector<std::string>
126};
127
142};
143
154 std::string field_name;
156 std::string probed;
157 std::optional<std::uint32_t> declared;
158 std::optional<std::uint32_t> alternate;
159};
160
177 std::string origin;
178 std::string source;
180 std::size_t required_bytes{2};
181 std::vector<InferredFieldConflict> conflicts;
182};
183
186 valid,
187 invalid,
189};
190
201 std::optional<std::size_t> size;
202};
203
216 std::vector<MetatileAttributeCandidateSet> candidates;
217 std::string error_message;
219 std::vector<std::string> unrecognized_defines;
220};
221
255infer_metatile_attribute_candidates(const MetatileAttributeScan &scan, gsl::not_null<const TextFormatter *> format);
256
257} // namespace porytiles
std::vector< MetatileAttributeFieldDefinition > MetatileAttributeFieldDefinitions
An ordered list of metatile attribute field definitions; order is display/declaration order.
MetatileAttributeInferenceResult infer_metatile_attribute_candidates(const MetatileAttributeScan &scan, gsl::not_null< const TextFormatter * > format)
Infers the metatile attribute mask candidate sets from a project's raw fieldmap facts.
AttributeDeclarationSource
What the scan found where struct Tileset's metatileAttributes member should be.
@ no_attributes_member
struct Tileset declares no metatileAttributes member
@ header_unreadable
the fieldmap header exists but could not be scanned
@ no_tileset_struct
the header was scanned and declares no struct Tileset
@ no_fieldmap_header
the project has no include/global.fieldmap.h
BehaviorsHeaderSource
What the scan found where the behavior constants header should be.
@ unreadable
the header exists but could not be scanned
@ no_constants
the header was scanned and declares no MB_ name
@ declared
the header declares at least one MB_ name
@ absent
the project has no include/constants/metatile_behaviors.h
AttributeInferenceStatus
The outcome kind of an inference run.
@ not_provided
nothing attribute-related was found; other providers should be consulted
@ valid
one or more usable candidate sets were inferred
@ invalid
no layout could be determined from what the project declares (fatal at resolution time)
std::string to_declaration_string(const AttributeDeclarationScan &scan)
Renders a declared metatileAttributes member the way the project wrote it.
constexpr auto metatile_attr_inference_tag
The diagnostic tag the infra-layer scanner emits its warnings under.
FieldConflictKind
Why one inferred field could not be settled from the project's sources alone.
@ provider_behaviors_unreadable
the behavior constants header exists but could not be scanned
@ provider_behaviors_absent
the behavior constants header does not exist
@ shift_vs_mask
the field's declared shift and its mask's bit offset disagree
@ provider_no_matching_enum
no enum member with the probed prefix exists in the fieldmap header
@ provider_behaviors_no_constants
the header was scanned and declares no MB_ name
@ mask_define_vs_table
the field's mask define and mask table entry disagree
struct Tileset's metatileAttributes declaration, as the project wrote it.
The behavior constants header, as the scan found it.
std::string path
the path looked at, so a diagnostic can name it
One designated entry of an attribute mask/shift table.
One integer #define gathered from a base game's fieldmap header.
One enum member gathered from a base game's fieldmap header.
The declared element width of a project's metatile attribute arrays, and the declaration behind it.
One unsettled fact about one inferred field, carried out of inference for the reconciler to rule on.
std::optional< std::uint32_t > declared
define mask, or the declared shift
std::string probed
header path or enum prefix (provider kinds only)
std::optional< std::uint32_t > alternate
table mask, or the shift the mask implies
One complete metatile attribute mask layout a project declares.
std::vector< MetatileAttributeCandidateSet > candidates
The raw facts a project exposes about its metatile attribute layout.
std::vector< std::string > unreadable_sources
files that exist but could not be read, so whatever they declare is missing above
std::vector< InferenceArrayEntry > masks_array
entries of the exact-name sMetatileAttrMasks table (may be empty)
std::string header_source
path of the fieldmap header the defines, enum members, and struct came from
std::vector< InferenceArrayEntry > shifts_array
entries of the exact-name sMetatileAttrShifts table (may be empty)
std::vector< InferenceEnumMember > enum_members
all enum members from the fieldmap header, in declaration order
AttributeDeclarationScan declaration
struct Tileset's metatileAttributes declaration, or why there is none
std::string masks_table_source
path of the file the mask table came from, empty when no table was read
BehaviorsHeaderScan behaviors_header
the behavior constants header, or why there is none
std::unordered_set< std::string > ambiguous_defines
mask defines with conflicting values in an undecidable conditional branch
std::vector< InferenceDefine > defines
all integer defines from the fieldmap header