mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
da90bbd356 | ||
|
13b07c0fe4 | ||
|
38d948ebdd | ||
|
9f8a933277 | ||
|
9f738da517 | ||
|
785cf8c025 | ||
|
0f3ee1fa79 | ||
|
c8cd6826c1 | ||
|
5afc24fd89 | ||
|
598abe095b | ||
|
d6eee273ff | ||
|
7edbe7378b | ||
|
b83bafb0f8 | ||
|
e750e3ffd9 | ||
|
d5b6c6e9c2 | ||
|
d6c1ef775e | ||
|
c05d4ea34e | ||
|
b2d9bf416d | ||
|
3134ec5a37 | ||
|
0d35696940 | ||
|
b215b22018 | ||
|
a447dd29fa | ||
|
985996975b | ||
|
f235798cf6 | ||
|
0228e86980 | ||
|
01302cf061 | ||
|
6f31e8cc29 | ||
|
37d52ae8da | ||
|
481d301545 |
@ -177,7 +177,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
|||||||
| ComWorld | ❌ | ❌ | |
|
| ComWorld | ❌ | ❌ | |
|
||||||
| GameWorldSp | ❌ | ❌ | |
|
| GameWorldSp | ❌ | ❌ | |
|
||||||
| GameWorldMp | ❌ | ❌ | |
|
| GameWorldMp | ❌ | ❌ | |
|
||||||
| MapEnts | ❌ | ❌ | |
|
| MapEnts | ✅ | ❌ | |
|
||||||
| GfxWorld | ❌ | ❌ | |
|
| GfxWorld | ❌ | ❌ | |
|
||||||
| GfxLightDef | ❌ | ❌ | |
|
| GfxLightDef | ❌ | ❌ | |
|
||||||
| Font_s | ❌ | ❌ | |
|
| Font_s | ❌ | ❌ | |
|
||||||
|
@ -16,7 +16,7 @@ workspace "OpenAssetTools"
|
|||||||
objdir "%{wks.location}/obj"
|
objdir "%{wks.location}/obj"
|
||||||
symbols "On"
|
symbols "On"
|
||||||
systemversion "latest"
|
systemversion "latest"
|
||||||
cppdialect "C++20"
|
cppdialect "C++23"
|
||||||
largeaddressaware "on"
|
largeaddressaware "on"
|
||||||
|
|
||||||
flags {
|
flags {
|
||||||
@ -54,6 +54,10 @@ workspace "OpenAssetTools"
|
|||||||
symbols "On"
|
symbols "On"
|
||||||
filter {}
|
filter {}
|
||||||
|
|
||||||
|
filter {"system:windows", "configurations:Debug" }
|
||||||
|
buildoptions { "/bigobj" }
|
||||||
|
filter {}
|
||||||
|
|
||||||
filter "configurations:Release"
|
filter "configurations:Release"
|
||||||
defines "NDEBUG"
|
defines "NDEBUG"
|
||||||
optimize "Full"
|
optimize "Full"
|
||||||
|
23
scripts/build.sh
Executable file
23
scripts/build.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Go to repository root
|
||||||
|
cd "$(dirname "$0")/.." || exit 2
|
||||||
|
|
||||||
|
TARGET='all'
|
||||||
|
ARCHITECTURE='x86'
|
||||||
|
CONFIG='debug'
|
||||||
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
if [ "$var" == "debug" ] || [ "$var" == "release" ]; then
|
||||||
|
CONFIG="$var"
|
||||||
|
elif [ "$var" == "x86" ] || [ "$var" == "x64" ]; then
|
||||||
|
ARCHITECTURE="$var"
|
||||||
|
else
|
||||||
|
TARGET="$var"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Building config=${CONFIG} architecture=${ARCHITECTURE} target=${TARGET}"
|
||||||
|
make -C build -j$(nproc) config=${CONFIG}_${ARCHITECTURE} "${TARGET}"
|
||||||
|
|
@ -5,3 +5,5 @@ cd "$(dirname "$0")/.." || exit 2
|
|||||||
|
|
||||||
make -C build -j$(nproc) config=debug_x86 clean
|
make -C build -j$(nproc) config=debug_x86 clean
|
||||||
make -C build -j$(nproc) config=release_x86 clean
|
make -C build -j$(nproc) config=release_x86 clean
|
||||||
|
make -C build -j$(nproc) config=debug_x64 clean
|
||||||
|
make -C build -j$(nproc) config=release_x64 clean
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
struct ZoneHeader
|
struct ZoneHeader
|
||||||
{
|
{
|
||||||
@ -7,21 +8,11 @@ struct ZoneHeader
|
|||||||
uint32_t m_version;
|
uint32_t m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ARCH_x64
|
|
||||||
typedef uint32_t scr_string_t;
|
|
||||||
typedef uint64_t xchunk_size_t;
|
|
||||||
typedef uint64_t xblock_size_t;
|
|
||||||
typedef uint64_t zone_pointer_t;
|
|
||||||
|
|
||||||
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
|
|
||||||
#elif ARCH_x86
|
|
||||||
typedef uint16_t scr_string_t;
|
typedef uint16_t scr_string_t;
|
||||||
typedef uint32_t xchunk_size_t;
|
typedef uint32_t xchunk_size_t;
|
||||||
typedef uint32_t xblock_size_t;
|
typedef uint32_t xblock_size_t;
|
||||||
typedef uint32_t zone_pointer_t;
|
|
||||||
|
|
||||||
constexpr uint16_t SCR_STRING_MAX = UINT16_MAX;
|
constexpr uint16_t SCR_STRING_MAX = std::numeric_limits<scr_string_t>::max();
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int block_t;
|
typedef int block_t;
|
||||||
typedef int asset_type_t;
|
typedef int asset_type_t;
|
||||||
|
@ -16,7 +16,7 @@ namespace ipak_consts
|
|||||||
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
||||||
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
||||||
|
|
||||||
static constexpr uint32_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
static constexpr size_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||||
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
||||||
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
||||||
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
||||||
|
@ -68,7 +68,7 @@ namespace
|
|||||||
T result;
|
T result;
|
||||||
} data{};
|
} data{};
|
||||||
|
|
||||||
const auto byteCount = utils::Align(bitCount, 8u) / 8u;
|
const auto byteCount = utils::Align(bitCount, 8uz) / 8uz;
|
||||||
assert(byteCount <= sizeof(T));
|
assert(byteCount <= sizeof(T));
|
||||||
|
|
||||||
const auto shiftCount = (8u - bitCount % 8) % 8;
|
const auto shiftCount = (8u - bitCount % 8) % 8;
|
||||||
@ -83,7 +83,7 @@ namespace
|
|||||||
|
|
||||||
while (remainingBits > 0)
|
while (remainingBits > 0)
|
||||||
{
|
{
|
||||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8u));
|
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8uz));
|
||||||
|
|
||||||
if (m_remaining_bits_last_byte > 0)
|
if (m_remaining_bits_last_byte > 0)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
|||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
||||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8u);
|
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8uz);
|
||||||
}
|
}
|
||||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
|||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
||||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8u);
|
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8uz);
|
||||||
}
|
}
|
||||||
|
|
||||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||||
|
@ -216,7 +216,7 @@ namespace
|
|||||||
const auto remainingSize = dataSize - dataOffset;
|
const auto remainingSize = dataSize - dataOffset;
|
||||||
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
||||||
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
||||||
0u);
|
0uz);
|
||||||
|
|
||||||
if (remainingChunkBufferWindowSize == 0)
|
if (remainingChunkBufferWindowSize == 0)
|
||||||
{
|
{
|
||||||
|
@ -53,15 +53,15 @@ namespace
|
|||||||
case CommonStructuredDataTypeCategory::SHORT:
|
case CommonStructuredDataTypeCategory::SHORT:
|
||||||
return {DATA_SHORT, {0}};
|
return {DATA_SHORT, {0}};
|
||||||
case CommonStructuredDataTypeCategory::STRING:
|
case CommonStructuredDataTypeCategory::STRING:
|
||||||
return {DATA_STRING, {inputType.m_info.string_length}};
|
return {DATA_STRING, {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||||
case CommonStructuredDataTypeCategory::ENUM:
|
case CommonStructuredDataTypeCategory::ENUM:
|
||||||
return {DATA_ENUM, {inputType.m_info.type_index}};
|
return {DATA_ENUM, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::STRUCT:
|
case CommonStructuredDataTypeCategory::STRUCT:
|
||||||
return {DATA_STRUCT, {inputType.m_info.type_index}};
|
return {DATA_STRUCT, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||||
return {DATA_INDEXED_ARRAY, {inputType.m_info.type_index}};
|
return {DATA_INDEXED_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||||
return {DATA_ENUM_ARRAY, {inputType.m_info.type_index}};
|
return {DATA_ENUM_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -129,14 +129,14 @@ namespace
|
|||||||
{
|
{
|
||||||
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
||||||
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
||||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8u) / 8u;
|
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||||
{
|
{
|
||||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8u) / 8u;
|
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
sizeof(SoundAssetBankEntry),
|
sizeof(SoundAssetBankEntry),
|
||||||
sizeof(SoundAssetBankChecksum),
|
sizeof(SoundAssetBankChecksum),
|
||||||
0x40,
|
0x40,
|
||||||
m_entries.size(),
|
static_cast<unsigned>(m_entries.size()),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
m_total_size,
|
m_total_size,
|
||||||
@ -157,9 +157,9 @@ public:
|
|||||||
|
|
||||||
SoundAssetBankEntry entry{
|
SoundAssetBankEntry entry{
|
||||||
sound.m_sound_id,
|
sound.m_sound_id,
|
||||||
soundSize,
|
static_cast<unsigned>(soundSize),
|
||||||
static_cast<size_t>(m_current_offset),
|
static_cast<unsigned>(m_current_offset),
|
||||||
frameCount,
|
static_cast<unsigned>(frameCount),
|
||||||
frameRateIndex,
|
frameRateIndex,
|
||||||
static_cast<unsigned char>(header.formatChunk.nChannels),
|
static_cast<unsigned char>(header.formatChunk.nChannels),
|
||||||
sound.m_looping,
|
sound.m_looping,
|
||||||
@ -188,8 +188,8 @@ public:
|
|||||||
const auto frameRateIndex = INDEX_FOR_FRAMERATE[metaData.m_sample_rate];
|
const auto frameRateIndex = INDEX_FOR_FRAMERATE[metaData.m_sample_rate];
|
||||||
SoundAssetBankEntry entry{
|
SoundAssetBankEntry entry{
|
||||||
sound.m_sound_id,
|
sound.m_sound_id,
|
||||||
soundSize,
|
static_cast<unsigned>(soundSize),
|
||||||
static_cast<size_t>(m_current_offset),
|
static_cast<unsigned>(m_current_offset),
|
||||||
static_cast<unsigned>(metaData.m_total_samples),
|
static_cast<unsigned>(metaData.m_total_samples),
|
||||||
frameRateIndex,
|
frameRateIndex,
|
||||||
metaData.m_number_of_channels,
|
metaData.m_number_of_channels,
|
||||||
|
@ -240,7 +240,7 @@ namespace sdd::struct_scope_sequences
|
|||||||
if (state->m_current_struct_is_root && state->m_current_struct->m_properties.empty())
|
if (state->m_current_struct_is_root && state->m_current_struct->m_properties.empty())
|
||||||
state->m_current_struct_padding_offset -= 64u;
|
state->m_current_struct_padding_offset -= 64u;
|
||||||
|
|
||||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8u) / 8;
|
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8uz) / 8;
|
||||||
state->m_current_struct_padding_offset = 0u;
|
state->m_current_struct_padding_offset = 0u;
|
||||||
state->m_current_struct_is_root = false;
|
state->m_current_struct_is_root = false;
|
||||||
state->m_current_struct = nullptr;
|
state->m_current_struct = nullptr;
|
||||||
|
@ -74,7 +74,7 @@ class StructuredDataDefSizeCalculatorInternal
|
|||||||
|
|
||||||
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
||||||
|
|
||||||
auto currentOffset = 0u;
|
auto currentOffset = 0uz;
|
||||||
for (auto& property : _struct.m_properties)
|
for (auto& property : _struct.m_properties)
|
||||||
{
|
{
|
||||||
CalculateForType(property.m_type);
|
CalculateForType(property.m_type);
|
||||||
@ -85,7 +85,7 @@ class StructuredDataDefSizeCalculatorInternal
|
|||||||
|
|
||||||
currentOffset += property.m_type.GetSizeInBits(m_def);
|
currentOffset += property.m_type.GetSizeInBits(m_def);
|
||||||
}
|
}
|
||||||
currentOffset = utils::Align(currentOffset, 8u);
|
currentOffset = utils::Align(currentOffset, 8uz);
|
||||||
_struct.m_size_in_byte += currentOffset / 8;
|
_struct.m_size_in_byte += currentOffset / 8;
|
||||||
|
|
||||||
m_struct_calculated[index] = true;
|
m_struct_calculated[index] = true;
|
||||||
|
@ -286,7 +286,7 @@ namespace
|
|||||||
|
|
||||||
common.m_vertices.emplace_back(vertex);
|
common.m_vertices.emplace_back(vertex);
|
||||||
|
|
||||||
XModelVertexBoneWeights vertexWeights{.weightOffset = common.m_bone_weight_data.weights.size(), .weightCount = 0u};
|
XModelVertexBoneWeights vertexWeights{.weightOffset = static_cast<unsigned>(common.m_bone_weight_data.weights.size()), .weightCount = 0u};
|
||||||
for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++)
|
for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++)
|
||||||
{
|
{
|
||||||
if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon())
|
if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon())
|
||||||
|
@ -284,7 +284,7 @@ namespace
|
|||||||
const auto& vertList = surface.vertList[vertListIndex];
|
const auto& vertList = surface.vertList[vertListIndex];
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
|
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||||
|
|
||||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||||
{
|
{
|
||||||
@ -301,7 +301,7 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||||
|
|
||||||
vertsBlendOffset += 1;
|
vertsBlendOffset += 1;
|
||||||
@ -313,8 +313,8 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||||
|
|
||||||
@ -330,10 +330,10 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||||
|
|
||||||
@ -350,12 +350,12 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||||
|
|
||||||
|
@ -37,22 +37,22 @@ CommonStructuredDataType AssetDumperStructuredDataDefSet::ConvertType(const Comm
|
|||||||
case DATA_ENUM:
|
case DATA_ENUM:
|
||||||
assert(!def->m_enums.empty());
|
assert(!def->m_enums.empty());
|
||||||
out.m_category = CommonStructuredDataTypeCategory::ENUM;
|
out.m_category = CommonStructuredDataTypeCategory::ENUM;
|
||||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1u), 0u);
|
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||||
break;
|
break;
|
||||||
case DATA_STRUCT:
|
case DATA_STRUCT:
|
||||||
assert(!def->m_structs.empty());
|
assert(!def->m_structs.empty());
|
||||||
out.m_category = CommonStructuredDataTypeCategory::STRUCT;
|
out.m_category = CommonStructuredDataTypeCategory::STRUCT;
|
||||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1u), 0u);
|
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1uz), 0uz);
|
||||||
break;
|
break;
|
||||||
case DATA_INDEXED_ARRAY:
|
case DATA_INDEXED_ARRAY:
|
||||||
assert(!def->m_indexed_arrays.empty());
|
assert(!def->m_indexed_arrays.empty());
|
||||||
out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY;
|
out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY;
|
||||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1u), 0u);
|
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1uz), 0uz);
|
||||||
break;
|
break;
|
||||||
case DATA_ENUM_ARRAY:
|
case DATA_ENUM_ARRAY:
|
||||||
assert(!def->m_enumed_arrays.empty());
|
assert(!def->m_enumed_arrays.empty());
|
||||||
out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY;
|
out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY;
|
||||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1u), 0u);
|
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1uz), 0uz);
|
||||||
break;
|
break;
|
||||||
case DATA_COUNT:
|
case DATA_COUNT:
|
||||||
default:
|
default:
|
||||||
@ -138,7 +138,7 @@ void AssetDumperStructuredDataDefSet::ConvertEnumedArray(const CommonStructuredD
|
|||||||
assert(!def->m_enums.empty());
|
assert(!def->m_enums.empty());
|
||||||
out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8;
|
out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8;
|
||||||
out->m_array_type = ConvertType(def, in->elementType);
|
out->m_array_type = ConvertType(def, in->elementType);
|
||||||
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1u), 0u);
|
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||||
|
|
||||||
if (def->m_enums.empty())
|
if (def->m_enums.empty())
|
||||||
{
|
{
|
||||||
|
@ -267,7 +267,7 @@ namespace
|
|||||||
const auto& vertList = surface.vertList[vertListIndex];
|
const auto& vertList = surface.vertList[vertListIndex];
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
|
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||||
|
|
||||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||||
{
|
{
|
||||||
@ -284,7 +284,7 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||||
|
|
||||||
vertsBlendOffset += 1;
|
vertsBlendOffset += 1;
|
||||||
@ -296,8 +296,8 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||||
|
|
||||||
@ -313,10 +313,10 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||||
|
|
||||||
@ -333,12 +333,12 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||||
|
|
||||||
|
23
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp
Normal file
23
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "AssetDumperMapEnts.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
using namespace T6;
|
||||||
|
|
||||||
|
bool AssetDumperMapEnts::ShouldDump(XAssetInfo<MapEnts>* asset)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
|
||||||
|
{
|
||||||
|
const auto* mapEnts = asset->Asset();
|
||||||
|
|
||||||
|
const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name));
|
||||||
|
|
||||||
|
if (!mapEntsFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& stream = *mapEntsFile;
|
||||||
|
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1);
|
||||||
|
}
|
14
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h
Normal file
14
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Dumping/AbstractAssetDumper.h"
|
||||||
|
#include "Game/T6/T6.h"
|
||||||
|
|
||||||
|
namespace T6
|
||||||
|
{
|
||||||
|
class AssetDumperMapEnts final : public AbstractAssetDumper<MapEnts>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
bool ShouldDump(XAssetInfo<MapEnts>* asset) override;
|
||||||
|
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset) override;
|
||||||
|
};
|
||||||
|
} // namespace T6
|
@ -110,7 +110,7 @@ namespace
|
|||||||
"devraw/",
|
"devraw/",
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr size_t FRAME_RATE_FOR_INDEX[]{
|
constexpr unsigned FRAME_RATE_FOR_INDEX[]{
|
||||||
8000,
|
8000,
|
||||||
12000,
|
12000,
|
||||||
16000,
|
16000,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
#include "AssetDumpers/AssetDumperLeaderboardDef.h"
|
#include "AssetDumpers/AssetDumperLeaderboardDef.h"
|
||||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||||
|
#include "AssetDumpers/AssetDumperMapEnts.h"
|
||||||
#include "AssetDumpers/AssetDumperMaterial.h"
|
#include "AssetDumpers/AssetDumperMaterial.h"
|
||||||
#include "AssetDumpers/AssetDumperPhysConstraints.h"
|
#include "AssetDumpers/AssetDumperPhysConstraints.h"
|
||||||
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
||||||
@ -53,7 +54,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
|||||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
||||||
|
@ -27,7 +27,7 @@ void WavWriter::WritePcmHeader(const WavMetaData& metaData, const size_t dataLen
|
|||||||
};
|
};
|
||||||
m_stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
m_stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
||||||
|
|
||||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, dataLen};
|
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, static_cast<unsigned>(dataLen)};
|
||||||
m_stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
m_stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void StructuredDataDefDumper::DumpType(const CommonStructuredDataDef& def,
|
|||||||
|
|
||||||
void StructuredDataDefDumper::DumpProperty(const CommonStructuredDataDef& def,
|
void StructuredDataDefDumper::DumpProperty(const CommonStructuredDataDef& def,
|
||||||
const CommonStructuredDataStructProperty& property,
|
const CommonStructuredDataStructProperty& property,
|
||||||
unsigned& currentOffsetInBit) const
|
size_t& currentOffsetInBit) const
|
||||||
{
|
{
|
||||||
std::string typeName;
|
std::string typeName;
|
||||||
std::vector<std::string> arraySpecifiers;
|
std::vector<std::string> arraySpecifiers;
|
||||||
@ -205,11 +205,11 @@ void StructuredDataDefDumper::DumpStruct(const CommonStructuredDataDef& def, con
|
|||||||
IncIndent();
|
IncIndent();
|
||||||
|
|
||||||
auto currentOffsetInBit =
|
auto currentOffsetInBit =
|
||||||
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64u : 0u;
|
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64uz : 0uz;
|
||||||
for (const auto& property : _struct.m_properties)
|
for (const auto& property : _struct.m_properties)
|
||||||
DumpProperty(def, property, currentOffsetInBit);
|
DumpProperty(def, property, currentOffsetInBit);
|
||||||
|
|
||||||
currentOffsetInBit = utils::Align(currentOffsetInBit, 8u);
|
currentOffsetInBit = utils::Align(currentOffsetInBit, 8uz);
|
||||||
if ((currentOffsetInBit / 8) < _struct.m_size_in_byte)
|
if ((currentOffsetInBit / 8) < _struct.m_size_in_byte)
|
||||||
{
|
{
|
||||||
Indent();
|
Indent();
|
||||||
|
@ -17,7 +17,7 @@ class StructuredDataDefDumper : AbstractTextDumper
|
|||||||
|
|
||||||
void DumpEnum(const CommonStructuredDataEnum& _enum);
|
void DumpEnum(const CommonStructuredDataEnum& _enum);
|
||||||
void DumpType(const CommonStructuredDataDef& def, CommonStructuredDataType type, std::string& typeName, std::vector<std::string>& arraySpecifiers) const;
|
void DumpType(const CommonStructuredDataDef& def, CommonStructuredDataType type, std::string& typeName, std::vector<std::string>& arraySpecifiers) const;
|
||||||
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, unsigned& currentOffsetInBit) const;
|
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, size_t& currentOffsetInBit) const;
|
||||||
void DumpStruct(const CommonStructuredDataDef& def, const CommonStructuredDataStruct& _struct, size_t structIndex);
|
void DumpStruct(const CommonStructuredDataDef& def, const CommonStructuredDataStruct& _struct, size_t structIndex);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -393,7 +393,8 @@ namespace
|
|||||||
const auto& vertList = surface.vertList[vertListIndex];
|
const auto& vertList = surface.vertList[vertListIndex];
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
|
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = vertList.boneOffset / sizeof(DObjSkelMat), .weight = 1.0f};
|
weightCollection.weights[weightOffset++] =
|
||||||
|
XModelBoneWeight{.boneIndex = static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f};
|
||||||
|
|
||||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||||
{
|
{
|
||||||
@ -410,7 +411,7 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
||||||
|
|
||||||
vertsBlendOffset += 1;
|
vertsBlendOffset += 1;
|
||||||
@ -422,8 +423,8 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||||
|
|
||||||
@ -439,10 +440,10 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||||
|
|
||||||
@ -459,12 +460,12 @@ namespace
|
|||||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||||
{
|
{
|
||||||
const auto boneWeightOffset = weightOffset;
|
const auto boneWeightOffset = weightOffset;
|
||||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include "AbstractDirectiveStreamProxy.h"
|
#include "AbstractDirectiveStreamProxy.h"
|
||||||
|
|
||||||
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const unsigned position)
|
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const size_t position)
|
||||||
{
|
{
|
||||||
return TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(position + 1));
|
return TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(position + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, unsigned& position)
|
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, size_t& position)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, unsign
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, unsigned& position, int& value)
|
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, size_t& position, int& value)
|
||||||
{
|
{
|
||||||
if (position >= line.m_line.size())
|
if (position >= line.m_line.size())
|
||||||
return false;
|
return false;
|
||||||
@ -40,7 +40,7 @@ bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, unsign
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, unsigned& position)
|
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, size_t& position)
|
||||||
{
|
{
|
||||||
auto firstChar = true;
|
auto firstChar = true;
|
||||||
while (true)
|
while (true)
|
||||||
@ -60,7 +60,7 @@ bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, uns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, unsigned& position, char c)
|
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, size_t& position, char c)
|
||||||
{
|
{
|
||||||
if (position < line.m_line.size() && line.m_line[position] == c)
|
if (position < line.m_line.size() && line.m_line[position] == c)
|
||||||
{
|
{
|
||||||
@ -71,12 +71,12 @@ bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, unsign
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, unsigned& position, char c)
|
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, size_t& position, char c)
|
||||||
{
|
{
|
||||||
return SkipWhitespace(line, position) && MatchCharacter(line, position, c);
|
return SkipWhitespace(line, position) && MatchCharacter(line, position, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||||
{
|
{
|
||||||
if (line.m_line.compare(position, len, str) == 0)
|
if (line.m_line.compare(position, len, str) == 0)
|
||||||
{
|
{
|
||||||
@ -87,12 +87,12 @@ bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, unsigned&
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||||
{
|
{
|
||||||
return SkipWhitespace(line, position) && MatchString(line, position, str, len);
|
return SkipWhitespace(line, position) && MatchString(line, position, str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos)
|
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos)
|
||||||
{
|
{
|
||||||
directiveStartPosition = 0;
|
directiveStartPosition = 0;
|
||||||
for (; directiveStartPosition < line.m_line.size(); directiveStartPosition++)
|
for (; directiveStartPosition < line.m_line.size(); directiveStartPosition++)
|
||||||
|
@ -3,20 +3,22 @@
|
|||||||
#include "Parsing/IParserLineStream.h"
|
#include "Parsing/IParserLineStream.h"
|
||||||
#include "Parsing/TokenPos.h"
|
#include "Parsing/TokenPos.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
class AbstractDirectiveStreamProxy : public IParserLineStream
|
class AbstractDirectiveStreamProxy : public IParserLineStream
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
AbstractDirectiveStreamProxy() = default;
|
AbstractDirectiveStreamProxy() = default;
|
||||||
|
|
||||||
static TokenPos CreatePos(const ParserLine& line, unsigned position);
|
static TokenPos CreatePos(const ParserLine& line, size_t position);
|
||||||
|
|
||||||
static bool SkipWhitespace(const ParserLine& line, unsigned& position);
|
static bool SkipWhitespace(const ParserLine& line, size_t& position);
|
||||||
static bool ExtractInteger(const ParserLine& line, unsigned& position, int& value);
|
static bool ExtractInteger(const ParserLine& line, size_t& position, int& value);
|
||||||
static bool ExtractIdentifier(const ParserLine& line, unsigned& position);
|
static bool ExtractIdentifier(const ParserLine& line, size_t& position);
|
||||||
static bool MatchCharacter(const ParserLine& line, unsigned& position, char c);
|
static bool MatchCharacter(const ParserLine& line, size_t& position, char c);
|
||||||
static bool MatchNextCharacter(const ParserLine& line, unsigned& position, char c);
|
static bool MatchNextCharacter(const ParserLine& line, size_t& position, char c);
|
||||||
static bool MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
static bool MatchString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||||
static bool MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
static bool MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||||
|
|
||||||
static bool FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos);
|
static bool FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos);
|
||||||
};
|
};
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool IsStringizeParameterForwardLookup(const std::string& value, unsigned pos)
|
bool IsStringizeParameterForwardLookup(const std::string& value, size_t pos)
|
||||||
{
|
{
|
||||||
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, unsigned pos)
|
bool IsTokenPastingOperatorForwardLookup(const std::string& value, size_t pos)
|
||||||
{
|
{
|
||||||
return pos + 1 < value.size() && value[pos + 1] == '#';
|
return pos + 1 < value.size() && value[pos + 1] == '#';
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const unsigned position, const bool stringize)
|
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const size_t position, const bool stringize)
|
||||||
: m_parameter_index(index),
|
: m_parameter_index(index),
|
||||||
m_parameter_position(position),
|
m_parameter_position(position),
|
||||||
m_stringize(stringize)
|
m_stringize(stringize)
|
||||||
@ -175,7 +175,7 @@ int DefinesStreamProxy::GetLineEndEscapePos(const ParserLine& line)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const unsigned currentPos)
|
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const size_t currentPos)
|
||||||
{
|
{
|
||||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||||
if (lineEndEscapePos < 0)
|
if (lineEndEscapePos < 0)
|
||||||
@ -204,7 +204,7 @@ void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const unsigned c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, unsigned& currentPos)
|
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, size_t& currentPos)
|
||||||
{
|
{
|
||||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||||
while (true)
|
while (true)
|
||||||
@ -241,7 +241,7 @@ void DefinesStreamProxy::ContinueParameters(const ParserLine& line, unsigned& cu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, unsigned& currentPos)
|
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, size_t& currentPos)
|
||||||
{
|
{
|
||||||
m_current_define_parameters = std::vector<std::string>();
|
m_current_define_parameters = std::vector<std::string>();
|
||||||
if (line.m_line[currentPos] != '(')
|
if (line.m_line[currentPos] != '(')
|
||||||
@ -253,7 +253,7 @@ void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, unsigned&
|
|||||||
ContinueParameters(line, currentPos);
|
ContinueParameters(line, currentPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ std::unique_ptr<ISimpleExpression> DefinesStreamProxy::ParseExpression(std::shar
|
|||||||
return expressionInterpreter.Evaluate();
|
return expressionInterpreter.Evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsign
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const unsig
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const unsign
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPosition;
|
auto currentPos = directiveStartPosition;
|
||||||
|
|
||||||
@ -486,8 +486,8 @@ bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const unsig
|
|||||||
|
|
||||||
bool DefinesStreamProxy::MatchDirectives(ParserLine& line)
|
bool DefinesStreamProxy::MatchDirectives(ParserLine& line)
|
||||||
{
|
{
|
||||||
unsigned directiveStartPos;
|
size_t directiveStartPos;
|
||||||
unsigned directiveEndPos;
|
size_t directiveEndPos;
|
||||||
|
|
||||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||||
return false;
|
return false;
|
||||||
@ -537,9 +537,9 @@ void DefinesStreamProxy::ExtractParametersFromMacroUsage(
|
|||||||
ContinueMacroParameters(line, linePos, state, input, inputPos);
|
ContinueMacroParameters(line, linePos, state, input, inputPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName)
|
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName)
|
||||||
{
|
{
|
||||||
unsigned currentPos = pos;
|
auto currentPos = pos;
|
||||||
|
|
||||||
if (!MatchNextCharacter(line, currentPos, '('))
|
if (!MatchNextCharacter(line, currentPos, '('))
|
||||||
return false;
|
return false;
|
||||||
@ -559,7 +559,7 @@ bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, unsigned
|
|||||||
|
|
||||||
void DefinesStreamProxy::ExpandDefinedExpressions(ParserLine& line) const
|
void DefinesStreamProxy::ExpandDefinedExpressions(ParserLine& line) const
|
||||||
{
|
{
|
||||||
auto currentPos = 0u;
|
auto currentPos = 0uz;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -1094,7 +1094,7 @@ ParserLine DefinesStreamProxy::NextLine()
|
|||||||
{
|
{
|
||||||
if (m_in_define)
|
if (m_in_define)
|
||||||
{
|
{
|
||||||
unsigned currentPos = 0u;
|
auto currentPos = 0uz;
|
||||||
|
|
||||||
if (m_parameter_state != ParameterState::NOT_IN_PARAMETERS)
|
if (m_parameter_state != ParameterState::NOT_IN_PARAMETERS)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "Parsing/IParserLineStream.h"
|
#include "Parsing/IParserLineStream.h"
|
||||||
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -29,11 +30,11 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unsigned m_parameter_index;
|
unsigned m_parameter_index;
|
||||||
unsigned m_parameter_position;
|
size_t m_parameter_position;
|
||||||
bool m_stringize;
|
bool m_stringize;
|
||||||
|
|
||||||
DefineParameterPosition();
|
DefineParameterPosition();
|
||||||
DefineParameterPosition(unsigned index, unsigned position, bool stringize);
|
DefineParameterPosition(unsigned index, size_t position, bool stringize);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Define
|
class Define
|
||||||
@ -96,22 +97,22 @@ private:
|
|||||||
MacroParameterState m_multi_line_macro_parameters;
|
MacroParameterState m_multi_line_macro_parameters;
|
||||||
|
|
||||||
static int GetLineEndEscapePos(const ParserLine& line);
|
static int GetLineEndEscapePos(const ParserLine& line);
|
||||||
void MatchDefineParameters(const ParserLine& line, unsigned& currentPos);
|
void MatchDefineParameters(const ParserLine& line, size_t& currentPos);
|
||||||
void ContinueDefine(const ParserLine& line, unsigned currentPos);
|
void ContinueDefine(const ParserLine& line, size_t currentPos);
|
||||||
void ContinueParameters(const ParserLine& line, unsigned& currentPos);
|
void ContinueParameters(const ParserLine& line, size_t& currentPos);
|
||||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchDirectives(ParserLine& line);
|
_NODISCARD bool MatchDirectives(ParserLine& line);
|
||||||
|
|
||||||
void ExtractParametersFromMacroUsage(const ParserLine& line, unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
void ExtractParametersFromMacroUsage(const ParserLine& line, unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
||||||
bool FindMacroForIdentifier(const std::string& input, unsigned wordStart, unsigned wordEnd, const Define*& value) const;
|
bool FindMacroForIdentifier(const std::string& input, unsigned wordStart, unsigned wordEnd, const Define*& value) const;
|
||||||
|
|
||||||
static bool MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName);
|
static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName);
|
||||||
void ExpandDefinedExpressions(ParserLine& line) const;
|
void ExpandDefinedExpressions(ParserLine& line) const;
|
||||||
|
|
||||||
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define);
|
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define);
|
||||||
|
@ -13,9 +13,9 @@ IncludingStreamProxy::IncludingStreamProxy(IParserLineStream* stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
||||||
const unsigned includeDirectivePosition,
|
const size_t includeDirectivePosition,
|
||||||
unsigned& filenameStartPosition,
|
size_t& filenameStartPosition,
|
||||||
unsigned& filenameEndPosition)
|
size_t& filenameEndPosition)
|
||||||
{
|
{
|
||||||
auto currentPos = includeDirectivePosition;
|
auto currentPos = includeDirectivePosition;
|
||||||
bool isDoubleQuotes;
|
bool isDoubleQuotes;
|
||||||
@ -60,7 +60,7 @@ bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos) const
|
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos) const
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPos;
|
auto currentPos = directiveStartPos;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const u
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned filenameStart, filenameEnd;
|
size_t filenameStart, filenameEnd;
|
||||||
|
|
||||||
if (!ExtractIncludeFilename(line, currentPos, filenameStart, filenameEnd))
|
if (!ExtractIncludeFilename(line, currentPos, filenameStart, filenameEnd))
|
||||||
throw ParsingException(TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(currentPos)), INCLUDE_QUOTES_ERROR);
|
throw ParsingException(TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(currentPos)), INCLUDE_QUOTES_ERROR);
|
||||||
@ -86,7 +86,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const u
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos)
|
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos)
|
||||||
{
|
{
|
||||||
auto currentPos = directiveStartPos;
|
auto currentPos = directiveStartPos;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, cons
|
|||||||
|
|
||||||
bool IncludingStreamProxy::MatchDirectives(const ParserLine& line)
|
bool IncludingStreamProxy::MatchDirectives(const ParserLine& line)
|
||||||
{
|
{
|
||||||
unsigned directiveStartPos, directiveEndPos;
|
size_t directiveStartPos, directiveEndPos;
|
||||||
|
|
||||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,9 +16,9 @@ class IncludingStreamProxy final : public AbstractDirectiveStreamProxy
|
|||||||
std::set<std::string> m_included_files;
|
std::set<std::string> m_included_files;
|
||||||
|
|
||||||
_NODISCARD static bool
|
_NODISCARD static bool
|
||||||
ExtractIncludeFilename(const ParserLine& line, unsigned includeDirectivePosition, unsigned& filenameStartPosition, unsigned& filenameEndPosition);
|
ExtractIncludeFilename(const ParserLine& line, size_t includeDirectivePosition, size_t& filenameStartPosition, size_t& filenameEndPosition);
|
||||||
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos) const;
|
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos) const;
|
||||||
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos);
|
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos);
|
||||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -7,7 +7,7 @@ PackDefinitionStreamProxy::PackDefinitionStreamProxy(IParserLineStream* stream)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||||
{
|
{
|
||||||
auto packValue = 0;
|
auto packValue = 0;
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
@ -60,7 +60,7 @@ bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const
|
|||||||
|
|
||||||
bool PackDefinitionStreamProxy::MatchDirectives(const ParserLine& line)
|
bool PackDefinitionStreamProxy::MatchDirectives(const ParserLine& line)
|
||||||
{
|
{
|
||||||
unsigned directiveStartPos, directiveEndPos;
|
size_t directiveStartPos, directiveEndPos;
|
||||||
|
|
||||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,7 @@ private:
|
|||||||
IParserLineStream* const m_stream;
|
IParserLineStream* const m_stream;
|
||||||
std::stack<int> m_current_pack;
|
std::stack<int> m_current_pack;
|
||||||
|
|
||||||
_NODISCARD bool MatchPackDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
_NODISCARD bool MatchPackDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -15,7 +15,7 @@ void SetDefineStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
|||||||
m_defines_proxy = definesProxy;
|
m_defines_proxy = definesProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||||
{
|
{
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsig
|
|||||||
|
|
||||||
bool SetDefineStreamProxy::MatchDirectives(const ParserLine& line) const
|
bool SetDefineStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||||
{
|
{
|
||||||
unsigned directiveStartPos, directiveEndPos;
|
size_t directiveStartPos, directiveEndPos;
|
||||||
|
|
||||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,7 +22,7 @@ namespace templating
|
|||||||
private:
|
private:
|
||||||
static constexpr const char* SET_DIRECTIVE = "set";
|
static constexpr const char* SET_DIRECTIVE = "set";
|
||||||
|
|
||||||
_NODISCARD bool MatchSetDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
_NODISCARD bool MatchSetDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||||
|
|
||||||
IParserLineStream* const m_stream;
|
IParserLineStream* const m_stream;
|
||||||
|
@ -18,7 +18,7 @@ void TemplatingStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
|||||||
m_defines_proxy = definesProxy;
|
m_defines_proxy = definesProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||||
{
|
{
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const u
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||||
{
|
{
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||||
{
|
{
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||||
{
|
{
|
||||||
auto currentPosition = directiveStartPosition;
|
auto currentPosition = directiveStartPosition;
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const uns
|
|||||||
|
|
||||||
bool TemplatingStreamProxy::MatchDirectives(const ParserLine& line) const
|
bool TemplatingStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||||
{
|
{
|
||||||
unsigned directiveStartPos, directiveEndPos;
|
size_t directiveStartPos, directiveEndPos;
|
||||||
|
|
||||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||||
return false;
|
return false;
|
||||||
|
@ -43,10 +43,10 @@ namespace templating
|
|||||||
static constexpr const char* FILENAME_DIRECTIVE = "filename";
|
static constexpr const char* FILENAME_DIRECTIVE = "filename";
|
||||||
static constexpr const char* SKIP_DIRECTIVE = "skip";
|
static constexpr const char* SKIP_DIRECTIVE = "skip";
|
||||||
|
|
||||||
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||||
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||||
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||||
_NODISCARD bool MatchSkipDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
_NODISCARD bool MatchSkipDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||||
|
|
||||||
IParserLineStream* const m_stream;
|
IParserLineStream* const m_stream;
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
int main(const int argc, const char** argv)
|
int main(const int argc, const char** argv)
|
||||||
{
|
{
|
||||||
const ZoneCodeGenerator zoneCodeGenerator;
|
auto zoneCodeGenerator = ZoneCodeGenerator::Create();
|
||||||
return zoneCodeGenerator.Run(argc, argv);
|
return zoneCodeGenerator->Run(argc, argv);
|
||||||
}
|
}
|
||||||
|
@ -2,32 +2,35 @@
|
|||||||
|
|
||||||
#include "Domain/Information/MemberInformation.h"
|
#include "Domain/Information/MemberInformation.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class MemberComputations
|
class MemberComputations
|
||||||
{
|
{
|
||||||
const MemberInformation* const m_info;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MemberComputations(const MemberInformation* member);
|
explicit MemberComputations(const MemberInformation* member);
|
||||||
|
|
||||||
_NODISCARD bool ShouldIgnore() const;
|
[[nodiscard]] bool ShouldIgnore() const;
|
||||||
_NODISCARD bool ContainsNonEmbeddedReference() const;
|
[[nodiscard]] bool ContainsNonEmbeddedReference() const;
|
||||||
_NODISCARD bool ContainsSinglePointerReference() const;
|
[[nodiscard]] bool ContainsSinglePointerReference() const;
|
||||||
_NODISCARD bool ContainsArrayPointerReference() const;
|
[[nodiscard]] bool ContainsArrayPointerReference() const;
|
||||||
_NODISCARD bool ContainsPointerArrayReference() const;
|
[[nodiscard]] bool ContainsPointerArrayReference() const;
|
||||||
_NODISCARD bool ContainsArrayReference() const;
|
[[nodiscard]] bool ContainsArrayReference() const;
|
||||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||||
_NODISCARD bool IsArray() const;
|
[[nodiscard]] bool IsArray() const;
|
||||||
_NODISCARD std::vector<int> GetArraySizes() const;
|
[[nodiscard]] std::vector<int> GetArraySizes() const;
|
||||||
_NODISCARD int GetArrayDimension() const;
|
[[nodiscard]] int GetArrayDimension() const;
|
||||||
_NODISCARD bool IsPointerToArray() const;
|
[[nodiscard]] bool IsPointerToArray() const;
|
||||||
_NODISCARD std::vector<int> GetPointerToArraySizes() const;
|
[[nodiscard]] std::vector<int> GetPointerToArraySizes() const;
|
||||||
_NODISCARD int GetPointerDepth() const;
|
[[nodiscard]] int GetPointerDepth() const;
|
||||||
_NODISCARD bool IsNotInDefaultNormalBlock() const;
|
[[nodiscard]] bool IsNotInDefaultNormalBlock() const;
|
||||||
_NODISCARD bool IsInTempBlock() const;
|
[[nodiscard]] bool IsInTempBlock() const;
|
||||||
_NODISCARD bool IsInRuntimeBlock() const;
|
[[nodiscard]] bool IsInRuntimeBlock() const;
|
||||||
_NODISCARD bool IsFirstMember() const;
|
[[nodiscard]] bool IsFirstMember() const;
|
||||||
_NODISCARD bool IsLastMember() const;
|
[[nodiscard]] bool IsLastMember() const;
|
||||||
_NODISCARD bool HasDynamicArraySize() const;
|
[[nodiscard]] bool HasDynamicArraySize() const;
|
||||||
_NODISCARD bool IsDynamicMember() const;
|
[[nodiscard]] bool IsDynamicMember() const;
|
||||||
_NODISCARD bool IsAfterPartialLoad() const;
|
[[nodiscard]] bool IsAfterPartialLoad() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const MemberInformation* const m_info;
|
||||||
};
|
};
|
||||||
|
@ -2,34 +2,36 @@
|
|||||||
|
|
||||||
#include "Domain/Evaluation/IEvaluation.h"
|
#include "Domain/Evaluation/IEvaluation.h"
|
||||||
#include "Domain/Information/MemberInformation.h"
|
#include "Domain/Information/MemberInformation.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class DeclarationModifierComputations
|
class DeclarationModifierComputations
|
||||||
{
|
{
|
||||||
const MemberInformation* const m_information;
|
|
||||||
std::vector<int> m_modifier_indices;
|
|
||||||
int m_combined_index;
|
|
||||||
|
|
||||||
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeclarationModifierComputations(const MemberInformation* member);
|
explicit DeclarationModifierComputations(const MemberInformation* member);
|
||||||
|
|
||||||
_NODISCARD DeclarationModifier* GetDeclarationModifier() const;
|
[[nodiscard]] DeclarationModifier* GetDeclarationModifier() const;
|
||||||
_NODISCARD DeclarationModifier* GetNextDeclarationModifier() const;
|
[[nodiscard]] DeclarationModifier* GetNextDeclarationModifier() const;
|
||||||
_NODISCARD std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
[[nodiscard]] std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
||||||
_NODISCARD std::vector<int> GetArrayIndices() const;
|
[[nodiscard]] std::vector<int> GetArrayIndices() const;
|
||||||
_NODISCARD bool IsArray() const;
|
[[nodiscard]] bool IsArray() const;
|
||||||
_NODISCARD int GetArraySize() const;
|
[[nodiscard]] int GetArraySize() const;
|
||||||
_NODISCARD bool HasDynamicArrayCount() const;
|
[[nodiscard]] bool HasDynamicArrayCount() const;
|
||||||
_NODISCARD const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
[[nodiscard]] const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
||||||
_NODISCARD std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
[[nodiscard]] std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
||||||
_NODISCARD bool IsSinglePointer() const;
|
[[nodiscard]] bool IsSinglePointer() const;
|
||||||
_NODISCARD bool IsArrayPointer() const;
|
[[nodiscard]] bool IsArrayPointer() const;
|
||||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||||
_NODISCARD bool IsPointerArray() const;
|
[[nodiscard]] bool IsPointerArray() const;
|
||||||
_NODISCARD const IEvaluation* GetPointerArrayCountEvaluation() const;
|
[[nodiscard]] const IEvaluation* GetPointerArrayCountEvaluation() const;
|
||||||
_NODISCARD bool IsDynamicArray() const;
|
[[nodiscard]] bool IsDynamicArray() const;
|
||||||
_NODISCARD const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
[[nodiscard]] const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
||||||
_NODISCARD unsigned GetAlignment() const;
|
[[nodiscard]] unsigned GetAlignment() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
||||||
|
|
||||||
|
const MemberInformation* const m_information;
|
||||||
|
std::vector<int> m_modifier_indices;
|
||||||
|
int m_combined_index;
|
||||||
};
|
};
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
class StructureComputations
|
class StructureComputations
|
||||||
{
|
{
|
||||||
const StructureInformation* const m_info;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StructureComputations(const StructureInformation* structure);
|
explicit StructureComputations(const StructureInformation* structure);
|
||||||
|
|
||||||
_NODISCARD bool IsAsset() const;
|
[[nodiscard]] bool IsAsset() const;
|
||||||
_NODISCARD MemberInformation* GetDynamicMember() const;
|
[[nodiscard]] MemberInformation* GetDynamicMember() const;
|
||||||
_NODISCARD std::vector<MemberInformation*> GetUsedMembers() const;
|
[[nodiscard]] std::vector<MemberInformation*> GetUsedMembers() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const StructureInformation* m_info;
|
||||||
};
|
};
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
#include "DeclarationModifier.h"
|
#include "DeclarationModifier.h"
|
||||||
#include "Domain/Evaluation/IEvaluation.h"
|
#include "Domain/Evaluation/IEvaluation.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class ArrayDeclarationModifier final : public DeclarationModifier
|
class ArrayDeclarationModifier final : public DeclarationModifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit ArrayDeclarationModifier(int size);
|
||||||
|
|
||||||
|
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||||
|
|
||||||
int m_size;
|
int m_size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,8 +23,4 @@ public:
|
|||||||
* \brief The array has a size that is given by \c m_size but only a certain dynamic amount is handled by generated count.
|
* \brief The array has a size that is given by \c m_size but only a certain dynamic amount is handled by generated count.
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<IEvaluation> m_dynamic_count_evaluation;
|
std::unique_ptr<IEvaluation> m_dynamic_count_evaluation;
|
||||||
|
|
||||||
explicit ArrayDeclarationModifier(int size);
|
|
||||||
|
|
||||||
_NODISCARD DeclarationModifierType GetType() const override;
|
|
||||||
};
|
};
|
||||||
|
@ -4,17 +4,6 @@
|
|||||||
class BaseTypeDefinition final : public DataDefinition
|
class BaseTypeDefinition final : public DataDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const unsigned m_size;
|
|
||||||
|
|
||||||
private:
|
|
||||||
BaseTypeDefinition(std::string name, unsigned size);
|
|
||||||
|
|
||||||
public:
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
|
||||||
_NODISCARD unsigned GetAlignment() const override;
|
|
||||||
_NODISCARD bool GetForceAlignment() const override;
|
|
||||||
_NODISCARD unsigned GetSize() const override;
|
|
||||||
|
|
||||||
static const BaseTypeDefinition* const FLOAT;
|
static const BaseTypeDefinition* const FLOAT;
|
||||||
static const BaseTypeDefinition* const DOUBLE;
|
static const BaseTypeDefinition* const DOUBLE;
|
||||||
static const BaseTypeDefinition* const BOOL;
|
static const BaseTypeDefinition* const BOOL;
|
||||||
@ -32,4 +21,14 @@ public:
|
|||||||
|
|
||||||
static const BaseTypeDefinition* const ALL_BASE_TYPES[];
|
static const BaseTypeDefinition* const ALL_BASE_TYPES[];
|
||||||
static const size_t ALL_BASE_TYPES_COUNT;
|
static const size_t ALL_BASE_TYPES_COUNT;
|
||||||
|
|
||||||
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
|
[[nodiscard]] unsigned GetAlignment() const override;
|
||||||
|
[[nodiscard]] bool GetForceAlignment() const override;
|
||||||
|
[[nodiscard]] unsigned GetSize() const override;
|
||||||
|
|
||||||
|
const unsigned m_size;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BaseTypeDefinition(std::string name, unsigned size);
|
||||||
};
|
};
|
||||||
|
@ -25,13 +25,13 @@ public:
|
|||||||
DataDefinition& operator=(const DataDefinition& other) = default;
|
DataDefinition& operator=(const DataDefinition& other) = default;
|
||||||
DataDefinition& operator=(DataDefinition&& other) noexcept = default;
|
DataDefinition& operator=(DataDefinition&& other) noexcept = default;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual DataDefinitionType GetType() const = 0;
|
||||||
|
[[nodiscard]] virtual unsigned GetAlignment() const = 0;
|
||||||
|
[[nodiscard]] virtual bool GetForceAlignment() const = 0;
|
||||||
|
[[nodiscard]] virtual unsigned GetSize() const = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] std::string GetFullName() const;
|
||||||
|
|
||||||
std::string m_namespace;
|
std::string m_namespace;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
_NODISCARD virtual DataDefinitionType GetType() const = 0;
|
|
||||||
_NODISCARD virtual unsigned GetAlignment() const = 0;
|
|
||||||
_NODISCARD virtual bool GetForceAlignment() const = 0;
|
|
||||||
_NODISCARD virtual unsigned GetSize() const = 0;
|
|
||||||
|
|
||||||
_NODISCARD std::string GetFullName() const;
|
|
||||||
};
|
};
|
||||||
|
@ -18,5 +18,5 @@ public:
|
|||||||
DeclarationModifier& operator=(const DeclarationModifier& other) = default;
|
DeclarationModifier& operator=(const DeclarationModifier& other) = default;
|
||||||
DeclarationModifier& operator=(DeclarationModifier&& other) noexcept = default;
|
DeclarationModifier& operator=(DeclarationModifier&& other) noexcept = default;
|
||||||
|
|
||||||
_NODISCARD virtual DeclarationModifierType GetType() const = 0;
|
[[nodiscard]] virtual DeclarationModifierType GetType() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -14,26 +14,6 @@ DefinitionWithMembers::DefinitionWithMembers(std::string _namespace, std::string
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DefinitionWithMembers::CalculateAlignment()
|
|
||||||
//{
|
|
||||||
// if (m_has_alignment_override)
|
|
||||||
// {
|
|
||||||
// m_flags |= FLAG_ALIGNMENT_FORCED;
|
|
||||||
// m_alignment = m_alignment_override;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// m_alignment = 0;
|
|
||||||
// for (const auto& member : m_members)
|
|
||||||
// {
|
|
||||||
// const auto memberAlignment = member->GetAlignment();
|
|
||||||
// if (memberAlignment > m_alignment)
|
|
||||||
// m_alignment = memberAlignment;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// m_flags |= FLAG_ALIGNMENT_CALCULATED;
|
|
||||||
// }
|
|
||||||
|
|
||||||
unsigned DefinitionWithMembers::GetAlignment() const
|
unsigned DefinitionWithMembers::GetAlignment() const
|
||||||
{
|
{
|
||||||
assert(m_flags & FLAG_FIELDS_CALCULATED);
|
assert(m_flags & FLAG_FIELDS_CALCULATED);
|
||||||
|
@ -13,6 +13,12 @@ public:
|
|||||||
static constexpr int FLAG_FIELDS_CALCULATING = 1 << 1;
|
static constexpr int FLAG_FIELDS_CALCULATING = 1 << 1;
|
||||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 2;
|
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 2;
|
||||||
|
|
||||||
|
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
||||||
|
|
||||||
|
[[nodiscard]] unsigned GetAlignment() const override;
|
||||||
|
[[nodiscard]] bool GetForceAlignment() const override;
|
||||||
|
[[nodiscard]] unsigned GetSize() const override;
|
||||||
|
|
||||||
unsigned m_flags;
|
unsigned m_flags;
|
||||||
unsigned m_size;
|
unsigned m_size;
|
||||||
unsigned m_alignment;
|
unsigned m_alignment;
|
||||||
@ -24,10 +30,4 @@ public:
|
|||||||
unsigned m_alignment_override;
|
unsigned m_alignment_override;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Variable>> m_members;
|
std::vector<std::shared_ptr<Variable>> m_members;
|
||||||
|
|
||||||
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
|
||||||
|
|
||||||
_NODISCARD unsigned GetAlignment() const override;
|
|
||||||
_NODISCARD bool GetForceAlignment() const override;
|
|
||||||
_NODISCARD unsigned GetSize() const override;
|
|
||||||
};
|
};
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
class EnumDefinition final : public DataDefinition
|
class EnumDefinition final : public DataDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const BaseTypeDefinition* m_parent_type;
|
|
||||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
|
||||||
|
|
||||||
EnumDefinition(std::string _namespace, std::string name, const BaseTypeDefinition* parentType);
|
EnumDefinition(std::string _namespace, std::string name, const BaseTypeDefinition* parentType);
|
||||||
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
_NODISCARD unsigned GetAlignment() const override;
|
[[nodiscard]] unsigned GetAlignment() const override;
|
||||||
_NODISCARD bool GetForceAlignment() const override;
|
[[nodiscard]] bool GetForceAlignment() const override;
|
||||||
_NODISCARD unsigned GetSize() const override;
|
[[nodiscard]] unsigned GetSize() const override;
|
||||||
|
|
||||||
void AddEnumMember(EnumMember enumMember);
|
void AddEnumMember(EnumMember enumMember);
|
||||||
|
|
||||||
|
const BaseTypeDefinition* m_parent_type;
|
||||||
|
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||||
};
|
};
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
class EnumMember
|
class EnumMember
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string m_name;
|
|
||||||
int m_value;
|
|
||||||
|
|
||||||
EnumMember();
|
EnumMember();
|
||||||
EnumMember(std::string name, int value);
|
EnumMember(std::string name, int value);
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
int m_value;
|
||||||
};
|
};
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
class ForwardDeclaration final : public DataDefinition
|
class ForwardDeclaration final : public DataDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const DataDefinitionType m_forwarded_type;
|
|
||||||
const DataDefinition* m_definition;
|
|
||||||
|
|
||||||
ForwardDeclaration(std::string _namespace, std::string name, DataDefinitionType type);
|
ForwardDeclaration(std::string _namespace, std::string name, DataDefinitionType type);
|
||||||
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
_NODISCARD unsigned GetAlignment() const override;
|
[[nodiscard]] unsigned GetAlignment() const override;
|
||||||
_NODISCARD bool GetForceAlignment() const override;
|
[[nodiscard]] bool GetForceAlignment() const override;
|
||||||
_NODISCARD unsigned GetSize() const override;
|
[[nodiscard]] unsigned GetSize() const override;
|
||||||
|
|
||||||
|
const DataDefinitionType m_forwarded_type;
|
||||||
|
const DataDefinition* m_definition;
|
||||||
};
|
};
|
||||||
|
@ -8,19 +8,19 @@
|
|||||||
|
|
||||||
class PointerDeclarationModifier final : public DeclarationModifier
|
class PointerDeclarationModifier final : public DeclarationModifier
|
||||||
{
|
{
|
||||||
static const IEvaluation* const DEFAULT_COUNT;
|
|
||||||
|
|
||||||
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||||
|
[[nodiscard]] const IEvaluation* GetCountEvaluation() const;
|
||||||
|
[[nodiscard]] const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
||||||
|
|
||||||
|
[[nodiscard]] bool CountEvaluationIsArray() const;
|
||||||
|
[[nodiscard]] bool CountEvaluationIsArray(int index) const;
|
||||||
|
[[nodiscard]] bool AnyCountEvaluationIsArray() const;
|
||||||
|
|
||||||
std::unique_ptr<IEvaluation> m_count_evaluation;
|
std::unique_ptr<IEvaluation> m_count_evaluation;
|
||||||
std::vector<std::unique_ptr<IEvaluation>> m_count_evaluation_by_array_index;
|
std::vector<std::unique_ptr<IEvaluation>> m_count_evaluation_by_array_index;
|
||||||
|
|
||||||
_NODISCARD DeclarationModifierType GetType() const override;
|
private:
|
||||||
_NODISCARD const IEvaluation* GetCountEvaluation() const;
|
static const IEvaluation* const DEFAULT_COUNT;
|
||||||
_NODISCARD const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
||||||
|
|
||||||
_NODISCARD bool CountEvaluationIsArray() const;
|
|
||||||
_NODISCARD bool CountEvaluationIsArray(int index) const;
|
|
||||||
_NODISCARD bool AnyCountEvaluationIsArray() const;
|
|
||||||
};
|
};
|
||||||
|
@ -7,5 +7,5 @@ class StructDefinition final : public DefinitionWithMembers
|
|||||||
public:
|
public:
|
||||||
StructDefinition(std::string _namespace, std::string name, int pack);
|
StructDefinition(std::string _namespace, std::string name, int pack);
|
||||||
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
};
|
};
|
||||||
|
@ -13,21 +13,21 @@ public:
|
|||||||
static constexpr int FLAG_FIELDS_CALCULATED = 1 << 0;
|
static constexpr int FLAG_FIELDS_CALCULATED = 1 << 0;
|
||||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 1;
|
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 1;
|
||||||
|
|
||||||
unsigned m_flags;
|
|
||||||
unsigned m_size;
|
|
||||||
unsigned m_alignment;
|
|
||||||
|
|
||||||
explicit TypeDeclaration(const DataDefinition* type);
|
explicit TypeDeclaration(const DataDefinition* type);
|
||||||
|
|
||||||
|
[[nodiscard]] unsigned GetSize() const;
|
||||||
|
[[nodiscard]] unsigned GetAlignment() const;
|
||||||
|
[[nodiscard]] bool GetForceAlignment() const;
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
||||||
|
|
||||||
bool m_is_const;
|
bool m_is_const;
|
||||||
bool m_has_custom_bit_size;
|
bool m_has_custom_bit_size;
|
||||||
|
|
||||||
const DataDefinition* m_type;
|
const DataDefinition* m_type;
|
||||||
unsigned m_custom_bit_size;
|
unsigned m_custom_bit_size;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
unsigned m_flags;
|
||||||
|
unsigned m_size;
|
||||||
_NODISCARD unsigned GetSize() const;
|
unsigned m_alignment;
|
||||||
_NODISCARD unsigned GetAlignment() const;
|
|
||||||
_NODISCARD bool GetForceAlignment() const;
|
|
||||||
};
|
};
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
class TypedefDefinition final : public DataDefinition
|
class TypedefDefinition final : public DataDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||||
|
|
||||||
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
|
[[nodiscard]] unsigned GetAlignment() const override;
|
||||||
|
[[nodiscard]] bool GetForceAlignment() const override;
|
||||||
|
[[nodiscard]] unsigned GetSize() const override;
|
||||||
|
|
||||||
bool m_has_alignment_override;
|
bool m_has_alignment_override;
|
||||||
unsigned m_alignment_override;
|
unsigned m_alignment_override;
|
||||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||||
|
|
||||||
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
|
||||||
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
|
||||||
_NODISCARD unsigned GetAlignment() const override;
|
|
||||||
_NODISCARD bool GetForceAlignment() const override;
|
|
||||||
_NODISCARD unsigned GetSize() const override;
|
|
||||||
};
|
};
|
||||||
|
@ -4,11 +4,8 @@
|
|||||||
|
|
||||||
class UnionDefinition final : public DefinitionWithMembers
|
class UnionDefinition final : public DefinitionWithMembers
|
||||||
{
|
{
|
||||||
// protected:
|
|
||||||
// void CalculateSize() override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnionDefinition(std::string _namespace, std::string name, int pack);
|
UnionDefinition(std::string _namespace, std::string name, int pack);
|
||||||
|
|
||||||
_NODISCARD DataDefinitionType GetType() const override;
|
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||||
};
|
};
|
||||||
|
@ -9,14 +9,14 @@
|
|||||||
class Variable
|
class Variable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||||
|
|
||||||
|
[[nodiscard]] unsigned GetAlignment() const;
|
||||||
|
[[nodiscard]] bool GetForceAlignment() const;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_has_alignment_override;
|
bool m_has_alignment_override;
|
||||||
unsigned m_alignment_override;
|
unsigned m_alignment_override;
|
||||||
unsigned m_offset;
|
unsigned m_offset;
|
||||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||||
|
|
||||||
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
|
||||||
|
|
||||||
_NODISCARD unsigned GetAlignment() const;
|
|
||||||
_NODISCARD bool GetForceAlignment() const;
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
|
||||||
enum class EvaluationType
|
enum class EvaluationType
|
||||||
{
|
{
|
||||||
OPERAND_DYNAMIC,
|
OPERAND_DYNAMIC,
|
||||||
@ -20,7 +18,7 @@ public:
|
|||||||
IEvaluation& operator=(const IEvaluation& other) = default;
|
IEvaluation& operator=(const IEvaluation& other) = default;
|
||||||
IEvaluation& operator=(IEvaluation&& other) noexcept = default;
|
IEvaluation& operator=(IEvaluation&& other) noexcept = default;
|
||||||
|
|
||||||
_NODISCARD virtual EvaluationType GetType() const = 0;
|
[[nodiscard]] virtual EvaluationType GetType() const = 0;
|
||||||
_NODISCARD virtual bool IsStatic() const = 0;
|
[[nodiscard]] virtual bool IsStatic() const = 0;
|
||||||
_NODISCARD virtual int EvaluateNumeric() const = 0;
|
[[nodiscard]] virtual int EvaluateNumeric() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -9,16 +9,16 @@
|
|||||||
class OperandDynamic final : public IEvaluation
|
class OperandDynamic final : public IEvaluation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StructureInformation* const m_structure;
|
|
||||||
std::vector<MemberInformation*> m_referenced_member_chain;
|
|
||||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
|
||||||
|
|
||||||
explicit OperandDynamic(StructureInformation* structure);
|
explicit OperandDynamic(StructureInformation* structure);
|
||||||
OperandDynamic(StructureInformation* structure,
|
OperandDynamic(StructureInformation* structure,
|
||||||
std::vector<MemberInformation*> referencedMemberChain,
|
std::vector<MemberInformation*> referencedMemberChain,
|
||||||
std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
||||||
|
|
||||||
_NODISCARD EvaluationType GetType() const override;
|
[[nodiscard]] EvaluationType GetType() const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
[[nodiscard]] bool IsStatic() const override;
|
||||||
_NODISCARD int EvaluateNumeric() const override;
|
[[nodiscard]] int EvaluateNumeric() const override;
|
||||||
|
|
||||||
|
StructureInformation* const m_structure;
|
||||||
|
std::vector<MemberInformation*> m_referenced_member_chain;
|
||||||
|
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||||
};
|
};
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
class OperandStatic final : public IEvaluation
|
class OperandStatic final : public IEvaluation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const int m_value;
|
|
||||||
EnumMember* const m_enum_member;
|
|
||||||
|
|
||||||
explicit OperandStatic(int value);
|
explicit OperandStatic(int value);
|
||||||
explicit OperandStatic(EnumMember* enumMember);
|
explicit OperandStatic(EnumMember* enumMember);
|
||||||
|
|
||||||
_NODISCARD EvaluationType GetType() const override;
|
[[nodiscard]] EvaluationType GetType() const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
[[nodiscard]] bool IsStatic() const override;
|
||||||
_NODISCARD int EvaluateNumeric() const override;
|
[[nodiscard]] int EvaluateNumeric() const override;
|
||||||
|
|
||||||
|
const int m_value;
|
||||||
|
EnumMember* const m_enum_member;
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
class Operation final : public IEvaluation
|
class Operation final : public IEvaluation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const OperationType* const m_operation_type;
|
|
||||||
std::unique_ptr<IEvaluation> m_operand1;
|
|
||||||
std::unique_ptr<IEvaluation> m_operand2;
|
|
||||||
|
|
||||||
explicit Operation(const OperationType* type);
|
explicit Operation(const OperationType* type);
|
||||||
Operation(const OperationType* type, std::unique_ptr<IEvaluation> operand1, std::unique_ptr<IEvaluation> operand2);
|
Operation(const OperationType* type, std::unique_ptr<IEvaluation> operand1, std::unique_ptr<IEvaluation> operand2);
|
||||||
|
|
||||||
_NODISCARD EvaluationType GetType() const override;
|
[[nodiscard]] EvaluationType GetType() const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
[[nodiscard]] bool IsStatic() const override;
|
||||||
_NODISCARD int EvaluateNumeric() const override;
|
[[nodiscard]] int EvaluateNumeric() const override;
|
||||||
|
|
||||||
_NODISCARD bool Operand1NeedsParenthesis() const;
|
[[nodiscard]] bool Operand1NeedsParenthesis() const;
|
||||||
_NODISCARD bool Operand2NeedsParenthesis() const;
|
[[nodiscard]] bool Operand2NeedsParenthesis() const;
|
||||||
|
|
||||||
|
const OperationType* const m_operation_type;
|
||||||
|
std::unique_ptr<IEvaluation> m_operand1;
|
||||||
|
std::unique_ptr<IEvaluation> m_operand2;
|
||||||
};
|
};
|
||||||
|
@ -20,14 +20,6 @@ enum class OperationPrecedence
|
|||||||
|
|
||||||
class OperationType
|
class OperationType
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
std::string m_syntax;
|
|
||||||
OperationPrecedence m_precedence;
|
|
||||||
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
|
||||||
|
|
||||||
private:
|
|
||||||
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const OperationType* const OPERATION_ADD;
|
static const OperationType* const OPERATION_ADD;
|
||||||
static const OperationType* const OPERATION_SUBTRACT;
|
static const OperationType* const OPERATION_SUBTRACT;
|
||||||
@ -49,4 +41,11 @@ public:
|
|||||||
static const OperationType* const OPERATION_OR;
|
static const OperationType* const OPERATION_OR;
|
||||||
|
|
||||||
static const OperationType* const ALL_OPERATION_TYPES[];
|
static const OperationType* const ALL_OPERATION_TYPES[];
|
||||||
|
|
||||||
|
std::string m_syntax;
|
||||||
|
OperationPrecedence m_precedence;
|
||||||
|
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
||||||
|
|
||||||
|
private:
|
||||||
|
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
||||||
};
|
};
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
class CustomAction
|
class CustomAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
||||||
|
|
||||||
std::string m_action_name;
|
std::string m_action_name;
|
||||||
std::vector<DataDefinition*> m_parameter_types;
|
std::vector<DataDefinition*> m_parameter_types;
|
||||||
|
|
||||||
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
|
||||||
};
|
};
|
||||||
|
@ -13,10 +13,10 @@ enum class FastFileBlockType
|
|||||||
class FastFileBlock
|
class FastFileBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
unsigned m_index;
|
unsigned m_index;
|
||||||
FastFileBlockType m_type;
|
FastFileBlockType m_type;
|
||||||
bool m_is_default;
|
bool m_is_default;
|
||||||
|
|
||||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,8 @@ class StructureInformation;
|
|||||||
class MemberInformation
|
class MemberInformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||||
|
|
||||||
StructureInformation* m_parent;
|
StructureInformation* m_parent;
|
||||||
StructureInformation* m_type;
|
StructureInformation* m_type;
|
||||||
Variable* m_member;
|
Variable* m_member;
|
||||||
@ -24,6 +26,4 @@ public:
|
|||||||
std::unique_ptr<CustomAction> m_post_load_action;
|
std::unique_ptr<CustomAction> m_post_load_action;
|
||||||
const FastFileBlock* m_fast_file_block;
|
const FastFileBlock* m_fast_file_block;
|
||||||
const EnumMember* m_asset_ref;
|
const EnumMember* m_asset_ref;
|
||||||
|
|
||||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
|
||||||
};
|
};
|
||||||
|
@ -5,13 +5,17 @@
|
|||||||
#include "Domain/Extension/CustomAction.h"
|
#include "Domain/Extension/CustomAction.h"
|
||||||
#include "Domain/FastFile/FastFileBlock.h"
|
#include "Domain/FastFile/FastFileBlock.h"
|
||||||
#include "MemberInformation.h"
|
#include "MemberInformation.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class MemberInformation;
|
class MemberInformation;
|
||||||
|
|
||||||
class StructureInformation
|
class StructureInformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||||
|
|
||||||
DefinitionWithMembers* const m_definition;
|
DefinitionWithMembers* const m_definition;
|
||||||
EnumMember* m_asset_enum_entry;
|
EnumMember* m_asset_enum_entry;
|
||||||
|
|
||||||
@ -31,6 +35,4 @@ public:
|
|||||||
std::unique_ptr<CustomAction> m_post_load_action;
|
std::unique_ptr<CustomAction> m_post_load_action;
|
||||||
const FastFileBlock* m_block;
|
const FastFileBlock* m_block;
|
||||||
std::vector<MemberInformation*> m_name_chain;
|
std::vector<MemberInformation*> m_name_chain;
|
||||||
|
|
||||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
|
||||||
};
|
};
|
||||||
|
@ -3,21 +3,24 @@
|
|||||||
#include "ICodeTemplate.h"
|
#include "ICodeTemplate.h"
|
||||||
#include "ZoneCodeGeneratorArguments.h"
|
#include "ZoneCodeGeneratorArguments.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class CodeGenerator
|
class CodeGenerator
|
||||||
{
|
{
|
||||||
const ZoneCodeGeneratorArguments* m_args;
|
public:
|
||||||
|
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
||||||
|
|
||||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
bool GenerateCode(IDataRepository* repository);
|
||||||
|
|
||||||
|
private:
|
||||||
void SetupTemplates();
|
void SetupTemplates();
|
||||||
|
|
||||||
bool GenerateCodeForTemplate(RenderingContext* context, ICodeTemplate* codeTemplate) const;
|
bool GenerateCodeForTemplate(RenderingContext* context, ICodeTemplate* codeTemplate) const;
|
||||||
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
||||||
|
|
||||||
public:
|
const ZoneCodeGeneratorArguments* m_args;
|
||||||
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
|
||||||
|
|
||||||
bool GenerateCode(IDataRepository* repository);
|
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
class RenderingUsedType
|
class RenderingUsedType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
||||||
|
|
||||||
bool m_members_loaded;
|
bool m_members_loaded;
|
||||||
const DataDefinition* m_type;
|
const DataDefinition* m_type;
|
||||||
StructureInformation* m_info;
|
StructureInformation* m_info;
|
||||||
@ -20,25 +22,13 @@ public:
|
|||||||
bool m_array_reference_exists;
|
bool m_array_reference_exists;
|
||||||
bool m_pointer_array_reference_exists;
|
bool m_pointer_array_reference_exists;
|
||||||
bool m_pointer_array_reference_is_reusable;
|
bool m_pointer_array_reference_is_reusable;
|
||||||
|
|
||||||
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderingContext
|
class RenderingContext
|
||||||
{
|
{
|
||||||
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
|
||||||
|
|
||||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
|
||||||
|
|
||||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
|
||||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
|
||||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
|
||||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
|
||||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
|
||||||
void CreateUsedTypeCollections();
|
|
||||||
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||||
|
|
||||||
std::string m_game;
|
std::string m_game;
|
||||||
std::vector<const FastFileBlock*> m_blocks;
|
std::vector<const FastFileBlock*> m_blocks;
|
||||||
|
|
||||||
@ -52,5 +42,16 @@ public:
|
|||||||
const FastFileBlock* m_default_normal_block;
|
const FastFileBlock* m_default_normal_block;
|
||||||
const FastFileBlock* m_default_temp_block;
|
const FastFileBlock* m_default_temp_block;
|
||||||
|
|
||||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
private:
|
||||||
|
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||||
|
|
||||||
|
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||||
|
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||||
|
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||||
|
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||||
|
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||||
|
void CreateUsedTypeCollections();
|
||||||
|
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
||||||
|
|
||||||
|
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
||||||
};
|
};
|
||||||
|
@ -6,69 +6,75 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
class AssetStructTestsTemplate::Internal final : BaseTemplate
|
namespace
|
||||||
{
|
{
|
||||||
void TestMethod(StructureInformation* structure)
|
static constexpr int TAG_SOURCE = 1;
|
||||||
{
|
|
||||||
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for " << structure->m_definition->GetFullName()
|
|
||||||
<< "\", \"[assetstruct]\")")
|
|
||||||
LINE("{")
|
|
||||||
m_intendation++;
|
|
||||||
|
|
||||||
for (const auto& member : structure->m_ordered_members)
|
class Template final : BaseTemplate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Template(std::ostream& stream, RenderingContext* context)
|
||||||
|
: BaseTemplate(stream, context)
|
||||||
{
|
{
|
||||||
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
}
|
||||||
|
|
||||||
|
void Source()
|
||||||
|
{
|
||||||
|
LINE("// ====================================================================")
|
||||||
|
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||||
|
LINE("// Do not modify.")
|
||||||
|
LINE("// Any changes will be discarded when regenerating.")
|
||||||
|
LINE("// ====================================================================")
|
||||||
|
LINE("")
|
||||||
|
LINE("#include <catch2/catch_test_macros.hpp>")
|
||||||
|
LINE("#include <catch2/generators/catch_generators.hpp>")
|
||||||
|
LINE("#include <cstddef>")
|
||||||
|
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||||
|
LINE("")
|
||||||
|
LINE("using namespace " << m_env.m_game << ";")
|
||||||
|
LINE("")
|
||||||
|
LINE("namespace game::" << m_env.m_game << "::xassets::asset_" << Lower(m_env.m_asset->m_definition->m_name))
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
TestMethod(m_env.m_asset);
|
||||||
|
for (auto* structure : m_env.m_used_structures)
|
||||||
{
|
{
|
||||||
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name << ") == " << member->m_member->m_offset
|
StructureComputations computations(structure->m_info);
|
||||||
<< ");")
|
if (!structure->m_info->m_definition->m_anonymous && !computations.IsAsset())
|
||||||
|
TestMethod(structure->m_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
LINE("")
|
private:
|
||||||
|
void TestMethod(StructureInformation* structure)
|
||||||
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
|
||||||
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
|
||||||
m_intendation--;
|
|
||||||
LINE("}")
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
Internal(std::ostream& stream, RenderingContext* context)
|
|
||||||
: BaseTemplate(stream, context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Source()
|
|
||||||
{
|
|
||||||
LINE("// ====================================================================")
|
|
||||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
|
||||||
LINE("// Do not modify.")
|
|
||||||
LINE("// Any changes will be discarded when regenerating.")
|
|
||||||
LINE("// ====================================================================")
|
|
||||||
LINE("")
|
|
||||||
LINE("#include <catch2/catch_test_macros.hpp>")
|
|
||||||
LINE("#include <catch2/generators/catch_generators.hpp>")
|
|
||||||
LINE("#include <cstddef>")
|
|
||||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
|
||||||
LINE("")
|
|
||||||
LINE("using namespace " << m_env.m_game << ";")
|
|
||||||
LINE("")
|
|
||||||
LINE("namespace game::" << m_env.m_game << "::xassets::asset_" << Lower(m_env.m_asset->m_definition->m_name))
|
|
||||||
LINE("{")
|
|
||||||
m_intendation++;
|
|
||||||
|
|
||||||
TestMethod(m_env.m_asset);
|
|
||||||
for (auto* structure : m_env.m_used_structures)
|
|
||||||
{
|
{
|
||||||
StructureComputations computations(structure->m_info);
|
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for "
|
||||||
if (!structure->m_info->m_definition->m_anonymous && !computations.IsAsset())
|
<< structure->m_definition->GetFullName() << "\", \"[assetstruct]\")")
|
||||||
TestMethod(structure->m_info);
|
LINE("{")
|
||||||
}
|
m_intendation++;
|
||||||
|
|
||||||
m_intendation--;
|
for (const auto& member : structure->m_ordered_members)
|
||||||
LINE("}")
|
{
|
||||||
}
|
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
||||||
};
|
{
|
||||||
|
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name
|
||||||
|
<< ") == " << member->m_member->m_offset << ");")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LINE("")
|
||||||
|
|
||||||
|
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
||||||
|
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(RenderingContext* context)
|
std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(RenderingContext* context)
|
||||||
{
|
{
|
||||||
@ -89,10 +95,10 @@ std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(Renderi
|
|||||||
|
|
||||||
void AssetStructTestsTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
void AssetStructTestsTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||||
{
|
{
|
||||||
Internal internal(stream, context);
|
Template t(stream, context);
|
||||||
|
|
||||||
if (fileTag == TAG_SOURCE)
|
if (fileTag == TAG_SOURCE)
|
||||||
internal.Source();
|
t.Source();
|
||||||
else
|
else
|
||||||
std::cout << "Invalid tag in AssetStructTestsTemplate\n";
|
std::cout << "Invalid tag in AssetStructTestsTemplate\n";
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
class AssetStructTestsTemplate final : public ICodeTemplate
|
class AssetStructTestsTemplate final : public ICodeTemplate
|
||||||
{
|
{
|
||||||
static constexpr int TAG_SOURCE = 1;
|
|
||||||
|
|
||||||
class Internal;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||||
|
@ -15,27 +15,10 @@ class BaseTemplate
|
|||||||
protected:
|
protected:
|
||||||
static constexpr const char* INTENDATION = " ";
|
static constexpr const char* INTENDATION = " ";
|
||||||
|
|
||||||
std::ostream& m_out;
|
|
||||||
RenderingContext& m_env;
|
|
||||||
unsigned m_intendation;
|
|
||||||
|
|
||||||
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
||||||
|
|
||||||
void DoIntendation() const;
|
void DoIntendation() const;
|
||||||
|
|
||||||
private:
|
|
||||||
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
|
||||||
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
|
||||||
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
|
||||||
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
|
||||||
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
|
||||||
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
|
||||||
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
|
||||||
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
|
||||||
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
|
||||||
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static std::string Upper(std::string str);
|
static std::string Upper(std::string str);
|
||||||
static std::string Lower(std::string str);
|
static std::string Lower(std::string str);
|
||||||
static std::string MakeTypeVarName(const DataDefinition* def);
|
static std::string MakeTypeVarName(const DataDefinition* def);
|
||||||
@ -55,6 +38,22 @@ protected:
|
|||||||
static std::string MakeCustomActionCall(CustomAction* action);
|
static std::string MakeCustomActionCall(CustomAction* action);
|
||||||
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
||||||
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
||||||
|
|
||||||
|
std::ostream& m_out;
|
||||||
|
RenderingContext& m_env;
|
||||||
|
unsigned m_intendation;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||||
|
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||||
|
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||||
|
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||||
|
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||||
|
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
||||||
|
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
||||||
|
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
||||||
|
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
||||||
|
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LINE(x) \
|
#define LINE(x) \
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
class ZoneLoadTemplate final : public ICodeTemplate
|
class ZoneLoadTemplate final : public ICodeTemplate
|
||||||
{
|
{
|
||||||
static constexpr int TAG_HEADER = 1;
|
|
||||||
static constexpr int TAG_SOURCE = 2;
|
|
||||||
|
|
||||||
class Internal;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
class ZoneMarkTemplate final : public ICodeTemplate
|
class ZoneMarkTemplate final : public ICodeTemplate
|
||||||
{
|
{
|
||||||
static constexpr int TAG_HEADER = 1;
|
|
||||||
static constexpr int TAG_SOURCE = 2;
|
|
||||||
|
|
||||||
class Internal;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
class ZoneWriteTemplate final : public ICodeTemplate
|
class ZoneWriteTemplate final : public ICodeTemplate
|
||||||
{
|
{
|
||||||
static constexpr int TAG_HEADER = 1;
|
|
||||||
static constexpr int TAG_SOURCE = 2;
|
|
||||||
|
|
||||||
class Internal;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||||
|
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||||
|
} // namespace
|
||||||
|
|
||||||
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||||
: m_args(args),
|
: m_args(args),
|
||||||
m_filename(std::move(filename)),
|
m_filename(std::move(filename)),
|
||||||
@ -30,7 +36,7 @@ bool CommandsFileReader::OpenBaseStream()
|
|||||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||||
if (!stream->IsOpen())
|
if (!stream->IsOpen())
|
||||||
{
|
{
|
||||||
std::cout << "Could not open commands file\n";
|
std::cerr << "Could not open commands file\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +74,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
|||||||
{
|
{
|
||||||
if (m_args->m_verbose)
|
if (m_args->m_verbose)
|
||||||
{
|
{
|
||||||
std::cout << "Reading commands file: " << m_filename << "\n";
|
std::cout << std::format("Reading commands file: {}\n", m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OpenBaseStream())
|
if (!OpenBaseStream())
|
||||||
@ -84,9 +90,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
|||||||
const auto end = std::chrono::steady_clock::now();
|
const auto end = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
if (m_args->m_verbose)
|
if (m_args->m_verbose)
|
||||||
{
|
std::cout << std::format("Processing commands took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||||
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,8 +9,15 @@
|
|||||||
|
|
||||||
class CommandsFileReader
|
class CommandsFileReader
|
||||||
{
|
{
|
||||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
public:
|
||||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||||
|
|
||||||
|
bool ReadCommandsFile(IDataRepository* repository);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool OpenBaseStream();
|
||||||
|
void SetupStreamProxies();
|
||||||
|
void SetupPostProcessors();
|
||||||
|
|
||||||
const ZoneCodeGeneratorArguments* m_args;
|
const ZoneCodeGeneratorArguments* m_args;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
@ -19,13 +26,4 @@ class CommandsFileReader
|
|||||||
IParserLineStream* m_stream;
|
IParserLineStream* m_stream;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||||
|
|
||||||
bool OpenBaseStream();
|
|
||||||
void SetupStreamProxies();
|
|
||||||
void SetupPostProcessors();
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
|
||||||
|
|
||||||
bool ReadCommandsFile(IDataRepository* repository);
|
|
||||||
};
|
};
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
class CommandsLexer final : public AbstractLexer<CommandsParserValue>
|
class CommandsLexer final : public AbstractLexer<CommandsParserValue>
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
CommandsParserValue GetNextToken() override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CommandsLexer(IParserLineStream* stream);
|
explicit CommandsLexer(IParserLineStream* stream);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CommandsParserValue GetNextToken() override;
|
||||||
};
|
};
|
||||||
|
@ -8,11 +8,12 @@
|
|||||||
|
|
||||||
class CommandsParser final : public AbstractParser<CommandsParserValue, CommandsParserState>
|
class CommandsParser final : public AbstractParser<CommandsParserValue, CommandsParserState>
|
||||||
{
|
{
|
||||||
IDataRepository* m_repository;
|
public:
|
||||||
|
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||||
|
|
||||||
public:
|
private:
|
||||||
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
IDataRepository* m_repository;
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,28 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Persistence/IDataRepository.h"
|
#include "Persistence/IDataRepository.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CommandsParserState
|
class CommandsParserState
|
||||||
{
|
{
|
||||||
IDataRepository* m_repository;
|
public:
|
||||||
StructureInformation* m_in_use;
|
explicit CommandsParserState(IDataRepository* repository);
|
||||||
|
|
||||||
|
[[nodiscard]] const IDataRepository* GetRepository() const;
|
||||||
|
|
||||||
|
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
||||||
|
void SetArchitecture(Architecture architecture) const;
|
||||||
|
void SetGame(std::string gameName) const;
|
||||||
|
|
||||||
|
[[nodiscard]] StructureInformation* GetInUse() const;
|
||||||
|
void SetInUse(StructureInformation* structure);
|
||||||
|
|
||||||
|
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||||
|
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
||||||
|
|
||||||
|
private:
|
||||||
static MemberInformation* GetMemberWithName(const std::string& memberName, StructureInformation* type);
|
static MemberInformation* GetMemberWithName(const std::string& memberName, StructureInformation* type);
|
||||||
static bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, unsigned startPos, unsigned& separatorPos);
|
static bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, unsigned startPos, unsigned& separatorPos);
|
||||||
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
||||||
@ -18,18 +30,6 @@ class CommandsParserState
|
|||||||
StructureInformation* type,
|
StructureInformation* type,
|
||||||
std::vector<MemberInformation*>& members);
|
std::vector<MemberInformation*>& members);
|
||||||
|
|
||||||
public:
|
IDataRepository* m_repository;
|
||||||
explicit CommandsParserState(IDataRepository* repository);
|
StructureInformation* m_in_use;
|
||||||
|
|
||||||
_NODISCARD const IDataRepository* GetRepository() const;
|
|
||||||
|
|
||||||
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
|
||||||
void SetArchitecture(Architecture architecture) const;
|
|
||||||
void SetGame(std::string gameName) const;
|
|
||||||
|
|
||||||
_NODISCARD StructureInformation* GetInUse() const;
|
|
||||||
void SetInUse(StructureInformation* structure);
|
|
||||||
|
|
||||||
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
|
||||||
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
|
||||||
};
|
};
|
||||||
|
@ -52,10 +52,6 @@ enum class CommandsParserValueType
|
|||||||
class CommandsParserValue final : public IParserValue
|
class CommandsParserValue final : public IParserValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TokenPos m_pos;
|
|
||||||
CommandsParserValueType m_type;
|
|
||||||
size_t m_hash;
|
|
||||||
|
|
||||||
union ValueType
|
union ValueType
|
||||||
{
|
{
|
||||||
char char_value;
|
char char_value;
|
||||||
@ -83,25 +79,28 @@ public:
|
|||||||
static CommandsParserValue TypeName(TokenPos pos, std::string* typeName);
|
static CommandsParserValue TypeName(TokenPos pos, std::string* typeName);
|
||||||
static CommandsParserValue OpType(TokenPos pos, const OperationType* operationType);
|
static CommandsParserValue OpType(TokenPos pos, const OperationType* operationType);
|
||||||
|
|
||||||
private:
|
|
||||||
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
|
||||||
|
|
||||||
public:
|
|
||||||
~CommandsParserValue() override;
|
|
||||||
CommandsParserValue(const CommandsParserValue& other) = delete;
|
CommandsParserValue(const CommandsParserValue& other) = delete;
|
||||||
|
~CommandsParserValue() override;
|
||||||
CommandsParserValue(CommandsParserValue&& other) noexcept;
|
CommandsParserValue(CommandsParserValue&& other) noexcept;
|
||||||
CommandsParserValue& operator=(const CommandsParserValue& other) = delete;
|
CommandsParserValue& operator=(const CommandsParserValue& other) = delete;
|
||||||
CommandsParserValue& operator=(CommandsParserValue&& other) noexcept;
|
CommandsParserValue& operator=(CommandsParserValue&& other) noexcept;
|
||||||
|
|
||||||
_NODISCARD bool IsEof() const override;
|
[[nodiscard]] bool IsEof() const override;
|
||||||
_NODISCARD const TokenPos& GetPos() const override;
|
[[nodiscard]] const TokenPos& GetPos() const override;
|
||||||
|
|
||||||
_NODISCARD char CharacterValue() const;
|
[[nodiscard]] char CharacterValue() const;
|
||||||
_NODISCARD int IntegerValue() const;
|
[[nodiscard]] int IntegerValue() const;
|
||||||
_NODISCARD double FloatingPointValue() const;
|
[[nodiscard]] double FloatingPointValue() const;
|
||||||
_NODISCARD std::string& StringValue() const;
|
[[nodiscard]] std::string& StringValue() const;
|
||||||
_NODISCARD std::string& IdentifierValue() const;
|
[[nodiscard]] std::string& IdentifierValue() const;
|
||||||
_NODISCARD size_t IdentifierHash() const;
|
[[nodiscard]] size_t IdentifierHash() const;
|
||||||
_NODISCARD std::string& TypeNameValue() const;
|
[[nodiscard]] std::string& TypeNameValue() const;
|
||||||
_NODISCARD const OperationType* OpTypeValue() const;
|
[[nodiscard]] const OperationType* OpTypeValue() const;
|
||||||
|
|
||||||
|
TokenPos m_pos;
|
||||||
|
CommandsParserValueType m_type;
|
||||||
|
size_t m_hash;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
||||||
};
|
};
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
class CommandsMatcherCharacter final : public AbstractMatcher<CommandsParserValue>
|
class CommandsMatcherCharacter final : public AbstractMatcher<CommandsParserValue>
|
||||||
{
|
{
|
||||||
char m_char;
|
public:
|
||||||
|
explicit CommandsMatcherCharacter(char c);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||||
|
|
||||||
public:
|
private:
|
||||||
explicit CommandsMatcherCharacter(char c);
|
char m_char;
|
||||||
};
|
};
|
||||||
|
@ -10,10 +10,10 @@ class CommandsMatcherFactory final : public AbstractMatcherFactory<CommandsParse
|
|||||||
public:
|
public:
|
||||||
explicit CommandsMatcherFactory(const IMatcherForLabelSupplier<CommandsParserValue>* labelSupplier);
|
explicit CommandsMatcherFactory(const IMatcherForLabelSupplier<CommandsParserValue>* labelSupplier);
|
||||||
|
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
||||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
||||||
};
|
};
|
||||||
|
@ -7,12 +7,13 @@
|
|||||||
|
|
||||||
class CommandsMatcherKeyword final : public AbstractMatcher<CommandsParserValue>
|
class CommandsMatcherKeyword final : public AbstractMatcher<CommandsParserValue>
|
||||||
{
|
{
|
||||||
size_t m_hash;
|
public:
|
||||||
std::string m_value;
|
explicit CommandsMatcherKeyword(std::string value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||||
|
|
||||||
public:
|
private:
|
||||||
explicit CommandsMatcherKeyword(std::string value);
|
size_t m_hash;
|
||||||
|
std::string m_value;
|
||||||
};
|
};
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
class CommandsMatcherValueType final : public AbstractMatcher<CommandsParserValue>
|
class CommandsMatcherValueType final : public AbstractMatcher<CommandsParserValue>
|
||||||
{
|
{
|
||||||
CommandsParserValueType m_type;
|
public:
|
||||||
|
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||||
|
|
||||||
public:
|
private:
|
||||||
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
CommandsParserValueType m_type;
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
||||||
|
static constexpr auto CAPTURE_TYPE = 2;
|
||||||
|
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
||||||
|
|
||||||
|
static constexpr auto LABEL_ACTION_ARGS = 1;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
SequenceAction::SequenceAction()
|
SequenceAction::SequenceAction()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,15 +4,9 @@
|
|||||||
|
|
||||||
class SequenceAction final : public CommandsParser::sequence_t
|
class SequenceAction final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
public:
|
||||||
static constexpr auto CAPTURE_TYPE = 2;
|
SequenceAction();
|
||||||
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
|
||||||
|
|
||||||
static constexpr auto LABEL_ACTION_ARGS = 1;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceAction();
|
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
SequenceAllocAlign::SequenceAllocAlign()
|
SequenceAllocAlign::SequenceAllocAlign()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
class SequenceAllocAlign final : public CommandsParser::sequence_t
|
class SequenceAllocAlign final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
public:
|
||||||
|
SequenceAllocAlign();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceAllocAlign();
|
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
SequenceArchitecture::SequenceArchitecture()
|
SequenceArchitecture::SequenceArchitecture()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
#include "Parsing/Commands/Impl/CommandsParser.h"
|
#include "Parsing/Commands/Impl/CommandsParser.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class SequenceArchitecture final : public CommandsParser::sequence_t
|
class SequenceArchitecture final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
public:
|
||||||
|
SequenceArchitecture();
|
||||||
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
private:
|
||||||
SequenceArchitecture();
|
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
SequenceArrayCount::SequenceArrayCount()
|
SequenceArrayCount::SequenceArrayCount()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
class SequenceArrayCount final : public CommandsParser::sequence_t
|
class SequenceArrayCount final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
public:
|
||||||
|
SequenceArrayCount();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceArrayCount();
|
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
|
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
SequenceArraySize::SequenceArraySize()
|
SequenceArraySize::SequenceArraySize()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,12 +4,9 @@
|
|||||||
|
|
||||||
class SequenceArraySize final : public CommandsParser::sequence_t
|
class SequenceArraySize final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
public:
|
||||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
SequenceArraySize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceArraySize();
|
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
|
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
SequenceAsset::SequenceAsset()
|
SequenceAsset::SequenceAsset()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,12 +4,9 @@
|
|||||||
|
|
||||||
class SequenceAsset final : public CommandsParser::sequence_t
|
class SequenceAsset final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
public:
|
||||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
SequenceAsset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceAsset();
|
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static constexpr auto TAG_DEFAULT = 1;
|
||||||
|
|
||||||
|
static constexpr auto CAPTURE_TYPE = 1;
|
||||||
|
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
SequenceAssetRef::SequenceAssetRef()
|
SequenceAssetRef::SequenceAssetRef()
|
||||||
{
|
{
|
||||||
const CommandsMatcherFactory create(this);
|
const CommandsMatcherFactory create(this);
|
||||||
|
@ -4,14 +4,9 @@
|
|||||||
|
|
||||||
class SequenceAssetRef final : public CommandsParser::sequence_t
|
class SequenceAssetRef final : public CommandsParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto TAG_DEFAULT = 1;
|
public:
|
||||||
|
SequenceAssetRef();
|
||||||
static constexpr auto CAPTURE_TYPE = 1;
|
|
||||||
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||||
|
|
||||||
public:
|
|
||||||
SequenceAssetRef();
|
|
||||||
};
|
};
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user